You are not logged in.

#1 2006-07-18 23:18:13

jaboua
Member
Registered: 2005-11-05
Posts: 634

Radon: A BASH-script to compile your future kernels

I made a BASH-script that downloads the kernel sources, applies Con Kolivas' patch, lets you into menuconfig/gconfig/xconfig/config to edit your kernel preferences (if the file /proc/config.gz exists, the running kernel's configuration file will be used as a base) and at last compile + install the new kernel. You need to be root for it to work. By default the script looks for the configuration file in /usr/local/etc/radon.conf - but this can easily be changed. Run it without arguments to get a description of how it works.

Any comments are appreciated.


Here is a compressed tarball with the script and config file:
http://elitelinux.org/jaboua/radon.tar.bz2

NOTE:
- Please read through and setup the configuration file before running the script

- if you for example are installing kernel 2.6.17 with radon and /usr/src/linux-2.6.17 allready exists, the directory and all it's contents will be deleted before extracting the sources.

Offline

#2 2006-07-18 23:21:52

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: Radon: A BASH-script to compile your future kernels

Sounds like an interesting enough script. Too bad I don't ever compile my own kernels. Base ones work fine for me smile

Offline

#3 2006-07-19 05:06:44

_Gandalf_
Member
Registered: 2006-01-12
Posts: 735

Re: Radon: A BASH-script to compile your future kernels

Looks interresting, at least saves some time, but I have a comment, make rmmod=0 in radon.conf by default, You are making so many newbie's computers not bootable smile

Offline

#4 2006-07-19 08:43:16

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Radon: A BASH-script to compile your future kernels

_Gandalf_ wrote:

make rmmod=0 in radon.conf by default

Exactly what I was going to say. I haven't looked at it yet, but why does it need to delete modules for ALL installed kernels? Seems like overkill to me.

One other thought - the user might prefer beyond to ck. Maybe you could offer a choice?

Offline

#5 2006-07-19 15:49:51

jaboua
Member
Registered: 2005-11-05
Posts: 634

Re: Radon: A BASH-script to compile your future kernels

The reason for being able to remove the other modules is that I don't need the modules of hundreds of old kernels that I overwrote long ago - so I thought it was convenient that people like me can turn rmmod on. But I will change the default to 0. I will upload the new one soon, just got to change something more first. Things I'm currently thinking of is a variable that will make the script refuse to run and set it in the config by default - so that the user has to go through the configuration file before running it, and a variable that will make the script run /sbin/lilo after installing the kernel to make things more convenient for lilo users. After that I might look at the patchset.

Offline

#6 2006-07-19 16:40:50

_Gandalf_
Member
Registered: 2006-01-12
Posts: 735

Re: Radon: A BASH-script to compile your future kernels

jaboua wrote:

and a variable that will make the script run /sbin/lilo after installing the kernel to make things more convenient for lilo users. After that I might look at the patchset.

If you do this, make sure you add a sanity check, to know which one is the user running you need to perform a special grep on the first sector of the hard disk (not the root partition but the HDD that contains it)
for me it's grub so

(0)[root@nasreddine ~]# dd if=/dev/hda bs=512 count=1 | grep -i grub
1+0 records in
1+0 records out
512 bytes (512 B) copied, 9.3e-05 seconds, 5.5 MB/s
Binary file (standard input) matches
(0)[root@nasreddine ~]# dd if=/dev/hda bs=512 count=1 | grep -i lilo
1+0 records in
1+0 records out
512 bytes (512 B) copied, 3.8e-05 seconds, 13.5 MB/s
(1)[root@nasreddine ~]# 

see the return value between () above ?? so you can have an "if dd .., then" smile

Offline

#7 2006-07-19 17:31:23

jaboua
Member
Registered: 2005-11-05
Posts: 634

Re: Radon: A BASH-script to compile your future kernels

Thanks for all the comments smile
btw tomk, you said rmmod was a bit overkill - do you have a suggestion how I can improve it?

I updated the original post (URL and removed a warning). Updated in the script:
- the script now refuses to run before the variable "setup" is set to 1 - it defaults to 0, so you have to edit the config file before running the script.
- rmmod defaults to 0
- a new variable introduced - "lilo" is set to 0 by default. When set to 1, it will automaticly update lilo on a successful kernel install.

