]> code.delx.au - gnu-emacs-elpa/blobdiff - admin/update-archive.sh
Add ergoemacs-mode; fix up externals maintenance
[gnu-emacs-elpa] / admin / update-archive.sh
index e4f33c8b0c0a30911c747cd6ff25d7a7a7bdfc6d..d7d4e931b3a6152c8a1e7c992a2ee7d2dcd315cd 100755 (executable)
 #!/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 '.-\(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 an email to warn about a problem.
-# Takes the body on STDIN and the subject as argument.
-signal_error () {
+send_mail () {
+    to="$1"; shift
     title="$*"
-    if [ "no" = "$batchmode" ]; then
-        cat -
-        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
+    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: <$to>"
+     sleep 1; echo "DATA"
+     sleep 1; cat <<ENDDOC
+From: ELPA update <do.not.reply@elpa.gnu.org>
+To: $to
 Subject: $title
 
 ENDDOC
-         cat -
+         cat -; echo
          echo "."; sleep 1) | telnet "$mx_gnu_org" smtp
-    fi
 }
 
-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
+# Send an email to warn about a problem.
+signal_error () {
+    title="$*"
+    if [ "" = "$makelog" ]; then
+        echo "Error: $title"
     else
-        mv "$base.new" "$base.old"
+        send_mail "emacs-elpa-diffs@gnu.org" "$title" <"$makelog"
     fi
+    exit 1
 }
 
-cd ~elpa/build
+announce_new () {
+    if [ "yes" != "$announce" ]; then return; fi
+    file="$1"
+    version="$(echo "$file" | sed -e 's|^.*/||' -e 's/^\(.*\)-\([^-]*\)\.[^-.]*$/\2/')"
+    pkg="$(echo "$file" | sed -e 's|^.*/||' -e 's/^\(.*\)-\([^-]*\)\.[^-.]*$/\1/')"
+    send_mail "$a_email" "[GNU ELPA] $pkg version $version" <<ENDDOC
+Version $version of GNU ELPA package $pkg has just been released.
+You can now find it in M-x package-list RET.
 
-(cd ~elpa/elpa; bzr up)
+More at http://elpa.gnu.org/packages/$pkg.html
+ENDDOC
+}
+
+cd ../elpa
+
+# Fetch changes.
+git pull || signal_error "git pull failed"
+
+# 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".
+
+# Setup and update externals.
+emacs --batch -l "$buildir/admin/archive-contents.el" \
+      -f archive-add/remove/update-externals
+
+make -f "$buildir/GNUmakefile" check_copyrights ||
+    signal_error "check_copyright failed"
+
+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 emacs-packages-latest.tgz 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
  # Move new files into place but don't throw out old package versions.
- mv build/archive/packages/* staging/packages/
- mv build/archive/* staging/ 2>/dev/null
+ for f in build/archive/packages/*; do
+     dst="staging/packages/$(basename "$f")"
+     # 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
+     # "immutable" policy, most importantly "archive-contents"
+     # and "*-readme.txt".
+     case $dst in
+         */archive-contents | *-readme.txt ) mv "$f" "$dst" ;;
+         * ) if [ -r "$dst" ]
+             then rm "$f"
+             else
+                 mv "$f" "$dst"
+                 # FIXME: Add a tag to remember the precise code used.
+                 announce_new "$f"
+             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