]> code.delx.au - gnu-emacs-elpa/blobdiff - GNUmakefile
Dereference symlinks when creating tarballs
[gnu-emacs-elpa] / GNUmakefile
index 03044dccc77b4bd0ba53d23bf6aca8cb147a732e..010d1658594d94be1f29979776ece3cfc1611eec 100644 (file)
@@ -13,8 +13,8 @@ CR_EXCEPTIONS=copyright_exceptions
 .PHONY: check_copyrights
 check_copyrights:
        @echo "Compute exceptions >$(CR_EXCEPTIONS)~"
-       @export LANG=C;                                                 \
-       (cd packages;                                                   \
+       @export LC_ALL=C;                                               \
+       (cd packages &&                                                 \
        find . -name '.git' -prune -o                                   \
               -name 'test' -prune -o                                   \
               -name '*.el' -print0 |                                   \
@@ -40,14 +40,21 @@ archive-tmp: packages
        mkdir -p $(ARCHIVE_TMP)
        cp -a packages/. $(ARCHIVE_TMP)/packages
 
+# Use && after the cd commands, not ;, to ensure the build fails
+# immediately if the directory $(ARCHIVE_TMP)/packages does not exist.
+# For process-archive this is crucial; otherwise batch-make-archive in
+# archive-contents.el will interpret directories in the current
+# directory as unreleased packages, and recursively delete them,
+# including .git.  Prior to using &&, running "make process-archive"
+# could silently delete all local git history!
 process-archive:
        # FIXME, we could probably speed this up significantly with
        # rules like "%.tar: ../%/ChangeLog" so we only rebuild the packages
        # that have indeed changed.
-       cd $(ARCHIVE_TMP)/packages;                             \
+       cd $(ARCHIVE_TMP)/packages &&                           \
          $(EMACS) -l $(CURDIR)/admin/archive-contents.el       \
                   -f batch-make-archive
-       @cd $(ARCHIVE_TMP)/packages;                            \
+       @cd $(ARCHIVE_TMP)/packages &&                          \
          for pt in *; do                                       \
              if [ -f "$${pt}/.elpaignore" ]; then              \
                  ignore="$${pt}/.elpaignore";                  \
@@ -56,7 +63,7 @@ process-archive:
              fi;                                               \
              if [ -d $$pt ]; then                              \
                  echo "Creating tarball $${pt}.tar" &&         \
-                 tar -cf $${pt}.tar $$pt --exclude-vcs -X "$$ignore";  \
+                 tar -chf $${pt}.tar $$pt --exclude-vcs -X "$$ignore"; \
                  rm -rf $${pt};                                \
              fi;                                               \
          done
@@ -76,7 +83,7 @@ archive-full: archive-tmp org-fetch
 # FIXME: Turn it into an `external', which will require adding the notion of
 # "snapshot" packages.
 org-fetch: archive-tmp
-       cd $(ARCHIVE_TMP)/packages; \
+       cd $(ARCHIVE_TMP)/packages && \
        pkgname=`curl -s http://orgmode.org/elpa/|perl -ne 'push @f, $$1 if m/(org-\d{8})\.tar/; END { @f = sort @f; print "$$f[-1]\n"}'`; \
        wget -q http://orgmode.org/elpa/$${pkgname}.tar -O $${pkgname}.tar; \
        if [ -f $${pkgname}.tar ]; then \
@@ -110,19 +117,20 @@ autoloads := $(foreach pkg, $(pkgs), $(pkg)/$(notdir $(pkg))-autoloads.el)
 # FIXME: In 99% of the cases, autoloads can be generated in any order.
 # But the `names' package is an exception because it sets up an advice that
 # changes the way autload.el operates, and that advice is needed when creating
-# the autoloads file of packages that use `names', such as `aggressive-indent'.
+# the autoloads file of packages that use `names'.
 # The right solution is to check the Package-Requires and create the autoloads
-# files in topological order, but for now we'll just do it the ad-hoc way
+# files in topological order, but for now we can just do it the ad-hoc way and
 # add hand-made dependencies between autoloads files, and explicitly
-# load the names-autoloads file when building autoloads files.
+# load the names-autoloads file when building autoloads files. An example entry
+# is commented below, this is what should be done if a package depends on Names.
 
-packages/aggressive-indent/aggressive-indent-autoloads.el: \
-    packages/names/names-autoloads.el
+packages/aggressive-indent/aggressive-indent-autoloads.el: \
+    packages/names/names-autoloads.el
 
 $(foreach al, $(autoloads), $(eval $(call RULE-srcdeps, $(al))))
 %-autoloads.el:
        @echo 'Generating autoloads for $@'
-       @cd $(dir $@); \
+       @cd $(dir $@) && \
          $(EMACS) -l $(CURDIR)/admin/archive-contents.el \
              --eval "(archive--refresh-pkg-file)" \
              --eval "(require 'package)" \