Merge remote-tracking branch 'cs/c9s' into eln

This commit is contained in:
Stephen Gallagher 2022-04-07 10:33:33 -04:00
commit 81ee746e12
No known key found for this signature in database
GPG Key ID: 45DB85A568286D11
6 changed files with 177 additions and 27 deletions

5
.gitignore vendored
View File

@ -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

View File

@ -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

View File

@ -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

40
README
View File

@ -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

View File

@ -75,4 +75,3 @@ cp -a 80-rhel/* $RPM_BUILD_ROOT/%{templatedir}
* Mon May 10 2021 Stephen Gallagher <sgallagh@redhat.com> - 10.0-1
- First release of lorax-templates-rhel for ELN

129
tools/git-changelog Executable file
View File

@ -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 <http://www.gnu.org/licenses/>.
#
# Author: David Cantrell <dcantrell@redhat.com>
# Author: Brian C. Lane <bcl@redhat.com>
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()