lkml.org 
[lkml]   [2012]   [Nov]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectKernel Source updater script
Hi all,

I know that this is useless to people using git, but it was so fun to write
and I use it to update regularly my pc kernel source from time to time
while saving servers (and home) bandwidth

cheers!

#!/bin/sh

ver=$(awk '/^VERSION/{print$3}' Makefile)
patch=$(awk '/^PATCHLEVEL/{print$3}' Makefile)
sub=$(awk '/^SUBLEVEL/{print$3}' Makefile)

echo "Current kernel: $ver.$patch.$sub"

[ -d .pc ] && quilt pop -a

up_sub() {
next=$((sub + 1))
while wget -q --spider
http://www.kernel.org/pub/linux/kernel/v$ver.0/incr/patch-$ver.$patch.$sub-$next.xz;
do
url="$url http://www.kernel.org/pub/linux/kernel/v$ver.0/incr/patch-$ver.$patch.$sub-$next.xz"
sub=$next
next=$((next + 1))
done

echo "Upgrading to version: $ver.$patch.$sub"

wget -qO- $url |xz -d |patch -p1 |sed -u 's/$/
/' |tr '[\n]' '[\r]'
echo
}

up_patch(){
if [ $sub -gt 0 ]; then
url=
next=$((sub - 1))
while [ $sub -gt 0 ] ; do
if [ $next -ne 0 ]; then
url="$url http://www.kernel.org/pub/linux/kernel/v$ver.0/incr/patch-$ver.$patch.$next-$sub.xz"
else
url="$url http://www.kernel.org/pub/linux/kernel/v$ver.0/patch-$ver.$patch.$sub.xz"
fi
sub=$next
next=$((next - 1))
done

echo "Downgrading to version: $ver.$patch.$sub"

wget -qO- $url |xz -d |patch -p1 -R |sed -u 's/$/
/' |tr '[\n]' '[\r]'
echo
fi

url=
patch=$((patch + 1))
while wget -q --spider
http://www.kernel.org/pub/linux/kernel/v$ver.0/patch-$ver.$patch.xz;
do
url="$url http://www.kernel.org/pub/linux/kernel/v$ver.0/patch-$ver.$patch.xz"
patch=$((patch + 1))
done
patch=$((patch - 1))

sub=1
while wget -q --spider
http://www.kernel.org/pub/linux/kernel/v$ver.0/patch-$ver.$patch.$sub.xz;
do
sub=$((sub + 1))
done
sub=$((sub - 1))
url="$url http://www.kernel.org/pub/linux/kernel/v$ver.0/patch-$ver.$patch.$sub.xz"

echo "Upgrading to version: $ver.$patch.$sub"

wget -qO- $url |xz -d |patch -p1 |sed -u 's/$/
/' |tr '[\n]' '[\r]'
echo
}

case $1 in
patch)
up_patch
;;

sub)
up_sub
;;

*)
echo "usage: $0 [patch|sub]"
esac

[ -d .pc ] && while quilt push; do
quilt refresh
done


\
 
 \ /
  Last update: 2012-11-06 01:22    [W:0.152 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site