common Makefile.common,1.49,1.50

Bill Nottingham (notting) fedora-extras-commits at redhat.com
Thu May 3 18:50:26 UTC 2007


Author: notting

Update of /cvs/pkgs/common
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv3248

Modified Files:
	Makefile.common 
Log Message:
add download-from-upstream and gpg-checking targets



Index: Makefile.common
===================================================================
RCS file: /cvs/pkgs/common/Makefile.common,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- Makefile.common	3 May 2007 18:32:59 -0000	1.49
+++ Makefile.common	3 May 2007 18:49:56 -0000	1.50
@@ -445,4 +445,145 @@
 gimmespec:
 	@echo "$(SPECFILE)"
 
+##################### EXPERIMENTAL ##########################
+# this stuff is very experimental in nature and should not be
+# relied upon until these targets are moved above this line
 
+# This section contains some hacks that instrument
+# download-from-upstream support. You'll have to talk to gafton, he
+# knows how this shit works.
+
+# Add to the list of hardcoded upstream files the contents of the
+# ./upstream file
+UPSTREAM_FILES	+= $(shell if test -f ./upstream ; then cat ./upstream ; fi)
+# extensions for signature files we need to retrieve for verification
+# Warning: if you update the set of defaults, please make sure to
+# update/add to the checking rules further down
+UPSTREAM_CHECKS	?= sign asc sig md5
+
+# check the signatures for the downloaded upstream stuff
+UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
+
+# Download a file from a particular host.
+# First argument contains the url base, the second the filename,
+# third extra curl options
+define download-host-file
+if test ! -e "$(2)" ; then \
+    echo -n "URL: $(1)/$(2) ..." ; \
+    $(CURL) --silent --head $(1)/$(2) && \
+        { \
+	  echo "OK, downloading..." ; \
+          $(CURL) $(3) $(1)/$(2) ; \
+        } || \
+	echo "not found" ; \
+fi
+endef
+
+# Download a file, trying each mirror in sequence. Also check for
+# signatures, if available
+# First argument contains the file name. We read the list of mirrors
+# from the ./mirrors file
+define download-file
+$(foreach h, $(shell cat mirrors), 
+    $(call download-host-file,$(h),$(1))
+    if test -e $(1) ; then \
+        $(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
+    fi
+)
+if test ! -e $(1) ; then \
+    echo "ERROR: Could not download file: $(1)" ; \
+    exit -1 ; \
+else \
+    echo "File $(1) available for local use" ; \
+fi
+endef
+
+# Download all the UPSTREAM files
+define download-files
+$(foreach f, $(UPSTREAM_FILES),
+    $(call download-file,$(f))
+    echo
+)
+endef
+
+# Make sure the signature files we download are properly added
+define cvs-add-upstream-sigs
+for s in $(UPSTREAM_CHECK_FILES) ; do \
+    if test -f "$$s" ; then \
+        if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
+	    cvs -Q add "$$s" ; \
+	fi ; \
+    fi ; \
+done
+endef
+
+download : upstream mirrors
+	@$(download-files)
+	$(MAKE) download-checks
+
+download-checks :: import-upstream-gpg
+download-checks :: $(UPSTREAM_CHECK_FILES)
+
+# how to check for a gpg signature, given a separate signature file
+define check-upstream-gpg-sig
+echo -n "Checking GPG signature on $* from $@ : "
+if ! test -f $@ ; then \
+    echo "ERROR" ; echo "GPG signature file $@ not found" ; \
+    exit 1 ; \
+fi
+if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
+    echo "FAILED" ; \
+    exit 1 ; \
+else \
+    echo "OK" ; \
+fi
+endef
+
+# how to check for a md5sum, given a separate .md5 file
+define check-upstream-md5sum
+echo -n "Checking md5sum on $* from $@ : "
+if ! test -f $@ ; then \
+    echo "ERROR" ; echo "md5sum file $@ not found" ; \
+    exit 1 ; \
+fi
+if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
+    echo "FAILED" ; \
+    exit 1 ; \
+else \
+    echo "OK" ; \
+fi
+endef
+
+# and now the rules, specific to each extension
+$(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
+	@$(check-upstream-gpg-sig)
+$(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
+	@$(check-upstream-gpg-sig)
+$(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
+	@$(check-upstream-gpg-sig)
+$(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
+	@$(check-upstream-md5sum)
+
+# We keep all the relevant GPG keys in the upstream-key.gpg so we can
+# check the signatures...
+import-upstream-gpg : upstream-key.gpg FORCE
+	mkdir -p $(HOME)/.gnupg
+	gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
+
+# A handy target to download the latest and greatest from upstream and
+# check it into the lookaside cache.
+# new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
+# rebase uses the standard "make upload"
+new-base : clean download
+	$(MAKE) new-source FILES="$(UPSTREAM_FILES)"
+	@$(cvs-add-upstream-sigs)
+	@echo "Don't forget to do a 'cvs commit' for your new sources file."
+
+rebase : clean download
+	$(MAKE) upload FILES="$(UPSTREAM_FILES)"
+	@$(cvs-add-upstream-sigs)
+	@echo "Don't forget to do a 'cvs commit' for your new sources file."
+
+# there is more stuff to clean, now that we have upstream files
+clean ::
+	@rm -fv $(UPSTREAM_FILES)




More information about the scm-commits mailing list