Things I hopefully will implement later:
- possibility to choose between multiple patchsets and a vanilla kernel
- maybe a variable making it possible to remove other kernels' sources (set to 0 by default offcourse)

Gandalf, that's a nice method - but do you think it's needed? By default $lilo is set to 0:

# Whether to update the bootloader LILO. Set this to 1 if you use LILO.
lilo=0

If /sbin/lilo fails the script will spit out an error message in red:

# Update LILO if $lilo is set to 1 in radon.conf
[ $lilo == 1 ] && /sbin/lilo || error-lilo
function error-lilo ()
{
        echo -e "ne[31;1mINSTALLATION OF LILO FAILED!e[0mn"
        echo -e "ne[31;1mYou will not be able to boot into the new kernel before you run /sbin/lilo!e[0mn"
        exit 1
}

But when I think of it, it might be usefull... Instead of setting lilo to "1", it can be set to a harddisk device. That way the script can first check if $lilo is set - then it checks if lilo exists on that harddrive device - and then it either
1) installs lilo or
2) states that LILO doesn't exist on that device, and perhaps that is because GRUB is installed instead of lilo. Then it asks if you still want to install lilo (requiring a full "yes" to proceed).

What do  you think of that?

Offline

#8 2006-07-19 21:07:14

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,839

Re: Radon: A BASH-script to compile your future kernels

jaboua wrote:

btw tomk, you said rmmod was a bit overkill - do you have a suggestion how I can improve it?

Not so far - I stil haven't had a chance to look at it properly. My initial response was due to the fact that I always have four kernels on my machine, and I still don't understand why rebuilding one of them should affect any of the others.

Offline

#9 2006-07-19 23:19:06

jaboua
Member
Registered: 2005-11-05
Posts: 634

Re: Radon: A BASH-script to compile your future kernels

tomk wrote:
jaboua wrote:

btw tomk, you said rmmod was a bit overkill - do you have a suggestion how I can improve it?

Not so far - I stil haven't had a chance to look at it properly. My initial response was due to the fact that I always have four kernels on my machine, and I still don't understand why rebuilding one of them should affect any of the others.

It shouldn't - $rmmod is simply to "clean up" after kernels that I don't use anymore (since I usually have one kernel installed at the time, I don't need the old modules)

_Gandalf_, if I use your method, will it work when LILO is installed to a partition instead of MBR too?

Offline

#10 2006-07-20 07:08:14

_Gandalf_
Member
Registered: 2006-01-12
Posts: 735

Re: Radon: A BASH-script to compile your future kernels

jaboua, I never tried a bootloader on a partition so am afraid I don't know the answer to that question, of course leave $lilo variable, but you should always perform sanity checks, like, what if the user made $lilo=1 and months later he switched to grub and used radon without making $lilo=0, puff his pc is screwed...

So what i suggest is to check for both grub and lilo, in MBR and root partition, whatever matches will be taken

Offline

#11 2006-07-20 15:59:36

jaboua
Member
Registered: 2005-11-05
Posts: 634

Re: Radon: A BASH-script to compile your future kernels

_Gandalf_ wrote:

jaboua, I never tried a bootloader on a partition so am afraid I don't know the answer to that question, of course leave $lilo variable, but you should always perform sanity checks, like, what if the user made $lilo=1 and months later he switched to grub and used radon without making $lilo=0, puff his pc is screwed...

So what i suggest is to check for both grub and lilo, in MBR and root partition, whatever matches will be taken

OK, I see what you mean.

I'm probably going to setup a harddisk image to test the commands on, just to check that it works the same way if LILO is on a partition. I think if $lilo is set to 1, it might grab the $boot variable from /etc/lilo.conf - and then check for lilo on that device. If not, it asks if it still should install lilo on the device.

But I don't think I need to check for GRUB - I mean, if lilo isn't found the script will write a warning (in bold, red text) that will say that lilo wasn't found, and installing it will overwrite any other bootloader on the partition/device.

Offline

Board footer

Powered by FluxBB