]> www.infradead.org Git - pidgin-chime.git/commitdiff
Clean up spec generation.
authorDavid Woodhouse <dwmw2@infradead.org>
Fri, 4 May 2018 12:58:18 +0000 (13:58 +0100)
committerDavid Woodhouse <dwmw2@infradead.org>
Fri, 4 May 2018 13:20:13 +0000 (14:20 +0100)
Do it at autogen.sh and 'make dist' time, not during configure.
Do it with a shell script and simplify .copr/Makefile

.copr/Makefile
Makefile.am
autogen.sh
configure.ac
mkspec.sh [new file with mode: 0755]
pidgin-chime.spec.in

index ab0750825494a5f027cd3fad2d6443b8bfc84554..0c3b7a67a6008e131f801308f69195397d20d23c 100644 (file)
@@ -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"
index 2ccd27d6a9663cab99d9efefaa2bf7a6c3ad8a33..c92b950f1e5dbf8fbe4101a598ba98df42cbbab2 100644 (file)
@@ -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
index fba4adcbf1e50461af8f85e47d258f5646048664..5b0e882a82761ac6084f261acd91ebecd6b20b5d 100755 (executable)
@@ -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" "$@"
index f34f87d43fd1ac559b7e809fd191e36157b9e202..8cfe73f223f71823d34765da2c0bfe4a168d21c7 100644 (file)
@@ -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 (executable)
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
index af38381163d55ad07d38919529bbeef4e6002837..f4d24240cb1640d1a46706403a2365bc983659f4 100644 (file)
@@ -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 <ajorgens@amazon.com> - 0.02-0
+* Fri May  4 2018 David Woodhouse <dwmw2@infradead.org> - %{version}-%{release}
 - Initial packaging.