Skip to content
Browse files
Headers are reused rom the downloaded kernel. ISO image is generated …
…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 1ca057ee0b86512a7e97f74baf5e06e54ce21084
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 52 deletions.
@@ -19,5 +19,8 @@ sed -i "s/.*CONFIG_DEFAULT_HOSTNAME.*/CONFIG_DEFAULT_HOSTNAME=\"minimal\"/" .con
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 ../../..

@@ -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 ]
unlink asm
ln -s /usr/include/asm asm
unlink asm
ln -s /usr/include/asm-generic asm

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

@@ -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 ../..

@@ -1,19 +1,53 @@

rm -f minimal_linux_live.iso

cd work/kernel
cd $(ls -d *)
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 .
if [ $i = end ]; then exit 1; fi;

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

# 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 initrd=rootfs.gz' > ./isolinux.cfg

# Now we generate the ISO image file
genisoimage -J -r -o ../minimal_linux_live.iso -b isolinux.bin -c -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.