## - the Org mode daily package
PATH="/bin:/usr/bin:/usr/local/bin:${PATH}"
+## Remove any trailing slash from DEST
DEST=${1%/}
FULL=$2
EMACS=emacs
BZR=bzr
TAR=tar
-
-LOG=$DEST/update-log
-PKGROOT=$DEST/packages
-TMP_PKGROOT=$DEST/packages-new
REPO_PACKAGES=packages
## Parse arguments
echo "Syntax: $0 DEST [fetch-extras-boolean]"
exit 1
elif [ -d $DEST ]; then
- echo "Installing into '$DEST', log is '$LOG'"
- echo "Installing into '$DEST'" > $LOG
+ cd $DEST
+ DEST_FULL=$(pwd)
+ PKGROOT=$DEST_FULL/packages
+ TMP_PKGROOT=$DEST_FULL/packages-new
+ echo "Installing into '$DEST_FULL'"
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
+ ADMINROOT=$DEST_FULL/admin
REPO_ADMIN=admin
fi
else
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."
## 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
+echo "Exporting packages to temporary working directory $TMP_PKGROOT"
rm -rf $TMP_PKGROOT
$BZR export $TMP_PKGROOT $REPO_PACKAGES
-## Call the `make-package-archive' Lisp function.
-
-## If second arg is provided, copy in the admin directory and run the
-## Org daily synch scripts
+## If second arg is provided, copy in the admin directory.
if [ -z $FULL ]; then
- echo "Skipping admin directory" >> $LOG
- echo "Skipping post-export fetchers" >> $LOG
+ echo "Skipping admin directory"
else
- echo "Exporting admin scripts to $ADMINROOT" >> $LOG
+ echo "Exporting admin scripts to $ADMINROOT"
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
-## Generate archive-contents and the readme files.
cd $TMP_PKGROOT
-$TAR xf *.tar
-rm -f *.tar
-$EMACS -batch -l $REPO_ROOT_DIR/admin/archive-contents.el -f batch-make-archive-contents
-## Tar up the multi-file packages.
-echo "Creating multi-file package tarballs in $TMP_PKGROOT" >> $LOG
+## If second arg is provided, grab the Org daily
+if [ -z $FULL ]; then
+ echo "Not fetching Org daily from orgmode.org"
+else
+ echo "Fetching Org daily from orgmode.org"
+ pkgname=`curl -s http://orgmode.org/elpa/|perl -ne 'push @f, $1 if m/(org-\d{8})\.tar/; END { @f = sort @f; print "$f[-1]\n"}'`
+ wget -q http://orgmode.org/elpa/${pkgname}.tar -O ${pkgname}.tar
+ if [ -f ${pkgname}.tar ]; then
+ tar xf ${pkgname}.tar
+ rm -f ${pkgname}.tar
+ mv ${pkgname} org
+ fi
+fi
+
+## Call `batch-make-archive' to generate archive-contents, the readme
+## files, etc.
+$EMACS -batch -l $REPO_ROOT_DIR/admin/archive-contents.el -f batch-make-archive
+
+## Tar up the multi-file packages.
+echo "Creating multi-file package tarballs in $TMP_PKGROOT"
for pt in *; do
if [ -d $pt ]; then
- echo "Creating tarball $TMP_PKGROOT/$pt.tar" >> $LOG
+ echo "Creating tarball $TMP_PKGROOT/$pt.tar"
tar -cf $pt.tar $pt --remove-files
fi
done
## Move the working directory to its final location
-echo "Moving $TMP_PKGROOT to $PKGROOT" >> $LOG
+cd ..
rm -rf $PKGROOT-old
if [ -d $PKGROOT ]; then
mv $PKGROOT $PKGROOT-old
## If doing a full update, make a tarball of the entire archive.
if [ -z $FULL ]; then
- echo "Skipping archive tarball" >> $LOG
+ echo "Skipping archive tarball"
else
- echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)" >> $LOG
+ echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)"
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
+echo "Update complete at" `/bin/date`