From cd3842f3629cf85d08c6c7d339a240b8b02e3212 Mon Sep 17 00:00:00 2001 From: "Justin M. Forbes" Date: Mon, 27 Aug 2018 11:19:30 -0500 Subject: Update headers script --- scripts/create_headers_tarball.sh | 110 +++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 61 deletions(-) (limited to 'scripts') diff --git a/scripts/create_headers_tarball.sh b/scripts/create_headers_tarball.sh index e96fe57f4..575b2bb8e 100755 --- a/scripts/create_headers_tarball.sh +++ b/scripts/create_headers_tarball.sh @@ -1,74 +1,44 @@ #!/bin/bash # # This script is aimed at generating the headers from the kernel sources. -# Please do a git checkout of the kernel sources, or run until %prep step of -# kernel rpm build. Then go into the directory with the sources, and run this -# script +# You should have a checkout of kernel-headers inside the kernel directory 'fedpkg clone kernel-headers' +# You will need to prep the kernel sources with 'make prep' or 'fedpkg prep' before running this script # # Author: Herton R. Krzesinski +# Author: Justin M. Forbes + +# Location of kernel-headers checkout +CURRENTDIR=`pwd` +PKGLOC='kernel-headers' + +if [ ! -f $PKGLOC/kernel-headers.spec ]; then + echo "Missing checkout of kernel-headers in $PKGLOC" + exit 1 +fi + +# Kernel version information taken from kernel.spec and change to prepared sources directory +MAJORVER='4' +RELEASED=`grep "%global released_kernel" kernel.spec| cut -d ' ' -f 3` +BASERELEASE=`cat kernel.spec | grep "%global baserelease" | cut -d ' ' -f 3` +BASE=`grep "%define base_sublevel" kernel.spec| cut -d ' ' -f 3` +STABLE=`grep "%define stable_update" kernel.spec| cut -d ' ' -f 3` +RC=`grep "%global rcrev" kernel.spec| cut -d ' ' -f 3` +GITREV=`grep "%define gitrev" kernel.spec| cut -d ' ' -f 3` +if [ $RELEASED -eq 0 ]; then + cd kernel-$MAJORVER.$BASE.fc?? + NEWBASE=$(($BASE+1)) + KVER=$MAJORVER.$NEWBASE.0-0.rc$RC.git$GITREV.$BASERELEASE + cd linux-$MAJORVER.$NEWBASE.0-0.rc$RC.git$GITREV.$BASERELEASE.fc*/ +else + cd kernel-$MAJORVER.$BASE.fc??/linux-$MAJORVER.$BASE.$STABLE-$BASERELEASE.fc*/ + KVER=$MAJORVER.$BASE.$STABLE-$BASERELEASE +fi # ARCH_LIST below has the default list of supported architectures # (the architectures names may be different from rpm, you list here the # names of arch/ directories in the kernel sources) ARCH_LIST="arm arm64 powerpc s390 x86" -# If the kernel Makefile doesn't contain enough information for the tarball -# release, you can specify the release of the package so it'll be included -# in the name of the created tarball -TB_RELEASE="" - -# If kernel Makefile has the package release number, you can specify the name of -# Makefile variable here. -MAKE_RELEASE="" - -# Extra string (usually dist tag) that goes into the tarball name -EXTRA="" - -while [ ! -z "$1" ]; do - opt="$1" - case $opt in - --arch-list|-a) - ARCH_LIST="$2" - shift - ;; - --extra|-e) - EXTRA="$2" - shift - ;; - --make-release|-m) - MAKE_RELEASE=$2 - shift - ;; - --release|-r) - TB_RELEASE=$2 - shift - ;; - *) - echo "Unknown option ($1) to $0" - exit - ;; - esac - shift -done - -KVERSION=$(cat Makefile | sed -ne '/^VERSION\ =\ /{s///;p;q}') -KPATCHLEVEL=$(cat Makefile | sed -ne '/^PATCHLEVEL\ =\ /{s///;p;q}') -KSUBLEVEL=$(cat Makefile | sed -ne '/^SUBLEVEL\ =\ /{s///;p;q}') -TB_VERSION=$KVERSION.$KPATCHLEVEL.$KSUBLEVEL -if [ -z "$TB_RELEASE" ]; then - KEXTRAVERSION=$(cat Makefile | sed -ne '/^EXTRAVERSION\ =\ /{s///;p;q}') - DISTRO_RELEASE="" - if [ -n "$MAKE_RELEASE" ]; then - DISTRO_RELEASE=.$(cat Makefile | sed -ne "/^$MAKE_RELEASE\ =\ /{s///;p;q}") - fi - if [ -n "$KEXTRAVERSION" ]; then - KEXTRAVERSION=$(echo $KEXTRAVERSION | sed -e s/-/./) - TB_RELEASE=0$KEXTRAVERSION$DISTRO_RELEASE$EXTRA - else - TB_RELEASE=$DISTRO_RELEASE$EXTRA - fi -fi - headers_dir=$(mktemp -d) trap 'rm -rf "$headers_dir"' SIGHUP SIGINT SIGTERM EXIT @@ -77,9 +47,27 @@ find $headers_dir \ \( -name .install -o -name .check -o \ -name ..install.cmd -o -name ..check.cmd \) | xargs rm -f -TARBALL=$PWD/kernel-headers-$TB_VERSION-$TB_RELEASE.tar.xz +TARBALL=$CURRENTDIR/$PKGLOC/kernel-headers-$KVER.tar.xz pushd $headers_dir tar -Jcf $TARBALL * popd echo wrote $TARBALL + +# Update kernel-headers.spec +cd $CURRENTDIR/$PKGLOC/ + +BASE=$BASE perl -p -i -e 's|%define base_sublevel.*|%define base_sublevel $ENV{'BASE'}|' kernel-headers.spec +BASERELEASE=$(($BASERELEASE-1)) +BASERELEASE=$BASERELEASE perl -p -i -e 's|%global baserelease.*|%global baserelease $ENV{'BASERELEASE'}|' kernel-headers.spec + +if [ $RELEASED -eq 0 ]; then + RC=$RC perl -p -i -e 's|%global rcrev.*|%global rcrev $ENV{'RC'}|' kernel-headers.spec + GITREV=$GITREV perl -p -i -e 's|%define gitrev.*|%define gitrev $ENV{'GITREV'}|' kernel-headers.spec + rpmdev-bumpspec -c "Linux v$MAJORVER.$NEWBASE-rc$RC.git$GITREV" kernel-headers.spec +else + STABLE=$STABLE perl -p -i -e 's|%define stable_update.*|%define stable_update $ENV{'STABLE'}|' kernel-headers.spec + rpmdev-bumpspec -c "Linux v$MAJORVER.$BASE.$STABLE" kernel-headers.spec +fi +echo "Modified $CURRENTDIR/$PKGLOC/kernel-headers.spec" +echo "Don't forget to upload the sources" -- cgit