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