Skip to content

Commit

Permalink
Merge remote-tracking branch 'clebergnu/copr_makefile'
Browse files Browse the repository at this point in the history
Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Feb 12, 2019
2 parents 4efe25d + cd67a68 commit 1c61a46
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 64 deletions.
15 changes: 15 additions & 0 deletions .copr/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pkg_install := $(shell dnf -y install git rpm-build)
commit := $(shell git log --pretty=format:'%H' -n 1)
commit_date := $(shell git log --pretty='format:%cd' --date='format:%Y%m%d' -n 1)
short_commit := $(shell git log --pretty=format:'%h' -n 1)

srpm:
if test ! -d SOURCES; then mkdir SOURCES; fi
if test ! -d SPEC; then mkdir SPEC; fi
git archive --prefix="avocado-vt-$(commit)/" -o "SOURCES/avocado-vt-$(short_commit).tar.gz" HEAD
cp avocado-plugins-vt.spec SPEC
sed -i -e 's/\%global rel_build .*/\%global rel_build 0/' SPEC/avocado-plugins-vt.spec
sed -i -e 's/\%global commit .*/\%global commit $(commit)/' SPEC/avocado-plugins-vt.spec
sed -i -e 's/\%global commit_date .*/\%global commit_date $(commit_date)/' SPEC/avocado-plugins-vt.spec
rpmbuild -D '_topdir .' -bs SPEC/avocado-plugins-vt.spec
mv SRPMS/*.src.rpm $(outdir)
84 changes: 20 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
PYTHON=$(shell which python 2>/dev/null || which python3 2>/dev/null)
ifndef PYTHON
PYTHON=$(shell which python3 2>/dev/null || which python2 2>/dev/null || which python 2>/dev/null)
endif
VERSION=$(shell $(PYTHON) setup.py --version 2>/dev/null)
PYTHON_DEVELOP_ARGS=$(shell if ($(PYTHON) setup.py develop --help 2>/dev/null | grep -q '\-\-user'); then echo "--user"; else echo ""; fi)
DESTDIR=/
BUILDIR=$(CURDIR)/debian/avocado-vt
PROJECT=avocado
VERSION=$(shell cat $(CURDIR)/VERSION)
AVOCADO_DIRNAME?=avocado

RELEASE_COMMIT=$(shell git log --abbrev=8 --pretty=format:'%H' -n 1 $(VERSION))
RELEASE_SHORT_COMMIT=$(shell git log --abbrev=8 --pretty=format:'%h' -n 1 $(VERSION))

COMMIT=$(shell git log --abbrev=8 --pretty=format:'%H' -n 1)
COMMIT_DATE=$(shell git log --pretty='format:%cd' --date='format:%Y%m%d' -n 1)
SHORT_COMMIT=$(shell git log --abbrev=8 --pretty=format:'%h' -n 1)
MOCK_CONFIG=default
ARCHIVE_BASE_NAME=avocado-vt
RPM_BASE_NAME=avocado-plugins-vt

include Makefile.include

all:
@echo
@echo "Development related targets:"
@echo "check: Runs tree static check, unittests and functional tests"
@echo "clean: Get rid of scratch and byte files"
@echo "link: Enables egg links and links needed resources"
@echo "unlink: Disables egg links and unlinks needed resources"
@echo "check: Runs tree static check, unittests and fast functional tests"
@echo "develop: Runs 'python setup.py --develop' on this tree alone"
@echo "link: Runs 'python setup.py --develop' in all subprojects and links the needed resources"
@echo "clean: Get rid of scratch, byte files and removes the links to other subprojects"
@echo "unlink: Disables egg links and unlinks needed resources"
@echo
@echo "Platform independent distribution/installtion related targets:"
@echo "source: Create source package"
Expand All @@ -28,65 +35,13 @@ all:
@echo "srpm: Generate a source RPM package (.srpm)"
@echo "rpm: Generate binary RPMs"
@echo
@echo "Debian related targets:"
@echo "deb: Generate both source and binary debian packages"
@echo "deb-src: Generate a source debian package"
@echo "deb-bin: Generate a binary debian package"
@echo
@echo "Release related targets:"
@echo "source-release: Create source package for the latest tagged release"
@echo "srpm-release: Generate a source RPM package (.srpm) for the latest tagged release"
@echo "rpm-release: Generate binary RPMs for the latest tagged release"
@echo


source: clean
if test ! -d SOURCES; then mkdir SOURCES; fi
git archive --prefix="avocado-vt-$(COMMIT)/" -o "SOURCES/avocado-vt-$(VERSION)-$(SHORT_COMMIT).tar.gz" HEAD

source-release: clean
if test ! -d SOURCES; then mkdir SOURCES; fi
git archive --prefix="avocado-plugins-vt-$(RELEASE_COMMIT)/" -o "SOURCES/avocado-plugins-vt-$(VERSION)-$(RELEASE_SHORT_COMMIT).tar.gz" $(VERSION)

install:
$(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)

prepare-source:
# build the source package in the parent directory
# then rename it to project_version.orig.tar.gz
dch -D "vivid" -M -v "$(VERSION)" "Automated (make builddeb) build."
$(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../ --prune
rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*

deb-src: prepare-source
# build the source package
dpkg-buildpackage -S [email protected] -rfakeroot

deb-bin: prepare-source
# build binary package
dpkg-buildpackage -b -rfakeroot

deb: prepare-source
# build both source and binary packages
dpkg-buildpackage -i -I -rfakeroot

srpm: source
if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
mock --old-chroot --resultdir BUILD/SRPM -D "commit $(COMMIT)" --buildsrpm --spec avocado-plugins-vt.spec --sources SOURCES

rpm: srpm
if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
mock --old-chroot --resultdir BUILD/RPM -D "commit $(COMMIT)" --rebuild BUILD/SRPM/avocado-plugins-vt-$(VERSION)-*.src.rpm

srpm-release: source-release
if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
mock --old-chroot --resultdir BUILD/SRPM -D "commit $(RELEASE_COMMIT)" --buildsrpm --spec avocado-plugins-vt.spec --sources SOURCES

rpm-release: srpm-release
if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
mock --old-chroot --resultdir BUILD/RPM -D "commit $(RELEASE_COMMIT)" --rebuild BUILD/SRPM/avocado-plugins-vt-$(VERSION)-*.src.rpm

requirements:
requirements: pip
- $(PYTHON) -m pip install "pip>=6.0.1"
- $(PYTHON) -m pip install -r requirements.txt

Expand All @@ -95,16 +50,17 @@ check:

clean:
$(PYTHON) setup.py clean
$(MAKE) -f $(CURDIR)/debian/rules clean || true
rm -rf build/ MANIFEST BUILD BUILDROOT SPECS RPMS SRPMS SOURCES
find . -name '*.pyc' -delete

link:
develop:
$(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS)

link: develop
for CONF in etc/avocado/conf.d/*; do\
[ -d "../$(AVOCADO_DIRNAME)/avocado/etc/avocado/conf.d" ] && ln -srf $(CURDIR)/$$CONF ../$(AVOCADO_DIRNAME)/avocado/$$CONF || true;\
[ -d "../$(AVOCADO_DIRNAME)/etc/avocado/conf.d" ] && ln -srf $(CURDIR)/$$CONF ../$(AVOCADO_DIRNAME)/$$CONF || true;\
done
$(PYTHON) setup.py develop $(PYTHON_DEVELOP_ARGS)

unlink:
$(PYTHON) setup.py develop --uninstall $(PYTHON_DEVELOP_ARGS)
Expand Down
29 changes: 29 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
source: clean
if test ! -d SOURCES; then mkdir SOURCES; fi
git archive --prefix="$(ARCHIVE_BASE_NAME)-$(COMMIT)/" -o "SOURCES/$(ARCHIVE_BASE_NAME)-$(SHORT_COMMIT).tar.gz" HEAD

source-release: clean
if test ! -d SOURCES; then mkdir SOURCES; fi
git archive --prefix="$(ARCHIVE_BASE_NAME)-$(VERSION)/" -o "SOURCES/$(ARCHIVE_BASE_NAME)-$(VERSION).tar.gz" $(VERSION)

install:
$(PYTHON) setup.py install --root $(DESTDIR) $(COMPILE)

srpm: source
if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
mock -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "rel_build 0" -D "commit $(COMMIT)" -D "commit_date $(COMMIT_DATE)" --buildsrpm --spec $(RPM_BASE_NAME).spec --sources SOURCES

rpm: srpm
if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
mock -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "rel_build 0" -D "commit $(COMMIT)" -D "commit_date $(COMMIT_DATE)" --rebuild BUILD/SRPM/$(RPM_BASE_NAME)-$(VERSION)-*.src.rpm

srpm-release: source-release
if test ! -d BUILD/SRPM; then mkdir -p BUILD/SRPM; fi
mock -r $(MOCK_CONFIG) --resultdir BUILD/SRPM -D "rel_build 1" --buildsrpm --spec $(RPM_BASE_NAME).spec --sources SOURCES

rpm-release: srpm-release
if test ! -d BUILD/RPM; then mkdir -p BUILD/RPM; fi
mock -r $(MOCK_CONFIG) --resultdir BUILD/RPM -D "rel_build 1" --rebuild BUILD/SRPM/$(RPM_BASE_NAME)-$(VERSION)-*.src.rpm

pip:
$(PYTHON) -m pip --version || $(PYTHON) -m ensurepip $(PYTHON_DEVELOP_ARGS) || $(PYTHON) -c "import os; import sys; import urllib; f = urllib.urlretrieve('https://bootstrap.pypa.io/get-pip.py')[0]; os.system('%s %s' % (sys.executable, f))"
28 changes: 28 additions & 0 deletions contrib/packages/debian/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
PROJECT=avocado

all:
@echo
@echo "Debian related targets:"
@echo "deb: Generate both source and binary debian packages"
@echo "deb-src: Generate a source debian package"
@echo "deb-bin: Generate a binary debian package"
@echo

prepare-source:
# build the source package in the parent directory
# then rename it to project_version.orig.tar.gz
dch -D "vivid" -M -v "$(VERSION)" "Automated (make builddeb) build."
$(PYTHON) setup.py sdist $(COMPILE) --dist-dir=../ --prune
rename -f 's/$(PROJECT)-(.*)\.tar\.gz/$(PROJECT)_$$1\.orig\.tar\.gz/' ../*

deb-src: prepare-source
# build the source package
dpkg-buildpackage -S [email protected] -rfakeroot

deb-bin: prepare-source
# build binary package
dpkg-buildpackage -b -rfakeroot

deb: prepare-source
# build both source and binary packages
dpkg-buildpackage -i -I -rfakeroot
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1c61a46

Please sign in to comment.