]> code.delx.au - gnu-emacs-elpa/blobdiff - admin/package-update.sh
admin/package-update.sh: Remove accidentally included code
[gnu-emacs-elpa] / admin / package-update.sh
index 38708b7024d1ddae278fabc1b63ebeabbcfbdc4e..6078604b269805f96b16a8f9c36c818963af37f5 100755 (executable)
-#/bin/sh
+#/bin/bash
+## package-update.sh -- Create a package archive from the elpa repository
 
-PATH=/bin:/usr/bin:/usr/local/bin
-ROOT=$1
-FETCHEXTRAS=$2
-
-LOG=$ROOT/update-log
-PKGROOT=$ROOT/packages
-ADMINROOT=$ROOT/admin
+## Usage: ./package-update.sh DEST [FULL-UPDATE]
+##
+## This creates a package archive beginning in DEST.
+##
+## The package archive itself is created in DEST/packages.  This dir
+## contains the package files and the `archive-contents' listing file.
+##
+## If a second argument FULL-UPDATE is specified (whatever its value),
+## also create the following:
+##   - the archive admin scripts in DEST/admin
+##   - a tarball contianing the entire archive in
+##     DEST/packages/emacs-packages-latest.tgz
+##   - the Org mode daily package
 
-TARBALL=$PKGROOT/emacs-packages-latest.tgz
-TARBALL_ROOT="emacs-24.1-packages-`/bin/date +'%F'`"
+PATH=/bin:/usr/bin:/usr/local/bin
+DEST=${1%/}
+FULL=$2
 
-REPO=bzr://bzr.savannah.gnu.org/emacs/elpa
-REPO_PACKAGES=$REPO/packages
-REPO_ADMIN=$REPO/admin
+EMACS=emacs
+BZR=bzr
 
-PACKAGE_TARBALLS="auctex-11.86 company-0.5 muse-3.20"
+LOG=$DEST/update-log
+PKGROOT=$DEST/packages
+TMP_PKGROOT=$DEST/packages-new
+REPO_PACKAGES=packages
 
-if [ -z $ROOT ]; then
+## Parse arguments
+if [ -z $DEST ]; then
     echo "Syntax: $0 HOMEDIR [fetch-extras-boolean]"
     exit 1
-elif [ -d $ROOT ]; then
-    echo "Installing into '$ROOT', log is '$LOG'"
-    echo "Installing into '$ROOT'" > $LOG
+elif [ -d $DEST ]; then
+    echo "Installing into '$DEST', log is '$LOG'"
+    echo "Installing into '$DEST'" > $LOG
+    if [ -z $FULL ]; then
+       echo "Base archive update only (pass second arg for full update)."
+    else
+       echo "Performing full archive update."
+       TARBALL=$PKGROOT/emacs-packages-latest.tgz
+       TARBALL_ROOT="emacs-24.1-packages-`/bin/date +'%F'`"
+       ADMINROOT=$DEST/admin
+       REPO_ADMIN=admin
+    fi
 else
-    echo "Sorry but $ROOT is not a directory, aborting."
+    echo "Sorry but $DEST is not a directory, aborting."
     exit 1
 fi
 
+## Change to the bzr root directory
+cd $(dirname $0)
+REPO_ROOT_DIR=`$BZR root`;
+if [ -z $REPO_ROOT_DIR ]; then
+    "This script should be run from a bzr repository, aborting."
+    exit 1
+else
+    cd $REPO_ROOT_DIR;
+fi
 
-## Create the world-facing copy
-echo "[$TMPROOT -> $PKGROOT] Creating the world-facing package repository copy in $PKGROOT" >> $LOG
-TMPROOT=$PKGROOT-new
-rm -rf $TMPROOT
-bzr export $TMPROOT $REPO_PACKAGES
+## Create the working directory that will be the world-facing copy of
+## the package archive base.
+echo "Exporting packages to temporary working directory $TMP_PKGROOT" >> $LOG
+rm -rf $TMP_PKGROOT
+$BZR export $TMP_PKGROOT $REPO_PACKAGES
 
-echo "[$TMPROOT -> $PKGROOT] Running the post-export fetchers in $ADMINROOT against $TMPROOT" >> $LOG
-rm -rf $ADMINROOT
-bzr export $ADMINROOT $REPO_ADMIN
+## Call the `make-package-archive' Lisp function.
 
-if [ -z $FETCHEXTRAS ]; then
-    echo "Skipping the post-export fetchers" >> $LOG
-    echo "(pass 1 as the second parameter to get them with $0 or just run them manually)" >> $LOG
+## If second arg is provided, copy in the admin directory and run the
+## Org daily synch scripts
+if [ -z $FULL ]; then
+    echo "Skipping admin directory" >> $LOG
+    echo "Skipping post-export fetchers" >> $LOG
 else
-    # Copy the org daily package from orgmode.org
-    echo "[$TMPROOT -> $PKGROOT] Running the post-export org-mode fetcher as '$ADMINROOT/org-synch.sh $TMPROOT $ADMINROOT'" >> $LOG
-    $ADMINROOT/org-synch.sh $TMPROOT $ADMINROOT >> $LOG 2>&1
+    echo "Exporting admin scripts to $ADMINROOT" >> $LOG
+    rm -rf $ADMINROOT
+    $BZR export $ADMINROOT $REPO_ADMIN
+    echo "Running post-export org-mode fetcher as '$ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT'" >> $LOG
+    $ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT >> $LOG 2>&1
 fi
 
-echo "Creating tarballs from unpacked packages $PACKAGE_TARBALLS in $TMPROOT" >> $LOG
-cd $TMPROOT
-for pt in $PACKAGE_TARBALLS; do
-    echo "Creating tarball of $pt: tar of $TMPROOT/$pt into $TMPROOT/$pt.tar" >> $LOG
-    tar -cf $pt.tar $pt
-    echo "Removing $TMPROOT/$pt" >> $LOG
-    rm -rf $pt
+## Tar up the multi-file packages.
+echo "Creating multi-file package tarballs in $TMP_PKGROOT" >> $LOG
+cd $TMP_PKGROOT
+for pt in *; do
+    if [ -d $pt ]; then
+       echo "Creating tarball $TMP_PKGROOT/$pt.tar" >> $LOG
+       tar -cf $pt.tar $pt --remove-files
+    fi
 done
-cd ..
 
-echo "[$TMPROOT -> $PKGROOT] Moving $TMPROOT to $PKGROOT" >> $LOG
-mv $PKGROOT $PKGROOT-old
-mv $TMPROOT $PKGROOT
+## Move the working directory to its final location
+echo "Moving $TMP_PKGROOT to $PKGROOT" >> $LOG
+rm -rf $PKGROOT-old
+if [ -d $PKGROOT ]; then
+    mv $PKGROOT $PKGROOT-old
+fi
+mv $TMP_PKGROOT $PKGROOT
 rm -rf $PKGROOT-old
 
-echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)" >> $LOG
-bzr export --format=tgz --root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
+## If doing a full update, make a tarball of the entire archive.
+if [ -z $FULL ]; then
+    echo "Skipping archive tarball" >> $LOG
+else
+    echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)" >> $LOG
+    cd $REPO_ROOT_DIR
+    $BZR export --format=tgz --root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
+fi
 
 chmod -R a+rX $PKGROOT
-
 echo "Update complete at" `/bin/date` >> $LOG