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