2 ## package-update.sh -- Create a package archive from the elpa repository
4 ## Usage: ./package-update.sh DEST [FULL-UPDATE]
6 ## This creates a package archive beginning in DEST.
8 ## The package archive itself is created in DEST/packages. This dir
9 ## contains the package files.
11 ## If a second argument FULL-UPDATE is specified (whatever its value),
12 ## also create the following:
13 ## - the archive admin scripts in DEST/admin
14 ## - a tarball containing the entire archive in
15 ## DEST/packages/emacs-packages-latest.tgz
16 ## - the Org mode daily package
18 PATH
="/bin:/usr/bin:/usr/local/bin:${PATH}"
19 ## Remove any trailing slash from DEST
26 REPO_PACKAGES
=packages
30 echo "Syntax: $0 DEST [fetch-extras-boolean]"
32 elif [ -d $DEST ]; then
35 PKGROOT
=$DEST_FULL/packages
36 TMP_PKGROOT
=$DEST_FULL/packages-new
37 echo "Installing into '$DEST_FULL'"
39 echo "Base archive update only (pass second arg for full update)."
41 echo "Performing full archive update."
42 TARBALL
=$PKGROOT/emacs-packages-latest.tgz
43 TARBALL_ROOT
="emacs-24.1-packages-`/bin/date +'%F'`"
44 ADMINROOT
=$DEST_FULL/admin
48 echo "Sorry but $DEST is not a directory, aborting."
52 ## Change to the bzr root directory
53 REPO_ROOT_DIR
=`$BZR root`;
54 if [ -z $REPO_ROOT_DIR ]; then
55 "This script should be run from a bzr repository, aborting."
61 ## Create the working directory that will be the world-facing copy of
62 ## the package archive base.
63 echo "Exporting packages to temporary working directory $TMP_PKGROOT"
65 $BZR export $TMP_PKGROOT $REPO_PACKAGES
67 ## If second arg is provided, copy in the admin directory.
69 echo "Skipping admin directory"
71 echo "Exporting admin scripts to $ADMINROOT"
73 $BZR export $ADMINROOT $REPO_ADMIN
80 ## If second arg is provided, grab the Org daily
82 echo "Not fetching Org daily from orgmode.org"
84 echo "Fetching Org daily from orgmode.org"
85 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"}'`
86 wget
-q http
://orgmode.org
/elpa
/${pkgname}.
tar -O ${pkgname}.
tar
87 if [ -f ${pkgname}.
tar ]; then
94 ## Call `batch-make-archive' to generate archive-contents, the readme
96 $EMACS -batch -l $REPO_ROOT_DIR/admin
/archive-contents.el
-f batch-make-archive
98 ## Tar up the multi-file packages.
99 echo "Creating multi-file package tarballs in $TMP_PKGROOT"
102 echo "Creating tarball $TMP_PKGROOT/$pt.tar"
103 tar -cf $pt.
tar $pt --remove-files
107 ## Move the working directory to its final location
110 if [ -d $PKGROOT ]; then
111 mv $PKGROOT $PKGROOT-old
113 mv $TMP_PKGROOT $PKGROOT
116 ## If doing a full update, make a tarball of the entire archive.
117 if [ -z $FULL ]; then
118 echo "Skipping archive tarball"
120 echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)"
122 $BZR export --format=tgz
--root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
125 chmod -R a
+rX
$PKGROOT
126 echo "Update complete at" `/bin/date`