/[smecontribs]/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.3 - (show annotations) (download)
Fri Mar 28 14:38:51 2008 UTC (16 years, 8 months ago) by slords
Branch: MAIN
Changes since 1.2: +7 -26 lines
Updates for local mock builds

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

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