375c71
#!/bin/bash
375c71
#set -x
375c71
set -e
375c71
usage()
375c71
{
375c71
cat << EOF
375c71
usage: $0 options
375c71
375c71
This script downloads calendar langpacks for Thunderbird.
375c71
375c71
OPTIONS:
375c71
   -h      Show this message
375c71
   -v      Version string (7.0.1)
375c71
   -b      Build number (1, 2, 3)
375c71
   -r      Reuse downloaded files (when you don't want to redownload)
375c71
EOF
375c71
}
375c71
375c71
VER=
375c71
BUILDNUM=
375c71
LANG_DATE=`date "+%Y%m%d"`
375c71
while getopts “hv:b:r” OPTION
375c71
do
375c71
     case $OPTION in
375c71
         h)
375c71
             usage
375c71
             exit 1
375c71
             ;;
375c71
         v)
375c71
             VER=$OPTARG
375c71
             ;;
375c71
         b)
375c71
             BUILDNUM=$OPTARG
375c71
             ;;
375c71
         ?)
375c71
             usage
375c71
             exit
375c71
             ;;
375c71
     esac
375c71
done
375c71
375c71
if [ -z "$VER" -o -z "$BUILDNUM"  ]
375c71
then
375c71
     echo "Missing version or build number."
375c71
     usage
375c71
     exit 1
375c71
fi
375c71
375c71
WHITE='\033[1;33m'
375c71
NC='\033[0m' # No Color
375c71
375c71
LOCALES=`curl -f https://archive.mozilla.org/pub/thunderbird/candidates/$VER-candidates/build$BUILDNUM/linux-i686/ | grep "a href"|sed -e "s|.*/\([^/]*\)/\".*|\1|"|tail -n+2 |grep -v xpi`
375c71
#echo $LOCALES
375c71
rm -rf lightning-langpacks
375c71
mkdir -p lightning-langpacks
375c71
cd lightning-langpacks
375c71
LOCALE_COUNT=`echo $LOCALES| tr ' ' '\n' | wc -l`
375c71
LOCALE_NUM=0
375c71
for lang in $LOCALES; do
375c71
  LOCALE_NUM=$((LOCALE_NUM+1))
375c71
  echo -e "${WHITE}Processing calendar locale: $lang ($LOCALE_NUM/$LOCALE_COUNT)${NC}"
375c71
  mkdir -p extracted_lightning
375c71
  mkdir -p calendar-locales
375c71
  #echo Downloading TB binary for locale: $lang
375c71
  wget --quiet https://archive.mozilla.org/pub/thunderbird/candidates/$VER-candidates/build$BUILDNUM/linux-i686/$lang/thunderbird-$VER.tar.bz2
375c71
375c71
  cd extracted_lightning
375c71
  tar -xf ../thunderbird-$VER.tar.bz2 thunderbird/distribution/extensions/\{e2fda1a4-762b-4020-b5ad-a41df1933103\}.xpi
375c71
  set +e
375c71
  unzip -qq thunderbird/distribution/extensions/\{e2fda1a4-762b-4020-b5ad-a41df1933103\}.xpi
375c71
  set -e
375c71
  LIGHTNING_VERSION=`cat app.ini |grep "^Version="|sed -e 's/Version=//'`
375c71
  BUILD_ID=`cat app.ini |grep "^BuildID="|sed -e 's/BuildID=//'`
375c71
  MAX_VERSION=`cat app.ini |grep MaxVersion|sed -e s/MaxVersion=//`
375c71
  MIN_VERSION=`cat app.ini |grep MinVersion|sed -e s/MinVersion=//`
375c71
  rm -rf thunderbird
375c71
  mkdir -p ../calendar-locales/chrome
375c71
  cp -r chrome/calendar-$lang ../calendar-locales/chrome
375c71
  cp -r chrome/lightning-$lang ../calendar-locales/chrome
375c71
  cd -
375c71
375c71
  cd calendar-locales
375c71
  # create manifest
375c71
  cat > manifest.json <
375c71
{
375c71
  "languages": {
375c71
    "$lang": {
375c71
      "chrome_resources": {
375c71
        "calendar": "chrome/calendar-$lang/locale/$lang/calendar/",
375c71
        "lightning": "chrome/lightning-$lang/locale/$lang/lightning/"
375c71
      },
375c71
      "version": "$LIGHTNING_VERSION"
375c71
    }
375c71
  },
375c71
  "applications": {
375c71
    "gecko": {
375c71
      "strict_min_version": "$MIN_VERSION",
375c71
      "id": "langpack-cal-$lang@lightning.mozilla.org",
375c71
      "strict_max_version": "$MAX_VERSION"
375c71
    }
375c71
  },
375c71
  "langpack_id": "$lang",
375c71
  "version": "$LIGHTNING_VERSION$BUILD_ID",
375c71
  "name": "$lang Language Pack Calendar",
375c71
  "manifest_version": 2,
375c71
  "sources": {
375c71
    "browser": {
375c71
      "base_path": "browser/"
375c71
    }
375c71
  },
375c71
  "author": "Mozilla.cz (contributors: Pavel Cvrček, Pavel Franc, Michal Stanke, Michal Vašíček)",
375c71
  "description": "Language pack for Thunderbird for $lang, this was repacked by Fedora/RHEL package maintainer from original binaries."
375c71
}
375c71
375c71
EOL
375c71
  zip --quiet -r ../langpack-cal-$lang@lightning.mozilla.org.xpi *
375c71
  cd -
375c71
  rm -rf calendar-locales
375c71
  rm -rf extracted_lightning
375c71
375c71
  rm -f thunderbird-$VER.tar.bz2
375c71
done
375c71
echo "Creating lightning-langpacks-$VER.tar.xz..."
375c71
tar cJf ../lightning-langpacks-$VER.tar.xz *.xpi
375c71
cd ..
375c71
rm -rf lightning-langpacks