Blame scripts/stable-update.sh

Justin M. Forbes 689c83
#!/bin/sh
Justin M. Forbes 689c83
#
Justin M. Forbes 689c83
# Author: Laura Abbott <labbott@fedoraproject.org>
Justin M. Forbes 689c83
#
Justin M. Forbes 689c83
# Apply a stable patch update to the Fedora tree. This takes care of
Justin M. Forbes 689c83
# - Downloading the patch from kernel.org
Justin M. Forbes 689c83
# - Uploading the source file
Justin M. Forbes 689c83
# - Removing old patch files
Justin M. Forbes 689c83
# - Updating the spec file stable version
Justin M. Forbes 689c83
# - Adding a proper changelog entry
Justin M. Forbes 689c83
#
Justin M. Forbes 689c83
# Based on steps from https://fedoraproject.org/wiki/Kernel/DayToDay#Stable_kernel_update
Justin M. Forbes 689c83
#
Justin M. Forbes 689c83
# Args: Stable version to update (e.g. 4.7.7, 4.8.1)
Justin M. Forbes 689c83
Justin M. Forbes 689c83
if [ $# -lt 1 ]; then
Justin M. Forbes 689c83
	echo "Need a version"
Justin M. Forbes 689c83
	exit 1
Justin M. Forbes 689c83
fi
Justin M. Forbes 689c83
Justin M. Forbes 689c83
VERSION=`echo $1 | cut -d . -f 1`
Justin M. Forbes 689c83
if [ -z $VERSION ]; then
Justin M. Forbes 689c83
	echo "Malformed version $1"
Justin M. Forbes 689c83
	exit 1
Justin M. Forbes 689c83
fi
Justin M. Forbes 689c83
PATCHLEVEL=`echo $1 | cut -d . -f 2`
Justin M. Forbes 689c83
if [ -z $VERSION ]; then
Justin M. Forbes 689c83
	echo "Malformed version $1"
Justin M. Forbes 689c83
	exit 1
Justin M. Forbes 689c83
fi
Justin M. Forbes 689c83
SUBLEVEL=`echo $1 | cut -d . -f 3`
Justin M. Forbes 689c83
if [ -z $VERSION ]; then
Justin M. Forbes 689c83
	echo "Malformed version $1"
Justin M. Forbes 689c83
	exit 1
Justin M. Forbes 689c83
fi
Justin M. Forbes 689c83
Justin M. Forbes 689c83
if [ ! -f patch-$1.xz ]; then
Justin M. Forbes 689c83
	wget https://cdn.kernel.org/pub/linux/kernel/v6.x/patch-$1.xz
Justin M. Forbes 689c83
	if [ ! $? -eq 0 ]; then
Justin M. Forbes 689c83
		echo "Download fail"
Justin M. Forbes 689c83
		exit 1
Justin M. Forbes 689c83
	fi
Justin M. Forbes 689c83
fi
Justin M. Forbes 689c83
Justin M. Forbes 689c83
# This all needs to be updated for the new generation system
Justin M. Forbes 689c83
#
Justin M. Forbes 689c83
# if [ ! -f "patch-$1.sign" ]; then
Justin M. Forbes 689c83
#        wget "https://cdn.kernel.org/pub/linux/kernel/v4.x/patch-$1.sign"
Justin M. Forbes 689c83
#        if [ ! $? -eq 0 ]; then
Justin M. Forbes 689c83
#                echo "Signature download failed"
Justin M. Forbes 689c83
#                exit 1
Justin M. Forbes 689c83
#        fi
Justin M. Forbes 689c83
# fi
Justin M. Forbes 689c83
Justin M. Forbes 689c83
# xzcat "patch-$1.xz" | gpg2 --verify "patch-$1.sign" -
Justin M. Forbes 689c83
# if [ ! $? -eq 0 ]; then
Justin M. Forbes 689c83
#        echo "Patch file has invalid or untrusted signature!"
Justin M. Forbes 689c83
#        echo "See https://www.kernel.org/category/signatures.html"
Justin M. Forbes 689c83
#        exit 1
Justin M. Forbes 689c83
# fi
Justin M. Forbes 689c83
Justin M. Forbes 689c83
grep $1 sources &> /dev/null
Justin M. Forbes 689c83
if [ ! $? -eq 0 ]; then
Justin M. Forbes 689c83
	fedpkg upload patch-$1.xz
Justin M. Forbes 689c83
Justin M. Forbes 689c83
	# Cryptic awk: search for the previous patch level (if one exists) and
Justin M. Forbes 689c83
	# remove it from the source file
Justin M. Forbes 689c83
	awk -v VER=$VERSION.$PATCHLEVEL.$((SUBLEVEL-1)) '$0 !~ VER { print $0; }' < sources > sources.tmp
Justin M. Forbes 689c83
	mv sources.tmp sources
Justin M. Forbes 689c83
fi
Justin M. Forbes 689c83
Justin M. Forbes 689c83
# Update the stable level
Justin M. Forbes 689c83
awk -v STABLE=$SUBLEVEL '/%global stable_update/ \
Justin M. Forbes 689c83
			{ print "%global stable_update " STABLE } \
Justin M. Forbes 689c83
			!/%global stable_update/ { print $0 }' \
Justin M. Forbes 689c83
			< kernel-tools.spec > kernel-tools.spec.tmp
Justin M. Forbes 689c83
mv kernel-tools.spec.tmp kernel-tools.spec
Justin M. Forbes 689c83
Justin M. Forbes 689c83
# Reset the base release for use with rpmdev-bumpspec
Justin M. Forbes 689c83
BASERELEASE=`cat kernel-tools.spec | grep "%global baserelease" | cut -d ' ' -f 3 | head -c 1`00
Justin M. Forbes 689c83
BASERELEASE=$(($BASERELEASE-1))
Justin M. Forbes 689c83
BASERELEASE=$BASERELEASE perl -p -i -e 's|%global baserelease.*|%global baserelease $ENV{'BASERELEASE'}|' kernel-tools.spec
Justin M. Forbes 689c83
Justin M. Forbes 689c83
rpmdev-bumpspec -c "Linux v$1" kernel-tools.spec