Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 03 Sep 2014, 03:37
All times are UTC - 4
 Forum index » Advanced Topics » Cutting edge
Kernel build script
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [43 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4348

PostPosted: Fri 13 May 2011, 21:17    Post subject:  

The kernel has the ability to include the initrd when built, have you considered adding such a beast?

+ easy install, fast boot, simple tracking, easier version control
- kernel may need to be rebuilt if the initrd is modified

Perhaps only do it if configured to do so?

I've done it once before with an lzma'd kernel with fairly impressive results, but I was working with an "extreme" minimal kernel and everything (including X) as a single static multicall binary in the initrd (a real painful learning experience btw)

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Sat 14 May 2011, 02:08    Post subject:  

That would be very problematic, since it requires integration with Woof ... but I have a cooler idea in mind - a JIT kernel build script that integrates with Woof to produce a UniPup Smile

Interesting, I'll check this out.

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
Lobster
Official Crustacean


Joined: 04 May 2005
Posts: 15117
Location: Paradox Realm

PostPosted: Sat 14 May 2011, 02:26    Post subject:  

Guys Rolling Eyes

(I am such a nag)
Are we anywhere near to having a kernel base for Saluki?
http://puppylinux.org/wikka/Puppy6

Sorry for nagging Embarassed

_________________
Puppy WIKI
Back to top
View user's profile Send private message Visit poster's website 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Sat 14 May 2011, 03:07    Post subject:  

I'm lost my interest in Saluki. While the nice "static or not static" conversation goes on in the Saluki front, the real hard work is done on the 5.3 and Wary fronts, by people who work more and talk less.

I wanted a kernel build script and wrote one. That's how I work. Enough talking and planning of a project without any product so far ... it's time to bring features to the table and that's what 01micko and the 5.3 guys do, unlike Saluki. I decided to join this effort.

So if you ask me - no, I won't help with Saluki's kernel ... well, at least I won't do it actively. However, this can be a kernel if the Saluki team wants it.

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
01micko


Joined: 11 Oct 2008
Posts: 7797
Location: qld

PostPosted: Fri 20 May 2011, 04:04    Post subject:  

I really like your script Iguleder.

of course I have some suggestions Laughing Very Happy

Being hard coded to 2.6.32 isn't a bad thing just a restrictive thing.

You could easy adjust to use any sauce you want.. with special cases for the LTS branches.

I just compiled 2.6.37.6 basically following your script manually. It may need a break at the configuration part where "make gconfig" (or whatever config option) could be run to configure the source. (hehe.. make xconfig is nice.. but needs qt :0 )

Cheers!

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Fri 20 May 2011, 04:43    Post subject:  

It's easy to tweak it to work with .37.x, just change from "2.6.32.40" to "2.6.37.whatever" and put matching patches in the patches directory. The rest is fully automated.

Let me know if you need me to tweak the script, I can do the testing and take care of everything.

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
01micko


Joined: 11 Oct 2008
Posts: 7797
Location: qld

PostPosted: Fri 20 May 2011, 06:40    Post subject:  

I reckon the kernel version could be passed as a commandline param.. that would nullify your little read at the start! Razz (no param, no start)

As for patches.. well aufs gets the right version from git anyway, printk.c patch is basic arithmetic.. the stumbling block would be the aufs-allow-sfs.patch.. however the version for 2.6.32 seemed to work perfectly for 2.6.37.6. (I haven't tested outside of the full install as yet, so that's tentative Wink ). Where does that patch come from anyway??? Is it a BK orig?

The vortex patch is machine specific and not needed for a main puppy kernel and probably (though I didn't test) wont work in newer kernels anyways. Perhaps a simple test there.

Ah.. then the config.. that would be daunting for a kernel noob (such as myself) .. so maybe a pause in the script so a config option could be run? Maybe based on a latish default DOTconfig? That way all the normal puppystuff is there.... and new stuff is tagged as (NEW) with a default recommendation (if using the commandline). The GUI version is super easy.. a dot (like a radiobutton) for module or a check for builtin. Just food for thought Smile . Even just stop the script instead of erroring to alert the user that a valid DOTconfig is needed. It can be restarted just fine.

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Fri 20 May 2011, 07:02    Post subject:  

I hand-crafted the aufs-allow-sfs.patch patch to be generic - the two lines it replaces are common to all Aufs branches, so it should work on any 2.x version, until the two lines it replaces are gone from Aufs.

The BFS patch and the vortex patch are Barry's. However, the bfs_cpufreq_tweaks patch is something I had to backport from later kernels, because Con Kolivas doesn't make one for 2.6.32.x.

Finally, regarding the .config - the defaults are really stupid in many cases, so it's impossible to make a .config generator. And the patches are suitable for a certain kernel version - you'll have to download patches that suit your kernel version manually, no matter what, that's why I don't add a command-line argument for the kernel version. Well, that's how I see it.

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
pemasu


Joined: 08 Jul 2009
Posts: 5463
Location: Finland

PostPosted: Fri 20 May 2011, 12:20    Post subject:  

About aufs-allow-sfs-as-branch patch. This may be relevant for it:
http://bkhome.org/blog/?viewDetailed=01470
Back to top
View user's profile Send private message 
pemasu


Joined: 08 Jul 2009
Posts: 5463
Location: Finland

PostPosted: Sat 04 Jun 2011, 03:31    Post subject:  

More info about the need of aufs-allow-sfs.patch

http://bkhome.org/blog/?viewDetailed=01731

Iguleders patch patches the loop.c from different row than Barrys patch and is hacked somehow also.

Iguleders patch:
Code:
@@ -28,6 +28,9 @@
  */
 int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_adding)
 {
+   /* allow Squashfs file systems to be used as Aufs branches */
+   return 0;
+   
    struct super_block *h_sb;
    struct loop_device *l;

My patch according to the Barrys patches:
Code:
@@ -31,6 +31,7 @@ int au_test_loopback_overlap(struct supe
    struct super_block *h_sb;
    struct loop_device *l;
 
+    return 0;
    h_sb = h_adding->d_sb;
    if (MAJOR(h_sb->s_dev) != LOOP_MAJOR)
       return 0;
Back to top
View user's profile Send private message 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Sat 04 Jun 2011, 03:37    Post subject:  

There are two reasons why my patch is better (IMHO):
- If the lines Barry's patch relies on are gone in a future Aufs version, a new patch is needed. Mine relies only on two lines, which persist through the Aufs history.
- Two structs are allocated on the stack and the function returns 0 without using them ... so why allocate them? GCC won't compile the code after the "return 0" and the structs won't be allocated with my patch.

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
pemasu


Joined: 08 Jul 2009
Posts: 5463
Location: Finland

PostPosted: Sat 04 Jun 2011, 04:11    Post subject:  

Anyway. The kernel-kit works like a charm. It is great almost automatic batched kernel builder. And also removes the minor number.

Absolutely wonderful platform.

Keep them coming Smile
Back to top
View user's profile Send private message 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Sat 04 Jun 2011, 04:26    Post subject:  

I'm currently doing a test build of a new version of the script. I already mentioned it in Barry's blog and the spup thread.

It's a Python script which generates a Bash build script. It has the ability to deblob the kernel with the Linux-libre scripts and has many improvements.

Also, it's much tidier because I replaced some strings. For example, instead of using "linux_kernel-$kernel_version-$suffix" in many places, I created a variable which stores this string, so many lines of code are shorter and clearer.

Moreover, there's a small bonus ... it patches the kernel with a patch which adds a 224-color Puppy Linux logo. People who use framebuffer consoles with enough colors should see it Cool

I already built a 5.2.5 with a previous version, but it wasn't Linux-libre. The logo appeared and it worked nicely, just like the 2.6.32.40 built by the script.

Here's the output of the latest development version (Linux-libre 2.6.32.41 with BFS):
Code:
#!/bin/sh

##########################################
#   Linux build script for Puppy Linux   #
##########################################

# the Linux version to build
LINUX_VERSION="2.6.32.41"

# the file name of the Linux sources tarball
LINUX_SOURCES_TARBALL="linux-2.6.32.41.tar.bz2"

# the Linux download mirror
LINUX_MIRROR="http://www.il.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.32"

# the Linux image and modules package name
LINUX_PACKAGE_NAME="linux_kernel"

# the Linux API headers package name
LINUX_HEADERS_PACKAGE_NAME="kernel_headers"

# the Linux sources package name
LINUX_SOURCES_PACKAGE_NAME="kernel_sources"

# the Aufs version to use
AUFS_VERSION="2.1"

# get the Linux major version number
LINUX_MAJOR_VERSION=`echo $LINUX_VERSION | cut -f 1-3 -d .`

# get the Linux release number
LINUX_RELEASE_NUMBER=`echo $LINUX_VERSION | cut -f 3 -d .`

# get the Linux minor version number
LINUX_MINOR_VERSION=`echo $LINUX_VERSION | cut -f 4 -d .`

# the package name suffix
PACKAGE_NAME_SUFFIX="${LINUX_MINOR_VERSION}-lts-libre-bfs"

# the Linux-libre scripts to use
LINUX_LIBRE_SCRIPTS="deblob-${LINUX_MAJOR_VERSION} deblob-check"

# the Linux-libre mirror to download the scripts from
LINUX_LIBRE_MIRROR="http://www.fsfla.org/svn/fsfla/software/linux-libre/scripts"

# get the build date
BUILD_DATE=`date +%d%m%Y`

# the absolute log file path                           
LOG_PATH=`pwd`/build.log

# delete old logs
[ -f "$LOG_PATH" ] && rm -f "$LOG_PATH"

# create directories for the output
mkdir -p dist/sources/{patches,vanilla}

# download the Linux sources tarball
if [ ! -f dist/sources/vanilla/$LINUX_SOURCES_TARBALL ]; then
   echo "Downloading the Linux sources tarball"
   wget -P dist/sources/vanilla $LINUX_MIRROR/$LINUX_SOURCES_TARBALL > "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to download the Linux sources tarball."
      exit 1
   fi
fi

# check whether the Linux-libre scripts are missing
download=0
for script in $LINUX_LIBRE_SCRIPTS
do
   if [ ! -f dist/sources/vanilla/$script ]
   then
      download=1
      break
   fi
done

# if at least one script is missing, download it
if [ $download -eq 1 ]
then
   echo "Downloading the Linux-libre deblob scripts"
   for script in $LINUX_LIBRE_SCRIPTS
   do
      if [ ! -f dist/sources/vanilla/$script ]
      then
         wget -P dist/sources/vanilla $LINUX_LIBRE_MIRROR/$script >> build.log 2>&1
         if [ $? -ne 0 ]
         then
            [ -f dist/sources/vanilla/$script ] && rm -f dist/sources/vanilla/$script
            echo "Error: failed to download the $script script."
            exit 1
         fi
      fi
   done   
fi

# get the full Aufs package name
AUFS_FULL_PACKAGE_NAME=aufs${AUFS_VERSION}-${LINUX_RELEASE_NUMBER}-git${BUILD_DATE}

# download the Aufs sources through git
if [ ! -f dist/sources/vanilla/${AUFS_FULL_PACKAGE_NAME}.tar.bz2 ]
then
   echo "Downloading the Aufs sources through git"
   git clone http://git.c3sl.ufpr.br/pub/scm/aufs/aufs2-standalone.git $AUFS_FULL_PACKAGE_NAME >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to download the Aufs sources through git."
      exit 1
   fi
   cd $AUFS_FULL_PACKAGE_NAME
   git checkout origin/aufs${AUFS_VERSION}-${LINUX_RELEASE_NUMBER} >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to download the Aufs sources through git."
      exit 1
   fi
   rm -rf .git
   cd ..
   echo "Creating the Aufs sources tarball"
   tar -c $AUFS_FULL_PACKAGE_NAME | bzip2 -9 > dist/sources/vanilla/${AUFS_FULL_PACKAGE_NAME}.tar.bz2
else
   echo "Extracting the Aufs sources tarball"
   tar xf dist/sources/vanilla/${AUFS_FULL_PACKAGE_NAME}.tar.bz2 >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to extract the Aufs sources tarball."
      exit 1
   fi
fi

# patch Aufs
echo "Patching the Aufs sources"
patch -d $AUFS_FULL_PACKAGE_NAME -p1 < aufs-allow-sfs.patch >> "$LOG_PATH" 2>&1
if [ $? -ne 0 ]
then
   echo "Error: failed to patch the Aufs sources."
   exit 1
fi
cp aufs-allow-sfs.patch dist/sources/patches

# extract the Linux sources tarball
echo "Extracting the Linux sources tarball"
tar xf dist/sources/vanilla/$LINUX_SOURCES_TARBALL >> "$LOG_PATH" 2>&1
if [ $? -ne 0 ]
then
   echo "Error: failed to extract the Linux sources tarball."
   exit 1
fi

echo "Deblobing the Linux sources"
echo "  creating a clean copy of the sources"
cp -r linux-${LINUX_VERSION} linux-${LINUX_VERSION}-orig
for script in $LINUX_LIBRE_SCRIPTS
do
   chmod +x dist/sources/vanilla/$script
done

echo "  deblobing"
cd linux-${LINUX_VERSION}
../dist/sources/vanilla/deblob-${LINUX_MAJOR_VERSION} > "$LOG_PATH" 2>&1
if [ $? -ne 0 ]
then
   echo "Error: failed to deblob the Linux sources."
   exit 1
fi

echo "  creating a patch"
cd ..
diff -rupN linux-${LINUX_VERSION}-orig linux-${LINUX_VERSION} > dist/sources/patches/deblob.patch
rm -rf linux-%{LINUX_VERSION}-orig

mkdir dist/packages

cd linux-${LINUX_VERSION}

echo "Cleaning the Linux sources"
make clean >> "$LOG_PATH" 2>&1
make mrproper >> "$LOG_PATH" 2>&1

echo "Creating the Linux API headers package"
echo "  checking the headers"
make headers_check >> "$LOG_PATH" 2>&1
LINUX_HEADERS_FULL_PACKAGE_NAME=${LINUX_HEADERS_PACKAGE_NAME}-${LINUX_MAJOR_VERSION}-${PACKAGE_NAME_SUFFIX}
echo "  installing the headers"
make INSTALL_HDR_PATH=$LINUX_HEADERS_FULL_PACKAGE_NAME headers_install >> "$LOG_PATH" 2>&1
echo "  removing unneeded files"
find $LINUX_HEADERS_FULL_PACKAGE_NAME/include \( -name .install -o -name ..install.cmd \) -delete
mv $LINUX_HEADERS_FULL_PACKAGE_NAME ../dist/packages

# patch the Linux sources with the Aufs patches and add the file system code itself
echo "Adding Aufs to the Linux sources"
for i in kbuild base standalone; do
   patch -p1 < ../$AUFS_FULL_PACKAGE_NAME/aufs2-$i.patch >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to add Aufs to the Linux sources."
      exit 1
   fi
done
cp -r ../$AUFS_FULL_PACKAGE_NAME/{fs,Documentation} .
cp -r ../$AUFS_FULL_PACKAGE_NAME/include/linux/aufs_type.h include/linux
cat ../$AUFS_FULL_PACKAGE_NAME/include/linux/Kbuild >> include/linux/Kbuild

echo "Resetting the minor version number"
cp Makefile Makefile-orig
sed -i s/'^EXTRAVERSION = .*$'/'EXTRAVERSION = '/ Makefile
echo "  creating a patch"
diff -up Makefile-orig Makefile > ../dist/sources/patches/extra-version.patch
rm Makefile-orig

echo "Reducing the number of consoles"
cp kernel/printk.c kernel/printk.c-orig
sed -i s/'#define MAX_CMDLINECONSOLES 8'/'#define MAX_CMDLINECONSOLES 5'/ kernel/printk.c
echo "  creating a patch"
diff -up kernel/printk.c-orig kernel/printk.c > ../dist/sources/patches/less-consoles.patch

echo "Reducing the verbosity level"
cp -f kernel/printk.c kernel/printk.c-orig
sed -i s/'#define DEFAULT_CONSOLE_LOGLEVEL 7 \/\* anything MORE serious than KERN_DEBUG \*\/'/'#define DEFAULT_CONSOLE_LOGLEVEL 3 \/\* anything MORE serious than KERN_ERR \*\/'/ kernel/printk.c
echo "  creating a patch"
diff -up kernel/printk.c-orig kernel/printk.c > ../dist/sources/patches/lower-verbosity.patch

echo "Applying patches"
for patch in ../patches/*
do
   echo "  applying $patch"
   patch -p1 < $patch >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to apply $patch on the Linux sources."
      exit 1
   fi
   cp $patch ../dist/sources/patches
done

echo "  cleaning up patch clutter"
find . -name '*.orig' -delete
find . -name '*.rej' -delete
find . -name '*~' -delete

echo "Building Linux"
cp ../DOTconfig .config
make bzImage modules >> "$LOG_PATH" 2>&1
if [[ ! -f arch/x86/boot/bzImage || ! -f System.map ]]; then
   echo "Error: failed to build Linux."
   exit 1
fi
cp .config ../dist/sources/DOTconfig-${LINUX_VERSION}-${BUILD_DATE}

echo "Creating the Linux image and modules package"
LINUX_FULL_PACKAGE_NAME=${LINUX_PACKAGE_NAME}-${LINUX_RELEASE_NUMBER}-${PACKAGE_NAME_SUFFIX}
echo "  installing the kernel modules"
make INSTALL_MOD_PATH=$LINUX_FULL_PACKAGE_NAME modules_install
echo "  removing firmware"
rm -rf $LINUX_FULL_PACKAGE_NAME/lib/firmware
echo "  removing links to the sources"
rm -f $LINUX_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION/{build,source}
ln -s $LINUX_MAJOR_VERSION $LINUX_FULL_PACKAGE_NAME/lib/modules/$LINUX_VERSION
echo "  stripping modules"
for module in `find $LINUX_FULL_PACKAGE_NAME -name *.ko -type f`
do
   strip --strip-unneeded $module > "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to strip the Linux modules."
      exit 1
   fi
done
echo "  adding the kernel image and System.map"
mkdir $LINUX_FULL_PACKAGE_NAME/boot
cp `find arch -name bzImage -type f` $LINUX_FULL_PACKAGE_NAME/boot/vmlinuz
cp System.map $LINUX_FULL_PACKAGE_NAME/boot
mv $LINUX_FULL_PACKAGE_NAME ../dist/packages

echo "Cleaning the Linux sources"
make clean >> "$LOG_PATH" 2>&1
make prepare >> "$LOG_PATH" 2>&1

cd ..

echo "Creating a Linux sources SFS extension"
LINUX_SOURCES_FULL_PACKAGE_NAME=${LINUX_SOURCES_PACKAGE_NAME}-${LINUX_RELEASE_NUMBER}-${PACKAGE_NAME_SUFFIX}
mkdir -p $LINUX_SOURCES_FULL_PACKAGE_NAME/usr/src
mv linux-${LINUX_VERSION} $LINUX_SOURCES_FULL_PACKAGE_NAME/usr/src/linux
mkdir -p $LINUX_SOURCES_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION
echo "  creating required links"
ln -s /usr/src/linux $LINUX_SOURCES_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION/build
ln -s /usr/src/linux $LINUX_SOURCES_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION/source
mksquashfs $LINUX_SOURCES_FULL_PACKAGE_NAME dist/sources/$LINUX_SOURCES_FULL_PACKAGE_NAME.sfs

echo "Compressing the log"
bzip2 -9 build.log
cp build.log.bz2 dist/sources

echo "Done!"
aplay /usr/share/sounds/2barks.au

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
Iguleder


Joined: 11 Aug 2009
Posts: 1890
Location: Israel, somewhere in the beautiful desert

PostPosted: Sat 04 Jun 2011, 13:00    Post subject:  

Here it is, the new kernel building kit. Much improved!

Features:
- A Python script which generates a kernel build script, more dynamic, more programmable.
- Support for Linux-libre deblobbing for free software lovers
- Support for firmware removal
- Patches the kernel for compatibility with all bug-fix releases of the same stable release (e.g all 2.6.32.x kernels are named "2.6.32")
- Automatically reduces the number of consoles and the kernel verbosity, to save memory and additional gray hair
- Automatically patches the kernel with a Puppy Linux logo
- Builds kernel headers and sources packages
- Strips kernel modules to reduce size
- Better!

How to use it?
- Create a directory named after the kernel branch you use (e.g 2.6.35 for 2.6.35.13) and a configuration file named DOTconfig-$kernel_version. See the 2.6.32 example.
- Run create_kit.sh and put the desired kernel version and download mirror.
- ROX will open in the output directory. Take all files from there to your desired build location and run build.sh.

Simple as A-B-C. For Linux 2.6.32.x you can skip the first step, because the kit already has the patches and the configuration file. I want to add another kernel to the kit - the more kernels I add, the easier things get. This mechanism allows Puppy kernel guys to build multiple kernel versions and track down changes.

The deblobbing needs some testing - the latest deblob-2.6.32 script broke 2.6.32.41 for some reason. It was some syntax error in a driver which got stripped by it. Also, the package creation part needs testing because so far it failed again and again as I added the more advanced features. However, an initial build of this kit produced a really solid kernel.

Here's the build script (the latest one, using it right now - it's a traditional, non-libre build with firmware) produced by it:
Code:
#!/bin/sh

######################################
# Linux build script for Puppy Linux #
######################################

################################
# Linux and Aufs configuration #
################################

# the Linux version to build
LINUX_VERSION="2.6.32.41"

# the file name of the Linux sources tarball
LINUX_SOURCES_TARBALL="linux-2.6.32.41.tar.bz2"

# the Linux download mirror
LINUX_MIRROR="http://www.il.kernel.org/pub/linux/kernel/v2.6/longterm/v2.6.32"

# the Aufs version to use
AUFS_VERSION="2.1"

################################
# Linux version number parsing #
################################

# get the Linux major version number
LINUX_MAJOR_VERSION=`echo $LINUX_VERSION | cut -f 1-3 -d .`

# get the Linux release number
LINUX_RELEASE_NUMBER=`echo $LINUX_VERSION | cut -f 3 -d .`

# get the Linux minor version number
LINUX_MINOR_VERSION=`echo $LINUX_VERSION | cut -f 4 -d .`

#########################
# package configuration #
#########################

# the Linux image and modules package name
LINUX_PACKAGE_NAME="linux_kernel"

# the Linux API headers package name
LINUX_HEADERS_PACKAGE_NAME="kernel_headers"

# the Linux sources package name
LINUX_SOURCES_PACKAGE_NAME="kernel_sources"

# the package name suffix
PACKAGE_NAME_SUFFIX="${LINUX_MINOR_VERSION}-lts-bfs"

#############
# boot logo #
#############

# the PNG image used as the boot logo
LOGO_IMAGE="/usr/share/doc/puppylogo96.png"

# the boot logo width
LOGO_WIDTH=80

# the boot logo height
LOGO_HEIGHT=80

##############################
# Output paths configuration #
##############################

# the root build directory
BUILD_ROOT=`pwd`

# the output directory
OUTPUT_DIR="$BUILD_ROOT/dist"

# the directory packages go to
PACKAGES_DIR="$OUTPUT_DIR/packages"

# the directory sources go to
SOURCES_DIR="$OUTPUT_DIR/sources"

# the directory patches go to
PATCHES_DIR="$OUTPUT_DIR/sources/patches"

# the log path                        
LOG_PATH="$BUILD_ROOT/build.log"

# get the build date
BUILD_DATE="`date +%d%m%Y`"

####################

# delete old logs
[ -f "$LOG_PATH" ] && rm -f "$LOG_PATH"

# create directories for the output
mkdir -p "$SOURCES_DIR" "$PATCHES_DIR" "$PACKAGES_DIR"

# download the Linux sources tarball
if [ ! -f "$SOURCES_DIR/$LINUX_SOURCES_TARBALL" ]; then
   echo "Downloading the Linux sources tarball"
   wget -P "$SOURCES_DIR" $LINUX_MIRROR/$LINUX_SOURCES_TARBALL > "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to download the Linux sources tarball."
      exit 1
   fi
fi

# get the full Aufs package name
AUFS_FULL_PACKAGE_NAME="aufs${AUFS_VERSION}-${LINUX_RELEASE_NUMBER}-git${BUILD_DATE}"

# download the Aufs sources through git
if [ ! -f "$SOURCES_DIR/${AUFS_FULL_PACKAGE_NAME}.tar.bz2" ]
then
   echo "Downloading the Aufs sources through git"
   git clone http://git.c3sl.ufpr.br/pub/scm/aufs/aufs2-standalone.git $AUFS_FULL_PACKAGE_NAME >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to download the Aufs sources through git."
      exit 1
   fi
   cd $AUFS_FULL_PACKAGE_NAME
   git checkout origin/aufs${AUFS_VERSION}-${LINUX_RELEASE_NUMBER} >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to download the Aufs sources through git."
      exit 1
   fi
   rm -rf .git
   cd ..
   echo "Creating the Aufs sources tarball"
   tar -c $AUFS_FULL_PACKAGE_NAME | bzip2 -9 > "$SOURCES_DIR/${AUFS_FULL_PACKAGE_NAME}.tar.bz2"
else
   echo "Extracting the Aufs sources tarball"
   tar xf "$SOURCES_DIR/${AUFS_FULL_PACKAGE_NAME}.tar.bz2" >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to extract the Aufs sources tarball."
      exit 1
   fi
fi

# patch Aufs
echo "Patching the Aufs sources"
patch -d $AUFS_FULL_PACKAGE_NAME -p1 < aufs-allow-sfs.patch >> "$LOG_PATH" 2>&1
if [ $? -ne 0 ]
then
   echo "Error: failed to patch the Aufs sources."
   exit 1
fi
cp aufs-allow-sfs.patch "$PATCHES_DIR"

# extract the Linux sources tarball
echo "Extracting the Linux sources tarball"
tar xf "$SOURCES_DIR/$LINUX_SOURCES_TARBALL" >> "$LOG_PATH" 2>&1
if [ $? -ne 0 ]
then
   echo "Error: failed to extract the Linux sources tarball."
   exit 1
fi


cd linux-${LINUX_VERSION}

echo "Cleaning the Linux sources"
make clean >> "$LOG_PATH" 2>&1
make mrproper >> "$LOG_PATH" 2>&1

# get the full Linux API headers package name
LINUX_HEADERS_FULL_PACKAGE_NAME="${LINUX_HEADERS_PACKAGE_NAME}-${LINUX_MAJOR_VERSION}-${PACKAGE_NAME_SUFFIX}"

echo "Creating the Linux API headers package"
echo "  checking the headers"
make headers_check >> "$LOG_PATH" 2>&1
echo "  installing the headers"
make INSTALL_HDR_PATH=$LINUX_HEADERS_FULL_PACKAGE_NAME headers_install >> "$LOG_PATH" 2>&1
echo "  removing unneeded files"
find $LINUX_HEADERS_FULL_PACKAGE_NAME/include \( -name .install -o -name ..install.cmd \) -delete
mv $LINUX_HEADERS_FULL_PACKAGE_NAME "$PACKAGES_DIR"

# patch the Linux sources with the Aufs patches and add the file system code itself
echo "Adding Aufs to the Linux sources"
for i in kbuild base standalone; do
   patch -p1 < ../$AUFS_FULL_PACKAGE_NAME/aufs2-$i.patch >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to add Aufs to the Linux sources."
      exit 1
   fi
done
cp -r ../$AUFS_FULL_PACKAGE_NAME/{fs,Documentation} .
cp -r ../$AUFS_FULL_PACKAGE_NAME/include/linux/aufs_type.h include/linux
cat ../$AUFS_FULL_PACKAGE_NAME/include/linux/Kbuild >> include/linux/Kbuild

echo "Resetting the minor version number"
cp Makefile Makefile-orig
sed -i s/'^EXTRAVERSION = .*$'/'EXTRAVERSION = '/ Makefile
echo "  creating a patch"
diff -up Makefile-orig Makefile > "$PATCHES_DIR/extra-version.patch"
rm Makefile-orig

echo "Reducing the number of consoles"
cp kernel/printk.c kernel/printk.c-orig
sed -i s/'#define MAX_CMDLINECONSOLES 8'/'#define MAX_CMDLINECONSOLES 5'/ kernel/printk.c
echo "  creating a patch"
diff -up kernel/printk.c-orig kernel/printk.c > "$PATCHES_DIR/less-consoles.patch"

echo "Reducing the verbosity level"
cp -f kernel/printk.c kernel/printk.c-orig
sed -i s/'#define DEFAULT_CONSOLE_LOGLEVEL 7 \/\* anything MORE serious than KERN_DEBUG \*\/'/'#define DEFAULT_CONSOLE_LOGLEVEL 3 \/\* anything MORE serious than KERN_ERR \*\/'/ kernel/printk.c
echo "  creating a patch"
diff -up kernel/printk.c-orig kernel/printk.c > "$PATCHES_DIR/lower-verbosity.patch"

echo "Applying patches"
for patch in ../patches/*
do
   echo "  applying `basename $patch`"
   patch -p1 < "$patch" >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to apply $patch on the Linux sources."
      exit 1
   fi
   cp "$patch" "$PATCHES_DIR"
done

echo "Adding the Puppy Linux boot logo"
echo "  creating a clean copy of the sources"
cp -r drivers/video/logo drivers/video/logo-orig
echo "  applying the Puppy Linux logo patch"
patch -p1 < ../puppy-logo.patch >> "$LOG_PATH" 2>&1
if [ $? -ne 0 ]
then
   echo "Error: failed to apply the Puppy Linux logo patch on the Linux sources."
   exit 1
fi

# resize the image and make the background black   
resized_image=`mktemp -u`
pngtopnm -mix -background black "$LOGO_IMAGE" | pnmscale -width $LOGO_WIDTH -height $LOGO_HEIGHT > $resized_image
if [ $? -ne 0 ]
then
   echo "Error: failed to resize ${LOGO_IMAGE}."
   exit 1
fi

# create 224-color, 16-color and monochrome variants
echo "  creating 224-color, 16-color and monochrome variants"
cat $resized_image | ppmquant 224 | pnmnoraw > drivers/video/logo/logo_puppy_clut224.ppm
cat $resized_image | ppmquant 16 | pnmnoraw > drivers/video/logo/logo_puppy_vga16.ppm
cat $resized_image | ppmquant 2 | pnmnoraw > drivers/video/logo/logo_puppy_mono.ppm

# delete the resized image
rm -f $resized_image

cd ..
echo "  creating a patch"
diff -rupN linux-${LINUX_VERSION}/drivers/video/logo-orig linux-${LINUX_VERSION}/drivers/video/logo > "$PATCHES_DIR/puppy-logo.patch"
rm -rf linux-${LINUX_VERSION}/drivers/video/logo-orig
cd linux-${LINUX_VERSION}

echo "  cleaning up patch clutter"
find . -name '*.orig' -delete
find . -name '*.rej' -delete
find . -name '*~' -delete

echo "Building Linux"
cp ../DOTconfig .config
make bzImage modules >> "$LOG_PATH" 2>&1
if [[ ! -f arch/x86/boot/bzImage || ! -f System.map ]]; then
   echo "Error: failed to build Linux."
   exit 1
fi
cp .config "$SOURCES_DIR/DOTconfig-${LINUX_VERSION}-${BUILD_DATE}"

# get the full Linux image and modules package name
LINUX_FULL_PACKAGE_NAME="${LINUX_PACKAGE_NAME}-${LINUX_RELEASE_NUMBER}-${PACKAGE_NAME_SUFFIX}"

echo "Creating the Linux image and modules package"
echo "  installing the kernel modules"
make INSTALL_MOD_PATH=$LINUX_FULL_PACKAGE_NAME modules_install
echo "  removing links to the sources"
rm -f $LINUX_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION/{build,source}
ln -s $LINUX_MAJOR_VERSION $LINUX_FULL_PACKAGE_NAME/lib/modules/$LINUX_VERSION
echo "  stripping modules"
for module in `find $LINUX_FULL_PACKAGE_NAME -name *.ko -type f`
do
   strip --strip-unneeded $module >> "$LOG_PATH" 2>&1
   if [ $? -ne 0 ]
   then
      echo "Error: failed to strip the Linux modules."
      exit 1
   fi
done
echo "  adding the kernel image and System.map"
mkdir $LINUX_FULL_PACKAGE_NAME/boot
cp `find arch -name bzImage -type f` $LINUX_FULL_PACKAGE_NAME/boot/vmlinuz
cp System.map $LINUX_FULL_PACKAGE_NAME/boot
mv $LINUX_FULL_PACKAGE_NAME "$PACKAGES_DIR"

echo "Cleaning the Linux sources"
make clean >> "$LOG_PATH" 2>&1
make prepare >> "$LOG_PATH" 2>&1

cd ..

# get the full Linux sources package name
LINUX_SOURCES_FULL_PACKAGE_NAME="${LINUX_SOURCES_PACKAGE_NAME}-${LINUX_RELEASE_NUMBER}-${PACKAGE_NAME_SUFFIX}"

echo "Creating a Linux sources SFS extension"
mkdir -p $LINUX_SOURCES_FULL_PACKAGE_NAME/usr/src
mv linux-${LINUX_VERSION} $LINUX_SOURCES_FULL_PACKAGE_NAME/usr/src/linux
mkdir -p $LINUX_SOURCES_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION
echo "  creating required links"
ln -s /usr/src/linux $LINUX_SOURCES_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION/build
ln -s /usr/src/linux $LINUX_SOURCES_FULL_PACKAGE_NAME/lib/modules/$LINUX_MAJOR_VERSION/source
mv $LINUX_SOURCES_FULL_PACKAGE_NAME "$PACKAGES_DIR"

echo "Compressing the log"
bzip2 -9 "$LOG_PATH"
cp "${LOG_PATH}.bz2" "$SOURCES_DIR"

echo "Compressing the patches"
for patch in "$PATCHES_DIR"/*
do
   bzip2 -9 "$patch"
done

echo "Done!"
aplay /usr/share/sounds/2barks.au


EDIT: forgot to mention - it won't support .0 kernels (e.g 2.6.32, 2.6.33, 2.6.34), only stable releases. That's a very logical assumption, since Puppy is a "just works" distro.
kernel-kit-001.tar.bz2
Description 
bz2

 Download 
Filename  kernel-kit-001.tar.bz2 
Filesize  115.97 KB 
Downloaded  298 Time(s) 

_________________
My homepage
Back to top
View user's profile Send private message Visit poster's website MSN Messenger 
ICQ Number 
majorfoo

Joined: 07 Mar 2011
Posts: 445
Location: Wish I knew

PostPosted: Sat 04 Jun 2011, 15:52    Post subject:  

James C wrote:
stu90 wrote:
Here is my lucid 525 EZ-woof build.

Full Lucid Puppy with updated:
kernel - 2.6.32-40-lts
flash
gnome-mplayer
geko-mediaplayer
mtpaint
lupu-update
mint openbox theme
changed icon set and wallpaper

(screen shot in my post above)
http://smokey01.com/stu90/lupu-540.iso
md5: 45c80dd429d6839875dfea8bf4febd14


Since I can't find a thread for this I'll make a quick post here. Smile Did a frugal install on the old P4 test box and everything appears to be working correctly ootb.


Stu - could you create a thread specific to lupu-540?

looks good so far -booted straight to desktop. sound working properly. added seamonkey 2.0.11, roxterm-1.17.1, deadbeef-0.42, abiword-2.90

only concern so far is networking did not autostart as it did in lupu 525
will continue testing. want to do a remaster after i load some more applications and do a full install - will advise later

thanks - majorfoo
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [43 Posts]   Goto page: Previous 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Cutting edge
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1693s ][ Queries: 13 (0.0075s) ][ GZIP on ]