Do it at autogen.sh and 'make dist' time, not during configure.
Do it with a shell script and simplify .copr/Makefile
#
# 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"
%.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-%,%,$@)
COMMITDATE=$$(git show -s --format=%cD); \
sed -e "s/%COMMITDESC%/$$COMMITDESC/" -e "s/%COMMITDATE%/$$COMMITDATE/" $< > $@
+dist-hook:
+ ./mkspec.sh
aclocal --install -I m4 || exit 1
autoreconf --force --install --verbose || exit 1
+./mkspec.sh
cd $OLDDIR
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
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
fs-app-transmitter/Makefile
gst-chime/Makefile
chimeseen/Makefile
- pidgin-chime.spec
])
AC_OUTPUT
--- /dev/null
+#!/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
%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}
%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.