]> code.delx.au - gnu-emacs-elpa/blob - admin/package-update.sh
b1c8b21c75363dbfa5ffd7a1ba16a76c32ca09bd
[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 ## If second arg is provided, copy in the admin directory and run the
69 ## Org daily synch scripts
70 if [ -z $FULL ]; then
71 echo "Skipping admin directory" >> $LOG
72 echo "Skipping post-export fetchers" >> $LOG
73 else
74 echo "Exporting admin scripts to $ADMINROOT" >> $LOG
75 rm -rf $ADMINROOT
76 $BZR export $ADMINROOT $REPO_ADMIN
77 echo "Running post-export org-mode fetcher as '$ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT'" >> $LOG
78 $ADMINROOT/org-synch.sh $TMP_PKGROOT $ADMINROOT >> $LOG 2>&1
79 fi
80
81 ## Generate archive-contents and the readme files.
82
83 cd $TMP_PKGROOT
84 $TAR xf *.tar
85 rm -f *.tar
86 $EMACS -batch -l $REPO_ROOT_DIR/admin/archive-contents.el -f batch-make-archive-contents
87
88 ## Tar up the multi-file packages.
89
90 echo "Creating multi-file package tarballs in $TMP_PKGROOT" >> $LOG
91 for pt in *; do
92 if [ -d $pt ]; then
93 echo "Creating tarball $TMP_PKGROOT/$pt.tar" >> $LOG
94 tar -cf $pt.tar $pt --remove-files
95 fi
96 done
97
98 ## Move the working directory to its final location
99 echo "Moving $TMP_PKGROOT to $PKGROOT" >> $LOG
100 rm -rf $PKGROOT-old
101 if [ -d $PKGROOT ]; then
102 mv $PKGROOT $PKGROOT-old
103 fi
104 mv $TMP_PKGROOT $PKGROOT
105 rm -rf $PKGROOT-old
106
107 ## If doing a full update, make a tarball of the entire archive.
108 if [ -z $FULL ]; then
109 echo "Skipping archive tarball" >> $LOG
110 else
111 echo "Exporting packages into $TARBALL (root = $TARBALL_ROOT)" >> $LOG
112 cd $REPO_ROOT_DIR
113 $BZR export --format=tgz --root=$TARBALL_ROOT $TARBALL $REPO_PACKAGES
114 fi
115
116 chmod -R a+rX $PKGROOT
117 echo "Update complete at" `/bin/date` >> $LOG