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