LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-08-2005, 10:04 AM   #1
chasingmytail
LQ Newbie
 
Registered: Jun 2004
Distribution: Slack 10-current
Posts: 23

Rep: Reputation: 15
2.6 compile script


Maybe this will help someone else, but mostly I'm posting this because I've lost & rewritten this (small) bash script to automate compiling my 'test' kernels more times than I can remember and can't think of a better place to keep a copy.


compile.sh
Code:
cmp_dir="/home/kernel";
src_dir="/usr/src";
lilo_conf="/etc/lilo.conf";
lilo_root="/dev/md2";
t1=$(($((`date +%H` *  60)) + $((`date +%M`))));

for i in `ls -1 $src_dir/linux-2.6*.bz2 | sed 's/^.*linux/linux/g' | sort`; do
	i=$i;
done;
ver=`echo $i | sed 's/.tar.bz2//g' | sed 's/linux-//g'`;
lin_ver="linux-$ver";

if [ -d $cmp_dir ]; then
	if [ -e $cmp_dir/.config ]; then
		cp $cmp_dir/.config $src_dir/config.save;
	fi;

	echo "Removing Compiled Directory ...";
	rm -r $cmp_dir;
	echo "Creating Compiled Directory ...";
	mkdir $cmp_dir;
	cp $src_dir/config.save $cmp_dir/.config;
else
	mkdir $cmp_dir;
	cp $src_dir/config.save $cmp_dir/.config;
fi;

if [ -d /lib/modules/${ver} ]; then
	echo "Removing Old Modules";
	rm -r /lib/modules/${ver};
else
	echo "Old modules do not exist - continuing ...";
fi;


if [ ! -z $lin_ver ] && [ -d $src_dir/$lin_ver ] && [ -e $src_dir/linux -a -h $src_dir/linux ]; then
	rm $src_dir/linux;
	ln -s $src_dir/$lin_ver $src_dir/linux;
	s1=1;
fi

if [ -z $lin_ver ] && [ -z $s1 ]; then
	echo "ERROR: No compressed Kernel source found in $src_dir";
	exit;
else
	if [ ! -d $src_dir/$lin_ver ]; then
		echo "Creating source directory";
		cd $src_dir;
		tar xjf $src_dir/$i;
	fi
	if [ -e $src_dir/linux ]; then
		if [ ! -h $src_dir/linux ]; then
			echo "ERROR: $src_dir/linux is not symbolic ";
			exit;
		fi;
		rm $src_dir/linux;
		ln -s $src_dir/$lin_ver $src_dir/linux;
	fi

fi;

echo "Cleaning source kernel";
cd $src_dir/linux/;
make -j3 mrproper;
make -j3 clean;
make -j3 O=$cmp_dir xconfig;
make -j3 O=$cmp_dir;
make -j3 O=$cmp_dir modules;
make -j3 O=$cmp_dir modules_install;
rm /boot/*-test;
cp $cmp_dir/System.map /boot/System.map-${ver}-test;
cp $cmp_dir/arch/i386/boot/bzImage /boot/vmlinuz-${ver}-test;
more $lilo_conf | grep -v "#test" > /tmp/lilo.tmp;
mv /tmp/lilo.tmp $lilo_conf;
echo "   #test
image = /boot/vmlinuz-${ver}-test   #test
root = $lilo_root   #test
label = Linux-Test   #test" >> $lilo_conf
/sbin/lilo


t2=$(($((`date +%H` *  60)) + $((`date +%M`))));
elapsed=$(( $t2 - $t1 ));

xmessage -center "Done in $elapsed minutes";
By the way, props go to the Digital Hermit's Rebuild Guide for getting me started on the basics.

Last edited by chasingmytail; 10-08-2005 at 10:09 AM.
 
Old 10-08-2005, 08:34 PM   #2
freakyg
Member
 
Registered: Apr 2005
Distribution: LFS 5.0 and 6.1
Posts: 705

Rep: Reputation: 30
Nice...........we'll get this off the no-replies list......
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile/Encrypt Bash Script DoubleOTeC Programming 6 10-09-2005 07:33 PM
ntop compile/post-compile problem? tjb Linux - Software 3 12-28-2004 04:22 PM
Bash script to compile kernel Keffin Programming 6 05-03-2004 06:31 PM
shell script to compile java czy11421 Programming 4 04-30-2004 09:42 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration