]> code.delx.au - gnu-emacs-elpa/blob - admin/package-update.sh
Add a top-level Makefile.
[gnu-emacs-elpa] / admin / package-update.sh
1 #/bin/bash
2 ## package-update.sh -- Create a package archive from the elpa repository
3
4 ## Usage: ./package-update.sh DEST [FULL-UPDATE]
5 ##
6 ## This creates a package archive beginning in DEST.
7 ##
8 ## The package archive itself is created in DEST/packages. This dir
9 ## contains the package files.
10 ##
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
17
18 PATH="/bin:/usr/bin:/usr/local/bin:${PATH}"
19 ## Remove any trailing slash from DEST
20 DEST=${1%/}
21 FULL=$2
22
23 EMACS=emacs
24 BZR=bzr
25 TAR=tar
26 REPO_PACKAGES=packages
27
28 ## Parse arguments
29 if [ -z $DEST ]; then
30 echo "Syntax: $0 DEST [fetch-extras-boolean]"
31 exit 1
32 elif [ -d $DEST ]; then
33 cd $DEST
34 DEST_FULL=$(pwd)
35 PKGROOT=$DEST_FULL/packages
36 TMP_PKGROOT=$DEST_FULL/packages-new
37 echo "Installing into '$DEST_FULL'"
38 if [ -z $FULL ]; then
39 echo "Base archive update only (pass second arg for full update)."
40 else
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
45 REPO_ADMIN=admin
46 fi
47 else
48 echo "Sorry but $DEST is not a directory, aborting."
49 exit 1
50 fi
51
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."
56 exit 1
57 else
58 cd $REPO_ROOT_DIR;
59 fi
60
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"
64 rm -rf $TMP_PKGROOT
65 $BZR export $TMP_PKGROOT $REPO_PACKAGES
66
67 ## If second arg is provided, copy in the admin directory.
68 if [ -z $FULL ]; then
69 echo "Skipping admin directory"
70 else
71 echo "Exporting admin scripts to $ADMINROOT"
72 rm -rf $ADMINROOT
73 $BZR export $ADMINROOT $REPO_ADMIN
74 fi
75
76
77 cd $TMP_PKGROOT
78
79
80 ## If second arg is provided, grab the Org daily
81 if [ -z $FULL ]; then
82 echo "Not fetching Org daily from orgmode.org"
83 else
84 echo "Fetching Org daily from orgmode.org"
85 pkgname=`curl -s http://orgmode.org/pkg/daily/|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/pkg/daily/${pkgname}.tar -O ${pkgname}.tar
87 if [ -f ${pkgname}.tar ]; then
88 tar xf ${pkgname}.tar
89 rm -f ${pkgname}.tar
90 mv ${pkgname} org
91 fi
92 fi
93
94 ## Call `batch-make-archive' to generate archive-contents, the readme
95 ## files, etc.
96 $EMACS -batch -l $REPO_ROOT_DIR/admin/archive-contents.el -f batch-make-archive
97
98 ## Tar up the multi-file packages.
99 echo "Creating multi-file package tarballs in $TMP_PKGROOT"
100 for pt in *; do
101 if [ -d $pt ]; then
102 echo "Creating tarball $TMP_PKGROOT/$pt.tar"
103 tar -cf $pt.tar $pt --remove-files
104 fi
105 done
106
107 ## Move the working directory to its final location
108 cd ..
109 rm -rf $PKGROOT-old
110 if [ -d $PKGROOT ]; then
111 mv $PKGROOT $PKGROOT-old
112 fi
113 mv $TMP_PKGROOT $PKGROOT
114 rm -rf $PKGROOT-old
115
116 ## If doing a full update, make a tarball of the entire archive.
117 if [ -z $FULL ]; then
118 echo "Skipping archive tarball"
119 else
120 echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)"
121 cd $REPO_ROOT_DIR
122 $BZR export --format=tgz --root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
123 fi
124
125 chmod -R a+rX $PKGROOT
126 echo "Update complete at" `/bin/date`