#!/bin/sh -x
-batchmode=no
+makelog=""
+buildir="$(pwd)"
+
+announce=no
+a_email="" #info-gnu-emacs@gnu.org
export LANG=C
-case "$1" in
- "--batch") batchmode=yes ;;
-esac
-
-# Return on STDOUT the files that don't seem to have the needed copyright
-# notice, or that have a copyright notice that looks suspicious.
-copyright_notices () {
- find . -name '*.el' -print0 |
- xargs -0 grep -L 'Free Software Foundation, Inc' |
- grep -v '\(\.dir-locals\|.-\(pkg\|autoloads\)\)\.el$'
-
- find . -name '*.el' -print |
- while read f; do
- sed -n -e '/[Cc]opyright.*, *[1-9][-0-9]*,\?$/N' \
- -e '/Free Software Foundation/d' \
- -e "s|^\\(.*[Cc]opyright\\)|$(echo $f | tr '|' '_'):\\1|p" "$f"
- done
+while [ $# -gt 0 ]; do
+ case "$1" in
+ "--announce") announce=yes; a_email="$2"; shift ;;
+ "--batch")
+ makelog="$(pwd)/make.log"
+ exec >"$makelog" 2>&1
+ ;;
+ esac
+ shift
+done
+
+send_mail () {
+ to="$1"; shift
+ title="$*"
+ (cat <<ENDDOC
+From: ELPA update <do.not.reply@elpa.gnu.org>
+To: $to
+Subject: $title
+
+ENDDOC
+ cat -) | /usr/sbin/sendmail "$to"
}
# Send an email to warn about a problem.
-# Takes the body on STDIN and the subject as argument.
signal_error () {
title="$*"
- if [ "no" = "$batchmode" ]; then
- cat -
+ if [ "" = "$makelog" ]; then
echo "Error: $title"
else
- mx_gnu_org="$(host -t mx gnu.org | sed 's/.*[ ]//')"
- (sleep 5; echo "HELO elpa.gnu.org"
- sleep 1; echo "MAIL FROM: <elpa@elpa.gnu.org>"
- sleep 1; echo "RCPT TO: <emacs-elpa-diffs@gnu.org>"
- sleep 1; echo "DATA"
- sleep 1; cat <<ENDDOC
-From: ELPA update <elpa@elpa.gnu.org>
-To: emacs-elpa-diffs@gnu.org
-Subject: $title
-
-ENDDOC
- cat -
- echo "."; sleep 1) | telnet "$mx_gnu_org" smtp
+ send_mail "emacs-elpa-diffs@gnu.org" "$title" <"$makelog"
fi
+ exit 1
}
-check_copyright () {
- base="copyright_exceptions"
- (cd packages; copyright_notices) >"$base.new"
- if [ -r "$base.old" ] &&
- ! diff "$base.old" "$base.new" >/dev/null;
- then
- diff -u "$base.old" "$base.new" |
- signal_error "Copyright notices changed"
- exit 1
- else
- mv "$base.new" "$base.old"
- fi
+announce_new () {
+ if [ "yes" != "$announce" ]; then return; fi
+ pv="$1"
+ pkg="$(echo "$pv" | sed -e 's/^\(.*\)-\([^-]*\)\.[^-.]*$/\1/')"
+ ver="$(echo "$pv" | sed -e 's/^\(.*\)-\([^-]*\)\.[^-.]*$/\2/')"
+ if [ -z "$pkg" ] || [ -z "$ver" ]; then signal_error "bad PKG-VER: $pv"; fi
+ send_mail "$a_email" "[GNU ELPA] $pkg version $ver" <<ENDDOC
+Version $ver of GNU ELPA package $pkg has just been released.
+You can now find it in M-x package-list RET.
+
+More at http://elpa.gnu.org/packages/$pkg.html
+ENDDOC
}
-cd ~elpa/build
+cd ../elpa
+
+# Fetch changes.
+git pull || signal_error "git pull failed"
-(cd ~elpa/elpa;
+# Remember we're inside the "elpa" branch which we don't want to trust,
+# So always refer to the makefile and admins files from $builddir".
- # Fetch changes.
- git pull || signal_error "git pull failed";
+# Setup and update externals.
+emacs --batch -l "$buildir/admin/archive-contents.el" \
+ -f archive-add/remove/update-externals
- # Refresh the ChangeLog files. This needs to be done in
- # the source tree, because it needs the Bzr data!
- (cd packages;
- emacs -batch -l ../admin/archive-contents.el -f batch-prepare-packages);
+make -f "$buildir/GNUmakefile" check_copyrights ||
+ signal_error "check_copyright failed"
- emacs --batch -l admin/archive-contents.el -f archive-add/remove-externals;
+cd "$buildir"
+
+rsync -av --delete \
+ --exclude=ChangeLog \
+ --exclude=.git \
+ --exclude='*.elc' \
+ --exclude='*~' \
+ --exclude='*-autoloads.el' \
+ ../elpa/packages ./
+
+# Refresh the ChangeLog files. This needs to be done in
+# the source tree, because it needs the VCS data!
+emacs -batch -l admin/archive-contents.el \
+ -eval '(archive-prepare-packages "../elpa")'
- check_copyright
- )
rm -rf archive # In case there's one left over!
-make archive-full >make.log 2>&1 || {
- signal_error "make archive-full failed" <make.log
- exit 1
+make archive-full || {
+ signal_error "make archive-full failed"
}
latest="emacs-packages-latest.tgz"
(cd archive
- tar zcf "$latest" packages)
-(cd ~elpa
+ GZIP=--best tar zcf "$latest" packages)
+(cd ../
+ mkdir -p staging/packages
# Not sure why we have `staging-old', but let's keep it for now.
- rm -rf staging-old
- cp -a staging staging-old
+ rsync -av --inplace --delete staging/. staging-old/.
# Move new files into place but don't throw out old package versions.
for f in build/archive/packages/*; do
- dst="staging/packages/$(basename "$f")"
+ # PKG-VER
+ pv=$(basename "$f")
+ dst="staging/packages/$pv"
# Actually, let's never overwrite an existing version. So changes can
# be installed without causing a new package to be built until the
# version field is changed. Some files need to be excluded from the
*/archive-contents | *-readme.txt ) mv "$f" "$dst" ;;
* ) if [ -r "$dst" ]
then rm "$f"
- else mv "$f" "$dst"
+ else
+ mv "$f" "$dst"
+ # FIXME: Add a tag to remember the precise code used.
+ announce_new "$pv"
fi ;;
esac
done
mv build/archive/"$latest" staging/
rm -rf build/archive)
-# Make the HTML files.
-(cd ~elpa/staging/packages
- emacs --batch -l ~elpa/build/admin/archive-contents.el \
+# Make the HTML and readme.txt files.
+(cd ../staging/packages
+ emacs --batch -l ../../build/admin/archive-contents.el \
--eval '(batch-html-make-index)')
-
-# "make archive-full" already does fetch the daily org build.
-#admin/org-synch.sh ~elpa/staging/packages ~elpa/build/admin