#4 kernel-rebase/c9s: Add prepdistgit stage to assist in the release process
Merged 5 months ago by ngompa. Opened 5 months ago by ngompa.

@@ -22,20 +22,21 @@ 

  kernelrebasesh="$(basename "$0")"

  

  usage() {

- 	echo >&2 "usage: $kernelrebasesh --kernel-srcdir=DIR [--only-stage=STAGE] [--release-build] [--debug]"

- 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --only-stage=prep --debug"

- 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --only-stage=prep"

- 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --release-build"

- 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work"

+ 	echo >&2 "usage: $kernelrebasesh --kernel-srcdir=DIR --kernel-pkgdir=DIR [--only-stage=STAGE] [--release-build] [--debug]"

+ 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork --only-stage=prep --debug"

+ 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork --only-stage=prep"

+ 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork --release-build"

+ 	echo >&2 "   eg: $kernelrebasesh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork"

  	exit 255

  }

  

- optTemp=$(getopt --options '+k:,s:,r,d,h' --longoptions 'kernel-srcdir:,only-stage:,release-build,debug,help' --name "$kernelrebasesh" -- "$@")

+ optTemp=$(getopt --options '+k:,p:,s:,r,d,h' --longoptions 'kernel-srcdir:,kernel-pkgdir:,only-stage:,release-build,debug,help' --name "$kernelrebasesh" -- "$@")

  eval set -- "$optTemp"

  unset optTemp

  

  current_dir="$PWD"

  kernel_srcdir=

+ kernel_pkgdir=

  only_stage="all"

  release_build=

  debug=
@@ -43,6 +44,7 @@ 

  while true; do

  	case "$1" in

  		-k|--kernel-srcdir) kernel_srcdir="$2" ; shift 2 ;;

+ 		-p|--kernel-pkgdir) kernel_pkgdir="$2" ; shift 2 ;;

  		-s|--only-stage) only_stage="$2" ; shift 2 ;;

  		-r|--release-build) release_build="yes" ; shift ;;

  		-d|--debug) debug="yes" ; shift ;;
@@ -56,8 +58,13 @@ 

  	usage

  fi

  

+ if [ -z "$kernel_pkgdir" ]; then

+ 	echo "Options not set!"

+ 	usage

+ fi

+ 

  if [ -n "$only_stage" ]; then

- 	valid_stages=("prep" "rebase" "buildsrpm" "all")

+ 	valid_stages=("prep" "rebase" "buildsrpm" "prepdistgit" "all")

  	stage_found=

  	for valid_stage in "${valid_stages[@]}"; do

  		if [ "$valid_stage" = "$only_stage" ]; then
@@ -168,3 +175,45 @@ 

  	make dist-srpm BUILDID=".test.$(date +'%Y%m%d%H%m' --utc)"

  fi

  popd

+ 

+ # Define stage for preparing to commit to Dist-Git

+ current_stage="prepdistgit"

+ 

+ [ "$only_stage" = "prep" ] || [ "$only_stage" = "rebase" ] || [ "$only_stage" = "buildsrpm" ] && echo "Short-circuiting and exiting early, per user request!" && exit 0

+ 

+ [ "$release_build" != "yes" ] && echo "Not a release build, so no Dist-Git work needed!" && exit 0

+ 

+ echo "[*] STAGE: $current_stage"

+ kernelsrpm_name="kernel-${kerneltree_latestcs9ver}.hs1.el9.src.rpm"

+ kernelsrpm_location="${kernel_srcdir}/redhat/rpm/SRPMS/${kernelsrpm_name}"

+ kerneldistgit_url="ssh://git@git.centos.org/rpms/kernel.git"

+ 

+ echo "Checking for existing checkout of Hyperscale kernel packaging tree..."

+ if [ -d "${kernel_pkgdir}" ]; then

+ 	pushd "${kernel_pkgdir}"

+ 	kernelpkgtree_origin_remote=$(git remote get-url origin)

+ 	[ "$kernelpkgtree_origin_remote" != "$kerneldistgit_url" ] && \

+ 		echo "Invalid repository, exiting!" && exit 10

+ 	git checkout c9s-sig-hyperscale

