chengshan / rpms / kernel

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