--- common/Makefile.common 2008/03/28 14:38:42 1.12 +++ common/Makefile.common 2008/07/30 18:02:34 1.13 @@ -5,7 +5,7 @@ # Copyright (C) 2004-2005 Red Hat, Inc. # Copyright (C) 2005 Fedora Foundation # -# $Id: Makefile.common,v 1.11 2008/03/12 04:42:51 slords Exp $ +# $Id: Makefile.common,v 1.12 2008/03/28 14:38:42 slords Exp $ # Define the common dir. # This needs to happen first. @@ -19,14 +19,20 @@ COMMON_DIR := $(shell $(find-common-dir) ifndef HEAD_BRANCH HEAD_BRANCH := devel endif -BRANCH:=$(shell [ -f branch ] && cat branch || echo $(HEAD_BRANCH)) +BASEDIR := $(shell basename `pwd`) +BRANCH := $(BASEDIR) BRANCHINFO = $(shell grep ^$(BRANCH): $(COMMON_DIR)/branches | cut -d: --output-delimiter=" " -f2-) TARGET := $(word 1, $(BRANCHINFO)) DIST = $(word 2, $(BRANCHINFO)) DISTVAR = $(word 3, $(BRANCHINFO)) DISTVAL = $(word 4, $(BRANCHINFO)) +DISTDEF = $(shell echo $(DIST) | sed -e s/^\\\.// ) SMEVAL = $(word 5, $(BRANCHINFO)) -DIST_DEFINES = --define "dist $(DIST)" --define "$(DISTVAR) $(DISTVAL)" --define "sme $(SMEVAL)" +DIST_DEFINES = --define "dist $(DIST)" --define "$(DISTVAR) $(DISTVAL)" --define "$(DISTDEF) 1" --define "sme $(SMEVAL)" + +BUILD_FLAGS ?= $(KOJI_FLAGS) + +LOCALARCH := $(if $(shell grep -i '^BuildArch:.*noarch' $(SPECFILE)), noarch, $(shell uname -m)) ## a base directory where we'll put as much temporary working stuff as we can ifndef WORKDIR @@ -48,9 +54,13 @@ MOCKCFG ?= smeserver-$(SMEVAL)-$(BUILDAR ifndef SOURCEDIR SOURCEDIR := $(shell pwd) endif +ifndef SPECDIR +SPECDIR := $(shell pwd) +endif ifndef RPM_DEFINES -RPM_DEFINES = --define "_sourcedir $(SOURCEDIR)" \ +RPM_DEFINES := --define "_sourcedir $(SOURCEDIR)" \ + --define "_specdir $(SPECDIR)" \ --define "_builddir $(BUILDDIR)" \ --define "_srcrpmdir $(SRCRPMDIR)" \ --define "_rpmdir $(RPMDIR)" \ @@ -59,15 +69,16 @@ endif # Initialize the variables that we need, but are not defined # the version of the package +VER_REL := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{VERSION} %{RELEASE}\n" --specfile $(SPECFILE)| head -1) ifndef NAME $(error "You can not run this Makefile without having NAME defined") endif ifndef VERSION -VERSION := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1) +VERSION := $(word 1, $(VER_REL)) endif # the release of the package ifndef RELEASE -RELEASE := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1) +RELEASE := $(word 2, $(VER_REL)) endif # this is used in make patch, maybe make clean eventually. # would be nicer to autodetermine from the spec file... @@ -76,6 +87,12 @@ RPM_BUILD_DIR ?= $(BUILDDIR)/$(NAME)-$(V # default target: just make sure we've got the sources all: sources +# user specific configuration +CVS_EXTRAS_RC := $(shell if test -f $(HOME)/.cvspkgsrc ; then echo $(HOME)/.cvspkgsrc ; fi) +ifdef CVS_EXTRAS_RC +include $(CVS_EXTRAS_RC) +endif + # The repository and the clients we use for the files REPOSITORY ?= http://lordsfam.net/yum/builds/source UPLOAD_REPOSITORY ?= /builds/source @@ -86,10 +103,14 @@ CURL ?= $(shell if test -f /usr/bin/curl WGET ?= $(shell if test -f /usr/bin/wget ; then echo "wget -nd -m" ; fi) CLIENT ?= $(if $(CURL),$(CURL),$(if $(WGET),$(WGET))) PLAGUE_CLIENT ?= $(shell which plague-client 2>/dev/null) +BUILD_CLIENT ?= $(shell which koji 2>/dev/null) +BODHI_CLIENT ?= $(shell which bodhi 2>/dev/null) -# RPM with all the overrides in place +# RPM with all the overrides in place; you can override this in your +# .cvspkgsrc also, to use a default rpm setup +# the rpm build command line ifndef RPM -RPM := $(shell if test -f /usr/bin/rpmbuild ; then echo rpmbuild ; else echo rpm ; fi) +RPM := rpmbuild endif ifndef RPM_WITH_DIRS RPM_WITH_DIRS = $(RPM) $(RPM_DEFINES) @@ -118,13 +139,13 @@ $(shell cat sources 2>/dev/null | while endef # list the possible targets for valid arches -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 +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 # for the modules that do different "make prep" depending on what arch we build for PREP_ARCHES = $(addprefix prep-,$(ARCHES)) ## list all our bogus targets -.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 +.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-% # The TARGETS define is meant for local module targets that should be # made in addition to the SOURCEFILES whenever needed @@ -144,6 +165,7 @@ $(SOURCEFILES): #FORCE break ; \ fi ; \ done + @if [ -z "$(CLIENT)" ]; then echo "Can't download, need curl or wget installed." ; exit 1; fi @if [ ! -e "$@" ] ; then $(CLIENT) $(REPOSITORY)/$(get_sources_md5)/$@ ; fi @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi @if test "$$(md5sum $@ | awk '{print $$1}')" != "$(get_sources_md5)" ; then \ @@ -225,18 +247,22 @@ endif # test build in mock mockbuild : srpm - mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm + mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) rebuild $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm + +# check the build with rpmlint +lint: + @test -e $(NAME)-$(VERSION)-$(RELEASE).src.rpm || (echo "run 'make local' first" ; exit 1 ) + rpmlint $(NAME)-$(VERSION)-$(RELEASE).src.rpm $(LOCALARCH)/*-$(VERSION)-$(RELEASE).$(LOCALARCH).rpm # build for a particular arch $(ARCHES) : sources $(TARGETS) - $(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log - @exit ${PIPESTATUS[0]} + $(RPM_WITH_DIRS) --target $@ -ba $(SPECFILE) 2>&1 | tee .build-$(VERSION)-$(RELEASE).log ; exit $${PIPESTATUS[0]} # empty target to force checking of md5sums in FULLSOURCEFILES FORCE: # build whatever's appropriate for the local architecture -local: $(if $(shell grep -i '^BuildArch:.*noarch' $(SPECFILE)), noarch, $(shell uname -m)) +local: $(LOCALARCH) # attempt to apply all the patches, optionally only for a particular arch ifdef PREPARCH @@ -254,6 +280,9 @@ prep-% : Makefile compile: sources $(TARGETS) $(RPM_WITH_DIRS) -bc $(SPECFILE) +install: sources $(TARGETS) + $(RPM_WITH_DIRS) -bi $(SPECFILE) + compile-short: sources $(TARGETS) $(RPM_WITH_DIRS) --nodeps --short-circuit -bc $(SPECFILE) @@ -262,6 +291,7 @@ install-short: sources $(TARGETS) CVS_ROOT := $(shell if [ -f CVS/Root ] ; then cat CVS/Root ; fi) CVS_REPOSITORY := $(shell if [ -f CVS/Repository ] ; then cat CVS/Repository ; fi) +CVS_URL := cvs://smeserver.cvs.sourceforge.net:/cvsroot/smeserver?$(CVS_REPOSITORY)\#$(TAG) ## create a clean exported copy in $(TMPCVS) export:: sources @@ -310,6 +340,24 @@ tag:: $(SPECFILE) $(COMMON_DIR)/branc force-tag: $(SPECFILE) $(COMMON_DIR)/branches @$(MAKE) tag TAG_OPTS="-F $(TAG_OPTS)" +define find-user +if [ `cat CVS/Root |grep -c [^:]@` -ne 0 ]; then cat CVS/Root |cut -d @ -f 1 | sed 's/:.*://' ; else echo $(USER); fi +endef +USER := $(shell $(find-user)) + +oldbuild: $(COMMON_DIR)/branches + @if [ -z "$(TARGET)" -a ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi + + @cvs status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\ + if [ $$ret -ne 0 ]; then echo "$(SPECFILE) not tagged with tag $(TAG)"; exit 1; fi + + @(pushd $(COMMON_DIR) >/dev/null ;\ + rm -f tobuild ;\ + cvs -Q update -C tobuild ;\ + echo -e "$(USER)\t$(CVS_REPOSITORY)\t$(TAG)\t$(TARGET)" >> tobuild ;\ + cvs commit -m "request build of $(CVS_REPOSITORY) $(TAG) for $(TARGET)" tobuild ;\ + popd >/dev/null) + build-check: $(SPECFILE) @if [ -z "$(TARGET)" -o ! -d CVS ]; then echo "Must be in a branch subdirectory"; exit 1; fi @cvs -f status -v $(SPECFILE) 2>/dev/null | grep -q $(TAG); ret=$$? ;\ @@ -317,9 +365,93 @@ build-check: $(SPECFILE) plague: build-check $(COMMON_DIR)/branches @if [ ! -x "$(PLAGUE_CLIENT)" ]; then echo "Must have plague-client installed - see http://fedoraproject.org/wiki/Extras/BuildSystemClientSetup"; exit 1; fi - @$(PLAGUE_CLIENT) build $(NAME) $(TAG) $(TARGET) + $(PLAGUE_CLIENT) build $(NAME) $(TAG) $(TARGET) +koji: build-check $(COMMON_DIR)/branches + @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi + $(BUILD_CLIENT) $(SECONDARY_CONFIG) build $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)' + +ifneq (, $(filter devel, $(BRANCH))) +build: koji +else build: plague +endif + +scratch-build: build-check + @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi + $(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)' + + +scratch-build-%: build-check + @if [ ! -x "$(BUILD_CLIENT)" ]; then echo "Must have koji installed - see http://fedoraproject.org/wiki/BuildSystemClientSetup"; exit 1; fi + $(BUILD_CLIENT) $(SECONDARY_CONFIG) build --scratch --arch-override=$* $(BUILD_FLAGS) $(TARGET) '$(CVS_URL)' + + +bodhi: build-check $(COMMON_DIR)/branches clog + @if [ ! -x "$(BODHI_CLIENT)" ]; then echo "Must have bodhi-client installed"; exit 1; fi + @echo -e "\ +# [ $(NAME)-$(VERSION)-$(RELEASE) ]\n\ +# type=[S|B|E] (S=security, B=bugfix, E=enhancement) (required)\n\ +# request=[T|S] (T=testing, S=stable) (default: testing)\n\ +# bug=123,456\n\ +# all other text will be considered to be part of the update notes\n\ +type=" > bodhi.template + @grep -iZ '\[SME' clog | xargs -0n1 | sed -n -e 's,[^]]*\[SME[: ]*\([0-9]*\)\],\1 ,igp' | xargs | tr ' ' ',' > $(NAME).bugs + @if [ `cat $(NAME).bugs` ]; then echo "bug=`cat $(NAME).bugs`" >> bodhi.template; fi + @sed -e '/^#/d' < bodhi.template > bodhi.template.orig + @if [ -z "$$EDITOR" ]; then vi bodhi.template; else $$EDITOR bodhi.template; fi + @if [ -n "`sed -e '/^#/d' < bodhi.template | diff bodhi.template.orig -`" ]; then \ + $(BODHI_CLIENT) -v --new --release $(subst -,,$(BRANCH)) \ + --file bodhi.template $(NAME)-$(VERSION)-$(RELEASE) -u $(BODHI_USER); \ + else \ + echo "Bodhi update aborted!"; \ + fi + @rm -f bodhi.template{,.orig} $(NAME).bugs clog + +ifndef $(BODHI_USER) +BODHI_USER=$(USER) +endif + +ifneq (, $(filter sme7 sme8, $(BRANCH))) +update: bodhi +endif + +cvsurl: + @echo '$(CVS_URL)' + +chain-build: build-check + @if [ -z "$(CHAIN)" ]; then \ + echo "Missing CHAIN variable, please specify the order of packages to" ; \ + echo "chain build. For example: make chain-build CHAIN='foo bar'" ; \ + exit 1 ; \ + fi ; \ + set -e ; \ + subdir=`basename $$(pwd)` ; \ + urls="" ; \ + for component in $(CHAIN) ; do \ + if [ "$$component" = "$(NAME)" ]; then \ + echo "$(NAME) must not appear in CHAIN" ; \ + exit 1 ; \ + fi ; \ + if [ "$$component" = ":" ]; then \ + urls="$$urls :" ; \ + continue ; \ + elif [ -n "$$urls" -a -z "$(findstring :,$(CHAIN))" ]; then \ + urls="$$urls :" ; \ + fi ; \ + rm -rf .tmp-$$$$ ; \ + mkdir -p .tmp-$$$$ ; \ + pushd .tmp-$$$$ > /dev/null ; \ + cvs -f -Q -z 3 -d $(CVS_ROOT) co $$component ; \ + urls="$$urls `make -s -C $$component/$$subdir cvsurl`" ; \ + popd > /dev/null ; \ + rm -rf .tmp-$$$$ ; \ + done ; \ + if [ -z "$(findstring :,$(CHAIN))" ]; then \ + urls="$$urls :" ; \ + fi ; \ + urls="$$urls `make -s cvsurl`" ; \ + $(BUILD_CLIENT) chain-build $(BUILD_FLAGS) $(TARGET) $$urls # "make new | less" to see what has changed since the last tag was assigned new: @@ -381,6 +513,7 @@ clog: $(SPECFILE) commit: clog @cvs commit -F $? + @rm -f clog help: @echo "Usage: make " @@ -393,13 +526,27 @@ help: @echo " local Local test rpmbuild binary" @echo " prep Local test rpmbuild prep" @echo " compile Local test rpmbuild compile" + @echo " install Local test rpmbuild install" @echo " compile-short Local test rpmbuild short-circuit compile" @echo " install-short Local test rpmbuild short-circuit install" + @echo " lint Run rpmlint against local build output" @echo " export Create clean export in \"cvs-$(TAG)\"" @echo " check Check test srpm preps on all archs" @echo " srpm Create a srpm" @echo " tag Tag sources as \"$(TAG)\"" @echo " build Request build of \"$(TAG)\" for $(TARGET)" + @echo " chain-build Build current package in order with other packages" + @echo " example: make chain-build CHAIN='libwidget libgizmo'" + @echo " The current package is added to the end of the CHAIN list." + @echo " Colons (:) can be used in the CHAIN parameter to define dependency groups." + @echo " Packages in a single group will be built in parallel, and all packages" + @echo " in a group must build successfully and populate the repository before" + @echo " the next group will begin building." + @echo " If no groups are defined, packages will be built sequentially." + @echo " scratch-build Request scratch build of \"$(TAG)\" for $(TARGET)" + @echo " scratch-build- Request scratch build of \"$(TAG)\" for $(TARGET) and archs " + @echo " examples: make scratch-build-i386,ppc64" + @echo " make scratch-build-x86_64" @echo " mockbuild Local test build using mock" @echo " verrel Echo \"$(NAME)-$(VERSION)-$(RELEASE)\"" @echo " new Diff against last tag" @@ -409,7 +556,9 @@ help: @echo " patch SUFFIX= Create and add a gendiff patch file" @echo " rediff SUFFIX= Recreates a gendiff patch file, retaining comments" @echo " unused-patches Print list of patches not referenced by name in specfile" + @echo " unused-fedora-patches Print Fedora patches not used by Patch and/or ApplyPatch directives" @echo " gimmespec Print the name of the specfile" + @echo " update Submit $(NAME)-$(VERSION)-$(RELEASE) as an update for $(BRANCH)" gimmespec: @echo "$(SPECFILE)" @@ -417,6 +566,9 @@ gimmespec: unused-patches: @for f in *.patch; do if [ -e $$f ]; then grep -q $$f $(SPECFILE) || echo $$f; fi; done +unused-fedora-patches: + @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 + ##################### EXPERIMENTAL ########################## # this stuff is very experimental in nature and should not be # relied upon until these targets are moved above this line