]> code.delx.au - gnu-emacs-elpa/blob - admin/update-archive.sh
Refine the deployment script to avoid deploying unstable code.
[gnu-emacs-elpa] / admin / update-archive.sh
1 #!/bin/sh -x
2
3 batchmode=no
4
5 export LANG=C
6 case "$1" in
7 "--batch") batchmode=yes ;;
8 esac
9
10 # Return on STDOUT the files that don't seem to have the needed copyright
11 # notice, or that have a copyright notice that looks suspicious.
12 copyright_notices () {
13 find . -name '*.el' -print0 |
14 xargs -0 grep -L 'Free Software Foundation, Inc' |
15 grep -v '.-\(pkg\|autoloads\)\.el$'
16
17 find . -name '*.el' -print |
18 while read f; do
19 sed -n -e '/[Cc]opyright.*, *[1-9][-0-9]*,\?$/N' \
20 -e '/Free Software Foundation/d' \
21 -e "s|^\\(.*[Cc]opyright\\)|$(echo $f | tr '|' '_'):\\1|p" "$f"
22 done
23 }
24
25 # Send an email to warn about a problem.
26 # Takes the body on STDIN and the subject as argument.
27 signal_error () {
28 title="$*"
29 if [ "no" = "$batchmode" ]; then
30 cat -
31 echo "Error: $title"
32 else
33 mx_gnu_org="$(host -t mx gnu.org | sed 's/.*[ ]//')"
34 (sleep 5; echo "HELO elpa.gnu.org"
35 sleep 1; echo "MAIL FROM: <elpa@elpa.gnu.org>"
36 sleep 1; echo "RCPT TO: <emacs-elpa-diffs@gnu.org>"
37 sleep 1; echo "DATA"
38 sleep 1; cat <<ENDDOC
39 From: ELPA update <elpa@elpa.gnu.org>
40 To: emacs-elpa-diffs@gnu.org
41 Subject: $title
42
43 ENDDOC
44 cat -
45 echo "."; sleep 1) | telnet "$mx_gnu_org" smtp
46 fi
47 }
48
49 check_copyright () {
50 base="copyright_exceptions"
51 (cd packages; copyright_notices) >"$base.new"
52 if [ -r "$base.old" ] &&
53 ! diff "$base.old" "$base.new" >/dev/null;
54 then
55 diff -u "$base.old" "$base.new" |
56 signal_error "Copyright notices changed"
57 exit 1
58 else
59 mv "$base.new" "$base.old"
60 fi
61 }
62
63 cd ~elpa/build
64
65 (cd ~elpa/elpa; bzr up)
66
67 check_copyright
68
69 rm -rf archive # In case there's one left over!
70 make archive-full >make.log 2>&1 || {
71 signal_error "make archive-full failed" <make.log
72 exit 1
73 }
74 latest="emacs-packages-latest.tgz"
75 (cd archive
76 tar zcf "$latest" packages)
77 (cd ~elpa
78 # Not sure why we have `staging-old', but let's keep it for now.
79 rm -rf staging-old
80 cp -a staging staging-old
81 # Move new files into place but don't throw out old package versions.
82 for f in build/archive/packages/*; do
83 dst="staging/packages/$(basename "$f")"
84 # FIXME: it'd be better to only rebuild the packages that have been
85 # modified, rather than rely on md5 to try and abort the refresh
86 # when we don't want it!
87 # Actually, let's never overwrite an existing version. So changes can
88 # be installed without causing a new package to be build until the
89 # version field is changed.
90 if [ -r "$dst" ] # && [ "$(md5sum <"$f")" = "$(md5sum <"$dst")" ]
91 then rm "$f"
92 else mv "$f" "$dst"
93 fi
94 done
95 mv build/archive/"$latest" staging/
96 rm -rf build/archive)
97
98 # Make the HTML files.
99 (cd ~elpa/staging/packages
100 emacs --batch -l ~elpa/build/admin/archive-contents.el \
101 --eval '(batch-html-make-index)')
102
103 # "make archive-full" already does fetch the daily org build.
104 #admin/org-synch.sh ~elpa/staging/packages ~elpa/build/admin