Skip to content

Commit

Permalink
Prepare project for use with tito
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestask committed Mar 20, 2020
1 parent 3f15b09 commit 7238287
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 1,043 deletions.
48 changes: 48 additions & 0 deletions .tito/custom/abrt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import os
import re
import shlex

from tito.common import info_out, run_command
from tito.tagger import VersionTagger


class Tagger(VersionTagger):
def _bump_version(self, release=False, zstream=False):
version = super()._bump_version().split('-', maxsplit=1)[0]
pattern = re.compile(r'(?<=^m4_define\(\[faf_version\], \[)'
r'.*'
r'(?=\]\))')

with FileInput(files='configure.ac', inplace=True) as input:
for line in input:
if pattern.search(line):
line = pattern.sub(version, line)

print(line, end='')

return version

def _tag_release(self):
version = self._bump_version()

self._check_tag_does_not_exist(version)
self._clear_package_metadata()

metadata_file = os.path.join(self.rel_eng_dir, 'packages', self.project_name)

with open(metadata_file, 'w') as file:
file.write('%s %s\n' % (version, self.relative_project_dir))

files = [
metadata_file,
os.path.join(self.full_project_dir, self.spec_file_name),
'configure.ac',
]
run_command('git add -- %s' % (' '.join([shlex.quote(file) for file in files])))

message = 'Release version %s' % (version)

run_command('git commit --message="%s"' % message)
run_command('git tag --message="%s" %s' % (message, version))

info_out('%s tagged' % version)
3 changes: 3 additions & 0 deletions .tito/packages/.readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
the .tito/packages directory contains metadata files
named after their packages. Each file has the latest tagged
version and the project's relative directory.
3 changes: 3 additions & 0 deletions .tito/releasers.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[copr]
releaser = tito.release.CoprReleaser
project_name = @abrt/faf-el8
5 changes: 5 additions & 0 deletions .tito/tito.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[buildconfig]
builder = tito.builder.Builder
tagger = abrt.Tagger
lib_dir = .tito/custom
tag_format = {version}
64 changes: 1 addition & 63 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ACLOCAL_AMFLAGS = -I m4

SUBDIRS = config src tests

EXTRA_DIST = autogen.sh gen-version faf-version faf.spec.in \
EXTRA_DIST = autogen.sh faf-version faf.spec \
init-scripts/faf-celery-beat.service \
init-scripts/faf-celery-worker.service \
init-scripts/faf-celery-tmpfiles.conf \
Expand All @@ -17,65 +17,3 @@ systemdsystemunit_DATA = init-scripts/faf-celery-beat.service \
tmpfilesddir=/usr/lib/tmpfiles.d/
tmpfilesd_DATA = init-scripts/faf-celery-tmpfiles.conf
endif

RPM_DIRS = --define "_sourcedir `pwd`" \
--define "_rpmdir `pwd`" \
--define "_specdir `pwd`" \
--define "_builddir `pwd`" \
--define "_srcrpmdir `pwd`"

rpm:
$(MAKE) dist
rpmbuild $(RPM_DIRS) -ba faf.spec

srpm:
$(MAKE) dist
rpmbuild $(RPM_DIRS) -bs faf.spec

# value for overriding from command line
# e.g: make scratch-build DIST=f15
DIST=rawhide
scratch-build: srpm
koji build --scratch $(DIST) `make srpm | grep Wrote | cut -d' ' -f2`

UPLOAD_URL ?= localhost

upload: dist
scp $(distdir).tar.gz $$(test -n "$$UPLOAD_LOGIN" && echo "$$UPLOAD_LOGIN@")$(UPLOAD_URL)

.PHONY: release-fix
release-fix:
OLD_VER=$$(git describe --tags --match "[0-9]*" --abbrev=0 HEAD 2>/dev/null); \
MAJOR_VER=$$(echo $$OLD_VER | cut -d. -f 1); \
MINOR_VER=$$(echo $$OLD_VER | cut -d. -f 2); \
FIX_VER=$$(echo $$OLD_VER | cut -d. -f 3); \
$(MAKE) release OLD_VER=$$OLD_VER NEW_VER="$$MAJOR_VER.$$MINOR_VER.$$((FIX_VER+1))"

.PHONY: release-minor
release-minor:
OLD_VER=$$(git describe --tags --match "[0-9]*" --abbrev=0 HEAD 2>/dev/null); \
MAJOR_VER=$$(echo $$OLD_VER | cut -d. -f 1); \
MINOR_VER=$$(echo $$OLD_VER | cut -d. -f 2); \
$(MAKE) release OLD_VER=$$OLD_VER NEW_VER="$$MAJOR_VER.$$((MINOR_VER+1)).0"

