]> code.delx.au - gnu-emacs-elpa/blob - admin/package-update.sh
95c389a76310b844408a3a31ca312b9d2b71b03b
[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 DEST=${1%/}
20 FULL=$2
21
22 EMACS=emacs
23 BZR=bzr
24 TAR=tar
25
26 LOG=$DEST/update-log
27 PKGROOT=$DEST/packages
28 TMP_PKGROOT=$DEST/packages-new
29 REPO_PACKAGES=packages
30
31 ## Parse arguments
32 if [ -z $DEST ]; then
33 echo "Syntax: $0 DEST [fetch-extras-boolean]"
34 exit 1
35 elif [ -d $DEST ]; then
36 echo "Installing into '$DEST', log is '$LOG'"
37 echo "Installing into '$DEST'" > $LOG
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/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 cd $(dirname $0)
54 REPO_ROOT_DIR=`$BZR root`;
55 if [ -z $REPO_ROOT_DIR ]; then
56 "This script should be run from a bzr repository, aborting."
57 exit 1
58 else
59 cd $REPO_ROOT_DIR;
60 fi
61
62 ## Create the working directory that will be the world-facing copy of
63 ## the package archive base.
64 echo "Exporting packages to temporary working directory $TMP_PKGROOT" >> $LOG
65 rm -rf $TMP_PKGROOT
66 $BZR export $TMP_PKGROOT $REPO_PACKAGES
67
68 ## Call the `make-package-archive' Lisp function.
69
70 ## If second arg is provided, copy in the admin directory and run the
71 ## Org daily synch scripts
72 if [ -z $FULL ]; then
73 echo "Skipping admin directory" >> $LOG
74 echo "Skipping post-export fetchers" >> $LOG
75 else
76 echo "Exporting admin scripts to $ADMINROOT" >> $LOG
77 rm -rf $ADMINROOT
78 $BZR export $ADMINROOT $REPO_ADMIN
79 echo "Running post-export org-mode fetcher as '$ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT'" >> $LOG
80 $ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT >> $LOG 2>&1
81 fi
82
83 ## Generate archive-contents and the readme files.
84
85 cd $TMP_PKGROOT
86 $TAR xf *.tar
87 rm -f *.tar
88 $EMACS -batch -l $REPO_ROOT_DIR/admin/archive-contents.el -f batch-make-archive-contents
89
90 ## Tar up the multi-file packages.
91
92 echo "Creating multi-file package tarballs in $TMP_PKGROOT" >> $LOG
93 for pt in *; do
94 if [ -d $pt ]; then
95 echo "Creating tarball $TMP_PKGROOT/$pt.tar" >> $LOG
96 tar -cf $pt.tar $pt --remove-files
97 fi
98 done
99
100 ## Move the working directory to its final location
101 echo "Moving $TMP_PKGROOT to $PKGROOT" >> $LOG
102 rm -rf $PKGROOT-old
103 if [ -d $PKGROOT ]; then
104 mv $PKGROOT $PKGROOT-old
105 fi
106 mv $TMP_PKGROOT $PKGROOT
107 rm -rf $PKGROOT-old
108
109 ## If doing a full update, make a tarball of the entire archive.
110 if [ -z $FULL ]; then
111 echo "Skipping archive tarball" >> $LOG
112 else
113 echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)" >> $LOG
114 cd $REPO_ROOT_DIR
115 $BZR export --format=tgz --root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
116 fi
117
118 chmod -R a+rX $PKGROOT
119 echo "Update complete at" `/bin/date` >> $LOG