/[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.10 - (show annotations) (download)
Sat Jun 30 05:57:35 2012 UTC (12 years, 5 months ago) by slords
Branch: MAIN
Changes since 1.9: +6 -1 lines
Update srpm building

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.9 2010/03/16 15:41:16 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 BASEDIR := $(shell basename `pwd`)
23 BRANCH := $(BASEDIR)
24 BRANCHINFO = $(shell grep ^$(BRANCH): $(COMMON_DIR)/branches | cut -d: --output-delimiter=" " -f2-)
25 TARGET := $(word 1, $(BRANCHINFO))
26 DIST = $(word 2, $(BRANCHINFO))
27 DISTVAR = $(word 3, $(BRANCHINFO))
28 DISTVAL = $(word 4, $(BRANCHINFO))
29 DISTDEF = $(shell echo $(DIST) | sed -e s/^\\\.// )
30 SMEVAL = $(word 5, $(BRANCHINFO))
31 DIST_DEFINES = --define "dist $(DIST)" --define "$(DISTVAR) $(DISTVAL)" --define "$(DISTDEF) 1" --define "sme $(SMEVAL)"
32
33 BUILD_FLAGS ?= $(KOJI_FLAGS)
34
35 LOCALARCH := $(if $(shell grep -i '^BuildArch:.*noarch' $(SPECFILE)), noarch, $(shell uname -m))
36
37 ## a base directory where we'll put as much temporary working stuff as we can
38 ifndef WORKDIR
39 WORKDIR := $(shell pwd)
40 endif
41 ## of course all this can also be overridden in your RPM macros file,
42 ## but this way you can separate your normal RPM setup from your CVS
43 ## setup. Override RPM_WITH_DIRS in ~/.cvspkgsrc to avoid the usage of
44 ## these variables.
45 SRCRPMDIR ?= $(WORKDIR)
46 BUILDDIR ?= $(WORKDIR)
47 RPMDIR ?= $(WORKDIR)
48 MOCKDIR ?= $(WORKDIR)
49 MOCKCFG ?= smeserver-$(SMEVAL)-$(BUILDARCH)-base
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 ifndef SPECDIR
58 SPECDIR := $(shell pwd)
59 endif
60
61 ifndef RPM_DEFINES
62 RPM_DEFINES := --define "_sourcedir $(SOURCEDIR)" \
63 --define "_specdir $(SPECDIR)" \
64 --define "_builddir $(BUILDDIR)" \
65 --define "_srcrpmdir $(SRCRPMDIR)" \
66 --define "_rpmdir $(RPMDIR)" \
67 $(DIST_DEFINES)
68 endif
69
70 # Initialize the variables that we need, but are not defined
71 # the version of the package
72 VER_REL := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{VERSION} %{RELEASE}\n" --specfile $(SPECFILE)| head -1)
73 ifndef NAME
74 $(error "You can not run this Makefile without having NAME defined")
75 endif
76 ifndef VERSION
77 VERSION := $(word 1, $(VER_REL))
78 endif
79 # the release of the package
80 ifndef RELEASE
81 RELEASE := $(word 2, $(VER_REL))
82 endif
83 # this is used in make patch, maybe make clean eventually.
84 # would be nicer to autodetermine from the spec file...
85 RPM_BUILD_DIR ?= $(BUILDDIR)/$(NAME)-$(VERSION)
86
87 # default target: just make sure we've got the sources
88 all: sources
89
90 # user specific configuration
91 CVS_EXTRAS_RC := $(shell if test -f $(HOME)/.cvspkgsrc ; then echo $(HOME)/.cvspkgsrc ; fi)
92 ifdef CVS_EXTRAS_RC
93 include $(CVS_EXTRAS_RC)
94 endif
95
96 # The repository and the clients we use for the files
97 REPOSITORY ?= http://buildsys.contribs.org/source
98 UPLOAD_REPOSITORY ?= /builds/source
99
100 # We define CURL and WGET in a way that makes if possible to have them
101 # overwritten from the module's Makefiles. Then CLIENT picks CURL, otherwise WGET
102 CURL ?= $(shell if test -f /usr/bin/curl ; then echo "curl -H Pragma: -O -R -S --fail --show-error" ; fi)
103 WGET ?= $(shell if test -f /usr/bin/wget ; then echo "wget -nd -m" ; fi)
104 CLIENT ?= $(if $(CURL),$(CURL),$(if $(WGET),$(WGET)))
105 PLAGUE_CLIENT ?= $(shell which plague-client 2>/dev/null)
106 BUILD_CLIENT ?= $(shell which koji 2>/dev/null)
107 BODHI_CLIENT ?= $(shell which bodhi 2>/dev/null)
108
109 # RPM with all the overrides in place; you can override this in your
110 # .cvspkgsrc also, to use a default rpm setup
111 # the rpm build command line
112 ifndef RPM
113 RPM := rpmbuild
114 endif
115 ifndef RPM_WITH_DIRS
116 RPM_WITH_DIRS = $(RPM) $(RPM_DEFINES)
117 endif
118
119 # CVS-safe version/release -- a package name like 4Suite screws things
120 # up, so we have to remove the leaving digits from the name
121 TAG_NAME := $(shell echo $(NAME) | sed -e s/\\\./_/g -e s/^[0-9]\\\+//g)
122 TAG_VERSION := $(shell echo $(VERSION) | sed s/\\\./_/g)
123 TAG_RELEASE := $(shell echo $(RELEASE) | sed s/\\\./_/g)
124
125 # tag to export, defaulting to current tag in the spec file
126 TAG?=$(TAG_NAME)-$(TAG_VERSION)-$(TAG_RELEASE)
127
128 # where to cvs export temporarily
129 TMPCVS := $(WORKDIR)/cvs-$(TAG)
130
131 # source file basenames
132 SOURCEFILES := $(shell cat sources 2>/dev/null | awk '{ print $$2 }')
133 # full path to source files
134 FULLSOURCEFILES := $(addprefix $(SOURCEDIR)/,$(SOURCEFILES))
135
136 # retrieve the stored md5 sum for a source download
137 define get_sources_md5
138 $(shell cat sources 2>/dev/null | while read m f ; do if test "$$f" = "$@" ; then echo $$m ; break ; fi ; done)
139 endef
140
141 # list the possible targets for valid arches
142 ARCHES = noarch i386 i586 i686 x86_64 # ia64 s390 s390x ppc ppc64 pseries ppc64pseries iseries ppc64iseries athlon alpha alphaev6 sparc sparc64 sparcv9 sparcv9v sparc64v i164 mac sh mips geode
143
144 # for the modules that do different "make prep" depending on what arch we build for
145 PREP_ARCHES = $(addprefix prep-,$(ARCHES))
146
147 ## list all our bogus targets
148 .PHONY :: $(ARCHES) commit sources uploadsource upload export check build-check plague koji build cvsurl chain-build test-srpm srpm tag force-tag verrel new clean patch prep compile install install-short compile-short FORCE local scratch-build scratch-build-%
149
150 # The TARGETS define is meant for local module targets that should be
151 # made in addition to the SOURCEFILES whenever needed
152 TARGETS ?=
153
154 # default target - retrieve the sources and make the module specific targets
155 sources: $(SOURCEFILES) $(TARGETS)
156
157 # Retrieve the sources we do not have in CVS
158 $(SOURCEFILES): #FORCE
159 @mkdir -p $(SOURCEDIR)
160 @echo "Downloading $@..."
161 @for i in `find ../ -maxdepth 2 -name "$@"`; do \
162 if test "$$(md5sum $$i | awk '{print $$1}')" = "$(get_sources_md5)" ; then \
163 echo "Copying from $$i" ; \
164 ln $$i $@ ; \
165 break ; \
166 fi ; \
167 done
168 @if [ -z "$(CLIENT)" ]; then echo "Can't download, need curl or wget installed." ; exit 1; fi
169 @if [ ! -e "$@" ] ; then $(CLIENT) $(REPOSITORY)/$(get_sources_md5)/$@ ; fi
170 @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi
171 @if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \
172 echo "md5sum of the downloaded $@ does not match the one from 'sources' file" ; \
173 echo "Local copy: $$(md5sum $@)" ; \
174 echo "In sources: $$(grep $@ sources)" ; \
175 exit 1 ; \
176 else \
177 ls -l $@ ; \
178 fi
179
180 # Support for uploading stuff into the repository.
181 ifdef FILES
182
183 upload-file = echo -F "name=$(NAME)" -F "md5sum=$${m%%[[:space:]]*}" -F "file=@$$f" $(UPLOAD_REPOSITORY)
184
185 define upload-request
186 echo "Checking : $$b on $(UPLOAD_REPOSITORY)..." ; \
187 if test -f "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f"; then \
188 echo "This file ($$m) is already uploaded" ; \
189 else \
190 echo "Uploading: $$b to $(UPLOAD_REPOSITORY)..." ; \
191 mkdir -p "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}" || exit 1 ; \
192 ln -f "$$f" "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f" 2> /dev/null || cp -f "$$f" "$(UPLOAD_REPOSITORY)/$${m%%[[:space:]]*}/$$f" || exit 1 ; \
193 fi
194 endef
195
196 # Upload the FILES, adding to the ./sources manifest
197 upload: $(FILES)
198 @if ! test -f ./sources ; then touch ./sources ; fi
199 @if ! test -f ./.cvsignore ; then touch ./.cvsignore ; fi
200 @for f in $(FILES); do \
201 if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
202 b="$$(basename $$f)" ; \
203 m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
204 if test "$$m" = "$$(grep $$b sources)" ; then \
205 echo "ERROR: file $$f is already listed in the sources file..." ; \
206 exit 1 ; \
207 fi ; \
208 chmod +r $$f ; \
209 echo ; $(upload-request) ; echo ; \
210 if test -z "$$(egrep ""[[:space:]]$$b$$"" sources)" ; then \
211 echo "$$m" >> sources ; \
212 else \
213 egrep -v "[[:space:]]$$b$$" sources > sources.new ; \
214 echo "$$m" >> sources.new ; \
215 mv sources.new sources ; \
216 fi ; \
217 if test -z "$$(egrep ""^$$b$$"" .cvsignore)" ; then \
218 echo $$b >> .cvsignore ; \
219 fi \
220 done
221 @if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
222 @echo "Source upload succeeded. Don't forget to commit the new ./sources file"
223 @cvs update sources .cvsignore
224
225 # Upload FILES and recreate the ./sources file to include only these FILES
226 new-source new-sources: $(FILES)
227 @rm -f sources && touch sources
228 @rm -f .cvsignore && touch .cvsignore
229 @for f in $(FILES); do \
230 if ! test -s $$f ; then echo "SKIPPING EMPTY FILE: $$f" ; continue ; fi ; \
231 b="$$(basename $$f)" ; \
232 m="$$(cd $$(dirname $$f) && md5sum $$b)" ; \
233 chmod +r $$f ; \
234 echo ; $(upload-request) ; echo ; \
235 echo "$$m" >> sources ; \
236 echo "$$b" >> .cvsignore ; \
237 done
238 @if grep "^/sources/" CVS/Entries >/dev/null; then true ; else cvs -Q add sources; fi
239 @echo "Source upload succeeded. Don't forget to commit the new ./sources file"
240 @cvs update sources .cvsignore
241 endif
242
243 # allow overriding buildarch so you can do, say, an i386 build on x86_64
244 ifndef BUILDARCH
245 BUILDARCH := $(shell rpm --eval "%{_arch}")
246 endif
247
248 # test build in mock
249 mockbuild : srpm
250 mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) rebuild $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm
251
252 # check the build with rpmlint
253 lint:
254 @test -e $(NAME)-$(VERSION)-$(RELEASE).src.rpm || (echo "run 'make local' first" ; exit 1 )
255 rpmlint $(NAME)-$(VERSION)-$(RELEASE).src.rpm $(LOCALARCH)/*-$(VERSION)-$(RELEASE).$(LOCALARCH).rpm
256
257 # build for a particular arch
258 $(ARCHES) : sources $(TARGETS)
259 $(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log ; exit $${PIPESTATUS[0]}
260
261 # empty target to force checking of md5sums in FULLSOURCEFILES
262 FORCE:
263
264 # build whatever's appropriate for the local architecture
265 local: $(LOCALARCH)
266
267 # attempt to apply all the patches, optionally only for a particular arch
268 ifdef PREPARCH
269 prep: sources $(TARGETS)
270 $(RPM_WITH_DIRS) --nodeps -bp --target $(PREPARCH) $(SPECFILE)
271 else
272 prep: sources $(TARGETS)
273 $(RPM_WITH_DIRS) --nodeps -bp $(SPECFILE)
274 endif
275
276 # this allows for make prep-i686, make prep-ppc64, etc
277 prep-% : Makefile
278 $(MAKE) prep PREPARCH=$*
279
280 compile: sources $(TARGETS)
281 $(RPM_WITH_DIRS) -bc $(SPECFILE)
282
283 install: sources $(TARGETS)
284 $(RPM_WITH_DIRS) -bi $(SPECFILE)
285
286 compile-short: sources $(TARGETS)
287 $(RPM_WITH_DIRS) --nodeps --short-circuit -bc $(SPECFILE)
288
289 install-short: sources $(TARGETS)
290 $(RPM_WITH_DIRS) --nodeps --short-circuit -bi $(SPECFILE)
291
292 CVS_ROOT := $(shell if [ -f CVS/Root ] ; then cat CVS/Root ; fi)
293 CVS_REPOSITORY := $(shell if [ -f CVS/Repository ] ; then cat CVS/Repository ; fi)
294 CVS_URL := cvs://smecontribs.cvs.sourceforge.net/cvsroot/smecontribs?$(CVS_REPOSITORY)\#$(TAG)
295
296 ## create a clean exported copy in $(TMPCVS)
297 export:: sources
298 @mkdir -p $(WORKDIR)
299 /bin/rm -rf $(TMPCVS)
300 @if test -z "$(TAG)" ; then echo "Must specify a tag to check out" ; exit 1; fi
301 @mkdir -p $(TMPCVS)
302 @cd $(TMPCVS) && \
303 cvs -Q -d $(CVS_ROOT) export -r$(TAG) -d $(NAME) $(CVS_REPOSITORY) && \
304 cvs -Q -d $(CVS_ROOT) export -rHEAD common
305 @if [ -n "$(FULLSOURCEFILES)" ]; then ln -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) 2> /dev/null || cp -f $(FULLSOURCEFILES) $(TMPCVS)/$(NAME) ; fi
306 @echo "Exported $(TMPCVS)/$(NAME)"
307
308 ## build a test-srpm and see if it will -bp on all arches
309 # XXX: I am not sure exactly what this is supposed to really do, since the
310 # query format returns (none) most of the time, and that is not
311 # handled --gafton
312 check: test-srpm
313 @archs=`rpm -qp $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm --qf "[%{EXCLUSIVEARCH}\n]" | egrep -v "(i586)|(i686)|(athlon)"` ;\
314 if test -z "$$archs"; then archs=noarch; fi ; \
315 echo "Checking arches: $$archs" ; \
316 for arch in $$archs; do \
317 echo "Checking $$arch..."; \
318 if ! $(RPM_WITH_DIRS) -bp --target $$arch $(SPECFILE); then \
319 echo "*** make prep failed for $$arch"; \
320 exit 1; \
321 fi; \
322 done;
323
324 ## use this to build an srpm locally
325 ifneq (, $(filter contribs7 contribs8, $(BRANCH)))
326 srpm: sources $(TARGETS)
327 $(RPM_WITH_DIRS) $(DIST_DEFINES) --define _source_filedigest_algorithm=md5 --nodeps -bs $(SPECFILE)
328 else
329 srpm: sources $(TARGETS)
330 $(RPM_WITH_DIRS) $(DIST_DEFINES) --nodeps -bs $(SPECFILE)
331 endif
332
333 test-srpm: srpm
334
335 verrel:
336 @echo $(NAME)-$(VERSION)-$(RELEASE)
337
338 # If you build a new version into the tree, first do "make tag",
339 # then "make srpm", then build the package.
340 tag:: $(SPECFILE) $(COMMON_DIR)/branches
341 cvs tag $(TAG_OPTS) -c $(TAG)
342 @echo "Tagged with: $(TAG)"
343 @echo
344
345 force-tag: $(SPECFILE) $(COMMON_DIR)/branches
346 @$(MAKE) tag TAG_OPTS="-F $(TAG_OPTS)"
347
348 define find-user
349 if [ `cat CVS/Root |grep -c [^:]@` -ne 0 ]; then cat CVS/Root |cut -d @ -f 1 | sed 's/:.*://' ; else echo $(USER); fi
350 endef
351 USER := $(shell $(find-user))
352
353 oldbuild: $(COMMON_DIR)/branches
354 @if [ -z "$(TARGET)" -a ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
355
356 @cvs status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
357 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
358
359 @(pushd $(COMMON_DIR) >/dev/null ;\
360 rm -f tobuild ;\
361 cvs -Q update -C tobuild ;\
362 echo -e "$(USER)\t$(CVS_REPOSITORY)\t$(TAG)\t$(TARGET)" >> tobuild ;\
363 cvs commit -m "request build of $(CVS_REPOSITORY) $(TAG) for $(TARGET)" tobuild ;\
364 popd >/dev/null)
365
366 build-check: $(SPECFILE)
367 @if [ -z "$(TARGET)" -o ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
368 @cvs -f status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
369 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
370
371 plague: build-check $(COMMON_DIR)/branches
372 @if [ ! -x "$(PLAGUE_CLIENT)" ]; then echo "Must have plague-client installed - see http://fedoraproject.org/wiki/Extras/BuildSystemClientSetup"; exit 1; fi
373 $(PLAGUE_CLIENT) build $(NAME) $(TAG) $(TARGET)
374
375 koji: build-check $(COMMON_DIR)/branches
376 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
377 $(BUILD_CLIENT) $(SECONDARY_CONFIG) build $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
378
379 ifneq (, $(filter devel, $(BRANCH)))
380 build: koji
381 else
382 build: plague
383 endif
384
385 scratch-build: build-check
386 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
387 $(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
388
389
390 scratch-build-%: build-check
391 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
392 $(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch --arch-override=$* $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
393
394
395 bodhi: build-check $(COMMON_DIR)/branches clog
396 @if [ ! -x "$(BODHI_CLIENT)" ]; then echo "Must have bodhi-client installed"; exit 1; fi
397 @echo -e "\
398 # [ $(NAME)-$(VERSION)-$(RELEASE) ]\n\
399 # type=[S|B|E] (S=security, B=bugfix, E=enhancement) (required)\n\
400 # request=[T|S] (T=testing, S=stable) (default: testing)\n\
401 # bug=123,456\n\
402 # all other text will be considered to be part of the update notes\n\
403 type=" > bodhi.template
404 @grep -iZ '\[SME' clog | xargs -0n1 | sed -n -e 's,[^]]*\[SME[: ]*\([0-9]*\)\],\1 ,igp' | xargs | tr ' ' ',' > $(NAME).bugs
405 @if [ `cat $(NAME).bugs` ]; then echo "bug=`cat $(NAME).bugs`" >> bodhi.template; fi
406 @sed -e '/^#/d' < bodhi.template > bodhi.template.orig
407 @if [ -z "$$EDITOR" ]; then vi bodhi.template; else $$EDITOR bodhi.template; fi
408 @if [ -n "`sed -e '/^#/d' < bodhi.template | diff bodhi.template.orig -`" ]; then \
409 $(BODHI_CLIENT) -v --new --release $(subst -,,$(BRANCH)) \
410 --file bodhi.template $(NAME)-$(VERSION)-$(RELEASE) -u $(BODHI_USER); \
411 else \
412 echo "Bodhi update aborted!"; \
413 fi
414 @rm -f bodhi.template{,.orig} $(NAME).bugs clog
415
416 ifndef $(BODHI_USER)
417 BODHI_USER=$(USER)
418 endif
419
420 ifneq (, $(filter contribs7 contribs8, $(BRANCH)))
421 update: bodhi
422 endif
423
424 cvsurl:
425 @echo '$(CVS_URL)'
426
427 chain-build: build-check
428 @if [ -z "$(CHAIN)" ]; then \
429 echo "Missing CHAIN variable, please specify the order of packages to" ; \
430 echo "chain build. For example: make chain-build CHAIN='foo bar'" ; \
431 exit 1 ; \
432 fi ; \
433 set -e ; \
434 subdir=`basename $$(pwd)` ; \
435 urls="" ; \
436 for component in $(CHAIN) ; do \
437 if [ "$$component" = "$(NAME)" ]; then \
438 echo "$(NAME) must not appear in CHAIN" ; \
439 exit 1 ; \
440 fi ; \
441 if [ "$$component" = ":" ]; then \
442 urls="$$urls :" ; \
443 continue ; \
444 elif [ -n "$$urls" -a -z "$(findstring :,$(CHAIN))" ]; then \
445 urls="$$urls :" ; \
446 fi ; \
447 rm -rf .tmp-$$$$ ; \
448 mkdir -p .tmp-$$$$ ; \
449 pushd .tmp-$$$$ > /dev/null ; \
450 cvs -f -Q -z 3 -d $(CVS_ROOT) co $$component ; \
451 urls="$$urls `make -s -C $$component/$$subdir cvsurl`" ; \
452 popd > /dev/null ; \
453 rm -rf .tmp-$$$$ ; \
454 done ; \
455 if [ -z "$(findstring :,$(CHAIN))" ]; then \
456 urls="$$urls :" ; \
457 fi ; \
458 urls="$$urls `make -s cvsurl`" ; \
459 $(BUILD_CLIENT) chain-build $(BUILD_FLAGS) $(TARGET) $$urls
460
461 # "make new | less" to see what has changed since the last tag was assigned
462 new:
463 -@cvs diff -u -r$$(cvs log Makefile 2>/dev/null | awk '/^symbolic names:$$/ {getline; sub(/^[ \t]*/, "") ; sub (/:.*$$/, ""); print; exit 0}')
464
465 # mop up, printing out exactly what was mopped.
466 clean ::
467 @echo "Running the %clean script of the rpmbuild..."
468 -@$(RPM_WITH_DIRS) --clean --nodeps $(SPECFILE)
469 @for F in $(FULLSOURCEFILES); do \
470 if test -e $$F ; then \
471 echo "Deleting $$F" ; /bin/rm -f $$F ; \
472 fi; \
473 done
474 @if test -d $(TMPCVS); then \
475 echo "Deleting CVS dir $(TMPCVS)" ; \
476 /bin/rm -rf $(TMPCVS); \
477 fi
478 @if test -e $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; then \
479 echo "Deleting $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm" ; \
480 /bin/rm -f $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; \
481 fi
482 @rm -fv *~ clog
483 @echo "Fully clean!"
484
485 # To prevent CVS noise due to changing file timestamps, upgrade
486 # to patchutils-0.2.23-3 or later, and add to ~/.cvspkgsrc:
487 # FILTERDIFF := filterdiff --remove-timestamps
488 ifndef FILTERDIFF
489 FILTERDIFF := cat
490 endif
491
492 ifdef CVE
493 PATCHFILE := $(NAME)-$(VERSION)-CVE-$(CVE).patch
494 SUFFIX := cve$(shell echo $(CVE) | sed s/.*-//)
495 else
496 PATCHFILE := $(NAME)-$(VERSION)-$(SUFFIX).patch
497 endif
498
499 patch:
500 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
501 (cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) > $(PATCHFILE) || true
502 @if ! test -s $(PATCHFILE); then echo "Patch is empty!"; exit 1; fi
503 @echo "Created $(PATCHFILE)"
504 @grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
505
506 # Recreates the patch file of specified suffix from the current working sources
507 # but keeping any comments at the top of file intact, and backing up the old copy
508 # with a '~' suffix.
509 rediff:
510 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
511 @if ! test -f "$(PATCHFILE)"; then echo "$(PATCHFILE) not found"; exit 1; fi
512 @mv -f $(PATCHFILE) $(PATCHFILE)\~
513 @sed '/^--- /,$$d' < $(PATCHFILE)\~ > $(PATCHFILE)
514 @(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) >> $(PATCHFILE) || true
515
516 clog: $(SPECFILE)
517 @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $(SPECFILE) | tee $@
518
519 commit: clog
520 @cvs commit -F $?
521 @rm -f clog
522
523 help:
524 @echo "Usage: make <target>"
525 @echo "Available targets are:"
526 @echo " help Show this text"
527 @echo " sources Download source files [default]"
528 @echo " upload FILES=<files> Add <files> to CVS"
529 @echo " new-sources FILES=<files> Replace sources in CVS with <files>"
530 @echo " <arch> Local test rpmbuild binary"
531 @echo " local Local test rpmbuild binary"
532 @echo " prep Local test rpmbuild prep"
533 @echo " compile Local test rpmbuild compile"
534 @echo " install Local test rpmbuild install"
535 @echo " compile-short Local test rpmbuild short-circuit compile"
536 @echo " install-short Local test rpmbuild short-circuit install"
537 @echo " lint Run rpmlint against local build output"
538 @echo " export Create clean export in \"cvs-$(TAG)\""
539 @echo " check Check test srpm preps on all archs"
540 @echo " srpm Create a srpm"
541 @echo " tag Tag sources as \"$(TAG)\""
542 @echo " build Request build of \"$(TAG)\" for $(TARGET)"
543 @echo " chain-build Build current package in order with other packages"
544 @echo " example: make chain-build CHAIN='libwidget libgizmo'"
545 @echo " The current package is added to the end of the CHAIN list."
546 @echo " Colons (:) can be used in the CHAIN parameter to define dependency groups."
547 @echo " Packages in a single group will be built in parallel, and all packages"
548 @echo " in a group must build successfully and populate the repository before"
549 @echo " the next group will begin building."
550 @echo " If no groups are defined, packages will be built sequentially."
551 @echo " scratch-build Request scratch build of \"$(TAG)\" for $(TARGET)"
552 @echo " scratch-build-<archs> Request scratch build of \"$(TAG)\" for $(TARGET) and archs <archs>"
553 @echo " examples: make scratch-build-i386,ppc64"
554 @echo " make scratch-build-x86_64"
555 @echo " mockbuild Local test build using mock"
556 @echo " verrel Echo \"$(NAME)-$(VERSION)-$(RELEASE)\""
557 @echo " new Diff against last tag"
558 @echo " clog Make a clog file containing top changelog entry"
559 @echo " commit Commit to CVS using the clog file as the log message"
560 @echo " clean Remove srcs ($(SOURCEFILES)), export dir (cvs-$(TAG)) and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
561 @echo " patch SUFFIX=<suff> Create and add a gendiff patch file"
562 @echo " rediff SUFFIX=<suff> Recreates a gendiff patch file, retaining comments"
563 @echo " unused-patches Print list of patches not referenced by name in specfile"
564 @echo " unused-fedora-patches Print Fedora patches not used by Patch and/or ApplyPatch directives"
565 @echo " gimmespec Print the name of the specfile"
566 @echo " update Submit $(NAME)-$(VERSION)-$(RELEASE) as an update for $(BRANCH)"
567
568 gimmespec:
569 @echo "$(SPECFILE)"
570
571 unused-patches:
572 @for f in *.patch; do if [ -e $$f ]; then grep -q $$f $(SPECFILE) || echo $$f; fi; done
573
574 unused-fedora-patches:
575 @for f in *.patch; do if [ -e $$f ]; then (egrep -q "^Patch[[:digit:]]+:[[:space:]]+$$f" $(SPECFILE) || echo "Unused: $$f") && egrep -q "^ApplyPatch[[:space:]]+$$f" $(SPECFILE) || echo "Unapplied: $$f"; fi; done
576
577 ##################### EXPERIMENTAL ##########################
578 # this stuff is very experimental in nature and should not be
579 # relied upon until these targets are moved above this line
580
581 # This section contains some hacks that instrument
582 # download-from-upstream support. You'll have to talk to gafton, he
583 # knows how this shit works.
584
585 # Add to the list of hardcoded upstream files the contents of the
586 # ./upstream file
587 UPSTREAM_FILES += $(shell if test -f ./upstream ; then cat ./upstream ; fi)
588 # extensions for signature files we need to retrieve for verification
589 # Warning: if you update the set of defaults, please make sure to
590 # update/add to the checking rules further down
591 UPSTREAM_CHECKS ?= sign asc sig md5
592
593 # check the signatures for the downloaded upstream stuff
594 UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
595
596 # Download a file from a particular host.
597 # First argument contains the url base, the second the filename,
598 # third extra curl options
599 define download-host-file
600 if test ! -e "$(2)" ; then \
601 echo -n "URL: $(1)/$(2) ..." ; \
602 $(CURL) --silent --head $(1)/$(2) && \
603 { \
604 echo "OK, downloading..." ; \
605 $(CURL) $(3) $(1)/$(2) ; \
606 } || \
607 echo "not found" ; \
608 fi
609 endef
610
611 # Download a file, trying each mirror in sequence. Also check for
612 # signatures, if available
613 # First argument contains the file name. We read the list of mirrors
614 # from the ./mirrors file
615 define download-file
616 $(foreach h, $(shell cat mirrors),
617 $(call download-host-file,$(h),$(1))
618 if test -e $(1) ; then \
619 $(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
620 fi
621 )
622 if test ! -e $(1) ; then \
623 echo "ERROR: Could not download file: $(1)" ; \
624 exit -1 ; \
625 else \
626 echo "File $(1) available for local use" ; \
627 fi
628 endef
629
630 # Download all the UPSTREAM files
631 define download-files
632 $(foreach f, $(UPSTREAM_FILES),
633 $(call download-file,$(f))
634 echo
635 )
636 endef
637
638 # Make sure the signature files we download are properly added
639 define cvs-add-upstream-sigs
640 for s in $(UPSTREAM_CHECK_FILES) ; do \
641 if test -f "$$s" ; then \
642 if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
643 cvs -Q add "$$s" ; \
644 fi ; \
645 fi ; \
646 done
647 endef
648
649 download : upstream mirrors
650 @$(download-files)
651 $(MAKE) download-checks
652
653 download-checks :: import-upstream-gpg
654 download-checks :: $(UPSTREAM_CHECK_FILES)
655
656 # how to check for a gpg signature, given a separate signature file
657 define check-upstream-gpg-sig
658 echo -n "Checking GPG signature on $* from $@ : "
659 if ! test -f $@ ; then \
660 echo "ERROR" ; echo "GPG signature file $@ not found" ; \
661 exit 1 ; \
662 fi
663 if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
664 echo "FAILED" ; \
665 exit 1 ; \
666 else \
667 echo "OK" ; \
668 fi
669 endef
670
671 # how to check for a md5sum, given a separate .md5 file
672 define check-upstream-md5sum
673 echo -n "Checking md5sum on $* from $@ : "
674 if ! test -f $@ ; then \
675 echo "ERROR" ; echo "md5sum file $@ not found" ; \
676 exit 1 ; \
677 fi
678 if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
679 echo "FAILED" ; \
680 exit 1 ; \
681 else \
682 echo "OK" ; \
683 fi
684 endef
685
686 # and now the rules, specific to each extension
687 $(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
688 @$(check-upstream-gpg-sig)
689 $(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
690 @$(check-upstream-gpg-sig)
691 $(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
692 @$(check-upstream-gpg-sig)
693 $(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
694 @$(check-upstream-md5sum)
695
696 # We keep all the relevant GPG keys in the upstream-key.gpg so we can
697 # check the signatures...
698 import-upstream-gpg : upstream-key.gpg FORCE
699 mkdir -p $(HOME)/.gnupg
700 gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
701
702 # A handy target to download the latest and greatest from upstream and
703 # check it into the lookaside cache.
704 # new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
705 # rebase uses the standard "make upload"
706 new-base : clean download
707 $(MAKE) new-source FILES="$(UPSTREAM_FILES)"
708 @$(cvs-add-upstream-sigs)
709 @echo "Don't forget to do a 'cvs commit' for your new sources file."
710
711 rebase : clean download
712 $(MAKE) upload FILES="$(UPSTREAM_FILES)"
713 @$(cvs-add-upstream-sigs)
714 @echo "Don't forget to do a 'cvs commit' for your new sources file."
715
716 # there is more stuff to clean, now that we have upstream files
717 clean ::
718 @rm -fv $(UPSTREAM_FILES)

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