]> code.delx.au - gnu-emacs-elpa/blobdiff - admin/update-archive.sh
Move check_copyright to the makefile
[gnu-emacs-elpa] / admin / update-archive.sh
index 7936a57a92f5ad22604702c78cefc00969fb8493..91090ac837e8f45ddf52f8374f3f01678ffb4256 100755 (executable)
@@ -1,37 +1,23 @@
 #!/bin/sh -x
 
-batchmode=no
+makelog=""
+buildir="$(pwd)"
 
 export LANG=C
 case "$1" in
-    "--batch") batchmode=yes ;;
+    "--batch")
+        makelog="$(pwd)/make.log"
+        exec >"$makelog" 2>&1
+        ;;
 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
-}
-
 # 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
-        set -- $(host -t mx gnu.org);
-        mx_gnu_org="$4"
+        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>"
@@ -42,46 +28,68 @@ To: emacs-elpa-diffs@gnu.org
 Subject: $title
 
 ENDDOC
-         cat -
-         echo ".") | telnet "$mx_gnu_org" smtp
+         cat "$makelog"
+         echo "."; sleep 1) | telnet "$mx_gnu_org" smtp
     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
-}
 
-cd ~elpa/build
+cd ../elpa
 
-(cd ~elpa/elpa; bzr up)
+# Fetch changes.
+git pull || signal_error "git pull failed"
+
+# Setup and update externals.
+make externals
+
+make check_copyrights || signal_error "check_copyright failed"
+
+cd "$buildir"
+
+rsync -av --delete --exclude=ChangeLog --exclude=.git ../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
+ 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
+                 # FIXME: Announce the new package/version on
+                 # gnu.emacs.sources!
+                 mv "$f" "$dst"
+             fi ;;
+     esac
+ done
+ mv build/archive/"$latest" staging/
  rm -rf build/archive)
 
-# "make archive-full" already does fetch the daily org build.
-#admin/org-synch.sh ~elpa/staging/packages ~elpa/build/admin
+# Make the HTML and readme.txt files.
+(cd ../staging/packages
+ emacs --batch -l ../../build/admin/archive-contents.el \
+       --eval '(batch-html-make-index)')