From bb2c8d196501f9b1de5c98e6a4ea3584e40b9f9e Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Tue, 20 Dec 2022 02:05:53 -0700 Subject: [PATCH] General Changes * Remove live directory as empanadas handles it * update readmes accordingly * add a quick-bump script for bumping release tags quickly --- README.md | 9 ++-- live/common | 34 ------------- mangle/README.md | 16 +++++- mangle/quick-bump.py | 116 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 39 deletions(-) delete mode 100644 live/common create mode 100755 mangle/quick-bump.py diff --git a/README.md b/README.md index 2b4f6cd..3ae6be6 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ What does this have? * analyze -> Analysis utilities (such as download stats) * chat -> mattermost related utilities * func -> (mostly defunct) testing scripts and tools to test base functionality -* iso -> ISO, Compose, and Sync related utilities, primarily for Rocky Linux 9+ -* live -> Live image related utilities +* iso -> Contains `empanadas`, which provides ISO, Compose, and Sync related utilities. * mangle -> Manglers and other misc stuff * sync -> Sync tools, primarily for Rocky Linux 8 and will eventually be deprecated @@ -24,11 +23,13 @@ How can I help? Fork this repository and open a PR with your changes. Keep these things in mind when you make changes: -* Have pre-commit installed -* Have shellcheck installed +* Have pre-commit installed if possible +* Have shellcheck installed if possible * Shell Scripts: These must pass a shellcheck test! * Python scripts: Try your best to follow PEP8 guidelines (even the best linters get things wrong) + * Note that not everything has to pass. Just try your best. + Your PR should be against the devel branch at all times. PR's against the main branch will be closed. diff --git a/live/common b/live/common deleted file mode 100644 index 7382a3f..0000000 --- a/live/common +++ /dev/null @@ -1,34 +0,0 @@ -# To be sourced by scripts that build live images - -# Variables that can be overriden should be noted with optional context. It is -# expected that these values are here in this file (per variable or per set): -# -# * Allowed -# * Allowed with caveats -# * Not Allowed -# * Required - -# Temporary probably. This makes it so if RLVER=... is called before the script -# it will set the version for the variables to call up. This was easier than -# creating duplicates of a bunch of stuff. Default version is 8. - -# Override: Required -if [ -z "$RLVER" ]; then - echo "RLVER is not defined." - exit 2 -fi - -# Set git branch name scheme -# Override: Allowed with caveats -GIT_BRANCH="r${RLVER}" - -# Source Major common -# Override: Not Allowed -test -f "$(dirname "$0")/common_${RLVER}" && source "$(dirname "$0")/common_${RLVER}" -if [ "$?" -ne 0 ]; then - echo "Could not source common_${RLVER}" - exit 1 -fi - -# Used to iterate over types of live images -VARIANTS=(XFCE KDE Workstation Workstation-Lite) diff --git a/mangle/README.md b/mangle/README.md index 3aba9a4..c9eb467 100644 --- a/mangle/README.md +++ b/mangle/README.md @@ -1 +1,15 @@ -# Mirrormanager Mangling tools and other Accessories +Release Engineering Mangler Accessories +================================================== + +This contains Mirror Manager mangling tools and other accessories. + +Scripts +------- + +* validate_repos -> Simple utility to validate mirror manager repositories +* quick-bump.py -> Simple utility to quickly bump a release version for a rebuild + +Directories +----------- + +* generators -> A directory of python and bash scripts for pungi/peridot data generation diff --git a/mangle/quick-bump.py b/mangle/quick-bump.py new file mode 100755 index 0000000..d268641 --- /dev/null +++ b/mangle/quick-bump.py @@ -0,0 +1,116 @@ +#!/usr/bin/env python3 +# +# quick-bump.py - Quickly bumps a release version for a rebuild. This is mostly +# used in cases of */src/* package rebuilds like for SIG's. It +# should be rare that the base distribution needs this. + +import os +import subprocess +import sys +import argparse +import subprocess + +parser = argparse.ArgumentParser() +parser.add_argument("--pkg", help="Package name to bump (can be comma delimited list)", required=True) +parser.add_argument("--branch", help="Package branch", required=True) +parser.add_argument("--sig", help="Name of SIG package", required=True) +parser.add_argument("--peridot-import", help="Tell peridot to import", + required=False, action='store_true') +parser.add_argument("--peridot-endpoint", + help="Peridot API Endpoint (PERIDOT_ENDPOINT)", + required=False, default="peridot-api.build.resf.org") +parser.add_argument("--peridot-hdr-endpoint", + help="Peridot HDR Endpoint (PERIDOT_HDR_ENDPOINT)", + required=False, default="hdr.build.resf.org") +parser.add_argument("--peridot-project-id", + help="Peridot project ID (PERIDOT_PROJECT_ID)", + required=False) +parser.add_argument("--peridot-client-id", + help="Peridot client ID (PERIDOT_CLIENT_ID)", + required=False) +parser.add_argument("--peridot-client-secret", + help="Peridot client secret (PERIDOT_CLIENT_SECRET)", + required=False) +parser.add_argument("--dry", help="Do a dry bump for testing", + required=False, action='store_true') + +parser.add_argument("--git-user", default="Release Engineering") +parser.add_argument("--git-email", default="releng@rockylinux.org") + +args = parser.parse_args() +user = 'Release Engineering ' +comment = 'Release tag bump for rebuild (https://sig-core.rocky.page/rebuild/)' + +if args.peridot_import: + peridot_api_endpoint = os.environ.get('PERIDOT_ENDPOINT') or args.peridot_endpoint + peridot_hdr_endpoint = os.environ.get('PERIDOT_HDR_ENDPOINT') or args.peridot_hdr_endpoint + peridot_project_id = os.environ.get('PERIDOT_PROJECT_ID') or args.peridot_project_id + peridot_client_id = os.environ.get('PERIDOT_CLIENT_ID') or args.peridot_client_id + peridot_client_secret = os.environ.get('PERIDOT_CLIENT_SECRET') or args.peridot_client_secret + print('Peridot import not supported yet') + sys.exit(1) + +default_url = 'ssh://git@git.rockylinux.org:22220/staging/src/%s.git' % args.pkg +if args.sig: + default_url = 'ssh://git@git.rockylinux.org:22220/sig/%s/src/%s.git' % (args.sig, args.pkg) + +# functions +workdir = '/var/tmp' +environment = os.environ +pkgs = args.pkg.split(',') + +def runcmd(cmd, action, package, env, pwd=workdir): + """ + Runs a command using subprocess and returns 0 or 1 + """ + try: + subprocess.check_call(cmd, env=env, cwd=pwd) + except subprocess.CalledProcessError as err: + sys.stderr.write('%s failed %s: %s\n' % (package, action, err)) + return 1 + return 0 + +for pkg in pkgs: + joined_dir = os.path.join(workdir, pkg) + spec_dir = os.path.join(workdir, pkg, 'SPECS') + print('Checking out ' + pkg) + gitcmd = ['git', 'clone', default_url, '--branch', args.branch, + joined_dir] + if runcmd(gitcmd, 'git clone', pkg, environment): + continue + + files = os.listdir(spec_dir) + spec = '' + for file in files: + if file.endswith('.spec'): + spec = os.path.join(spec_dir, file) + break + + if not spec: + sys.stderr.write('Failed to find a spec for %s\n' % pkg) + continue + + print('Bumping release of %s' % spec) + bumprel = ['rpmdev-bumpspec', '-D', '-u', user, '-c', comment, spec] + if runcmd(bumprel, 'rpmdev-bumpspec', pkg, environment): + continue + + print('Setting git user and email for this operation') + git_name = ['git', 'config', 'user.name', args.git_user] + git_mail = ['git', 'config', 'user.email', args.git_email] + if runcmd(git_name, 'git_name', pkg, environment, pwd=joined_dir): + continue + + if runcmd(git_mail, 'git_mail', pkg, environment, pwd=joined_dir): + continue + + print('Committing changes') + commit = ['git', 'commit', '-asm', comment, '--allow-empty'] + if runcmd(commit, 'commit', pkg, environment, pwd=joined_dir): + continue + + if not args.dry: + push = ['git', 'push'] + print('Pushing changes for %s' % pkg) + if runcmd(push, 'push', pkg, environment, pwd=joined_dir): + continue