[Openais] [PATCH] corosync/trunk: add support for make rpm and make srpm targets

Jim Meyering jim at meyering.net
Thu Jun 25 05:04:51 PDT 2009


Fabio M. Di Nitto wrote:
> Howto:
>
> svn co...
> ./autogen.sh
> ./configure
> make rpm or make srpm
>
> The resulting srpm can be built _without_ autotools installed
> and the resulting rpm is equivalent of the one you would get from Fedora
> rawhide.

I know what you mean, but just to clarify:
  - building (i.e., creating) the srpm requires autoconf and automake.
  - building *from* the srpm (as from any distribution tarball) does not.

...
> Index: Makefile.am
> ===================================================================
...
>  clean-generic:
> -	rm -rf doc/api
> +	rm -rf doc/api $(SPEC) $(TARFILE) *.rpm .build-*

Please don't remove names via wildcards like that.
I might have a directory named PRECIOUS_IMPORTANT.rpm.build-DO_NOT_DELETE.

> +## make rpm/srpm section.
> +
> +$(SPEC): $(SPEC).in
> +	LC_ALL=C date="$(shell date "+%a %b %d %Y")" && \
> +	alphatag="$(shell svnversion)" && \
> +	cat $^ | sed \
> +		-e "s#@alphatag@#r$$alphatag#g" \
> +		-e "s#@version@#$(VERSION)#g" \
> +		-e "s#@date@#$$date#g" \
> +	> $@

You can save a process, i.e., remove the cat:
(also,
  - using $< is slightly more precise than $^
  - don't "redirect directly to target" (for why, search for that phrase)
  - make the generated file read-only (i.e., harder to accidentally modify)

	sed \
		-e "s#@alphatag@#r$$alphatag#g" \
		-e "s#@version@#$(VERSION)#g" \
		-e "s#@date@#$$date#g" \
	    $< > $@-t
	chmod a-w $@-t
	mv $@-t $@

> +srpm: clean $(SPEC) $(TARFILE)
> +	rpmbuild \
> +		$(RPMBUILDOPTS) \
> +		--nodeps -bs $(SPEC)

These (above and below) don't do what you want when built with -jN.
I.e., they'll run the clean rule and the ones to create
$(SPEC) and $(TARFILE) in parallel.

You can use this in place of the above.

srpm: clean
	$(MAKE) $(SPEC) $(TARFILE)
	rpmbuild $(RPMBUILDOPTS) --nodeps -bs $(SPEC)


> +rpm: clean $(SPEC) $(TARFILE)
> +	rpmbuild \
> +		$(RPMBUILDOPTS) \
> +		-ba $(SPEC) 2>&1 | \
> +	tee .build-$(VERSION).log


More information about the Openais mailing list