Skip to content

Commit

Permalink
Headers are reused rom the downloaded kernel. ISO image is generated …
Browse files Browse the repository at this point in the history
…in custom shell script.

This commit is prerequisite for major switch from glibc to musl.
  • Loading branch information
ivandavidov committed Jan 24, 2016
1 parent 8b96da4 commit 1ca057e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
3 changes: 3 additions & 0 deletions src/experimental/musl-busybox/02_build_kernel.sh
Expand Up @@ -19,5 +19,8 @@ sed -i "s/.*CONFIG_DEFAULT_HOSTNAME.*/CONFIG_DEFAULT_HOSTNAME=\"minimal\"/" .con
# http://unix.stackexchange.com/questions/5518/what-is-the-difference-between-the-following-kernel-makefile-terms-vmlinux-vmlinux
make bzImage -j $(grep ^processor /proc/cpuinfo | wc -l)

# We need the kernel headers later, so we install them now in ./usr (this is not /usr)
make headers_install -j $(grep ^processor /proc/cpuinfo | wc -l)

cd ../../..

50 changes: 9 additions & 41 deletions src/experimental/musl-busybox/05_prepare_musl.sh
Expand Up @@ -12,51 +12,19 @@ cd $(ls -d *)

cd musl-installed/bin

unlink musl-ar
unlink musl-ar 2>/dev/null
ln -s `which ar` musl-ar

unlink musl-strip
unlink musl-strip 2>/dev/null
ln -s `which strip` musl-strip

cd ../include

#
# Should work with headers from the newly downloaded kernel
# but it diesn't work. Damn!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#unlink linux
#ln -s $WORK_KERNEL_DIR/include/linux linux
#
#unlink mtd
#ln -s $WORK_KERNEL_DIR/include/linux/mtd mtd
#
#unlink asm
#ln -s $WORK_KERNEL_DIR/include/uapi/asm-generic asm
#
#unlink asm-generic
#ln -s $WORK_KERNEL_DIR/include/uapi/asm-generic asm-generic
#
#unlink uapi
#ln -s $WORK_KERNEL_DIR/include/uapi uapi
#
#unlink uapi
#ln -s $WORK_KERNEL_DIR/include/uapi uapi

unlink linux
ln -s /usr/include/linux linux

unlink mtd
ln -s /usr/include/mtd mtd

if [ -d /usr/include/asm ]
then
unlink asm
ln -s /usr/include/asm asm
else
unlink asm
ln -s /usr/include/asm-generic asm
fi

unlink asm-generic
ln -s /usr/include/asm-generic asm-generic
# Copy all kernel headers to musl's 'include' folder
cp -rf $WORK_KERNEL_DIR/usr/include/* .

# Make sure some C structs are not defined in kernel headers if thgey are already defined in musl
sed -i "s/^\#if.__UAPI_DEF_IN6_ADDR$/#if !defined(_NETINET_IN_H) \&\& defined(__UAPI_DEF_IN6_ADDR)/" ./linux/in6.h
sed -i "s/^\#if.__UAPI_DEF_SOCKADDR_IN6$/#if !defined(_NETINET_IN_H) \&\& defined(__UAPI_DEF_SOCKADDR_IN6)/" ./linux/in6.h
sed -i "s/^\#if.__UAPI_DEF_IPV6_MREQ$/#if !defined(_NETINET_IN_H) \&\& defined(__UAPI_DEF_IPV6_MREQ)/" ./linux/in6.h

2 changes: 1 addition & 1 deletion src/experimental/musl-busybox/09_pack_rootfs.sh
Expand Up @@ -8,7 +8,7 @@ rm -f rootfs.cpio.gz
cd rootfs

# Packs the current folder structure in "cpio.gz" archive.
find . | cpio -H newc -o | gzip > ../rootfs.cpio.gz
find . | cpio -R root:root -H newc -o | gzip > ../rootfs.cpio.gz

cd ../..

54 changes: 44 additions & 10 deletions src/experimental/musl-busybox/10_generate_iso.sh
@@ -1,19 +1,53 @@
#!/bin/sh

rm -f minimal_linux_live.iso

cd work/kernel
cd $(ls -d *)
WORK_KERNEL_DIR=$(pwd)
cd ../../..

# Edit Makefile to look for genisoimage instead of mkisofs. This was added as a
# workaround for some "Debian" and "Arch Linux" distributions. In general this
# fix should be harmless.
sed -i 's/mkisofs/genisoimage/g' arch/x86/boot/Makefile
rm -f minimal_linux_live.iso
rm -rf work/isoimage

# Generate the ISO image with optimization for "parallel jobs" = "number of processors"
make isoimage FDINITRD=../../rootfs.cpio.gz -j $(grep ^processor /proc/cpuinfo | wc -l)
# This is the root folder of the ISO image
mkdir work/isoimage
cd work/isoimage

cp arch/x86/boot/image.iso ../../../minimal_linux_live.iso
# Search and copy the files 'isolinux.bin' and 'ldlinux.c32'
for i in lib lib64 share end ; do
if [ -f /usr/$i/syslinux/isolinux.bin ]; then
cp /usr/$i/syslinux/isolinux.bin .
if [ -f /usr/$i/syslinux/ldlinux.c32 ]; then
cp /usr/$i/syslinux/ldlinux.c32 .
fi;
break;
fi;
if [ $i = end ]; then exit 1; fi;
done

cd ../../..
# Now we copy the kernel
cp $WORK_KERNEL_DIR/arch/x86/boot/bzImage ./kernel.bz

# Now we copy the root file system
cp ../rootfs.cpio.gz ./rootfs.gz

# Copy all source files to "/src". Note that the scripts won't work there.
mkdir src
cp ../../*.sh src
cp ../../.config src
chmod +rx src/*.sh
chmod +r src/.config

# Create ISOLINUX configuration file
echo 'default kernel.bz initrd=rootfs.gz' > ./isolinux.cfg

# Now we generate the ISO image file
genisoimage -J -r -o ../minimal_linux_live.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ./

# This allows the ISO image to be bootable if it is burned on USB flash drive
isohybrid ../minimal_linux_live.iso 2>/dev/null || true

# Copy the ISO image to the root project folder
cp ../minimal_linux_live.iso ../../

cd ../..

0 comments on commit 1ca057e

Please sign in to comment.