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