]> code.delx.au - gnu-emacs-elpa/blob - admin/update-archive.sh
Merge commit '500222d5378f55bbfd6f35cbb65107f2342bf3c3'
[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 rsync -av --inplace --delete staging/. staging-old/.
100 # Move new files into place but don't throw out old package versions.
101 for f in build/archive/packages/*; do
102 # PKG-VER
103 pv=$(basename "$f")
104 dst="staging/packages/$pv"
105 # Actually, let's never overwrite an existing version. So changes can
106 # be installed without causing a new package to be built until the
107 # version field is changed. Some files need to be excluded from the
108 # "immutable" policy, most importantly "archive-contents"
109 # and "*-readme.txt".
110 case $dst in
111 */archive-contents | *-readme.txt ) mv "$f" "$dst" ;;
112 * ) if [ -r "$dst" ]
113 then rm "$f"
114 else
115 mv "$f" "$dst"
116 # FIXME: Add a tag to remember the precise code used.
117 announce_new "$pv"
118 fi ;;
119 esac
120 done
121 mv build/archive/"$latest" staging/
122 rm -rf build/archive)
123
124 # Make the HTML and readme.txt files.
125 (cd ../staging/packages
126 emacs --batch -l ../../build/admin/archive-contents.el \
127 --eval '(batch-html-make-index)')