Both scripts create modules that follow Porteus naming patters, but add kernel version in the end (just before file extension). Example: 000-kernel-4.11.4.xzm crippled_sources-4.11.4.xzm.
Feel free to ask, suggest or change anything you want.

Here is the script that creates a kernel module and copy it to Porteus current running unit (usually the user USB stick):
Code: Select all
#set variables
porteusRootDir=`grep -q copy2ram /proc/cmdline && echo "/mnt/live/memory/copy2ram" || grep -A1 "Porteus data found in" /var/log/porteus-livedbg | tail -n1`
kernelVersion=4.11.4
#create file structure
cd v$kernelVersion/64/lib/modules/$kernelVersion-porteus
rm build
ln -s /usr/src/linux-$kernelVersion build
rm source
ln -s /usr/src/linux source
cd ../../..
mkdir kernelModule
cp -r lib/* kernelModule
#if user has kernel files outside a Linux partition then permissions will be wrong so we need to execute the command below
#sudo chown root:root -R kernelModule
#create module
dir2xzm kernelModule 000-kernel-$kernelVersion.xzm
#backup current kernel and vmlinuz
rename xzm xzm_ $porteusRootDir/base/000-*.xzm &>/dev/null
rm $porteusRootDir/../boot/syslinux/vmlinuz_ &>/dev/null
mv $porteusRootDir/../boot/syslinux/vmlinuz $porteusRootDir/../boot/syslinux/vmlinuz_
#copy new kernel and vmlinuz
cp 000-kernel-$kernelVersion.xzm $porteusRootDir/base
cp vmlinuz $porteusRootDir/../boot/syslinux/
#clean up
rm -f 000-kernel-$kernelVersion.xzm
rm -rf kernelModule
Code: Select all
#set variables
porteusRootDir=`grep -q copy2ram /proc/cmdline && echo "/mnt/live/memory/copy2ram" || grep -A1 "Porteus data found in" /var/log/porteus-livedbg | tail -n1`
kernelVersion=4.11.4
cd v$kernelVersion/64/linux-$kernelVersion
#remove useless files
rm vmlinux* &>/dev/null
find . -maxdepth 99 -type f -name ".gitignore" -delete &>/dev/null
find . -maxdepth 99 -type f -name "*.o" -delete &>/dev/null
find . -maxdepth 99 -type f -name "*.bin" -delete &>/dev/null
find . -maxdepth 99 -type f -name "*.elf" -delete &>/dev/null
find . -maxdepth 99 -type f -name "*.xz" -delete &>/dev/null
rm -rf .tmp_versions &>/dev/null
rm -rf Documentation &>/dev/null
rm -rf drivers &>/dev/null
rm -rf firmware &>/dev/null
rm -rf fs &>/dev/null
rm -rf net &>/dev/null
rm -rf sound &>/dev/null
rm arch/x86/boot/bzImage
rm arch/x86/boot/compressed/vmlinux
cp -r arch/x86 .
rm -rf arch
mkdir arch
mv x86 arch
#create file structure
cd ..
mkdir -p crippled_sources/usr/src
mv linux-$kernelVersion crippled_sources/usr/src
cd crippled_sources/usr/src
ln -s /usr/src/linux-$kernelVersion linux
cd ../../..
#create module
dir2xzm crippled_sources crippled_sources-$kernelVersion.xzm
#backup current crippled sources
rename xzm xzm_ $porteusRootDir/base/crippled_sources*.xzm &>/dev/null
#copy new crippled_sources
cp crippled_sources-$kernelVersion.xzm $porteusRootDir/base/
#clean up
rm -f crippled_sources-$kernelVersion.xzm
rm -rf crippled_sources