/[smeserver]/common/Makefile.common
ViewVC logotype

Contents of /common/Makefile.common

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.8 - (show annotations) (download)
Mon Dec 24 17:30:34 2007 UTC (16 years, 4 months ago) by slords
Branch: MAIN
Changes since 1.7: +0 -0 lines
test

1 # -*- Makefile -*-
2 #
3 # Common Makefile for building RPMs
4 # Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
5 # Copyright (C) 2004-2005 Red Hat, Inc.
6 # Copyright (C) 2005 Fedora Foundation
7 #
8 # $Id: Makefile.common,v 1.5 2007/12/24 16:50:52 slords Exp $
9
10 # Define the common dir.
11 # This needs to happen first.
12 define find-common-dir
13 for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then echo "$$d"; break ; fi ; done
14 endef
15 COMMON_DIR := $(shell $(find-common-dir))
16
17 # Branch and disttag definitions
18 # These need to happen second.
19 ifndef HEAD_BRANCH
20 HEAD_BRANCH := devel
21 endif
22 BRANCH:=$(shell [ -f branch ] && cat branch || echo $(HEAD_BRANCH))
23 BRANCHINFO = $(shell grep ^$(BRANCH): $(COMMON_DIR)/branches | cut -d: --output-delimiter=" " -f2-)
24 TARGET := $(word 1, $(BRANCHINFO))
25 DIST = $(word 2, $(BRANCHINFO))
26 DISTVAR = $(word 3, $(BRANCHINFO))
27 DISTVAL = $(word 4, $(BRANCHINFO))
28 DIST_DEFINES = --define "dist $(DIST)" --define "$(DISTVAR) $(DISTVAL)"
29
30 BUILD_FLAGS ?= $(shell echo $(KOJI_FLAGS))
31
32 ## a base directory where we'll put as much temporary working stuff as we can
33 ifndef WORKDIR
34 WORKDIR := $(shell pwd)
35 endif
36 ## of course all this can also be overridden in your RPM macros file,
37 ## but this way you can separate your normal RPM setup from your CVS
38 ## setup. Override RPM_WITH_DIRS in ~/.cvspkgsrc to avoid the usage of
39 ## these variables.
40 SRCRPMDIR ?= $(WORKDIR)
41 BUILDDIR ?= $(WORKDIR)
42 RPMDIR ?= $(WORKDIR)
43 MOCKDIR ?= $(WORKDIR)
44 ifeq ($(DISTVAR),epel)
45 DISTVAR := rhel
46 MOCKCFG ?= fedora-$(DISTVAL)-$(BUILDARCH)-epel.cfg
47 else
48 MOCKCFG ?= fedora-$(DISTVAL)-$(BUILDARCH)-core.cfg
49 endif
50 ## SOURCEDIR is special; it has to match the CVS checkout directory,
51 ## because the CVS checkout directory contains the patch files. So it basically
52 ## can't be overridden without breaking things. But we leave it a variable
53 ## for consistency, and in hopes of convincing it to work sometime.
54 ifndef SOURCEDIR
55 SOURCEDIR := $(shell pwd)
56 endif
57
58 ifndef RPM_DEFINES
59 RPM_DEFINES = --define "_sourcedir $(SOURCEDIR)" \
60 --define "_builddir $(BUILDDIR)" \
61 --define "_srcrpmdir $(SRCRPMDIR)" \
62 --define "_rpmdir $(RPMDIR)" \
63 $(DIST_DEFINES)
64 endif
65
66 # Initialize the variables that we need, but are not defined
67 # the version of the package
68 ifndef NAME
69 $(error "You can not run this Makefile without having NAME defined")
70 endif
71 ifndef VERSION
72 VERSION := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1)
73 endif
74 # the release of the package
75 ifndef RELEASE
76 RELEASE := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1)
77 endif
78 # this is used in make patch, maybe make clean eventually.
79 # would be nicer to autodetermine from the spec file...
80 RPM_BUILD_DIR ?= $(BUILDDIR)/$(NAME)-$(VERSION)
81
82 # default target: just make sure we've got the sources
83 all: sources
84
85 # user specific configuration
86 CVS_EXTRAS_RC := $(shell if test -f $(HOME)/.cvspkgsrc ; then echo $(HOME)/.cvspkgsrc ; fi)
87 ifdef CVS_EXTRAS_RC
88 include $(CVS_EXTRAS_RC)
89 endif
90
91 # The repository and the clients we use for the files
92 REPOSITORY ?= http://lordsfam.net/yum/builds/source
93 UPLOAD_REPOSITORY ?= /builds/source
94
95 # We define CURL and WGET in a way that makes if possible to have them
96 # overwritten from the module's Makefiles. Then CLIENT picks CURL, otherwise WGET
97 CURL ?= $(shell if test -f /usr/bin/curl ; then echo "curl -H Pragma: -O -R -S --fail --show-error" ; fi)
98 WGET ?= $(shell if test -f /usr/bin/wget ; then echo "wget -nd -m" ; fi)
99 CLIENT ?= $(if $(CURL),$(CURL),$(if $(WGET),$(WGET)))
100 PLAGUE_CLIENT ?= $(shell which plague-client 2>/dev/null)
101 BUILD_CLIENT ?= $(shell which koji 2>/dev/null)
102
103 # RPM with all the overrides in place; you can override this in your
104 # .cvspkgsrc also, to use a default rpm setup
105 # the rpm build command line
106 ifndef RPM
107 RPM := $(shell if test -f /usr/bin/rpmbuild ; then echo rpmbuild ; else echo rpm ; fi)
108 endif
109 ifndef RPM_WITH_DIRS
110 RPM_WITH_DIRS = $(RPM) $(RPM_DEFINES)
111 endif
112
113 # CVS-safe version/release -- a package name like 4Suite screws things
114 # up, so we have to remove the leaving digits from the name
115 TAG_NAME := $(shell echo $(NAME) | sed -e s/\\\./_/g -e s/^[0-9]\\\+//g)
116 TAG_VERSION := $(shell echo $(VERSION) | sed s/\\\./_/g)
117 TAG_RELEASE := $(shell echo $(RELEASE) | sed s/\\\./_/g)
118
119 # tag to export, defaulting to current tag in the spec file
120 TAG?=$(TAG_NAME)-$(TAG_VERSION)-$(TAG_RELEASE)
121
122 # where to cvs export temporarily
123 TMPCVS := $(WORKDIR)/cvs-$(TAG)
124
125 # source file basenames
126 SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print $$2 }')
127 # full path to source files
128 FULLSOURCEFILES := $(addprefix $(SOURCEDIR)/,$(SOURCEFILES))
129
130 # retrieve the stored md5 sum for a source download
131 define get_sources_md5
132 $(shell cat sources 2>/dev/null | while read m f ; do if test "$$f" = "$@" ; then echo $$m ; break ; fi ; done)
133 endef
134
135 # list the possible targets for valid arches
136 ARCHES = noarch i386 i586 i686 x86_64 ia64 s390 s390x ppc ppc64 pseries ppc64pseries iseries ppc64iseries # athlon alpha alphaev6 sparc sparc64 sparcv9 i164 mac sh mips
137
138 # for the modules that do different "make prep" depending on what arch we build for
139 PREP_ARCHES = $(addprefix prep-,$(ARCHES))
140
141 ## list all our bogus targets
142 .PHONY :: $(ARCHES) sources uploadsource upload export check build-check plague koji build test-srpm srpm tag force-tag verrel new clean patch prep compile install-short compile-short FORCE local
143
144 # The TARGETS define is meant for local module targets that should be
145 # made in addition to the SOURCEFILES whenever needed
146 TARGETS ?=
147
148 # default target - retrieve the sources and make the module specific targets
149 sources: $(SOURCEFILES) $(TARGETS)
150
151 # Retrieve the sources we do not have in CVS
152 $(SOURCEFILES): #FORCE
153 @mkdir -p $(SOURCEDIR)
154 @echo "Downloading $@..."
155 @for i in `find ../ -maxdepth 2 -name "$@"`; do \
156 if test "$$(md5sum $$i | awk '{print $$1}')" = "$(get_sources_md5)" ; then \
157 echo "Copying from $$i" ; \
158 ln $$i $@ ; \
159 break ; \
160 fi ; \
161 done
162 @if [ ! -e "$@" ] ; then $(CLIENT) $(REPOSITORY)/$(get_sources_md5)/$@ ; fi
163 @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
164 @if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \
165 echo "md5sum of the downloaded $@ does not match the one from 'sources' file" ; \
166 echo "Local copy: $$(md5sum $@)" ; \
167 echo "In sources: $$(grep $@ sources)" ; \
168 exit 1 ; \
169 else \
170 ls -l $@ ; \
171 fi
172
173 # Support for uploading stuff into the repository.
174 ifdef FILES
175
176 upload-file = echo -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "file=@$$f" $(UPLOAD_REPOSITORY)
177
178 define upload-request
179 echo "Checking : $$b on $(UPLOAD_REPOSITORY)..." ; \
180 if test -f "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f"; then \
181 echo "This file ($$m) is already uploaded" ; \
182 else \
183 echo "Uploading: $$b to $(UPLOAD_REPOSITORY)..." ; \
184 mkdir -p "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}" || exit 1 ; \
185 ln -f "$$f" "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f" 2> /dev/null || cp -f "$$f" "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f" || exit 1 ; \
186 fi
187 endef
188
189 # Upload the FILES, adding to the ./sources manifest
190 upload: $(FILES)
191 @if ! test -f ./sources ; then touch ./sources ; fi
192 @if ! test -f ./.cvsignore ; then touch ./.cvsignore ; fi
193 @for f in $(FILES); do \
194 if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
195 b="$$(basename $$f)" ; \
196 m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
197 if test "$$m" = "$$(grep $$b sources)" ; then \
198 echo "ERROR: file $$f is already listed in the sources file..." ; \
199 exit 1 ; \
200 fi ; \
201 chmod +r $$f ; \
202 echo ; $(upload-request) ; echo ; \
203 if test -z "$$(egrep ""[[:space:]]$$b$$"" sources)" ; then \
204 echo "$$m" >> sources ; \
205 else \
206 egrep -v "[[:space:]]$$b$$" sources > sources.new ; \
207 echo "$$m" >> sources.new ; \
208 mv sources.new sources ; \
209 fi ; \
210 if test -z "$$(egrep ""^$$b$$"" .cvsignore)" ; then \
211 echo $$b >> .cvsignore ; \
212 fi \
213 done
214 @if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
215 @echo "Source upload succeeded. Don't forget to commit the new ./sources file"
216 @cvs update sources .cvsignore
217
218 # Upload FILES and recreate the ./sources file to include only these FILES
219 new-source new-sources: $(FILES)
220 @rm -f sources && touch sources
221 @rm -f .cvsignore && touch .cvsignore
222 @for f in $(FILES); do \
223 if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
224 b="$$(basename $$f)" ; \
225 m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
226 chmod +r $$f ; \
227 echo ; $(upload-request) ; echo ; \
228 echo "$$m" >> sources ; \
229 echo "$$b" >> .cvsignore ; \
230 done
231 @if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
232 @echo "Source upload succeeded. Don't forget to commit the new ./sources file"
233 @cvs update sources .cvsignore
234 endif
235
236 # allow overriding buildarch so you can do, say, an i386 build on x86_64
237 ifndef BUILDARCH
238 BUILDARCH := $(shell rpm --eval "%{_arch}")
239 endif
240
241 # test build in mock
242 mockbuild : srpm
243 mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
244
245 # build for a particular arch
246 $(ARCHES) : sources $(TARGETS)
247 $(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log
248 @exit ${PIPESTATUS[0]}
249
250 # empty target to force checking of md5sums in FULLSOURCEFILES
251 FORCE:
252
253 # build whatever's appropriate for the local architecture
254 local: $(if $(shell grep -i '^BuildArch:.*noarch' $(SPECFILE)), noarch, $(shell uname -m))
255
256 # attempt to apply all the patches, optionally only for a particular arch
257 ifdef PREPARCH
258 prep: sources $(TARGETS)
259 $(RPM_WITH_DIRS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
260 else
261 prep: sources $(TARGETS)
262 $(RPM_WITH_DIRS) --nodeps -bp $(SPECFILE)
263 endif
264
265 # this allows for make prep-i686, make prep-ppc64, etc
266 prep-% : Makefile
267 $(MAKE) prep PREPARCH=$*
268
269 compile: sources $(TARGETS)
270 $(RPM_WITH_DIRS) -bc $(SPECFILE)
271
272 compile-short: sources $(TARGETS)
273 $(RPM_WITH_DIRS) --nodeps --short-circuit -bc $(SPECFILE)
274
275 install-short: sources $(TARGETS)
276 $(RPM_WITH_DIRS) --nodeps --short-circuit -bi $(SPECFILE)
277
278 CVS_ROOT := $(shell if [ -f CVS/Root ] ; then cat CVS/Root ; fi)
279 CVS_REPOSITORY := $(shell if [ -f CVS/Repository ] ; then cat CVS/Repository ; fi)
280
281 ## create a clean exported copy in $(TMPCVS)
282 export:: sources
283 @mkdir -p $(WORKDIR)
284 /bin/rm -rf $(TMPCVS)
285 @if test -z "$(TAG)" ; then echo "Must specify a tag to check out" ; exit 1; fi
286 @mkdir -p $(TMPCVS)
287 @cd $(TMPCVS) && \
288 cvs -Q -d $(CVS_ROOT) export -r$(TAG) -d $(NAME) $(CVS_REPOSITORY) && \
289 cvs -Q -d $(CVS_ROOT) export -rHEAD common
290 @if [ -n "$(FULLSOURCEFILES)" ]; then ln -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) 2> /dev/null || cp -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) ; fi
291 @echo "Exported $(TMPCVS)/$(NAME)"
292
293 ## build a test-srpm and see if it will -bp on all arches
294 # XXX: I am not sure exactly what this is supposed to really do, since the
295 # query format returns (none) most of the time, and that is not
296 # handled --gafton
297 check: test-srpm
298 @archs=`rpm -qp $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm --qf "[%{EXCLUSIVEARCH}\n]" | egrep -v "(i586)|(i686)|(athlon)"` ;\
299 if test -z "$$archs"; then archs=noarch; fi ; \
300 echo "Checking arches: $$archs" ; \
301 for arch in $$archs; do \
302 echo "Checking $$arch..."; \
303 if ! $(RPM_WITH_DIRS) -bp --target $$arch $(SPECFILE); then \
304 echo "*** make prep failed for $$arch"; \
305 exit 1; \
306 fi; \
307 done;
308
309 ## use this to build an srpm locally
310 srpm: sources $(TARGETS)
311 $(RPM_WITH_DIRS) $(DIST_DEFINES) --nodeps -bs $(SPECFILE)
312
313 test-srpm: srpm
314
315 verrel:
316 @echo $(NAME)-$(VERSION)-$(RELEASE)
317
318 # If you build a new version into the tree, first do "make tag",
319 # then "make srpm", then build the package.
320 tag:: $(SPECFILE) $(COMMON_DIR)/branches
321 cvs tag $(TAG_OPTS) -c $(TAG)
322 @echo "Tagged with: $(TAG)"
323 @echo
324
325 force-tag: $(SPECFILE) $(COMMON_DIR)/branches
326 @$(MAKE) tag TAG_OPTS="-F $(TAG_OPTS)"
327
328 build-check: $(SPECFILE)
329 @if [ -z "$(TARGET)" -o ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
330 @cvs -f status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
331 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
332
333 plague: build-check $(COMMON_DIR)/branches
334 @if [ ! -x "$(PLAGUE_CLIENT)" ]; then echo "Must have plague-client installed - see http://fedoraproject.org/wiki/Extras/BuildSystemClientSetup"; exit 1; fi
335 @$(PLAGUE_CLIENT) build $(NAME) $(TAG) $(TARGET)
336
337 koji: build-check $(COMMON_DIR)/branches
338 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
339 @$(BUILD_CLIENT) build $(BUILD_FLAGS) $(TARGET) 'cvs://smeserver.cvs.sourceforge.net/cvsroot/smeserver?$(CVS_REPOSITORY)#$(TAG)'
340
341 build: plague
342
343 # "make new | less" to see what has changed since the last tag was assigned
344 new:
345 -@cvs diff -u -r$$(cvs log Makefile 2>/dev/null | awk '/^symbolic names:$$/ {getline; sub(/^[ \t]*/, "") ; sub (/:.*$$/, ""); print; exit 0}')
346
347 # mop up, printing out exactly what was mopped.
348 clean ::
349 @echo "Running the %clean script of the rpmbuild..."
350 -@$(RPM_WITH_DIRS) --clean --nodeps $(SPECFILE)
351 @for F in $(FULLSOURCEFILES); do \
352 if test -e $$F ; then \
353 echo "Deleting $$F" ; /bin/rm -f $$F ; \
354 fi; \
355 done
356 @if test -d $(TMPCVS); then \
357 echo "Deleting CVS dir $(TMPCVS)" ; \
358 /bin/rm -rf $(TMPCVS); \
359 fi
360 @if test -e $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; then \
361 echo "Deleting $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm" ; \
362 /bin/rm -f $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; \
363 fi
364 @rm -fv *~ clog
365 @echo "Fully clean!"
366
367 # To prevent CVS noise due to changing file timestamps, upgrade
368 # to patchutils-0.2.23-3 or later, and add to ~/.cvspkgsrc:
369 # FILTERDIFF := filterdiff --remove-timestamps
370 ifndef FILTERDIFF
371 FILTERDIFF := cat
372 endif
373
374 ifdef CVE
375 PATCHFILE := $(NAME)-$(VERSION)-CVE-$(CVE).patch
376 SUFFIX := cve$(shell echo $(CVE) | sed s/.*-//)
377 else
378 PATCHFILE := $(NAME)-$(VERSION)-$(SUFFIX).patch
379 endif
380
381 patch:
382 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
383 (cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) > $(PATCHFILE) || true
384 @if ! test -s $(PATCHFILE); then echo "Patch is empty!"; exit 1; fi
385 @echo "Created $(PATCHFILE)"
386 @grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
387
388 # Recreates the patch file of specified suffix from the current working sources
389 # but keeping any comments at the top of file intact, and backing up the old copy
390 # with a '~' suffix.
391 rediff:
392 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
393 @if ! test -f "$(PATCHFILE)"; then echo "$(PATCHFILE) not found"; exit 1; fi
394 @mv -f $(PATCHFILE) $(PATCHFILE)\~
395 @sed '/^--- /,$$d' < $(PATCHFILE)\~ > $(PATCHFILE)
396 @(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) >> $(PATCHFILE) || true
397
398 clog: $(SPECFILE)
399 @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $(SPECFILE) | tee $@
400
401 help:
402 @echo "Usage: make <target>"
403 @echo "Available targets are:"
404 @echo " help Show this text"
405 @echo " sources Download source files [default]"
406 @echo " upload FILES=<files> Add <files> to CVS"
407 @echo " new-sources FILES=<files> Replace sources in CVS with <files>"
408 @echo " <arch> Local test rpmbuild binary"
409 @echo " local Local test rpmbuild binary"
410 @echo " prep Local test rpmbuild prep"
411 @echo " compile Local test rpmbuild compile"
412 @echo " compile-short Local test rpmbuild short-circuit compile"
413 @echo " install-short Local test rpmbuild short-circuit install"
414 @echo " export Create clean export in \"cvs-$(TAG)\""
415 @echo " check Check test srpm preps on all archs"
416 @echo " srpm Create a srpm"
417 @echo " tag Tag sources as \"$(TAG)\""
418 @echo " build Request build of \"$(TAG)\" for $(TARGET)"
419 @echo " mockbuild Local test build using mock"
420 @echo " verrel Echo \"$(NAME)-$(VERSION)-$(RELEASE)\""
421 @echo " new Diff against last tag"
422 @echo " clog Make a clog file containing top changelog entry"
423 @echo " clean Remove srcs ($(SOURCEFILES)), export dir (cvs-$(TAG)) and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
424 @echo " patch SUFFIX=<suff> Create and add a gendiff patch file"
425 @echo " rediff SUFFIX=<suff> Recreates a gendiff patch file, retaining comments"
426 @echo " unused-patches Print list of patches not referenced by name in specfile"
427 @echo " gimmespec Print the name of the specfile"
428
429 gimmespec:
430 @echo "$(SPECFILE)"
431
432 unused-patches:
433 @for f in *.patch; do if [ -e $$f ]; then grep -q $$f $(SPECFILE) || echo $$f; fi; done
434
435 ##################### EXPERIMENTAL ##########################
436 # this stuff is very experimental in nature and should not be
437 # relied upon until these targets are moved above this line
438
439 # This section contains some hacks that instrument
440 # download-from-upstream support. You'll have to talk to gafton, he
441 # knows how this shit works.
442
443 # Add to the list of hardcoded upstream files the contents of the
444 # ./upstream file
445 UPSTREAM_FILES += $(shell if test -f ./upstream ; then cat ./upstream ; fi)
446 # extensions for signature files we need to retrieve for verification
447 # Warning: if you update the set of defaults, please make sure to
448 # update/add to the checking rules further down
449 UPSTREAM_CHECKS ?= sign asc sig md5
450
451 # check the signatures for the downloaded upstream stuff
452 UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
453
454 # Download a file from a particular host.
455 # First argument contains the url base, the second the filename,
456 # third extra curl options
457 define download-host-file
458 if test ! -e "$(2)" ; then \
459 echo -n "URL: $(1)/$(2) ..." ; \
460 $(CURL) --silent --head $(1)/$(2) && \
461 { \
462 echo "OK, downloading..." ; \
463 $(CURL) $(3) $(1)/$(2) ; \
464 } || \
465 echo "not found" ; \
466 fi
467 endef
468
469 # Download a file, trying each mirror in sequence. Also check for
470 # signatures, if available
471 # First argument contains the file name. We read the list of mirrors
472 # from the ./mirrors file
473 define download-file
474 $(foreach h, $(shell cat mirrors),
475 $(call download-host-file,$(h),$(1))
476 if test -e $(1) ; then \
477 $(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
478 fi
479 )
480 if test ! -e $(1) ; then \
481 echo "ERROR: Could not download file: $(1)" ; \
482 exit -1 ; \
483 else \
484 echo "File $(1) available for local use" ; \
485 fi
486 endef
487
488 # Download all the UPSTREAM files
489 define download-files
490 $(foreach f, $(UPSTREAM_FILES),
491 $(call download-file,$(f))
492 echo
493 )
494 endef
495
496 # Make sure the signature files we download are properly added
497 define cvs-add-upstream-sigs
498 for s in $(UPSTREAM_CHECK_FILES) ; do \
499 if test -f "$$s" ; then \
500 if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
501 cvs -Q add "$$s" ; \
502 fi ; \
503 fi ; \
504 done
505 endef
506
507 download : upstream mirrors
508 @$(download-files)
509 $(MAKE) download-checks
510
511 download-checks :: import-upstream-gpg
512 download-checks :: $(UPSTREAM_CHECK_FILES)
513
514 # how to check for a gpg signature, given a separate signature file
515 define check-upstream-gpg-sig
516 echo -n "Checking GPG signature on $* from $@ : "
517 if ! test -f $@ ; then \
518 echo "ERROR" ; echo "GPG signature file $@ not found" ; \
519 exit 1 ; \
520 fi
521 if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
522 echo "FAILED" ; \
523 exit 1 ; \
524 else \
525 echo "OK" ; \
526 fi
527 endef
528
529 # how to check for a md5sum, given a separate .md5 file
530 define check-upstream-md5sum
531 echo -n "Checking md5sum on $* from $@ : "
532 if ! test -f $@ ; then \
533 echo "ERROR" ; echo "md5sum file $@ not found" ; \
534 exit 1 ; \
535 fi
536 if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
537 echo "FAILED" ; \
538 exit 1 ; \
539 else \
540 echo "OK" ; \
541 fi
542 endef
543
544 # and now the rules, specific to each extension
545 $(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
546 @$(check-upstream-gpg-sig)
547 $(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
548 @$(check-upstream-gpg-sig)
549 $(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
550 @$(check-upstream-gpg-sig)
551 $(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
552 @$(check-upstream-md5sum)
553
554 # We keep all the relevant GPG keys in the upstream-key.gpg so we can
555 # check the signatures....
556 import-upstream-gpg : upstream-key.gpg FORCE
557 mkdir -p $(HOME)/.gnupg
558 gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
559
560 # A handy target to download the latest and greatest from upstream and
561 # check it into the lookaside cache.
562 # new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
563 # rebase uses the standard "make upload"
564 new-base : clean download
565 $(MAKE) new-source FILES="$(UPSTREAM_FILES)"
566 @$(cvs-add-upstream-sigs)
567 @echo "Don't forget to do a 'cvs commit' for your new sources file."
568
569 rebase : clean download
570 $(MAKE) upload FILES="$(UPSTREAM_FILES)"
571 @$(cvs-add-upstream-sigs)
572 @echo "Don't forget to do a 'cvs commit' for your new sources file."
573
574 # there is more stuff to clean, now that we have upstream files
575 clean ::
576 @rm -fv $(UPSTREAM_FILES)

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed