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