+ 	git pull --ff-only

+ 	echo "Existing checkout found and configured!"

+ 	popd

+ else

+ 	echo "No existing checkout of the Hyperscale kernel packaging tree found!"

+ 	echo "Setting up new checkout at ${kernel_pkgdir}..."

+ 	git clone "${kerneldistgit_url}" --branch c9s-sig-hyperscale "${kernel_pkgdir}"

+ 	echo "New checkout configured!"

+ fi

+ echo "Fetching code from Git remotes..."

+ kernelsrpm_unpacktmpdir="${kernel_pkgdir}/tmp-$(date +'%Y%m%d%H%m' --utc)"

+ pushd "${kernel_pkgdir}"

+ 	rm *

+ 	mkdir -p "${kernelsrpm_unpacktmpdir}"

+ 	bsdtar --extract --verbose --file "${kernelsrpm_location}" --directory "${kernelsrpm_unpacktmpdir}"

+ 	pushd "${kernelsrpm_unpacktmpdir}"

+ 		sha512sum --tag *.tar.* *.x509 > sources

+ 		mv * ..

+ 	popd

+ 	rm -rf "${kernelsrpm_unpacktmpdir}"

+ 	patch --no-backup-if-mismatch -p1 < "${current_dir}"/package-diffs/*.patch

+ popd

@@ -0,0 +1,35 @@ 

+ From fa7e9e6a6d7427398a7a93caec12dd1f576b2fe3 Mon Sep 17 00:00:00 2001

+ From: Neal Gompa <ngompa@centosproject.org>

+ Date: Sun, 12 Dec 2021 18:08:38 -0500

+ Subject: [PATCH] Do not sign the kernel or modules for now

+ 

+ The capability to do this is not yet available...

+ 

+ Reference: https://pagure.io/centos-infra/issue/307

+ Reference: https://git.centos.org/centos/board/issue/67

+ ---

+  kernel.spec | 10 +++++++++-

+  1 file changed, 9 insertions(+), 1 deletion(-)

+ 

+ diff --git a/kernel.spec b/kernel.spec

+ index cfadf41..b47a31d 100755

+ --- a/kernel.spec

+ +++ b/kernel.spec

+ @@ -103,6 +103,14 @@ Summary: The Linux kernel

+  # Sign modules on all arches

+  %global signmodules 1

+  

+ +%if 0%{?centos_hs}

+ +# We cannot do signing for secure boot yet...

+ +# Cf. https://pagure.io/centos-infra/issue/307

+ +# Cf. https://git.centos.org/centos/board/issue/67

+ +%global signkernel 0

+ +%global signmodules 0

+ +%endif

+ +

+  # Compress modules only for architectures that build modules

+  %ifarch noarch

+  %global zipmodules 0

+ -- 

+ 2.35.1

+ 

This new stage does the work to prepare the Dist-Git repository to commit
the update. It does not actually upload sources or commit to the repo,
but it does simplify the process to actually prepare for doing that.

rebased onto 0879cf5

5 months ago

rebased onto 3239a2d

5 months ago

Shouldn't the new option be optional since it's also only used with releases?

@jvreeland it is, it gets skipped entirely if releases aren't happening.

rebased onto 73e031c

5 months ago

rebased onto 9432169

5 months ago

Pull-Request has been merged by ngompa

5 months ago

@jvreeland it is, it gets skipped entirely if releases aren't happening.

You check if it's set at the beginning of the script then exit if it's not. The usage notation also doesn't indicate that it's optional. From my understanding this command should still work since it's not a release and there's no need for the pkgdir option.

$ ./kernel-rebase.sh  --kernel-srcdir=/var/tmp/work
Options not set!
usage: kernel-rebase.sh --kernel-srcdir=DIR --kernel-pkgdir=DIR [--only-stage=STAGE] [--release-build] [--debug]
   eg: kernel-rebase.sh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork --only-stage=prep --debug
   eg: kernel-rebase.sh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork --only-stage=prep
   eg: kernel-rebase.sh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork --release-build
   eg: kernel-rebase.sh --kernel-srcdir=/var/tmp/work --kernel-pkgdir=/var/tmp/pkgwork