.PHONY: release-major
release-major:
OLD_VER=$$(git describe --tags --match "[0-9]*" --abbrev=0 HEAD 2>/dev/null); \
MAJOR_VER=$$(echo $$OLD_VER | cut -d. -f 1); \
$(MAKE) release OLD_VER=$$OLD_VER NEW_VER="$$((MAJOR_VER+1)).0.0"

.PHONY: release
release:
echo "* $$(LANG='en.UTF-8' date +'%a %b %d %Y') $$(git config --get user.name) <$$(git config --get user.email)> $$NEW_VER-1" | sort > /tmp/changelog.tmp; \
git log --oneline $$OLD_VER..HEAD | awk '{$$1=""; if (a[$$0]++ == 0) print "-" $$0} END {print ""}' | grep -v -e "- Merge" -e "- testsuite:" -e "- make:" -e "- tests:" -e "- container:" >> /tmp/changelog.tmp; \
sed "$$(grep -n changelog faf.spec.in | cut -f1 -d:| head -n 1)"'r /tmp/changelog.tmp' -i faf.spec.in; \
sed -e "s/^## \[Unreleased\]/## [Unreleased]\n\n## [$$NEW_VER] - $$(date +'%F')/" \
-e "s/^\[Unreleased\]: \(https:\/\/.*\/compare\)\(\/.*\)\.\.\.HEAD/[Unreleased]: \1\/$$NEW_VER...HEAD\n[$$NEW_VER]: \1\2...$$NEW_VER/" \
-i CHANGELOG.md; \
sed 's|DEF_VER=.*$$|DEF_VER='$$NEW_VER'|' -i gen-version; \
git add gen-version faf.spec.in CHANGELOG.md; \
git commit -m "New version $$NEW_VER"; \
git tag "$$NEW_VER"; \
echo -n "$$NEW_VER" > faf-version
autoconf --force
$(MAKE) dist
57 changes: 4 additions & 53 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,6 @@
#!/bin/sh

print_help()
{
cat << EOH
Prepares the source tree for configuration
Usage:
autogen.sh [sydeps [--install]]
Options:
sysdeps prints out all dependencies
--install install all dependencies ('sudo dnf install \$DEPS')
EOH
}

build_depslist()
{
PACKAGE=$1
TEMPFILE=$(mktemp -u --suffix=.spec)
sed 's/@PACKAGE_VERSION@/1/' < $PACKAGE.spec.in | sed 's/@.*@//' > $TEMPFILE
rpmspec -P $TEMPFILE | grep "^\(Build\)\?Requires:" | \
tr -s " " | tr "," "\n" | cut -f2- -d " " | \
grep -v "^"$PACKAGE | sort -u | sed -E 's/^(.*) (.*)$/"\1 \2"/' | tr \" \'
rm $TEMPFILE
}

case "$1" in
"--help"|"-h")
print_help
exit 0
;;
"sysdeps")
DEPS_LIST=$( build_depslist faf)

if [ "$2" == "--install" ]; then
set -x verbose
eval sudo dnf install --setopt=strict=0 $DEPS_LIST
set +x verbose
else
echo $DEPS_LIST
fi
exit 0
;;
*)
./gen-version
autoreconf --install --force
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi
;;
esac

autoreconf --install --force
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi
7 changes: 5 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ AC_DEFUN([FAF_PARSE_WITH],
fi
m4_popdef([FAF_UC_PACKAGE])])

m4_define([faf_version], [2.2.0])

AC_INIT([faf],
m4_esyscmd([cat ./faf-version]),
[faf_version],
[[email protected]])

AM_INIT_AUTOMAKE([foreign -Wall tar-ustar])
Expand Down Expand Up @@ -39,14 +41,14 @@ AM_CONDITIONAL(HAVE_SYSTEMD, false)
fi

AC_CONFIG_FILES([
faf.spec
Makefile
config/Makefile
config/plugins/Makefile
config/templates/Makefile
src/Makefile
src/bin/Makefile
src/pyfaf/Makefile
src/pyfaf/__init__.py
src/pyfaf/actions/Makefile
src/pyfaf/bugtrackers/Makefile
src/pyfaf/celery_tasks/Makefile
Expand All @@ -61,6 +63,7 @@ AC_CONFIG_FILES([
src/pyfaf/storage/fixtures/sql/Makefile
src/pyfaf/utils/Makefile
src/schema/Makefile
src/schema/setup.py
src/webfaf/Makefile
src/webfaf/blueprints/Makefile
src/webfaf/static/Makefile
Expand Down
Loading

0 comments on commit 7238287

Please sign in to comment.