2012-11-05 23:53:29

by Matteo Croce

[permalink] [raw]
Subject: Kernel 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


2012-11-06 04:43:48

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: Kernel Source updater script

On Tue, Nov 06, 2012 at 12:52:46AM +0100, Matteo Croce wrote:
> 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

Have you looked at the python script called 'ketchup'? I think it
already does a lot of what you are doing here.

greg k-h

2012-11-20 13:40:40

by Pavel Machek

[permalink] [raw]
Subject: Re: Kernel Source updater script

On Tue 2012-11-06 05:43:46, Greg KH wrote:
> On Tue, Nov 06, 2012 at 12:52:46AM +0100, Matteo Croce wrote:
> > 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
>
> Have you looked at the python script called 'ketchup'? I think it
> already does a lot of what you are doing here.

I tried to get it to work with 3.x kernels, and I don't think I was
successful. Hopefully someone else did the job?

It would be nice to include it in the scripts/ directory, to save
duplicate work. (Or drivers/staging/scripts? :-).
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2012-11-20 16:21:36

by Matteo Croce

[permalink] [raw]
Subject: Re: Kernel Source updater script

I have an updated version here:

git://github.com/teknoraver/misc.git

2012/11/20 Pavel Machek <[email protected]>:
> On Tue 2012-11-06 05:43:46, Greg KH wrote:
>> On Tue, Nov 06, 2012 at 12:52:46AM +0100, Matteo Croce wrote:
>> > 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
>>
>> Have you looked at the python script called 'ketchup'? I think it
>> already does a lot of what you are doing here.
>
> I tried to get it to work with 3.x kernels, and I don't think I was
> successful. Hopefully someone else did the job?
>
> It would be nice to include it in the scripts/ directory, to save
> duplicate work. (Or drivers/staging/scripts? :-).
> Pavel
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html



--
Matteo Croce
OpenWrt Developer
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
ATTITUDE ADJUSTMENT (bleeding edge) --------------
* 1/4 oz Vodka Pour all ingredients into mixing
* 1/4 oz Gin tin with ice, strain into glass.
* 1/4 oz Amaretto
* 1/4 oz Triple sec
* 1/4 oz Peach schnapps
* 1/4 oz Sour mix
* 1 splash Cranberry juice
-----------------------------------------------------