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