Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 199 lines (168 sloc) 6.52 KB
#!/bin/bash
# build -stable release from current -stable series
# Copyright (c) 2005 Chris Wright <chrisw@osdl.org>
# Copyright (c) 2006-2011 Greg Kroah-Hartman <greg@kroah.com>
#
if [ $# -ne 1 ]; then
KETCHUP=`which kv 2>/dev/null`
if [ -z "$KETCHUP" ]; then
echo -e "Usage:\t $0 release_number"
echo -e "e.g.\t $0 2.6.11.12"
echo -e "or install ketchup to automatically release the latest kernel version."
exit 1
fi
RELEASE=`kv`
else
RELEASE=$1
fi
REL_ARRAY=(${RELEASE//./ })
BASE=${REL_ARRAY[0]}.${REL_ARRAY[1]}.${REL_ARRAY[2]}
REL=${REL_ARRAY[3]}
MAJOR=${REL_ARRAY[0]}
MINOR=${REL_ARRAY[2]}
LONGTERM=0
# see if this is a "longterm" kernel or not
if [ $MAJOR == "2" ]; then
if [ $MINOR == "27" ]; then
LONGTERM=1
fi
if [ $MINOR == "32" ]; then
LONGTERM=1
fi
if [ $MINOR == "33" ]; then
LONGTERM=1
fi
if [ $MINOR == "34" ]; then
LONGTERM=1
fi
if [ $MINOR == "35" ]; then
LONGTERM=1
fi
fi
#echo "major = $MAJOR, minor = $MINOR, longterm = $LONGTERM"
# 4.x or 3.x or 2.6?
VER="2.6"
if [ ${MAJOR} == "3" ] ; then
# 3.x series
VER="3.0"
BASE=${REL_ARRAY[0]}.${REL_ARRAY[1]}
REL=${REL_ARRAY[2]}
MINOR=${REL_ARRAY[1]}
fi
if [ ${MAJOR} == "4" ] ; then
# 4.x series
VER="4.x"
BASE=${REL_ARRAY[0]}.${REL_ARRAY[1]}
REL=${REL_ARRAY[2]}
MINOR=${REL_ARRAY[1]}
fi
LAST=$(($REL - 1))
INCREMENTAL=1
if [ $LAST -eq 0 ]; then
LAST_REL=${BASE}
INCREMENTAL=0
else
LAST_REL=${BASE}.${LAST}
fi
echo "# About to create stable release $RELEASE (base $BASE last version $LAST_REL)"
echo "# "
BASE_COMMIT="$(git cat-file tag v${BASE} | grep object | cut -d" " -f2)"
LAST_COMMIT="$(git cat-file tag v${LAST_REL} | grep object | cut -d" " -f2)"
RELEASE_COMMIT="$(git cat-file tag v${RELEASE} | grep object | cut -d" " -f2)"
#echo "# BASE_COMMIT=$BASE_COMMIT"
#echo "# LAST_COMMIT=$LAST_COMMIT"
#echo "# RELEASE_COMMIT=$RELEASE_COMMIT"
#echo "#"
echo -n "# [ret] to continue"
read
RELDIR="../release-$RELEASE"
if [ -d ${RELDIR} ] ; then
rm ${RELDIR}/*
else
mkdir ${RELDIR}
fi
echo "# building tree in ${RELDIR}"
# build release materials, tarball, base patch, incr patch, changelog
#git archive --format=tar --prefix=linux-$RELEASE/ HEAD | gzip -9 > $RELDIR/linux-${RELEASE}.tar.gz
#git diff-tree -p $BASE_COMMIT $RELEASE_COMMIT | gzip -9 > $RELDIR/patch-${RELEASE}.gz
#if [ $INCREMENTAL -ne 0 ]; then
# git diff-tree -p $LAST_COMMIT $RELEASE_COMMIT | gzip -9 > $RELDIR/patch-${LAST_REL}-${REL}.gz
#fi
#zcat $RELDIR/patch-${LAST_REL}-${REL}.gz | diffstat -p1 > $RELDIR/diffstat-${LAST_REL}-${REL} 2>/dev/null
git archive --format=tar --prefix=linux-$RELEASE/ $RELEASE_COMMIT > $RELDIR/linux-${RELEASE}.tar
git diff-tree -p $BASE_COMMIT $RELEASE_COMMIT > $RELDIR/patch-${RELEASE}
if [ $INCREMENTAL -ne 0 ]; then
git diff-tree -p $LAST_COMMIT $RELEASE_COMMIT > $RELDIR/patch-${LAST_REL}-${REL}
cat $RELDIR/patch-${LAST_REL}-${REL} | diffstat -p1 > $RELDIR/diffstat-${LAST_REL}-${REL} 2>/dev/null
else
cat $RELDIR/patch-${RELEASE} | diffstat -p1 > $RELDIR/diffstat-${RELEASE} 2>/dev/null
fi
git log ${LAST_COMMIT}..${RELEASE_COMMIT} > $RELDIR/ChangeLog-$RELEASE
< $RELDIR/ChangeLog-$RELEASE git shortlog > $RELDIR/shortlog-$RELEASE
# sign all the needed files
gpg -a -b ${RELDIR}/linux-${RELEASE}.tar
gpg -a -b ${RELDIR}/patch-${RELEASE}
gpg -a -b ${RELDIR}/ChangeLog-${RELEASE}
if [ $INCREMENTAL -ne 0 ]; then
gpg -a -b ${RELDIR}/patch-${LAST_REL}-${REL}
fi
echo "# "
HOST="gregkh@geb.kernel.org"
SCRIPT="${RELDIR}/upload_v${RELEASE}"
touch ${SCRIPT}
chmod 755 ${SCRIPT}
if [ $LONGTERM -eq 1 ]; then
echo "# This is a longterm release"
echo "# finalize the release:"
echo "cd ${RELDIR}"
echo "kup --host=${HOST} put --tar --prefix=linux-${RELEASE}/ /pub/scm/linux/kernel/git/stable/linux-stable.git v${RELEASE} linux-${RELEASE}.tar.asc /pub/linux/kernel/v${VER}/longterm/v${BASE}/linux-${RELEASE}.tar.gz" | tee -a ${SCRIPT}
echo "kup --host=${HOST} put ChangeLog-${RELEASE} ChangeLog-${RELEASE}.asc /pub/linux/kernel/v${VER}/longterm/v${BASE}/" | tee -a ${SCRIPT}
echo "kup --host=${HOST} put patch-${RELEASE} patch-${RELEASE}.asc /pub/linux/kernel/v${VER}/longterm/v${BASE}/patch-${RELEASE}.gz" | tee -a ${SCRIPT}
if [ $INCREMENTAL -ne 0 ]; then
echo "kup --host=${HOST} put patch-${LAST_REL}-${REL} patch-${LAST_REL}-${REL}.asc /pub/linux/kernel/v${VER}/longterm/v${BASE}/incr/patch-${LAST_REL}-${REL}.gz" | tee -a ${SCRIPT}
fi
# echo "mv $RELDIR/linux-${RELEASE}.tar.gz ~/v2.6/longterm/v${BASE}/"
# echo "mv $RELDIR/ChangeLog-${RELEASE} ~/v2.6/longterm/v${BASE}/"
# echo "mv $RELDIR/patch-${RELEASE}.gz ~/v2.6/longterm/v${BASE}/"
# echo "cp $RELDIR/patch-${LAST_REL}-${REL}.gz ~/v2.6/longterm/v${BASE}/incr/"
# echo "mv $RELDIR/patch-${LAST_REL}-${REL}.gz ~"
# echo "mv $RELDIR/diffstat-${LAST_REL}-${REL} ~"
# echo "mv $RELDIR/shortlog-${RELEASE} ~"
else
echo "# This is a stable release"
echo "# finalize it:"
echo "cd ${RELDIR}"
echo "kup --host=${HOST} put --tar --prefix=linux-${RELEASE}/ /pub/scm/linux/kernel/git/stable/linux-stable.git v${RELEASE} linux-${RELEASE}.tar.asc /pub/linux/kernel/v${VER}/linux-${RELEASE}.tar.gz" | tee -a ${SCRIPT}
echo "kup --host=${HOST} put ChangeLog-${RELEASE} ChangeLog-${RELEASE}.asc /pub/linux/kernel/v${VER}/" | tee -a ${SCRIPT}
echo "kup --host=${HOST} put patch-${RELEASE} patch-${RELEASE}.asc /pub/linux/kernel/v${VER}/patch-${RELEASE}.gz" | tee -a ${SCRIPT}
if [ $INCREMENTAL -ne 0 ]; then
echo "kup --host=${HOST} put patch-${LAST_REL}-${REL} patch-${LAST_REL}-${REL}.asc /pub/linux/kernel/v${VER}/incr/patch-${LAST_REL}-${REL}.gz" | tee -a ${SCRIPT}
fi
# echo "mv $RELDIR/patch-${LAST_REL}-${REL}.gz ~"
# echo "mv $RELDIR/diffstat-${LAST_REL}-${REL} ~"
# echo "mv $RELDIR/shortlog-${RELEASE} ~"
# LATEST=`ls ~/v${VER}/LATEST-IS*`
# LATEST=`basename $LATEST`
# echo "# current LATEST-IS is '$LATEST' is that what it should be?"
# echo "# mv ~/v${VER}/${LATEST} ~/v${VER}/LATEST-IS-${RELEASE}"
fi
# create the email
cat << __EOF__ > ${RELDIR}/email
Subject: Linux ${RELEASE}
I'm announcing the release of the ${RELEASE} kernel.
All users of the ${BASE} kernel series must upgrade.
The updated ${BASE}.y git tree can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-${BASE}.y
and can be browsed at the normal kernel.org git web browser:
http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary
thanks,
greg k-h
------------
__EOF__
if [ $INCREMENTAL -ne 0 ]; then
cat ${RELDIR}/diffstat-${LAST_REL}-${REL} >> ${RELDIR}/email
else
cat ${RELDIR}/diffstat-${RELEASE} >> ${RELDIR}/email
fi
echo "" >> ${RELDIR}/email
cat $RELDIR/shortlog-$RELEASE >> ${RELDIR}/email