From 9077295ba2beb5e5319f6c11bae78205f9214398 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 14:38:52 -0500 Subject: [PATCH 1/8] Makefile: default to Python 3 Now that Avocado-VT supports Python 3, let's default to during regular development usage. This syncs the behavior to Avocado's one. Signed-off-by: Cleber Rosa --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d2faedd655..0aa593e52a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -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 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 From 0d3ba9c38797a3947368c661a075d14b18c245f0 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 14:41:37 -0500 Subject: [PATCH 2/8] Makefile: get the version from setup.py This has the downside of making things go through another layer, but at the same time, it abstracts the implementation currently used for versioning. If we ever change the method for setting the version number, there will be no update needed here. Most importantly, this also syncs the behavior with Avocado. Signed-off-by: Cleber Rosa --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0aa593e52a..96ad64193e 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,11 @@ 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)) From e171b038c3d877dde6f60cf67926561ce6bc4dce Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 14:49:42 -0500 Subject: [PATCH 3/8] Makefile: remove unused variable BUILDIR Signed-off-by: Cleber Rosa --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 96ad64193e..f89c5932fb 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ 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 AVOCADO_DIRNAME?=avocado From 292da4aa6e20925b92424a22f74935340407e1d1 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 15:01:23 -0500 Subject: [PATCH 4/8] Makefile: add a develop target This gives a consistent experience if an Avocado-VT developer treats Avocado itself as a library that is already available and installed on its system. This fulfills the use case where Avocado is installed by a distro package and Avocado-VT is being developed on top of it. It also syncs another target and experience from Avocado itself. Signed-off-by: Cleber Rosa --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f89c5932fb..760466c71a 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ all: @echo @echo "Development related targets:" @echo "check: Runs tree static check, unittests and functional tests" + @echo "develop: Runs 'python setup.py --develop' on this tree alone" @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" @@ -100,12 +101,14 @@ clean: 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) From e49a0a3f19d8f3cd174377700d9692c37b497593 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 15:08:56 -0500 Subject: [PATCH 5/8] Makefile: give maximum of two spaces on target descriptions Some blocks are putting way too much whitespaces between the title names and descriptions. Let's limit that to two spaces. While at it, let's sync the description with Avocado's. This is a visual change only. Signed-off-by: Cleber Rosa --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 760466c71a..e92ad72fda 100644 --- a/Makefile +++ b/Makefile @@ -16,11 +16,11 @@ SHORT_COMMIT=$(shell git log --abbrev=8 --pretty=format:'%h' -n 1) all: @echo @echo "Development related targets:" - @echo "check: Runs tree static check, unittests and functional tests" - @echo "develop: Runs 'python setup.py --develop' on this tree alone" - @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" From fe5b55a5390d180ac7df8d29bec19ada5a1ae8ed Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 15:50:41 -0500 Subject: [PATCH 6/8] Makefile: move Debian package rules to contrib These have, to the best of my knowledge, not being maintained for a while. Let's do while it was done with Avocado, and move it to contrib. Signed-off-by: Cleber Rosa --- Makefile | 26 ----------------- contrib/packages/debian/Makefile | 28 +++++++++++++++++++ {debian => contrib/packages/debian}/changelog | 0 {debian => contrib/packages/debian}/compat | 0 {debian => contrib/packages/debian}/control | 0 {debian => contrib/packages/debian}/copyright | 0 .../packages/debian}/pyversions | 0 {debian => contrib/packages/debian}/rules | 0 .../packages/debian}/source/format | 0 .../packages/debian}/source/options | 0 {debian => contrib/packages/debian}/watch | 0 11 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 contrib/packages/debian/Makefile rename {debian => contrib/packages/debian}/changelog (100%) rename {debian => contrib/packages/debian}/compat (100%) rename {debian => contrib/packages/debian}/control (100%) rename {debian => contrib/packages/debian}/copyright (100%) rename {debian => contrib/packages/debian}/pyversions (100%) rename {debian => contrib/packages/debian}/rules (100%) rename {debian => contrib/packages/debian}/source/format (100%) rename {debian => contrib/packages/debian}/source/options (100%) rename {debian => contrib/packages/debian}/watch (100%) diff --git a/Makefile b/Makefile index e92ad72fda..e65199ecfc 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ 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=/ -PROJECT=avocado AVOCADO_DIRNAME?=avocado RELEASE_COMMIT=$(shell git log --abbrev=8 --pretty=format:'%H' -n 1 $(VERSION)) @@ -30,11 +29,6 @@ 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" @@ -53,25 +47,6 @@ source-release: clean 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 -elookkas@gmail.com -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 @@ -97,7 +72,6 @@ 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 diff --git a/contrib/packages/debian/Makefile b/contrib/packages/debian/Makefile new file mode 100644 index 0000000000..c3d268a57d --- /dev/null +++ b/contrib/packages/debian/Makefile @@ -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 -elookkas@gmail.com -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 diff --git a/debian/changelog b/contrib/packages/debian/changelog similarity index 100% rename from debian/changelog rename to contrib/packages/debian/changelog diff --git a/debian/compat b/contrib/packages/debian/compat similarity index 100% rename from debian/compat rename to contrib/packages/debian/compat diff --git a/debian/control b/contrib/packages/debian/control similarity index 100% rename from debian/control rename to contrib/packages/debian/control diff --git a/debian/copyright b/contrib/packages/debian/copyright similarity index 100% rename from debian/copyright rename to contrib/packages/debian/copyright diff --git a/debian/pyversions b/contrib/packages/debian/pyversions similarity index 100% rename from debian/pyversions rename to contrib/packages/debian/pyversions diff --git a/debian/rules b/contrib/packages/debian/rules similarity index 100% rename from debian/rules rename to contrib/packages/debian/rules diff --git a/debian/source/format b/contrib/packages/debian/source/format similarity index 100% rename from debian/source/format rename to contrib/packages/debian/source/format diff --git a/debian/source/options b/contrib/packages/debian/source/options similarity index 100% rename from debian/source/options rename to contrib/packages/debian/source/options diff --git a/debian/watch b/contrib/packages/debian/watch similarity index 100% rename from debian/watch rename to contrib/packages/debian/watch From ea224a396c88f2d4b6692ed4043961e0aea7d063 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 16:19:55 -0500 Subject: [PATCH 7/8] Makefile: use Makefile.include from Avocado To allow for a better development/packaging experience, let's use the same rules accross Avocado projects. This syncs Makefile.include to the exact same version proposed on Avocado. Signed-off-by: Cleber Rosa --- Makefile | 36 +++++++----------------------------- Makefile.include | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 Makefile.include diff --git a/Makefile b/Makefile index e65199ecfc..5a4bcc0d07 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,13 @@ 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 @@ -35,35 +41,7 @@ all: @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) - -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 diff --git a/Makefile.include b/Makefile.include new file mode 100644 index 0000000000..a022d35c5f --- /dev/null +++ b/Makefile.include @@ -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))" From cd67a6875a61eb24d6aadff2197d82dd5c5d8d85 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Fri, 8 Feb 2019 17:35:38 -0500 Subject: [PATCH 8/8] COPR SCM/"make srpm" support This adds a Makefile that adds support for the Fedora COPR service to build packages for Avocado-VT, right out of a Git repo. To do so, create your project, and in "Builds" tab, select "New Build". On "1. Select source type" section, select "SCM". On section "2. Provide the source", under "Clone url" add the URL of your repo. For instance, this has been tested with: https://github.com/clebergnu/avocado-vt Under "Committish", enter a reference to a given commit. For instance, this has been tested with the name of this branch: "copr_makefile". Under "3. How to build SRPM from the source", select "make srpm". Finally, select the appropriate Chroots. It's better not to have "Enable internet access during this build" option checked. Finally, it's advisable to not attempt to run this Makefile locally, as it's designed to be run on the environment that CORP provides, that is, a mock based chroot with super user privileges. Signed-off-by: Cleber Rosa --- .copr/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .copr/Makefile diff --git a/.copr/Makefile b/.copr/Makefile new file mode 100644 index 0000000000..7179b91a4f --- /dev/null +++ b/.copr/Makefile @@ -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)