From: David Woodhouse Date: Fri, 4 May 2018 12:58:18 +0000 (+0100) Subject: Clean up spec generation. X-Git-Tag: v0.91~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9e9afb3a58d3c99dba622c541754f0c657915032;p=pidgin-chime.git Clean up spec generation. Do it at autogen.sh and 'make dist' time, not during configure. Do it with a shell script and simplify .copr/Makefile --- diff --git a/.copr/Makefile b/.copr/Makefile index ab07508..0c3b7a6 100644 --- a/.copr/Makefile +++ b/.copr/Makefile @@ -2,34 +2,21 @@ # # https://docs.pagure.org/copr.copr/user_documentation.html#make-srpm # -WTF := $(shell dnf install git) -GITCOMMIT := $(shell git rev-parse HEAD) -GITDESC := $(shell git describe --tags HEAD) -GITDESC_WORDS := $(subst -, ,$(GITDESC)) -GITTAG := $(patsubst v%,%,$(word 1,$(GITDESC_WORDS))) -GITCOUNT := $(word 2,$(GITDESC_WORDS)) +srpm: pidgin-chime.spec /usr/bin/git + ./mkspec.sh + set -x; if grep -q "global gitsnapshot 1" pidgin-chime.spec; then \ + tarprefix=$$(sed -n '/^%global snapcommit /s/.* //p' $<); \ + tarname=$${tarprefix:0:7}; \ + else \ + tarprefix=$$(sed -n '/^%global tagver /s/.* //p' $<); \ + tarname=$${tarprefix}; \ + fi; \ + git archive --prefix=pidgin-chime-$${tarprefix}/ HEAD -o .copr/pidgin-chime-$${tarname}.tar.gz + rpmbuild -bs pidgin-chime.spec --define "_sourcedir .copr" --define "_srcrpmdir $(outdir)" -ifeq ($(GITCOUNT),) -ISSNAP := 0 -TARNAME := $(GITTAG) -TARPREFIX := $(GITTAG) -else -ISSNAP := 1 -TARNAME := $(shell echo $(GITCOMMIT) | cut -c1-7) -TARPREFIX := $(GITCOMMIT) -endif +/usr/bin/git: + dnf install git -srpm: .copr/pidgin-chime.spec .copr/pidgin-chime-$(TARNAME).tar.gz - rpmbuild -bs .copr/pidgin-chime.spec --define "_sourcedir .copr" --define "_srcrpmdir $(outdir)" - -.copr/pidgin-chime.spec: pidgin-chime.spec.in .copr/Makefile - sed -e "s/@ISSNAP@/$(ISSNAP)/" \ - -e "s/@VERSION@/$(GITTAG)/" \ - -e "s/@SNAPCOMMIT@/$(GITCOMMIT)/" \ - -e "s/@SNAPCOUNT@/$(GITCOUNT)/" \ - $< > $@ - - -.copr/pidgin-chime-$(TARNAME).tar.gz ./copr/Makefile: - git archive --prefix=pidgin-chime-$(TARPREFIX)/ $(GITCOMMIT) -o $@ +build: srpm + rpmbuild -bb pidgin-chime.spec --define "_sourcedir `pwd`/.copr" diff --git a/Makefile.am b/Makefile.am index 2ccd27d..c92b950 100644 --- a/Makefile.am +++ b/Makefile.am @@ -78,7 +78,7 @@ chime/chime-call-transport.c chime/chime-call-audio.c chime/chime-call.c: chime/ %.pb-c.c %.pb-c.h: %.proto $(PROTOC) $< --c_out . -EXTRA_DIST = LICENSE README +EXTRA_DIST = LICENSE README pidgin-chime.spec pidgin-chime.spec.in deb-%: debian/changelog fakeroot debian/rules $(patsubst deb-%,%,$@) @@ -88,3 +88,5 @@ debian/changelog: debian/changelog.in COMMITDATE=$$(git show -s --format=%cD); \ sed -e "s/%COMMITDESC%/$$COMMITDESC/" -e "s/%COMMITDATE%/$$COMMITDATE/" $< > $@ +dist-hook: + ./mkspec.sh diff --git a/autogen.sh b/autogen.sh index fba4adc..5b0e882 100755 --- a/autogen.sh +++ b/autogen.sh @@ -15,6 +15,7 @@ fi aclocal --install -I m4 || exit 1 autoreconf --force --install --verbose || exit 1 +./mkspec.sh cd $OLDDIR test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" diff --git a/configure.ac b/configure.ac index f34f87d..8cfe73f 100644 --- a/configure.ac +++ b/configure.ac @@ -112,19 +112,6 @@ RAWLINGUAS=`sed -e "/^#/d" -e "s/#.*//" "${srcdir}/po/LINGUAS"` LINGUAS=`echo $RAWLINGUAS` AC_SUBST(LINGUAS) -# This will fail if we're building from a tarball not a git checkout, -# but that's probably fine for now. Although actually we should probably -# make the specfile in autogen.sh not at configure time, and then we -# can trust that the ones included by 'make dist' should be right. -if git diff --name-only --exit-code v${PACKAGE_VERSION} HEAD > /dev/null 2>/dev/null; then - gitdesc=$(git describe --tags HEAD) - AC_SUBST(SNAPCOUNT, $(echo "$gitdesc" | cut -f2 -d-)) - AC_SUBST(SNAPCOMMIT, $(git rev-parse HEAD)) - AC_SUBST(ISSNAP, 1) -else - AC_SUBST(ISSNAP, 0) -fi - AC_CONFIG_FILES([ Makefile po/Makefile @@ -139,6 +126,5 @@ AC_CONFIG_FILES([ fs-app-transmitter/Makefile gst-chime/Makefile chimeseen/Makefile - pidgin-chime.spec ]) AC_OUTPUT diff --git a/mkspec.sh b/mkspec.sh new file mode 100755 index 0000000..e261ce0 --- /dev/null +++ b/mkspec.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +GITCOMMIT="$(git rev-parse HEAD)" +GITDESC="$(git describe --tags HEAD)" + +GITTAG="$(echo $GITDESC | cut -f1 -d-)" +GITTAG="${GITTAG#v}" + +if [ "v$GITTAG" = "$GITDESC" ]; then + ISSNAP=0 + GITCOUNT=0 +else + ISSNAP=1 + GITCOUNT="$(echo $GITDESC | cut -f2 -d-)" +fi + +sed -e "s/@ISSNAP@/${ISSNAP}/" \ + -e "s/@VERSION@/${GITTAG}/" \ + -e "s/@SNAPCOMMIT@/${GITCOMMIT}/" \ + -e "s/@SNAPCOUNT@/${GITCOUNT}/" \ + pidgin-chime.spec.in > pidgin-chime.spec diff --git a/pidgin-chime.spec.in b/pidgin-chime.spec.in index af38381..f4d2424 100644 --- a/pidgin-chime.spec.in +++ b/pidgin-chime.spec.in @@ -17,7 +17,7 @@ %bcond_without evolution # with Name: pidgin-chime -Summary: libpurple / Pidgin protocol plugin for Amazon Chime +Summary: Pidgin/libpurple protocol plugin for Amazon Chime Version: %{tagver}%{?snapver} Release: 0%{?dist} @@ -141,5 +141,5 @@ make %{?_smp_mflags} check %endif # with evolution %changelog -* Fri Apr 13 2018 Andrew Jorgensen - 0.02-0 +* Fri May 4 2018 David Woodhouse - %{version}-%{release} - Initial packaging.