Permalink
Browse files

Add batch repacking scripts + intruction file.

  • Loading branch information...
1 parent 678a8f4 commit c816f9f6e0d26f62d93962b432a498f9c4ce4fbd @ochameau committed Jul 31, 2012
Showing with 114 additions and 0 deletions.
  1. +67 −0 scripts/README
  2. +8 −0 scripts/clone_all_sdk_versions.sh
  3. +2 −0 scripts/fetch-ftp.sh
  4. +37 −0 scripts/unzip.sh
View
@@ -0,0 +1,67 @@
+
+=== REPACK INSTRUCTIONS ===
+
+0/ Setup environnement and download these scripts
+```
+# We assume that we segregate all these repack files in '/addons' folder
+$ mkdir /addons
+$ cd /addons
+$ git clone https://github.com/ochameau/jetpack-repacker repacker
+ - or -
+$ wget --no-check-certificate https://github.com/ochameau/jetpack-repacker/tarball/master -O - | tar xz
+```
+
+1/ Download xpi files
+```
+$ mkdir /addons/ftp
+$ cd /addons/ftp
+$ /addons/scripts/fetch-ftp.sh
+# This script will download all xpi files. You can re-run it at anytime to download only new files.
+# but note that remove files from mozilla ftp will be kept locally.
+# xpi will be in /addons/ftp/ftp.mozilla.org/pub/mozilla.org/addons/
+```
+
+2/ Unzip jetpack xpi files
+```
+$ /addons/repacker/scripts/unzip.sh /addons/ftp/ftp.mozilla.org/pub/mozilla.org/addons/ /addons/src
+# This script will unzip all jetpack xpi files to /addons/src/jetpack folder
+```
+
+3/ Checkout all SDK released versions
+```
+$ mkdir /addons/sdks
+$ /addons/sdks
+$ /addons/repacker/scripts/clone_add_sdk_versions.sh
+# It will take some time as it will checkout all tagged versions on git repo
+```
+
+4/ Compute repackability
+```
+$ cd /addons
+$ python /addons/repacker/unpack.py --sdks /addons/sdks/ --batch repackability /addons/src/jetpack/ > repackability 2>&1
+# This will process each addon source code and try to repack it against same SDK version
+# and will tell for each addon, which one is safely repackable
+```
+
+5/ Compute addons list to repack
+```
+# remove diffs
+$ cat repackability | grep -E "[0-9]+: " > t
+# select only repackable and filter only path
+$ cat info | grep repackable | grep -oE "^[^:]+" > to-repack
+# /addons/to-repack now contains only path to repackable addons
+```
+
+4/ Repack selected addons
+```
+$ mkdir /addons/repacked
+$ for i in `cat /addons/to-repack`; do python /addons/repacker/unpack.py repack $i --sdk /addons/sdks/1.8.2 --target /addons/repacked/ ;done
+# Replace 1.8.2 with SDK version you want to repack to.
+# repacked addons will be available in /addons/repacked/ folder
+```
+
+5/ Eventually compute dependencies and detailed info about each addon
+```
+for i in `cat /addons/to-repack`; do python /addons/repacker/unpack.py deps $i; done > /addons/repacked-info
+```
+
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+for i in `git ls-remote -t http://github.com/mozilla/addon-sdk "refs/tags/[1-9].*" | sed 's:.*/::'`; do
+ if [ ! -d $i ]; then
+ echo "clone " $i " ..."
+ git clone http://github.com/mozilla/addon-sdk -q --branch $i --depth 1 $i;
+ fi
+done
@@ -0,0 +1,2 @@
+#!/bin/bash
+wget -m ftp://ftp.mozilla.org/pub/mozilla.org/addons/
View
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# `ftp` folder should be a clone of ftp://ftp.mozilla.org/pub/mozilla.org/addons/
+# `src` will contain unzipped addons content
+# `src/jetpack/` will contain all jetpack addons
+# `src/xul` will contain other kind of addons
+
+FTP_DIR=$1
+SRC_DIR=$2
+
+mkdir -p $SRC_DIR/xul
+mkdir -p $SRC_DIR/jetpack
+
+#set -x
+for XPI_DIR in $(ls -d $FTP_DIR/*/)
+do
+ # Retrieve most recent xpi file
+ XPI=$(ls -t $XPI_DIR*.xpi 2>/dev/null | head -1)
+ # We may not have any xpi file ...
+ if ! test $XPI; then
+ continue
+ fi
+
+ # Check if that's a jetpack addon or not
+ KIND=xul
+ if $(unzip -l $XPI | grep -q harness-options.json); then
+ KIND=jetpack
+ else
+ # avoid unpacking xul addons
+ continue
+ fi
+ ID=$(basename $XPI_DIR)
+ # echo $XPI $KIND $ID
+ DST_DIR=$SRC_DIR/$KIND/$ID
+ mkdir -p $DST_DIR
+ unzip -oq $XPI -d $DST_DIR || echo "Failed to unzip $ID"
+done

0 comments on commit c816f9f

Please sign in to comment.