]> code.delx.au - gnu-emacs-elpa/blob - admin/package-update.sh
admin/package-update.sh: Make it run from a bzr repository.
[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 and the `archive-contents' listing file.
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 contianing 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
19 DEST=${1%/}
20 FULL=$2
21
22 EMACS=emacs
23 BZR=bzr
24
25 LOG=$DEST/update-log
26 PKGROOT=$DEST/packages
27 TMP_PKGROOT=$DEST/packages-new
28 REPO_PACKAGES=packages
29
30 ## Parse arguments
31 if [ -z $DEST ]; then
32 echo "Syntax: $0 HOMEDIR [fetch-extras-boolean]"
33 exit 1
34 elif [ -d $DEST ]; then
35 echo "Installing into '$DEST', log is '$LOG'"
36 echo "Installing into '$DEST'" > $LOG
37 if [ -z $FULL ]; then
38 echo "Base archive update only (pass second arg for full update)."
39 else
40 echo "Performing full archive update."
41 TARBALL=$PKGROOT/emacs-packages-latest.tgz
42 TARBALL_ROOT="emacs-24.1-packages-`/bin/date +'%F'`"
43 ADMINROOT=$DEST/admin
44 REPO_ADMIN=admin
45 fi
46 else
47 echo "Sorry but $DEST is not a directory, aborting."
48 exit 1
49 fi
50
51 ## Change to the bzr root directory
52 cd $(dirname $0)
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" >> $LOG
64 rm -rf $TMP_PKGROOT
65 $BZR export $TMP_PKGROOT $REPO_PACKAGES
66
67 ## Call the `make-package-archive' Lisp function.
68
69 ## If second arg is provided, copy in the admin directory and run the
70 ## Org daily synch scripts
71 if [ -z $FULL ]; then
72 echo "Skipping admin directory" >> $LOG
73 echo "Skipping post-export fetchers" >> $LOG
74 else
75 echo "Exporting admin scripts to $ADMINROOT" >> $LOG
76 rm -rf $ADMINROOT
77 $BZR export $ADMINROOT $REPO_ADMIN
78 echo "Running post-export org-mode fetcher as '$ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT'" >> $LOG
79 $ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT >> $LOG 2>&1
80 fi
81
82 ## Tar up the multi-file packages.
83 echo "Creating multi-file package tarballs in $TMP_PKGROOT" >> $LOG
84 cd $TMP_PKGROOT
85 for pt in *; do
86 if [ -d $pt ]; then
87 if [ -f $pt/README ]; then
88 cp $pt/README $pt-readme.txt;
89 fi
90 echo "Creating tarball $TMP_PKGROOT/$pt.tar" >> $LOG
91 tar -cf $pt.tar $pt --remove-files
92 fi
93 done
94
95 ## Move the working directory to its final location
96 echo "Moving $TMP_PKGROOT to $PKGROOT" >> $LOG
97 rm -rf $PKGROOT-old
98 if [ -d $PKGROOT ]; then
99 mv $PKGROOT $PKGROOT-old
100 fi
101 mv $TMP_PKGROOT $PKGROOT
102 rm -rf $PKGROOT-old
103
104 ## If doing a full update, make a tarball of the entire archive.
105 if [ -z $FULL ]; then
106 echo "Skipping archive tarball" >> $LOG
107 else
108 echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)" >> $LOG
109 cd $REPO_ROOT_DIR
110 $BZR export --format=tgz --root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
111 fi
112
113 chmod -R a+rX $PKGROOT
114 echo "Update complete at" `/bin/date` >> $LOG