]> code.delx.au - gnu-emacs-elpa/blob - admin/update-archive.sh
New package systemd
[gnu-emacs-elpa] / admin / update-archive.sh
1 #!/bin/sh -x
2
3 makelog=""
4 buildir="$(pwd)"
5
6 announce=no
7 a_email="" #info-gnu-emacs@gnu.org
8
9 export LANG=C
10 while [ $# -gt 0 ]; do
11 case "$1" in
12 "--announce") announce=yes; a_email="$2"; shift ;;
13 "--batch")
14 makelog="$(pwd)/make.log"
15 exec >"$makelog" 2>&1
16 ;;
17 esac
18 shift
19 done
20
21 send_mail () {
22 to="$1"; shift
23 title="$*"
24 (cat <<ENDDOC
25 From: ELPA update <do.not.reply@elpa.gnu.org>
26 To: $to
27 Subject: $title
28
29 ENDDOC
30 cat -) | /usr/sbin/sendmail "$to"
31 }
32
33 # Send an email to warn about a problem.
34 signal_error () {
35 title="$*"
36 if [ "" = "$makelog" ]; then
37 echo "Error: $title"
38 else
39 send_mail "emacs-elpa-diffs@gnu.org" "$title" <"$makelog"
40 fi
41 exit 1
42 }
43
44 announce_new () {
45 if [ "yes" != "$announce" ]; then return; fi
46 pv="$1"
47 pkg="$(echo "$pv" | sed -e 's/^\(.*\)-\([^-]*\)\.[^-.]*$/\1/')"
48 ver="$(echo "$pv" | sed -e 's/^\(.*\)-\([^-]*\)\.[^-.]*$/\2/')"
49 if [ -z "$pkg" ] || [ -z "$ver" ]; then signal_error "bad PKG-VER: $pv"; fi
50 send_mail "$a_email" "[GNU ELPA] $pkg version $ver" <<ENDDOC
51 Version $ver of GNU ELPA package $pkg has just been released.
52 You can now find it in M-x package-list RET.
53
54 More at http://elpa.gnu.org/packages/$pkg.html
55 ENDDOC
56 }
57
58 cd ../elpa
59
60 # Fetch changes.
61 git pull || signal_error "git pull failed"
62
63 # Remember we're inside the "elpa" branch which we don't want to trust,
64 # So always refer to the makefile and admins files from $builddir".
65
66 # Setup and update externals.
67 emacs --batch -l "$buildir/admin/archive-contents.el" \
68 -f archive-add/remove/update-externals
69
70 make -f "$buildir/GNUmakefile" check_copyrights ||
71 signal_error "check_copyright failed"
72
73 cd "$buildir"
74
75 rsync -av --delete \
76 --exclude=ChangeLog \
77 --exclude=.git \
78 --exclude='*.elc' \
79 --exclude='*~' \
80 --exclude='*-autoloads.el' \
81 ../elpa/packages ./
82
83 # Refresh the ChangeLog files. This needs to be done in
84 # the source tree, because it needs the VCS data!
85 emacs -batch -l admin/archive-contents.el \
86 -eval '(archive-prepare-packages "../elpa")'
87
88
89 rm -rf archive # In case there's one left over!
90 make archive-full || {
91 signal_error "make archive-full failed"
92 }
93 latest="emacs-packages-latest.tgz"
94 (cd archive
95 GZIP=--best tar zcf "$latest" packages)
96 (cd ../
97 mkdir -p staging/packages
98 # Not sure why we have `staging-old', but let's keep it for now.
99 mkdir -p staging-old
100 rsync -av --inplace --delete staging/. staging-old/.
101 # Move new files into place but don't throw out old package versions.
102 for f in $buildir/archive/packages/*; do
103 # PKG-VER
104 pv=$(basename "$f")
105 dst="staging/packages/$pv"
106 # Actually, let's never overwrite an existing version. So changes can
107 # be installed without causing a new package to be built until the
108 # version field is changed. Some files need to be excluded from the
109 # "immutable" policy, most importantly "archive-contents"
110 # and "*-readme.txt".
111 case $dst in
112 */archive-contents | *-readme.txt ) mv "$f" "$dst" ;;
113 * ) if [ -r "$dst" ]
114 then rm "$f"
115 else
116 mv "$f" "$dst"
117 # FIXME: Add a tag to remember the precise code used.
118 announce_new "$pv"
119 fi ;;
120 esac
121 done
122 mv $buildir/archive/"$latest" staging/
123 rm -rf $buildid/archive)
124
125 # Make the HTML and readme.txt files.
126 (cd ../staging/packages
127 emacs --batch -l $buildir/admin/archive-contents.el \
128 --eval '(batch-html-make-index)')