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

Contents of /rpms/common/Makefile.common

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


Revision 1.2 - (show annotations) (download)
Tue Jun 12 14:28:07 2007 UTC (17 years, 5 months ago) by slords
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
Wrong directory

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.1 2007/05/20 06:07:53 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://cvs.fedora.redhat.com/repo/pkgs
93 UPLOAD_REPOSITORY ?= https://cvs.fedora.redhat.com/repo/pkgs/upload.cgi
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)/$(NAME)/$@/$(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. Since this is
174 # pretty specific to the upload.cgi we use, we hardwire the assumption
175 # that we're always using upload.cgi
176 ifdef FILES
177
178 # we hardwire curl in here because the upload rules are very dependent
179 # on curl's behavior on missing pages, ISEs, etc.
180 UPLOAD_CERT = $(shell if test -f $(HOME)/.fedora.cert ; then echo " --cert $(HOME)/.fedora.cert" ; fi)
181 UPLOAD_CHECK = curl -k $(UPLOAD_CERT) --fail --silent
182 UPLOAD_CLIENT = curl -k $(UPLOAD_CERT) --fail --show-error --progress-bar
183
184 upload-check = $(UPLOAD_CHECK) -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "filename=$$f" $(UPLOAD_REPOSITORY)
185 upload-file = $(UPLOAD_CLIENT) -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "file=@$$f" $(UPLOAD_REPOSITORY)
186
187 define upload-request
188 echo "Checking : $$b on $(UPLOAD_REPOSITORY)..." ; \
189 check=$$($(upload-check)) ; retc=$$? ; \
190 if test $$retc -ne 0 ; then \
191 echo "ERROR: could not check remote file status" ; \
192 exit -1 ; \
193 elif test "$$check" = "Available" ; then \
194 echo "This file ($$m) is already uploaded" ; \
195 elif test "$$check" = "Missing" ; then \
196 echo "Uploading: $$b to $(UPLOAD_REPOSITORY)..." ; \
197 $(upload-file) || exit 1 ; \
198 else \
199 echo "$$check" ; \
200 exit 1 ; \
201 fi
202 endef
203
204 OPENSSL=$(shell which openssl 2>/dev/null)
205 define check-cert
206 @if ! test -f $(HOME)/.fedora.cert ; then echo "ERROR: You need to download your Fedora client certificate" >&2 ; echo " from https://admin.fedora.redhat.com/accounts/" >&2; exit 1 ; fi
207 @if [ -x ${OPENSSL} ]; then \
208 ${OPENSSL} x509 -checkend 6000 -noout -in ${HOME}/.fedora.cert ; \
209 if [ $$? -ne 0 ]; then \
210 echo "ERROR: Your Fedora client-side certificate expired." >&2 ; \
211 echo " You need to download a new client-side certificate" >&2 ; \
212 echo " from https://admin.fedora.redhat.com/accounts/" >&2 ; \
213 exit 1 ; \
214 fi ; \
215 fi
216 endef
217
218 # Upload the FILES, adding to the ./sources manifest
219 upload: $(FILES)
220 $(check-cert)
221 @if ! test -f ./sources ; then touch ./sources ; fi
222 @if ! test -f ./.cvsignore ; then touch ./.cvsignore ; fi
223 @for f in $(FILES); do \
224 if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
225 b="$$(basename $$f)" ; \
226 m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
227 if test "$$m" = "$$(grep $$b sources)" ; then \
228 echo "ERROR: file $$f is already listed in the sources file..." ; \
229 exit 1 ; \
230 fi ; \
231 chmod +r $$f ; \
232 echo ; $(upload-request) ; echo ; \
233 if test -z "$$(egrep ""[[:space:]]$$b$$"" sources)" ; then \
234 echo "$$m" >> sources ; \
235 else \
236 egrep -v "[[:space:]]$$b$$" sources > sources.new ; \
237 echo "$$m" >> sources.new ; \
238 mv sources.new sources ; \
239 fi ; \
240 if test -z "$$(egrep ""^$$b$$"" .cvsignore)" ; then \
241 echo $$b >> .cvsignore ; \
242 fi \
243 done
244 @if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
245 @echo "Source upload succeeded. Don't forget to commit the new ./sources file"
246 @cvs update sources .cvsignore
247
248 # Upload FILES and recreate the ./sources file to include only these FILES
249 new-source new-sources: $(FILES)
250 $(check-cert)
251 @rm -f sources && touch sources
252 @rm -f .cvsignore && touch .cvsignore
253 @for f in $(FILES); do \
254 if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
255 b="$$(basename $$f)" ; \
256 m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
257 chmod +r $$f ; \
258 echo ; $(upload-request) ; echo ; \
259 echo "$$m" >> sources ; \
260 echo "$$b" >> .cvsignore ; \
261 done
262 @if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
263 @echo "Source upload succeeded. Don't forget to commit the new ./sources file"
264 @cvs update sources .cvsignore
265 endif
266
267 # allow overriding buildarch so you can do, say, an i386 build on x86_64
268 ifndef BUILDARCH
269 BUILDARCH := $(shell rpm --eval "%{_arch}")
270 endif
271
272 # test build in mock
273 mockbuild : srpm
274 mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
275
276 # build for a particular arch
277 $(ARCHES) : sources $(TARGETS)
278 $(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log
279 @exit ${PIPESTATUS[0]}
280
281 # empty target to force checking of md5sums in FULLSOURCEFILES
282 FORCE:
283
284 # build whatever's appropriate for the local architecture
285 local: $(if $(shell grep -i '^BuildArch:.*noarch' $(SPECFILE)), noarch, $(shell uname -m))
286
287 # attempt to apply all the patches, optionally only for a particular arch
288 ifdef PREPARCH
289 prep: sources $(TARGETS)
290 $(RPM_WITH_DIRS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
291 else
292 prep: sources $(TARGETS)
293 $(RPM_WITH_DIRS) --nodeps -bp $(SPECFILE)
294 endif
295
296 # this allows for make prep-i686, make prep-ppc64, etc
297 prep-% : Makefile
298 $(MAKE) prep PREPARCH=$*
299
300 compile: sources $(TARGETS)
301 $(RPM_WITH_DIRS) -bc $(SPECFILE)
302
303 compile-short: sources $(TARGETS)
304 $(RPM_WITH_DIRS) --nodeps --short-circuit -bc $(SPECFILE)
305
306 install-short: sources $(TARGETS)
307 $(RPM_WITH_DIRS) --nodeps --short-circuit -bi $(SPECFILE)
308
309 CVS_ROOT := $(shell if [ -f CVS/Root ] ; then cat CVS/Root ; fi)
310 CVS_REPOSITORY := $(shell if [ -f CVS/Repository ] ; then cat CVS/Repository ; fi)
311
312 ## create a clean exported copy in $(TMPCVS)
313 export:: sources
314 @mkdir -p $(WORKDIR)
315 /bin/rm -rf $(TMPCVS)
316 @if test -z "$(TAG)" ; then echo "Must specify a tag to check out" ; exit 1; fi
317 @mkdir -p $(TMPCVS)
318 @cd $(TMPCVS) && \
319 cvs -Q -d $(CVS_ROOT) export -r$(TAG) -d $(NAME) $(CVS_REPOSITORY) && \
320 cvs -Q -d $(CVS_ROOT) export -rHEAD common
321 @if [ -n "$(FULLSOURCEFILES)" ]; then ln -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) 2> /dev/null || cp -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) ; fi
322 @echo "Exported $(TMPCVS)/$(NAME)"
323
324 ## build a test-srpm and see if it will -bp on all arches
325 # XXX: I am not sure exactly what this is supposed to really do, since the
326 # query format returns (none) most of the time, and that is not
327 # handled --gafton
328 check: test-srpm
329 @archs=`rpm -qp $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm --qf "[%{EXCLUSIVEARCH}\n]" | egrep -v "(i586)|(i686)|(athlon)"` ;\
330 if test -z "$$archs"; then archs=noarch; fi ; \
331 echo "Checking arches: $$archs" ; \
332 for arch in $$archs; do \
333 echo "Checking $$arch..."; \
334 if ! $(RPM_WITH_DIRS) -bp --target $$arch $(SPECFILE); then \
335 echo "*** make prep failed for $$arch"; \
336 exit 1; \
337 fi; \
338 done;
339
340 ## use this to build an srpm locally
341 srpm: sources $(TARGETS)
342 $(RPM_WITH_DIRS) $(DIST_DEFINES) --nodeps -bs $(SPECFILE)
343
344 test-srpm: srpm
345
346 verrel:
347 @echo $(NAME)-$(VERSION)-$(RELEASE)
348
349 # If you build a new version into the tree, first do "make tag",
350 # then "make srpm", then build the package.
351 tag:: $(SPECFILE) $(COMMON_DIR)/branches
352 cvs tag $(TAG_OPTS) -c $(TAG)
353 @echo "Tagged with: $(TAG)"
354 @echo
355
356 force-tag: $(SPECFILE) $(COMMON_DIR)/branches
357 @$(MAKE) tag TAG_OPTS="-F $(TAG_OPTS)"
358
359 define find-user
360 if [ `cat CVS/Root |grep -c [^:]@` -ne 0 ]; then cat CVS/Root |cut -d @ -f 1 | sed 's/:.*://' ; else echo $(USER); fi
361 endef
362 USER := $(shell $(find-user))
363
364 oldbuild: $(COMMON_DIR)/branches
365 @if [ -z "$(TARGET)" -a ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
366
367 @cvs status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
368 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
369
370 @(pushd $(COMMON_DIR) >/dev/null ;\
371 rm -f tobuild ;\
372 cvs -Q update -C tobuild ;\
373 echo -e "$(USER)\t$(CVS_REPOSITORY)\t$(TAG)\t$(TARGET)" >> tobuild ;\
374 cvs commit -m "request build of $(CVS_REPOSITORY) $(TAG) for $(TARGET)" tobuild ;\
375 popd >/dev/null)
376
377 build-check: $(SPECFILE)
378 @if [ -z "$(TARGET)" -o ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
379 @cvs -f status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
380 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
381
382 plague: build-check $(COMMON_DIR)/branches
383 @if [ ! -x "$(PLAGUE_CLIENT)" ]; then echo "Must have plague-client installed - see http://fedoraproject.org/wiki/Extras/BuildSystemClientSetup"; exit 1; fi
384 @$(PLAGUE_CLIENT) build $(NAME) $(TAG) $(TARGET)
385
386 koji: build-check $(COMMON_DIR)/branches
387 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
388 @$(BUILD_CLIENT) build $(BUILD_FLAGS) $(TARGET) 'cvs://cvs.fedoraproject.org/cvs/pkgs?$(CVS_REPOSITORY)#$(TAG)'
389
390 ifneq (, $(filter devel F-7, $(BRANCH)))
391 build: koji
392 else
393 build: plague
394 endif
395
396 # "make new | less" to see what has changed since the last tag was assigned
397 new:
398 -@cvs diff -u -r$$(cvs log Makefile 2>/dev/null | awk '/^symbolic names:$$/ {getline; sub(/^[ \t]*/, "") ; sub (/:.*$$/, ""); print; exit 0}')
399
400 # mop up, printing out exactly what was mopped.
401 clean ::
402 @echo "Running the %clean script of the rpmbuild..."
403 -@$(RPM_WITH_DIRS) --clean --nodeps $(SPECFILE)
404 @for F in $(FULLSOURCEFILES); do \
405 if test -e $$F ; then \
406 echo "Deleting $$F" ; /bin/rm -f $$F ; \
407 fi; \
408 done
409 @if test -d $(TMPCVS); then \
410 echo "Deleting CVS dir $(TMPCVS)" ; \
411 /bin/rm -rf $(TMPCVS); \
412 fi
413 @if test -e $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; then \
414 echo "Deleting $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm" ; \
415 /bin/rm -f $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; \
416 fi
417 @rm -fv *~ clog
418 @echo "Fully clean!"
419
420 # To prevent CVS noise due to changing file timestamps, upgrade
421 # to patchutils-0.2.23-3 or later, and add to ~/.cvspkgsrc:
422 # FILTERDIFF := filterdiff --remove-timestamps
423 ifndef FILTERDIFF
424 FILTERDIFF := cat
425 endif
426
427 ifdef CVE
428 PATCHFILE := $(NAME)-$(VERSION)-CVE-$(CVE).patch
429 SUFFIX := cve$(shell echo $(CVE) | sed s/.*-//)
430 else
431 PATCHFILE := $(NAME)-$(VERSION)-$(SUFFIX).patch
432 endif
433
434 patch:
435 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
436 (cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) > $(PATCHFILE) || true
437 @if ! test -s $(PATCHFILE); then echo "Patch is empty!"; exit 1; fi
438 @echo "Created $(PATCHFILE)"
439 @grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
440
441 # Recreates the patch file of specified suffix from the current working sources
442 # but keeping any comments at the top of file intact, and backing up the old copy
443 # with a '~' suffix.
444 rediff:
445 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
446 @if ! test -f "$(PATCHFILE)"; then echo "$(PATCHFILE) not found"; exit 1; fi
447 @mv -f $(PATCHFILE) $(PATCHFILE)\~
448 @sed '/^--- /,$$d' < $(PATCHFILE)\~ > $(PATCHFILE)
449 @(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) >> $(PATCHFILE) || true
450
451 clog: $(SPECFILE)
452 @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $(SPECFILE) | tee $@
453
454 help:
455 @echo "Usage: make <target>"
456 @echo "Available targets are:"
457 @echo " help Show this text"
458 @echo " sources Download source files [default]"
459 @echo " upload FILES=<files> Add <files> to CVS"
460 @echo " new-sources FILES=<files> Replace sources in CVS with <files>"
461 @echo " <arch> Local test rpmbuild binary"
462 @echo " local Local test rpmbuild binary"
463 @echo " prep Local test rpmbuild prep"
464 @echo " compile Local test rpmbuild compile"
465 @echo " compile-short Local test rpmbuild short-circuit compile"
466 @echo " install-short Local test rpmbuild short-circuit install"
467 @echo " export Create clean export in \"cvs-$(TAG)\""
468 @echo " check Check test srpm preps on all archs"
469 @echo " srpm Create a srpm"
470 @echo " tag Tag sources as \"$(TAG)\""
471 @echo " build Request build of \"$(TAG)\" for $(TARGET)"
472 @echo " mockbuild Local test build using mock"
473 @echo " verrel Echo \"$(NAME)-$(VERSION)-$(RELEASE)\""
474 @echo " new Diff against last tag"
475 @echo " clog Make a clog file containing top changelog entry"
476 @echo " clean Remove srcs ($(SOURCEFILES)), export dir (cvs-$(TAG)) and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
477 @echo " patch SUFFIX=<suff> Create and add a gendiff patch file"
478 @echo " rediff SUFFIX=<suff> Recreates a gendiff patch file, retaining comments"
479 @echo " unused-patches Print list of patches not referenced by name in specfile"
480 @echo " gimmespec Print the name of the specfile"
481
482 gimmespec:
483 @echo "$(SPECFILE)"
484
485 unused-patches:
486 @for f in *.patch; do if [ -e $$f ]; then grep -q $$f $(SPECFILE) || echo $$f; fi; done
487
488 ##################### EXPERIMENTAL ##########################
489 # this stuff is very experimental in nature and should not be
490 # relied upon until these targets are moved above this line
491
492 # This section contains some hacks that instrument
493 # download-from-upstream support. You'll have to talk to gafton, he
494 # knows how this shit works.
495
496 # Add to the list of hardcoded upstream files the contents of the
497 # ./upstream file
498 UPSTREAM_FILES += $(shell if test -f ./upstream ; then cat ./upstream ; fi)
499 # extensions for signature files we need to retrieve for verification
500 # Warning: if you update the set of defaults, please make sure to
501 # update/add to the checking rules further down
502 UPSTREAM_CHECKS ?= sign asc sig md5
503
504 # check the signatures for the downloaded upstream stuff
505 UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
506
507 # Download a file from a particular host.
508 # First argument contains the url base, the second the filename,
509 # third extra curl options
510 define download-host-file
511 if test ! -e "$(2)" ; then \
512 echo -n "URL: $(1)/$(2) ..." ; \
513 $(CURL) --silent --head $(1)/$(2) && \
514 { \
515 echo "OK, downloading..." ; \
516 $(CURL) $(3) $(1)/$(2) ; \
517 } || \
518 echo "not found" ; \
519 fi
520 endef
521
522 # Download a file, trying each mirror in sequence. Also check for
523 # signatures, if available
524 # First argument contains the file name. We read the list of mirrors
525 # from the ./mirrors file
526 define download-file
527 $(foreach h, $(shell cat mirrors),
528 $(call download-host-file,$(h),$(1))
529 if test -e $(1) ; then \
530 $(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
531 fi
532 )
533 if test ! -e $(1) ; then \
534 echo "ERROR: Could not download file: $(1)" ; \
535 exit -1 ; \
536 else \
537 echo "File $(1) available for local use" ; \
538 fi
539 endef
540
541 # Download all the UPSTREAM files
542 define download-files
543 $(foreach f, $(UPSTREAM_FILES),
544 $(call download-file,$(f))
545 echo
546 )
547 endef
548
549 # Make sure the signature files we download are properly added
550 define cvs-add-upstream-sigs
551 for s in $(UPSTREAM_CHECK_FILES) ; do \
552 if test -f "$$s" ; then \
553 if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
554 cvs -Q add "$$s" ; \
555 fi ; \
556 fi ; \
557 done
558 endef
559
560 download : upstream mirrors
561 @$(download-files)
562 $(MAKE) download-checks
563
564 download-checks :: import-upstream-gpg
565 download-checks :: $(UPSTREAM_CHECK_FILES)
566
567 # how to check for a gpg signature, given a separate signature file
568 define check-upstream-gpg-sig
569 echo -n "Checking GPG signature on $* from $@ : "
570 if ! test -f $@ ; then \
571 echo "ERROR" ; echo "GPG signature file $@ not found" ; \
572 exit 1 ; \
573 fi
574 if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
575 echo "FAILED" ; \
576 exit 1 ; \
577 else \
578 echo "OK" ; \
579 fi
580 endef
581
582 # how to check for a md5sum, given a separate .md5 file
583 define check-upstream-md5sum
584 echo -n "Checking md5sum on $* from $@ : "
585 if ! test -f $@ ; then \
586 echo "ERROR" ; echo "md5sum file $@ not found" ; \
587 exit 1 ; \
588 fi
589 if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
590 echo "FAILED" ; \
591 exit 1 ; \
592 else \
593 echo "OK" ; \
594 fi
595 endef
596
597 # and now the rules, specific to each extension
598 $(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
599 @$(check-upstream-gpg-sig)
600 $(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
601 @$(check-upstream-gpg-sig)
602 $(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
603 @$(check-upstream-gpg-sig)
604 $(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
605 @$(check-upstream-md5sum)
606
607 # We keep all the relevant GPG keys in the upstream-key.gpg so we can
608 # check the signatures...
609 import-upstream-gpg : upstream-key.gpg FORCE
610 mkdir -p $(HOME)/.gnupg
611 gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
612
613 # A handy target to download the latest and greatest from upstream and
614 # check it into the lookaside cache.
615 # new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
616 # rebase uses the standard "make upload"
617 new-base : clean download
618 $(MAKE) new-source FILES="$(UPSTREAM_FILES)"
619 @$(cvs-add-upstream-sigs)
620 @echo "Don't forget to do a 'cvs commit' for your new sources file."
621
622 rebase : clean download
623 $(MAKE) upload FILES="$(UPSTREAM_FILES)"
624 @$(cvs-add-upstream-sigs)
625 @echo "Don't forget to do a 'cvs commit' for your new sources file."
626
627 # there is more stuff to clean, now that we have upstream files
628 clean ::
629 @rm -fv $(UPSTREAM_FILES)

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