Add scripts for automatically generating builds

Many of the steps for day-to-day updates still require a lot of
manual steps which can lead to typos. Add a series of scripts to
make automate the manual steps and hopefully reduce errors. These
are a work in progress because having them in tree makes it easier
to work out issues.
This commit is contained in:
Laura Abbott 2016-10-07 13:59:14 -07:00
parent da8efd59db
commit 2f50aa19db
6 changed files with 180 additions and 0 deletions

12
scripts/add-changelog.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# Emulate the changelog part of rpmdev-bumpspec without the bumping of the
# rev. Because Laura keeps typoing her name and the date.
CURDATE=`date +"%a %b %d %Y"`
PACKAGER=`rpmdev-packager`
CHANGELOG="%changelog\n* $CURDATE $PACKAGER\n- $1\n"
awk -v CHANGE="$CHANGELOG" '/%changelog/ {print CHANGE} \
!/%changelog/ { print $0 }' \
< kernel.spec > kernel.spec.tmp
mv kernel.spec.tmp kernel.spec

12
scripts/fixup-bumpspec.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
# rpmdev-bumpspec 'helpfully' bumps the release which we don't always want.
# This script fixes it up.
RELEASE=`grep "%global baserelease" kernel.spec | cut -d ' ' -f 3`
export RELEASE=$(($RELEASE-1))
echo $RELEASE
perl -p -i -e 's|%global baserelease.*|%global baserelease $ENV{'RELEASE'}|' kernel.spec
TODAY=`date +"%a %b %d %Y"`
echo $TODAY
awk -v DATE="$TODAY" 'START { marked = 0; } $0 ~ DATE { if (marked == 1) { print $0 } else {out=$1; for(i = 2; i <= NF - 2; i++) { out=out" "$i } print out; marked = 1; } } $0 !~ DATE { print $0; }' < kernel.spec > kernel.spec.tmp

View File

@ -0,0 +1,8 @@
VER=$(grep patch sources | head -n1 | awk '{ print $2 }' | sed s/patch-// | sed s/-git.*// | sed s/.xz//)
if [ -z "$VER" ] ;
then
VER=$(grep linux sources | head -1 | awk '{ print $2 }' | sed s/linux-// | sed s/.tar.xz//)
fi

26
scripts/rawhide-rc.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/sh
# Generate a commit for a rawhide RC release
source scripts/kernel-version.sh
make release
# fixup the release because rpmdev-bumpspec *sigh*
scripts/fixup-bumpspec.sh
fedpkg commit -c
# Figure out what is our RC
RC=`grep kernel.spec "%define rcrev" | cut -d ' ' -f 3`
RC=$(($RC+1))
# Kill all patches
awk '!/patch/ { print $0 }' < sources > sources.tmp
mv sources.tmp sources
# Grab the tarball
# FILL this in laura
# bump rcrev in the spec and set git snapshot to 0
perl -p -i -e 's|%define rcrev.*|%global rcrev $ENV{'RC'}|' kernel.spec
perl -p -i -e 's|%define gitrev.*|%define gitrev 0|' kernel.spec

48
scripts/rawhide-snapshot.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
# A coffeeproof rawhide script. You should be able to run this before the
# coffee has kicked in and generate a good rawhide commit.
#
# - Updates the local Fedora tree to master and verifies that you are working
# off of the correct master
# - Updates the upstream tree to the latest master.
# - Generates a git snapshot via generate-git-snapshot.sh
# - Clears out old git snapshots from the sources
# - Uploads the new snapshot
source scripts/kernel-version.sh
git fetch origin
if [ "$(git rev-parse origin/master)" != "$(git rev-parse HEAD)" ]; then
echo "I just did a git fetch and this branch does not match master"
echo "Re-check out this branch to work off of the latest master"
exit 1
fi
if [ ! -d "$LINUX_GIT" ]; then
echo "error: set \$LINUX_GIT to point at an upstream git tree"
exit 1
fi
pushd $LINUX_GIT
git pull
if [ ! $? -eq 0 ]; then
echo "Git pull failed. Is your tree clean/correct?"
exit 1
fi
popd
GIT=`grep "%define gitrev" kernel.spec | cut -d ' ' -f 3`
if [ "$GIT" -eq 0 ]; then
make debug
./scripts/fixup-bumpspec.sh
fedpkg commit -c
fi
./scripts/generate-git-snapshot.sh
#Nuke the old patch from the source
awk '!/git/ { print $0 }' < sources > sources.tmp
mv sources.tmp sources
GIT=`grep "%define gitrev" kernel.spec | cut -d ' ' -f 3`
fedpkg upload patch-$VER-git$GIT.xz

74
scripts/stable-update.sh Executable file
View File

@ -0,0 +1,74 @@
#!/bin/sh
#
# Author: Laura Abbott <labbott@fedoraproject.org>
#
# Apply a stable patch update to the Fedora tree. This takes care of
# - Downloading the patch from kernel.org
# - Uploading the source file
# - Removing old patch files
# - Updating the spec file stable version
# - Adding a proper changelog entry
#
# Based on steps from https://fedoraproject.org/wiki/Kernel/DayToDay#Stable_kernel_update
#
# Args: Stable version to update (e.g. 4.7.7, 4.8.1)
if [ $# -lt 1 ]; then
echo "Need a version"
exit 1
fi
VERSION=`echo $1 | cut -d . -f 1`
if [ -z $VERSION ]; then
echo "Malformed version $1"
exit 1
fi
PATCHLEVEL=`echo $1 | cut -d . -f 2`
if [ -z $VERSION ]; then
echo "Malformed version $1"
exit 1
fi
SUBLEVEL=`echo $1 | cut -d . -f 3`
if [ -z $VERSION ]; then
echo "Malformed version $1"
exit 1
fi
if [ ! -f patch-$1.xz ]; then
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/patch-$1.xz
if [ ! $? -eq 0 ]; then
echo "Download fail"
exit 1
fi
fi
grep $1 sources &> /dev/null
if [ ! $? -eq 0 ]; then
fedpkg upload patch-$1.xz
# Cryptic awk: search for the previous patch level (if one exists) and
# remove it from the source file
awk -v VER=$VERSION.$PATCHLEVEL.$((SUBLEVEL-1)) '$0 !~ VER { print $0; }' < sources > sources.tmp
mv sources.tmp sources
fi
# Update the stable level
awk -v STABLE=$SUBLEVEL '/%define stable_update/ \
{ print "%define stable_update " STABLE } \
!/%define stable_update/ { print $0 }' \
< kernel.spec > kernel.spec.tmp
mv kernel.spec.tmp kernel.spec
# Add the changelog entry. Ideally we would get rpmdev-bumpspec to do so
# but that also bumps the release which we don't want so do this manually
# for now
BASERELEASE=`cat kernel.spec | grep "%global baserelease" | cut -d ' ' -f 3`
CURDATE=`date +"%a %b %d %Y"`
PACKAGER=`rpmdev-packager`
CHANGELOG="%changelog\n* $CURDATE $PACKAGER - $1\n- Linux v$1\n"
awk -v CHANGE="$CHANGELOG" '/%changelog/ {print CHANGE } \
!/%changelog/ { print $0 }' \
< kernel.spec > kernel.spec.tmp
mv kernel.spec.tmp kernel.spec