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