From 1f69df73fa73a66d12233907cef449d1f3a1fbed Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 1 Apr 2022 11:15:12 -0700 Subject: [PATCH 1/3] runtime-postinstall: Remove machine specific nvme files These need to be created on the installed system, and should not be included in the image. Resolves: rhbz#2071074 --- 80-rhel/runtime-postinstall.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/80-rhel/runtime-postinstall.tmpl b/80-rhel/runtime-postinstall.tmpl index ddcf8b9..ca4d251 100644 --- a/80-rhel/runtime-postinstall.tmpl +++ b/80-rhel/runtime-postinstall.tmpl @@ -112,6 +112,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 From 63d7f7ca0423e1d5d59abe0787ce744842a29baf Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 5 Apr 2022 10:07:56 -0700 Subject: [PATCH 2/3] Makefile: Making it easier to create releases Related: rhbz#2071074 --- .gitignore | 62 +-------------------- Makefile | 25 +++++++-- README | 21 +++----- tools/git-changelog | 129 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 76 deletions(-) create mode 100755 tools/git-changelog diff --git a/.gitignore b/.gitignore index 59bb09b..8d90e0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,61 +1,3 @@ -/lorax-templates-rhel-8.0-0.tar.gz -/lorax-templates-rhel-8.0-3.tar.gz -/lorax-templates-rhel-8.0-4.tar.gz -/lorax-templates-rhel-8.0-5.tar.gz -/lorax-templates-rhel-8.0-6.tar.gz -/lorax-templates-rhel-8.0-7.tar.gz -/lorax-templates-rhel-8.0-8.tar.gz -/lorax-templates-rhel-8.0-9.tar.gz -/lorax-templates-rhel-8.0-10.tar.gz -/lorax-templates-rhel-8.0-11.tar.gz -/lorax-templates-rhel-8.0-12.tar.gz -/lorax-templates-rhel-8.0-13.tar.gz -/lorax-templates-rhel-8.0-14.tar.gz -/lorax-templates-rhel-8.0-15.tar.gz -/lorax-templates-rhel-8.0-16.tar.gz -/lorax-templates-rhel-8.0-17.tar.gz -/lorax-templates-rhel-8.0-18.tar.gz -/lorax-templates-rhel-8.0-19.tar.gz -/lorax-templates-rhel-8.1-1.tar.gz -/lorax-templates-rhel-8.1-2.tar.gz -/lorax-templates-rhel-8.1-3.tar.gz -/lorax-templates-rhel-8.2-1.tar.gz -/lorax-templates-rhel-8.2-2.tar.gz -/lorax-templates-rhel-8.2-3.tar.gz -/lorax-templates-rhel-8.2-4.tar.gz -/lorax-templates-rhel-8.2-5.tar.gz -/lorax-templates-rhel-8.2-6.tar.gz -/lorax-templates-rhel-8.3-1.tar.gz -/lorax-templates-rhel-8.3-2.tar.gz -/lorax-templates-rhel-8.3-3.tar.gz -/lorax-templates-rhel-8.3-4.tar.gz -/lorax-templates-rhel-9.0-1.tar.gz -/lorax-templates-rhel-9.0-4.tar.gz -/lorax-templates-rhel-9.0-5.tar.gz -/lorax-templates-rhel-9.0-6.tar.gz -/lorax-templates-rhel-9.0-7.tar.gz -/lorax-templates-rhel-9.0-8.tar.gz -/lorax-templates-rhel-9.0-9.tar.gz -/lorax-templates-rhel-9.0-10.tar.gz -/lorax-templates-rhel-9.0-11.tar.gz -/lorax-templates-rhel-9.0-12.tar.gz -/lorax-templates-rhel-9.0-14.tar.gz -/lorax-templates-rhel-9.0-15.tar.gz -/lorax-templates-rhel-9.0-16.tar.gz -/lorax-templates-rhel-9.0-17.tar.gz -/lorax-templates-rhel-9.0-18.tar.gz -/lorax-templates-rhel-9.0-19.tar.gz -/lorax-templates-rhel-9.0-20.tar.gz -/lorax-templates-rhel-9.0-21.tar.gz -/lorax-templates-rhel-9.0-22.tar.gz -/lorax-templates-rhel-9.0-24.tar.gz -/lorax-templates-rhel-9.0-25.tar.gz -/lorax-templates-rhel-9.0-26.tar.gz -/lorax-templates-rhel-9.0-27.tar.gz -/lorax-templates-rhel-9.0-28.tar.gz -/lorax-templates-rhel-9.0-29.tar.gz -/lorax-templates-rhel-9.0-30.tar.gz -/lorax-templates-rhel-9.0-31.tar.gz -/lorax-templates-rhel-9.0-32.tar.gz -/lorax-templates-rhel-9.0-33.tar.gz +clog-spec +clog /lorax-templates-rhel-9.0-34.tar.gz diff --git a/Makefile b/Makefile index 73bd126..e502e83 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,12 @@ NAME=lorax-templates-rhel # RHEL version these templates are designed for RHELVER=9.0 +RHPKG=centpkg --release=c9s + +# 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 4d1276f..3b00ccb 100644 --- a/README +++ b/README @@ -1,16 +1,11 @@ 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. `rhpkg-sha512 new-sources` the new tarball -8. `git add lorax-templates-rhel.spec SERIAL` -9. `git commit` - -Steps 8 and 9 can be combined as: - `rhpkg-sha512 clog && rhpkg-sha512 ci -F clog` - -You're now ready to do a new build. Isn't spec wonderful? +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. 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() From 8bec248824874c220471cada3e7583565f13509d Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 5 Apr 2022 10:11:16 -0700 Subject: [PATCH 3/3] - Makefile: Making it easier to create releases (bcl) Related: rhbz#2071074 - runtime-postinstall: Remove machine specific nvme files (bcl) Resolves: rhbz#2071074 --- .gitignore | 1 + SERIAL | 2 +- lorax-templates-rhel.spec | 10 ++++++++-- sources | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8d90e0b..e624c7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ clog-spec clog /lorax-templates-rhel-9.0-34.tar.gz +/lorax-templates-rhel-9.0-35.tar.gz diff --git a/SERIAL b/SERIAL index a787364..8f92bfd 100644 --- a/SERIAL +++ b/SERIAL @@ -1 +1 @@ -34 +35 diff --git a/lorax-templates-rhel.spec b/lorax-templates-rhel.spec index b6cb135..d79b985 100644 --- a/lorax-templates-rhel.spec +++ b/lorax-templates-rhel.spec @@ -1,12 +1,12 @@ Name: lorax-templates-rhel Version: 9.0 -Release: 34%{?dist} +Release: 35%{?dist} Summary: RHEL8 build templates for lorax and livemedia-creator License: GPLv2+ URL: https://github.com/weldr/lorax BuildArch: noarch -Source0: lorax-templates-rhel-9.0-34.tar.gz +Source0: lorax-templates-rhel-9.0-35.tar.gz # Required for the template branding support Requires: lorax >= 34.9.1 @@ -34,6 +34,12 @@ cp -a 80-rhel/* $RPM_BUILD_ROOT/%{templatedir} %{templatedir}/* %changelog +* Tue Apr 05 2022 Brian C. Lane - 9.0-35 +- Makefile: Making it easier to create releases (bcl) + Related: rhbz#2071074 +- runtime-postinstall: Remove machine specific nvme files (bcl) + Resolves: rhbz#2071074 + * Thu Feb 24 2022 Brian C. Lane - 9.0-34 - Restore missing packages (bcl) Resolves: rhbz#2056086 diff --git a/sources b/sources index 8ab6e66..bf127eb 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (lorax-templates-rhel-9.0-34.tar.gz) = b4f41df4e01d9223e336080caa0b064368d3a086a0a3293a63c2ca9e4caf6d80b9913f785ab8f2cb2122fda056ae93a0cb02e52ab16357d025908e68a035bb90 +SHA512 (lorax-templates-rhel-9.0-35.tar.gz) = cf1e55d2dd1a7add203773c5d9eddfda542da58d7c7378e6717eb3f434c96d84862c23ca1eb48e648b13caef95d17a656ce0cab9df5a3f909417da9daea69add