diff --git a/.gitignore b/.gitignore index f05bda1..ee0843a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +clog-spec +clog +/lorax-templates-rhel-9.0-34.tar.gz +/lorax-templates-rhel-9.0-35.tar.gz /lorax-templates-rhel-10.0-1.tar.gz /lorax-templates-rhel-10.0-2.tar.gz /lorax-templates-rhel-10.0-3.tar.gz @@ -10,3 +14,4 @@ /lorax-templates-rhel-10.0-10.tar.gz /lorax-templates-rhel-10.0-11.tar.gz /lorax-templates-rhel-10.0-12.tar.gz +/lorax-templates-rhel-10.0-13.tar.gz diff --git a/80-rhel/runtime-postinstall.tmpl b/80-rhel/runtime-postinstall.tmpl index 6fd0c78..23ff37f 100644 --- a/80-rhel/runtime-postinstall.tmpl +++ b/80-rhel/runtime-postinstall.tmpl @@ -111,6 +111,10 @@ remove etc/lvm/cache remove etc/lvm/lvm.conf append etc/lvm/lvm.conf "global {\n\tuse_lvmetad = 1\n}\n" +## Remove machine specific nvme-cli files +remove etc/nvme/hostid +remove etc/nvme/hostnqn + ## Record the package versions used to create the image ## rpm initializes nss, which requires /dev/urandom to be present, hence the mknod runcmd chroot ${root} /usr/bin/mknod -m 666 /dev/random c 1 8 diff --git a/Makefile b/Makefile index 9b1eb0f..0cf4684 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ NAME=lorax-templates-rhel # RHEL version these templates are designed for RHELVER=10.0 +RHPKG=fedpkg --release=eln + +# git user.email and user.name must be setup +GITEMAIL := $(shell git config user.email) +GITNAME := $(shell git config user.name) + # Serial number for this release SERIAL=$(shell [ -f SERIAL ] && cat SERIAL || echo 0) @@ -18,13 +24,26 @@ bump-serial: echo $$((${SERIAL}+1)) > SERIAL git add SERIAL -update-spec: +update-spec: clog sed -r -i \ -e 's/^(Release:\s+)[^%]+(%.*)$$/\1${SERIAL}\2/' \ -e 's/^(Version:\s+).*$$/\1${RHELVER}/' \ -e 's/^(Source0:\s+).*$$/\1${TARBALL}/' \ + -e '/%changelog/ r clog-spec' \ ${SPEC} -release: tar update-spec +clog: + @echo "* $(shell date '+%a %b %d %Y') ${GITNAME} <${GITEMAIL}> - ${RHELVER}-${SERIAL}" > clog-spec + ./tools/git-changelog -t origin/c9s > clog + cat clog >> clog-spec -.PHONY: tar ${TARBALL} bump-serial update-spec release +# These need to rerun make to pick up the bumped serial number +release: + $(MAKE) bump-serial && $(MAKE) tar && $(MAKE) update-spec && $(MAKE) commit + +commit: + $(RHPKG) new-sources ${TARBALL} + git add -u + git commit -F clog + +.PHONY: tar ${TARBALL} bump-serial update-spec release clog commit diff --git a/README b/README index 9145d0f..114107e 100644 --- a/README +++ b/README @@ -1,27 +1,21 @@ -# To rebase from RHEL: -1. Add "cs" remote: `git remote add cs https://gitlab.com/redhat/centos-stream/rpms/lorax-templates-rhel.git` -2. `git merge -X ours cs/c9s` -3. `make bump` to bump SERIAL -4. `make tar` to make a new tarball -5. `make update-spec` to update specfile -6. Add changelog entry to .spec -7. `fedpkg new-sources` the new tarball -8. `git add lorax-templates-rhel.spec SERIAL` -9. `git commit --amend` - - -# To make ELN-specific changes: - Hi there! If you're trying to fix something here, do the following: 1. Make whatever edits you need to in 80-rhel/ -2. `git commit` the changes -3. `make bump` to bump SERIAL -4. `make tar` to make a new tarball -5. `make update-spec` to update specfile -6. Add changelog entry to .spec -7. `fedpkg new-sources` the new tarball -8. `git add lorax-templates-rhel.spec SERIAL` -9. `git commit --amend` +2. `git commit` the changes with the relevant 'Resolves/Related' bug reference +3. `make release` + This will bump the release, update the spec with changes in this branch, + create a new tarball, upload it, and commit the changes. +4. Examine the changes with 'git show' and make sure they look ok. +5. Push the changes to your fork of the project with: + 'git push REMOTE BRANCHNAME' and follow the instructions to + create a merge request in gitlab. -You're now ready to do a new build. Isn't spec wonderful? +# To rebase from RHEL: +1. Add "cs" remote: `git remote add cs https://gitlab.com/redhat/centos-stream/rpms/lorax-templates-rhel.git` +2. `git merge [-X ours] cs/c9s` +3. `make release` +4. Examine the changes with 'git show' and make sure they look ok. +5. Push the changes to your fork of the project with: + 'git push REMOTE BRANCHNAME' and follow the instructions to + create a merge request in gitlab. +6. `git rebase --interactive HEAD~2` and merge the commits together diff --git a/lorax-templates-rhel.spec b/lorax-templates-rhel.spec index 4e9b35f..d491532 100644 --- a/lorax-templates-rhel.spec +++ b/lorax-templates-rhel.spec @@ -75,4 +75,3 @@ cp -a 80-rhel/* $RPM_BUILD_ROOT/%{templatedir} * Mon May 10 2021 Stephen Gallagher - 10.0-1 - First release of lorax-templates-rhel for ELN - diff --git a/tools/git-changelog b/tools/git-changelog new file mode 100755 index 0000000..032ad94 --- /dev/null +++ b/tools/git-changelog @@ -0,0 +1,129 @@ +#!/usr/bin/python3 +# +# git-changelog - Output a rpm changelog +# +# Copyright (C) 2009 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 +# by the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program. If not, see . +# +# Author: David Cantrell +# Author: Brian C. Lane + +import os +import re +import subprocess +import sys +import textwrap +from argparse import ArgumentParser + + + +class ChangeLog: + def __init__(self, tag): + self.tag = tag + self.ignore = None + + def _getCommitDetail(self, commit, field, long=False): + proc = subprocess.Popen(['git', 'log', '-1', + "--pretty=format:%s" % field, commit], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() + + ret = proc[0].decode("utf8").strip("\n").split('\n') + + if long: + return ret + + if len(ret) == 1 and ret[0].find('@') != -1: + ret = ret[0].split('@')[0] + elif len(ret) == 1: + ret = ret[0] + else: + ret = filter(lambda x: x != '', ret) + + return ret + + def getBugs(self, msg): + """Get the Resolves/Related bugs from the commit. + Bug in first line is considered Resolves + """ + bugs = [] + if not msg: + return [] + + # summary line format is ^.*#([0-9]+).* + # Make sure the bz# isn't likely to be a github issue + for line in msg: + m = re.match(r"^(Resolves|Related|Conflicts):\ +rhbz#(\d+)", line) + if m and m.group(1) and m.group(2): + bugs.append((m.group(1), m.group(2))) + else: + m = re.match(r"^.*#(\d+).*", line) + if m and m.group(1) and int(m.group(1)) > 100000: + bugs.append(("Resolves", m.group(1))) + + return bugs + + def getLog(self): + rev_range = "%s.." % (self.tag) + proc = subprocess.Popen(['git', 'log', '--pretty=oneline', rev_range], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate() + lines = filter(lambda x: x.find('l10n: ') != 41 and \ + x.find('Merge commit') != 41 and \ + x.find('Merge branch') != 41, + proc[0].decode("utf8").strip('\n').split('\n')) + + if self.ignore and self.ignore != '': + for commit in self.ignore.split(','): + lines = filter(lambda x: not x.startswith(commit), lines) + + log = [] + for line in lines: + fields = line.split(' ') + commit = fields[0] + + summary = self._getCommitDetail(commit, "%s") + long = self._getCommitDetail(commit, "%b", True) + author = self._getCommitDetail(commit, "%aE") + + msg = ["%s (%s)" % (summary.strip(), author)] + for r, bz in self.getBugs(long): + msg.append("%s: rhbz#%s" % (r, bz)) + log.append(msg) + + return log + + def formatLog(self): + s = "" + for msg in self.getLog(): + sublines = textwrap.wrap(msg[0], 77) + + s = s + "- %s\n" % sublines[0] + for line in sublines[1:] + msg[1:]: + s = s + " %s\n" % line + + return s + +def main(): + parser = ArgumentParser(description="Generate changelog entries from git commits") + parser.add_argument("-t", "--tag", dest="tag", + help="Last tag, changelog is commits after this tag") + args = parser.parse_args() + + cl = ChangeLog(args.tag) + print(cl.formatLog()) + +if __name__ == "__main__": + main()