/[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.14 - (show annotations) (download)
Mon Oct 12 21:02:01 2009 UTC (15 years, 1 month ago) by slords
Branch: MAIN
Changes since 1.13: +2 -2 lines
Update mock config ref

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.13 2008/07/30 18:02:34 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://lordsfam.net/yum/builds/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://smeserver.cvs.sourceforge.net:/cvsroot/smeserver?$(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 srpm: sources $(TARGETS)
326 $(RPM_WITH_DIRS) $(DIST_DEFINES) --nodeps -bs $(SPECFILE)
327
328 test-srpm: srpm
329
330 verrel:
331 @echo $(NAME)-$(VERSION)-$(RELEASE)
332
333 # If you build a new version into the tree, first do "make tag",
334 # then "make srpm", then build the package.
335 tag:: $(SPECFILE) $(COMMON_DIR)/branches
336 cvs tag $(TAG_OPTS) -c $(TAG)
337 @echo "Tagged with: $(TAG)"
338 @echo
339
340 force-tag: $(SPECFILE) $(COMMON_DIR)/branches
341 @$(MAKE) tag TAG_OPTS="-F $(TAG_OPTS)"
342
343 define find-user
344 if [ `cat CVS/Root |grep -c [^:]@` -ne 0 ]; then cat CVS/Root |cut -d @ -f 1 | sed 's/:.*://' ; else echo $(USER); fi
345 endef
346 USER := $(shell $(find-user))
347
348 oldbuild: $(COMMON_DIR)/branches
349 @if [ -z "$(TARGET)" -a ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
350
351 @cvs status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
352 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
353
354 @(pushd $(COMMON_DIR) >/dev/null ;\
355 rm -f tobuild ;\
356 cvs -Q update -C tobuild ;\
357 echo -e "$(USER)\t$(CVS_REPOSITORY)\t$(TAG)\t$(TARGET)" >> tobuild ;\
358 cvs commit -m "request build of $(CVS_REPOSITORY) $(TAG) for $(TARGET)" tobuild ;\
359 popd >/dev/null)
360
361 build-check: $(SPECFILE)
362 @if [ -z "$(TARGET)" -o ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi
363 @cvs -f status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\
364 if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi
365
366 plague: build-check $(COMMON_DIR)/branches
367 @if [ ! -x "$(PLAGUE_CLIENT)" ]; then echo "Must have plague-client installed - see http://fedoraproject.org/wiki/Extras/BuildSystemClientSetup"; exit 1; fi
368 $(PLAGUE_CLIENT) build $(NAME) $(TAG) $(TARGET)
369
370 koji: build-check $(COMMON_DIR)/branches
371 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
372 $(BUILD_CLIENT) $(SECONDARY_CONFIG) build $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
373
374 ifneq (, $(filter devel, $(BRANCH)))
375 build: koji
376 else
377 build: plague
378 endif
379
380 scratch-build: build-check
381 @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi
382 $(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
383
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 --arch-override=$* $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)'
388
389
390 bodhi: build-check $(COMMON_DIR)/branches clog
391 @if [ ! -x "$(BODHI_CLIENT)" ]; then echo "Must have bodhi-client installed"; exit 1; fi
392 @echo -e "\
393 # [ $(NAME)-$(VERSION)-$(RELEASE) ]\n\
394 # type=[S|B|E] (S=security, B=bugfix, E=enhancement) (required)\n\
395 # request=[T|S] (T=testing, S=stable) (default: testing)\n\
396 # bug=123,456\n\
397 # all other text will be considered to be part of the update notes\n\
398 type=" > bodhi.template
399 @grep -iZ '\[SME' clog | xargs -0n1 | sed -n -e 's,[^]]*\[SME[: ]*\([0-9]*\)\],\1 ,igp' | xargs | tr ' ' ',' > $(NAME).bugs
400 @if [ `cat $(NAME).bugs` ]; then echo "bug=`cat $(NAME).bugs`" >> bodhi.template; fi
401 @sed -e '/^#/d' < bodhi.template > bodhi.template.orig
402 @if [ -z "$$EDITOR" ]; then vi bodhi.template; else $$EDITOR bodhi.template; fi
403 @if [ -n "`sed -e '/^#/d' < bodhi.template | diff bodhi.template.orig -`" ]; then \
404 $(BODHI_CLIENT) -v --new --release $(subst -,,$(BRANCH)) \
405 --file bodhi.template $(NAME)-$(VERSION)-$(RELEASE) -u $(BODHI_USER); \
406 else \
407 echo "Bodhi update aborted!"; \
408 fi
409 @rm -f bodhi.template{,.orig} $(NAME).bugs clog
410
411 ifndef $(BODHI_USER)
412 BODHI_USER=$(USER)
413 endif
414
415 ifneq (, $(filter sme7 sme8, $(BRANCH)))
416 update: bodhi
417 endif
418
419 cvsurl:
420 @echo '$(CVS_URL)'
421
422 chain-build: build-check
423 @if [ -z "$(CHAIN)" ]; then \
424 echo "Missing CHAIN variable, please specify the order of packages to" ; \
425 echo "chain build. For example: make chain-build CHAIN='foo bar'" ; \
426 exit 1 ; \
427 fi ; \
428 set -e ; \
429 subdir=`basename $$(pwd)` ; \
430 urls="" ; \
431 for component in $(CHAIN) ; do \
432 if [ "$$component" = "$(NAME)" ]; then \
433 echo "$(NAME) must not appear in CHAIN" ; \
434 exit 1 ; \
435 fi ; \
436 if [ "$$component" = ":" ]; then \
437 urls="$$urls :" ; \
438 continue ; \
439 elif [ -n "$$urls" -a -z "$(findstring :,$(CHAIN))" ]; then \
440 urls="$$urls :" ; \
441 fi ; \
442 rm -rf .tmp-$$$$ ; \
443 mkdir -p .tmp-$$$$ ; \
444 pushd .tmp-$$$$ > /dev/null ; \
445 cvs -f -Q -z 3 -d $(CVS_ROOT) co $$component ; \
446 urls="$$urls `make -s -C $$component/$$subdir cvsurl`" ; \
447 popd > /dev/null ; \
448 rm -rf .tmp-$$$$ ; \
449 done ; \
450 if [ -z "$(findstring :,$(CHAIN))" ]; then \
451 urls="$$urls :" ; \
452 fi ; \
453 urls="$$urls `make -s cvsurl`" ; \
454 $(BUILD_CLIENT) chain-build $(BUILD_FLAGS) $(TARGET) $$urls
455
456 # "make new | less" to see what has changed since the last tag was assigned
457 new:
458 -@cvs diff -u -r$$(cvs log Makefile 2>/dev/null | awk '/^symbolic names:$$/ {getline; sub(/^[ \t]*/, "") ; sub (/:.*$$/, ""); print; exit 0}')
459
460 # mop up, printing out exactly what was mopped.
461 clean ::
462 @echo "Running the %clean script of the rpmbuild..."
463 -@$(RPM_WITH_DIRS) --clean --nodeps $(SPECFILE)
464 @for F in $(FULLSOURCEFILES); do \
465 if test -e $$F ; then \
466 echo "Deleting $$F" ; /bin/rm -f $$F ; \
467 fi; \
468 done
469 @if test -d $(TMPCVS); then \
470 echo "Deleting CVS dir $(TMPCVS)" ; \
471 /bin/rm -rf $(TMPCVS); \
472 fi
473 @if test -e $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; then \
474 echo "Deleting $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm" ; \
475 /bin/rm -f $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm ; \
476 fi
477 @rm -fv *~ clog
478 @echo "Fully clean!"
479
480 # To prevent CVS noise due to changing file timestamps, upgrade
481 # to patchutils-0.2.23-3 or later, and add to ~/.cvspkgsrc:
482 # FILTERDIFF := filterdiff --remove-timestamps
483 ifndef FILTERDIFF
484 FILTERDIFF := cat
485 endif
486
487 ifdef CVE
488 PATCHFILE := $(NAME)-$(VERSION)-CVE-$(CVE).patch
489 SUFFIX := cve$(shell echo $(CVE) | sed s/.*-//)
490 else
491 PATCHFILE := $(NAME)-$(VERSION)-$(SUFFIX).patch
492 endif
493
494 patch:
495 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
496 (cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) > $(PATCHFILE) || true
497 @if ! test -s $(PATCHFILE); then echo "Patch is empty!"; exit 1; fi
498 @echo "Created $(PATCHFILE)"
499 @grep "$(PATCHFILE)" CVS/Entries >&/dev/null || cvs add -ko $(PATCHFILE) || true
500
501 # Recreates the patch file of specified suffix from the current working sources
502 # but keeping any comments at the top of file intact, and backing up the old copy
503 # with a '~' suffix.
504 rediff:
505 @if test -z "$(SUFFIX)"; then echo "Must specify SUFFIX=whatever" ; exit 1; fi
506 @if ! test -f "$(PATCHFILE)"; then echo "$(PATCHFILE) not found"; exit 1; fi
507 @mv -f $(PATCHFILE) $(PATCHFILE)\~
508 @sed '/^--- /,$$d' < $(PATCHFILE)\~ > $(PATCHFILE)
509 @(cd $(RPM_BUILD_DIR)/.. && gendiff $(NAME)-$(VERSION) .$(SUFFIX) | $(FILTERDIFF)) >> $(PATCHFILE) || true
510
511 clog: $(SPECFILE)
512 @sed -n '/^%changelog/,/^$$/{/^%/d;/^$$/d;s/%%/%/g;p}' $(SPECFILE) | tee $@
513
514 commit: clog
515 @cvs commit -F $?
516 @rm -f clog
517
518 help:
519 @echo "Usage: make <target>"
520 @echo "Available targets are:"
521 @echo " help Show this text"
522 @echo " sources Download source files [default]"
523 @echo " upload FILES=<files> Add <files> to CVS"
524 @echo " new-sources FILES=<files> Replace sources in CVS with <files>"
525 @echo " <arch> Local test rpmbuild binary"
526 @echo " local Local test rpmbuild binary"
527 @echo " prep Local test rpmbuild prep"
528 @echo " compile Local test rpmbuild compile"
529 @echo " install Local test rpmbuild install"
530 @echo " compile-short Local test rpmbuild short-circuit compile"
531 @echo " install-short Local test rpmbuild short-circuit install"
532 @echo " lint Run rpmlint against local build output"
533 @echo " export Create clean export in \"cvs-$(TAG)\""
534 @echo " check Check test srpm preps on all archs"
535 @echo " srpm Create a srpm"
536 @echo " tag Tag sources as \"$(TAG)\""
537 @echo " build Request build of \"$(TAG)\" for $(TARGET)"
538 @echo " chain-build Build current package in order with other packages"
539 @echo " example: make chain-build CHAIN='libwidget libgizmo'"
540 @echo " The current package is added to the end of the CHAIN list."
541 @echo " Colons (:) can be used in the CHAIN parameter to define dependency groups."
542 @echo " Packages in a single group will be built in parallel, and all packages"
543 @echo " in a group must build successfully and populate the repository before"
544 @echo " the next group will begin building."
545 @echo " If no groups are defined, packages will be built sequentially."
546 @echo " scratch-build Request scratch build of \"$(TAG)\" for $(TARGET)"
547 @echo " scratch-build-<archs> Request scratch build of \"$(TAG)\" for $(TARGET) and archs <archs>"
548 @echo " examples: make scratch-build-i386,ppc64"
549 @echo " make scratch-build-x86_64"
550 @echo " mockbuild Local test build using mock"
551 @echo " verrel Echo \"$(NAME)-$(VERSION)-$(RELEASE)\""
552 @echo " new Diff against last tag"
553 @echo " clog Make a clog file containing top changelog entry"
554 @echo " commit Commit to CVS using the clog file as the log message"
555 @echo " clean Remove srcs ($(SOURCEFILES)), export dir (cvs-$(TAG)) and srpm ($(NAME)-$(VERSION)-$(RELEASE).src.rpm)"
556 @echo " patch SUFFIX=<suff> Create and add a gendiff patch file"
557 @echo " rediff SUFFIX=<suff> Recreates a gendiff patch file, retaining comments"
558 @echo " unused-patches Print list of patches not referenced by name in specfile"
559 @echo " unused-fedora-patches Print Fedora patches not used by Patch and/or ApplyPatch directives"
560 @echo " gimmespec Print the name of the specfile"
561 @echo " update Submit $(NAME)-$(VERSION)-$(RELEASE) as an update for $(BRANCH)"
562
563 gimmespec:
564 @echo "$(SPECFILE)"
565
566 unused-patches:
567 @for f in *.patch; do if [ -e $$f ]; then grep -q $$f $(SPECFILE) || echo $$f; fi; done
568
569 unused-fedora-patches:
570 @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
571
572 ##################### EXPERIMENTAL ##########################
573 # this stuff is very experimental in nature and should not be
574 # relied upon until these targets are moved above this line
575
576 # This section contains some hacks that instrument
577 # download-from-upstream support. You'll have to talk to gafton, he
578 # knows how this shit works.
579
580 # Add to the list of hardcoded upstream files the contents of the
581 # ./upstream file
582 UPSTREAM_FILES += $(shell if test -f ./upstream ; then cat ./upstream ; fi)
583 # extensions for signature files we need to retrieve for verification
584 # Warning: if you update the set of defaults, please make sure to
585 # update/add to the checking rules further down
586 UPSTREAM_CHECKS ?= sign asc sig md5
587
588 # check the signatures for the downloaded upstream stuff
589 UPSTREAM_CHECK_FILES = $(foreach e, $(UPSTREAM_CHECKS), $(addsuffix .$(e), $(UPSTREAM_FILES)))
590
591 # Download a file from a particular host.
592 # First argument contains the url base, the second the filename,
593 # third extra curl options
594 define download-host-file
595 if test ! -e "$(2)" ; then \
596 echo -n "URL: $(1)/$(2) ..." ; \
597 $(CURL) --silent --head $(1)/$(2) && \
598 { \
599 echo "OK, downloading..." ; \
600 $(CURL) $(3) $(1)/$(2) ; \
601 } || \
602 echo "not found" ; \
603 fi
604 endef
605
606 # Download a file, trying each mirror in sequence. Also check for
607 # signatures, if available
608 # First argument contains the file name. We read the list of mirrors
609 # from the ./mirrors file
610 define download-file
611 $(foreach h, $(shell cat mirrors),
612 $(call download-host-file,$(h),$(1))
613 if test -e $(1) ; then \
614 $(foreach e,$(UPSTREAM_CHECKS),$(call download-host-file,$(h),$(1).$(e),--silent) ; ) \
615 fi
616 )
617 if test ! -e $(1) ; then \
618 echo "ERROR: Could not download file: $(1)" ; \
619 exit -1 ; \
620 else \
621 echo "File $(1) available for local use" ; \
622 fi
623 endef
624
625 # Download all the UPSTREAM files
626 define download-files
627 $(foreach f, $(UPSTREAM_FILES),
628 $(call download-file,$(f))
629 echo
630 )
631 endef
632
633 # Make sure the signature files we download are properly added
634 define cvs-add-upstream-sigs
635 for s in $(UPSTREAM_CHECK_FILES) ; do \
636 if test -f "$$s" ; then \
637 if ! grep "^/$$s/" CVS/Entries >/dev/null 2>/dev/null ; then \
638 cvs -Q add "$$s" ; \
639 fi ; \
640 fi ; \
641 done
642 endef
643
644 download : upstream mirrors
645 @$(download-files)
646 $(MAKE) download-checks
647
648 download-checks :: import-upstream-gpg
649 download-checks :: $(UPSTREAM_CHECK_FILES)
650
651 # how to check for a gpg signature, given a separate signature file
652 define check-upstream-gpg-sig
653 echo -n "Checking GPG signature on $* from $@ : "
654 if ! test -f $@ ; then \
655 echo "ERROR" ; echo "GPG signature file $@ not found" ; \
656 exit 1 ; \
657 fi
658 if ! gpg --no-secmem-warning --no-permission-warning -q --verify $@ $* 2>/dev/null ; then \
659 echo "FAILED" ; \
660 exit 1 ; \
661 else \
662 echo "OK" ; \
663 fi
664 endef
665
666 # how to check for a md5sum, given a separate .md5 file
667 define check-upstream-md5sum
668 echo -n "Checking md5sum on $* from $@ : "
669 if ! test -f $@ ; then \
670 echo "ERROR" ; echo "md5sum file $@ not found" ; \
671 exit 1 ; \
672 fi
673 if ! md5sum $* | diff >/dev/null --brief "$@" - ; then \
674 echo "FAILED" ; \
675 exit 1 ; \
676 else \
677 echo "OK" ; \
678 fi
679 endef
680
681 # and now the rules, specific to each extension
682 $(addsuffix .sign,$(UPSTREAM_FILES)): %.sign: % FORCE
683 @$(check-upstream-gpg-sig)
684 $(addsuffix .asc,$(UPSTREAM_FILES)): %.asc: % FORCE
685 @$(check-upstream-gpg-sig)
686 $(addsuffix .sig,$(UPSTREAM_FILES)): %.sig: % FORCE
687 @$(check-upstream-gpg-sig)
688 $(addsuffix .md5,$(UPSTREAM_FILES)): %.md5: % FORCE
689 @$(check-upstream-md5sum)
690
691 # We keep all the relevant GPG keys in the upstream-key.gpg so we can
692 # check the signatures...
693 import-upstream-gpg : upstream-key.gpg FORCE
694 mkdir -p $(HOME)/.gnupg
695 gpg --quiet --import --no-secmem-warning --no-permission-warning $< || :
696
697 # A handy target to download the latest and greatest from upstream and
698 # check it into the lookaside cache.
699 # new-base assumes that all the sources are downloaded from upstream, so it uses "make new-source"
700 # rebase uses the standard "make upload"
701 new-base : clean download
702 $(MAKE) new-source FILES="$(UPSTREAM_FILES)"
703 @$(cvs-add-upstream-sigs)
704 @echo "Don't forget to do a 'cvs commit' for your new sources file."
705
706 rebase : clean download
707 $(MAKE) upload 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 # there is more stuff to clean, now that we have upstream files
712 clean ::
713 @rm -fv $(UPSTREAM_FILES)

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