Hi, I've spent a little bit of time on the shuttle to/from work hacking on Makefile.common. The general idea is to remove the Release: and % changelog fields from spec files, and have them generated automatically. The goals are: * Allow for automated (re-)builds without hackish scripts * Avoid developer time being spent incrementing integers in spec file * Obviate the need to keep two changelogs in sync * Resolve clashes about what disttags should be by having them determined by the build system * Longer term, make it easier to transition to a better source format For example, with this change we can go from the workflow of: edit foo.spec make clog cvs commit -F clog make tag build # discover error edit foo.spec make force-tag build Now: edit foo.spec2 make build # discover error edit foo.spec2 make build Much nicer! And we're being generous with the first system - if you want to do it without the unsafe force-tag it's even longer. In the new system, you only need to know two commands: "make local" to do a local build, and "make build" for Koji. The attached patch is a work in progress; you can patch your Makefile.common, delete the Release: line from your spec file, and rename your spec file to .spec2 (suggestions for a better name are appreciated). It works for "make local" which gives you a feel for how the system can operate. You can verify that after every 'make local' you get a new RPM release, and thus you can install them sanely on your system without using --force. One tweak I'd like to implement for 'make local' is have it use '.local' or something for a disttag. What remains to be implemented is the Koji side of things. The idea is that "make build" will run 'cvs commit; make tag koji', and that Koji will have a database of package Release tags, and increment them itself for each new build. It will generate the %changelog section from the CVS changelog between the last tag and the new one.
cvs diff: Diffing . Index: Makefile.common =================================================================== RCS file: /cvs/pkgs/common/Makefile.common,v retrieving revision 1.87 diff -u -u -r1.87 Makefile.common --- Makefile.common 15 Jan 2008 14:22:36 -0000 1.87 +++ Makefile.common 5 Mar 2008 17:53:31 -0000 @@ -14,6 +14,16 @@ endef COMMON_DIR := $(shell $(find-common-dir)) +# Determine spec input source; spec2 denotes a traditional RPM spec file, but without +# a Release: or changelog +SPEC2FILE := $(firstword $(wildcard *.spec2)) +ifneq ($(SPEC2FILE),) +SPECSRC := $(SPEC2FILE) +SPECFILE := $(SPEC2FILE:.spec2=.spec) +else +SPECSRC := $(SPECFILE) +endif + # Branch and disttag definitions # These need to happen second. ifndef HEAD_BRANCH @@ -34,7 +44,6 @@ BUILD_FLAGS ?= $(shell echo $(KOJI_FLAGS)) - ## a base directory where we'll put as much temporary working stuff as we can ifndef WORKDIR WORKDIR := $(shell pwd) @@ -93,12 +102,41 @@ ifndef NAME $(error "You can not run this Makefile without having NAME defined") endif +define extract-var + rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{$(2)}\n" --specfile $(1)| head -1 +endef ifndef VERSION -VERSION := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{VERSION}\n" --specfile $(SPECFILE)| head -1) +VERSION := $(shell $(extract-var $(SPECSRC) VERSION)) endif -# the release of the package + +#define get-changelog +# cvs log -S -b -N $(SPECSRC) | grep -v '^\?' | head -1000 +#endef + +define get-release-serial +$$(if test -f release-serial; then \ + cat release-serial | tr -d '\n'; \ + else \ + echo 0; \ + fi) +endef + +define increment-release-serial + release=$$(($(get-release-serial)+1)); \ + echo $${release} > release-serial.tmp && mv release-serial.tmp release-serial +endef + +ifneq ($(SPEC2FILE),) +# Now we generate the specfile with this simple transformation of +# adding the Release: line at the top. +# TODO: generate changelog in here too +$(SPECFILE): $(SPEC2FILE) $(MAKEFILE_COMMON) + release=$(get-release-serial); \ + (echo -n "Release: " && echo $${release}$(DIST) && cat $(SPEC2FILE)) > $(SPECFILE).tmp && mv $(SPECFILE).tmp $(SPECFILE) +endif + ifndef RELEASE -RELEASE := $(shell rpm $(RPM_DEFINES) $(DIST_DEFINES) -q --qf "%{RELEASE}\n" --specfile $(SPECFILE)| head -1) +RELEASE := $(shell $(extract-var $(SPECSRC) RELEASE)) endif # this is used in make patch, maybe make clean eventually. # would be nicer to autodetermine from the spec file... @@ -309,14 +347,16 @@ mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCKDIR)/$(TAG) rebuild $(SRCRPMDIR)/$(NAME)-$(VERSION)-$(RELEASE).src.rpm # build for a particular arch -$(ARCHES) : sources $(TARGETS) +$(ARCHES) : $(SPECFILE) sources $(TARGETS) $(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: Makefile $(MAKEFILE_COMMON) + $(increment-release-serial) + $(MAKE) $(if $(shell grep -i '^BuildArch:.*noarch' $(SPECSRC)), noarch, $(shell uname -m)) # attempt to apply all the patches, optionally only for a particular arch ifdef PREPARCH @@ -373,7 +413,7 @@ done; ## use this to build an srpm locally -srpm: sources $(TARGETS) +srpm: sources $(SPECFILE) $(TARGETS) $(RPM_WITH_DIRS) $(DIST_DEFINES) --nodeps -bs $(SPECFILE) test-srpm: srpm
-- fedora-devel-list mailing list fedora-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/fedora-devel-list