Make the Makefile more intelligent, so that it can bump the version,
tag & create archives, push translations, clean build artifacts,
run tests, etc.
Signed-off-by: Martin Kolman <mkolman(a)redhat.com>
---
Makefile | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++----
initial-setup.spec | 15 +++++++-----
po/Makefile | 2 +-
3 files changed, 74 insertions(+), 11 deletions(-)
diff --git a/Makefile b/Makefile
index 4a64d87..347f7ea 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
-# Taken from the anaconda sources
+# Taken from the anaconda and python-meh sources
#
-# Copyright (C) 2009-2013 Red Hat, Inc.
+# Copyright (C) 2009-2015 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
@@ -16,13 +16,62 @@
# along with this program. If not, see <
http://www.gnu.org/licenses/>.
#
# Author: Martin Sivak <msivak(a)redhat.com>
+# Author: Martin Kolman <mkolman(a)redhat.com>
+
+PKGNAME=initial-setup
+VERSION=$(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
+RELEASE=$(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e
's|%.*$$||g')
+TAG=r$(VERSION)-$(RELEASE)
+
+PREFIX=/usr
+
+PYTHON2=python2
+PYTHON3=python3
+PYTHON=$(PYTHON2)
ZANATA_PULL_ARGS = --transdir po/
+ZANATA_PUSH_ARGS = --srcdir po/ --push-type source --force
default: all
all: po-files
+install:
+ $(PYTHON) setup.py install --root=$(DESTDIR)
+ $(MAKE) -C po install
+
+clean:
+ -rm *.tar.gz ChangeLog
+ -find . -name "*.pyc" -exec rm -rf {} \;
+
+test:
+ echo 'tests not yet implemented'
+
+ChangeLog:
+ (GIT_DIR=.git git log > .changelog.tmp && mv .changelog.tmp ChangeLog; rm -f
.changelog.tmp) || (touch ChangeLog; echo 'git directory not found: installing
possibly empty changelog.' >&2)
+
+tag:
+ git tag -a -m "Tag as $(TAG)" -f $(TAG)
+ @echo "Tagged as $(TAG)"
+
+archive: tag local
+
+local: po-pull
+ @rm -f ChangeLog
+ @make ChangeLog
+ git archive --format=tar --prefix=$(PKGNAME)-$(VERSION)/ $(TAG) >
$(PKGNAME)-$(VERSION).tar
+ mkdir -p $(PKGNAME)-$(VERSION)/po
+ cp ChangeLog $(PKGNAME)-$(VERSION)/
+ cp po/*.po $(PKGNAME)-$(VERSION)/po/
+ tar -rf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)
+ gzip -9 $(PKGNAME)-$(VERSION).tar
+ rm -rf $(PKGNAME)-$(VERSION)
+ @echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"
+
+rpmlog:
+ @git log --pretty="format:- %s (%ae)" $(TAG).. |sed -e 's/@.*)/)/'
+ @echo
+
po-files:
$(MAKE) -C po
@@ -33,5 +82,16 @@ po-pull:
rpm -q zanata-python-client &>/dev/null || ( echo "need to run: dnf install
zanata-python-client"; exit 1 )
zanata pull $(ZANATA_PULL_ARGS)
-install-po-files:
- $(MAKE) -C po install
+bumpver: potfile
+ zanata push $(ZANATA_PUSH_ARGS) || ( echo "zanata push failed"; exit 1 )
+ @NEWSUBVER=$$((`echo $(VERSION) |cut -d . -f 3` + 1)) ; \
+ NEWVERSION=`echo $(VERSION).$$NEWSUBVER |cut -d . -f 1,2,4` ; \
+ DATELINE="* `LANG=c date "+%a %b %d %Y"` `git config user.name` <`git
config user.email`> - $$NEWVERSION-1" ; \
+ cl=`grep -n %changelog initial-setup.spec |cut -d : -f 1` ; \
+ tail --lines=+$$(($$cl + 1)) initial-setup.spec > speclog ; \
+ (head -n $$cl initial-setup.spec ; echo "$$DATELINE" ; make --quiet rpmlog
2>/dev/null ; echo ""; cat speclog) > initial-setup.spec.new ; \
+ mv initial-setup.spec.new initial-setup.spec ; rm -f speclog ; \
+ sed -i "s/Version: $(VERSION)/Version: $$NEWVERSION/" initial-setup.spec ; \
+ sed -i "s/version='$(VERSION)'/version='$$NEWVERSION'/"
setup.py
+
+.PHONY: clean install tag archive local
diff --git a/initial-setup.spec b/initial-setup.spec
index 697b9b7..fcf1e25 100644
--- a/initial-setup.spec
+++ b/initial-setup.spec
@@ -26,6 +26,7 @@ BuildRequires: gtk3-devel
BuildRequires: glade-devel
BuildRequires: anaconda >= %{anacondaver}
BuildRequires: python-di
+BuildRequires: intltool
Requires: python
Requires: anaconda-tui >= %{anacondaver}
@@ -60,18 +61,20 @@ initial-setup utility.
rm -rf *.egg-info
%build
-python setup.py build
-make po-files
+make
%check
-export XDG_RUNTIME_DIR=/tmp
-python setup.py nosetests
+make test
%install
-python setup.py install --skip-build --root $RPM_BUILD_ROOT
-make install-po-files
+rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install
+
%find_lang %{name}
+%clean
+rm -rf %{buildroot}
+
%post
if [ $1 -ne 2 -a ! -f /etc/sysconfig/initial-setup ]; then
platform="$(arch)"
diff --git a/po/Makefile b/po/Makefile
index febb30a..990407c 100644
--- a/po/Makefile
+++ b/po/Makefile
@@ -44,7 +44,7 @@ glade-po: $(GLADEFILES)
intltool-extract --type=gettext/glade -l $$f ;\
done
-update-po: Makefile refresh-po
+update-po: Makefile potfile refresh-po
refresh-po: Makefile
for cat in $(POFILES); do \
--
2.3.5