Reorganized the 'experimental' folder. Added 'experimental/musl' whish solves the DNS resolving issue. This should be optimized to use the newly downloaded kernel headers (if possible).
This commit is contained in:
parent
23f1725fdf
commit
130ffa2cec
10
.gitignore
vendored
10
.gitignore
vendored
@ -6,7 +6,11 @@
|
|||||||
/src/work/**
|
/src/work/**
|
||||||
/src/*.iso
|
/src/*.iso
|
||||||
|
|
||||||
/src/experimental/source/**
|
/src/experimental/toybox/source/**
|
||||||
/src/experimental/work/**
|
/src/experimental/toybox/work/**
|
||||||
/src/experimental/*.iso
|
/src/experimental/toybox/*.iso
|
||||||
|
|
||||||
|
/src/experimental/musl/source/**
|
||||||
|
/src/experimental/musl/work/**
|
||||||
|
/src/experimental/musl/*.iso
|
||||||
|
|
||||||
|
18
src/experimental/musl/.config
Normal file
18
src/experimental/musl/.config
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# You can find the latest Linux kernel source bundles here:
|
||||||
|
#
|
||||||
|
# http://kernel.org
|
||||||
|
#
|
||||||
|
KERNEL_SOURCE_URL=https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.6.tar.xz
|
||||||
|
|
||||||
|
# You can find the latest Musl source bundles here:
|
||||||
|
#
|
||||||
|
# http://musl-libc.org
|
||||||
|
#
|
||||||
|
MUSL_SOURCE_URL=http://musl-libc.org/releases/musl-1.1.11.tar.gz
|
||||||
|
|
||||||
|
# You can find the latest BusyBox source bundles here:
|
||||||
|
#
|
||||||
|
# http://busybox.net
|
||||||
|
#
|
||||||
|
BUSYBOX_SOURCE_URL=http://busybox.net/downloads/busybox-1.23.2.tar.bz2
|
||||||
|
|
8
src/experimental/musl/00_prepare.sh
Executable file
8
src/experimental/musl/00_prepare.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -rf work
|
||||||
|
mkdir work
|
||||||
|
|
||||||
|
# -p stops errors if the directory already exists
|
||||||
|
mkdir -p source
|
||||||
|
|
24
src/experimental/musl/01_get_kernel.sh
Executable file
24
src/experimental/musl/01_get_kernel.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Grab everything after the '=' character
|
||||||
|
DOWNLOAD_URL=$(grep -i KERNEL_SOURCE_URL .config | cut -f2 -d'=')
|
||||||
|
|
||||||
|
# Grab everything after the last '/' character
|
||||||
|
ARCHIVE_FILE=${DOWNLOAD_URL##*/}
|
||||||
|
|
||||||
|
cd source
|
||||||
|
|
||||||
|
# Downloading kernel file
|
||||||
|
# -c option allows the download to resume
|
||||||
|
wget -c $DOWNLOAD_URL
|
||||||
|
|
||||||
|
# Delete folder with previously extracted kernel
|
||||||
|
rm -rf ../work/kernel
|
||||||
|
mkdir ../work/kernel
|
||||||
|
|
||||||
|
# Extract kernel to folder 'work/kernel'
|
||||||
|
# Full path will be something like 'work/kernel/linux-3.16.1'
|
||||||
|
tar -xvf $ARCHIVE_FILE -C ../work/kernel
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
23
src/experimental/musl/02_build_kernel.sh
Executable file
23
src/experimental/musl/02_build_kernel.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd work/kernel
|
||||||
|
|
||||||
|
# Change to the first directory ls finds, e.g. 'linux-3.18.6'
|
||||||
|
cd $(ls -d *)
|
||||||
|
|
||||||
|
# Cleans up the kernel sources, including configuration files
|
||||||
|
make mrproper
|
||||||
|
|
||||||
|
# Create a default configuration file for the kernel
|
||||||
|
make defconfig
|
||||||
|
|
||||||
|
# Changes the name of the system
|
||||||
|
sed -i "s/.*CONFIG_DEFAULT_HOSTNAME.*/CONFIG_DEFAULT_HOSTNAME=\"minimal\"/" .config
|
||||||
|
|
||||||
|
# Compile the kernel with optimization for "parallel jobs" = "number of processors"
|
||||||
|
# Good explanation of the different kernels
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
cd ../../..
|
||||||
|
|
24
src/experimental/musl/03_get_musl.sh
Executable file
24
src/experimental/musl/03_get_musl.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Grab everything after the '=' character
|
||||||
|
DOWNLOAD_URL=$(grep -i MUSL_SOURCE_URL .config | cut -f2 -d'=')
|
||||||
|
|
||||||
|
# Grab everything after the last '/' character
|
||||||
|
ARCHIVE_FILE=${DOWNLOAD_URL##*/}
|
||||||
|
|
||||||
|
cd source
|
||||||
|
|
||||||
|
# Downloading musl file
|
||||||
|
# -c option allows the download to resume
|
||||||
|
wget -c $DOWNLOAD_URL
|
||||||
|
|
||||||
|
# Delete folder with previously extracted musl
|
||||||
|
rm -rf ../work/musl
|
||||||
|
mkdir ../work/musl
|
||||||
|
|
||||||
|
# Extract musl to folder 'work/musl'
|
||||||
|
# Full path will be something like 'work/musl/musl-1.1.11'
|
||||||
|
tar -xvf $ARCHIVE_FILE -C ../work/musl
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
18
src/experimental/musl/04_build_musl.sh
Executable file
18
src/experimental/musl/04_build_musl.sh
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd work/musl
|
||||||
|
|
||||||
|
# Change to the first directory ls finds, e.g. 'musl-1.1.11'
|
||||||
|
cd $(ls -d *)
|
||||||
|
|
||||||
|
make distclean
|
||||||
|
|
||||||
|
mkdir musl-installed
|
||||||
|
./configure --prefix=$(pwd)/musl-installed
|
||||||
|
|
||||||
|
make -j $(grep ^processor /proc/cpuinfo | wc -l)
|
||||||
|
|
||||||
|
make install -j $(grep ^processor /proc/cpuinfo | wc -l)
|
||||||
|
|
||||||
|
cd ../../..
|
||||||
|
|
62
src/experimental/musl/05_prepare_musl.sh
Executable file
62
src/experimental/musl/05_prepare_musl.sh
Executable file
@ -0,0 +1,62 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd work/kernel
|
||||||
|
cd $(ls -d *)
|
||||||
|
WORK_KERNEL_DIR=$(pwd)
|
||||||
|
cd ../../..
|
||||||
|
|
||||||
|
cd work/musl
|
||||||
|
|
||||||
|
# Change to the first directory ls finds, e.g. 'musl-1.1.11'
|
||||||
|
cd $(ls -d *)
|
||||||
|
|
||||||
|
cd musl-installed/bin
|
||||||
|
|
||||||
|
unlink musl-ar
|
||||||
|
ln -s `which ar` musl-ar
|
||||||
|
|
||||||
|
unlink musl-strip
|
||||||
|
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
|
||||||
|
|
24
src/experimental/musl/06_get_busybox.sh
Executable file
24
src/experimental/musl/06_get_busybox.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Grab everything after the '=' character
|
||||||
|
DOWNLOAD_URL=$(grep -i BUSYBOX_SOURCE_URL .config | cut -f2 -d'=')
|
||||||
|
|
||||||
|
# Grab everything after the last '/' character
|
||||||
|
ARCHIVE_FILE=${DOWNLOAD_URL##*/}
|
||||||
|
|
||||||
|
cd source
|
||||||
|
|
||||||
|
# Downloading busybox source
|
||||||
|
# -c option allows the download to resume
|
||||||
|
wget -c $DOWNLOAD_URL
|
||||||
|
|
||||||
|
# Delete folder with previously extracted busybox
|
||||||
|
rm -rf ../work/busybox
|
||||||
|
mkdir ../work/busybox
|
||||||
|
|
||||||
|
# Extract busybox to folder 'busybox'
|
||||||
|
# Full path will be something like 'work/busybox/busybox-1.23.1'
|
||||||
|
tar -xvf $ARCHIVE_FILE -C ../work/busybox
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
41
src/experimental/musl/07_build_busybox.sh
Executable file
41
src/experimental/musl/07_build_busybox.sh
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd work/musl
|
||||||
|
cd $(ls -d *)
|
||||||
|
cd musl-installed
|
||||||
|
cd bin
|
||||||
|
MUSL_BIN_DIR=$(pwd)
|
||||||
|
cd ../../../../..
|
||||||
|
|
||||||
|
cd work/busybox
|
||||||
|
|
||||||
|
# Change to the first directory ls finds, e.g. 'busybox-1.23.1'
|
||||||
|
cd $(ls -d *)
|
||||||
|
|
||||||
|
PATH_BACKUP=$PATH
|
||||||
|
PATH=$MUSL_BIN_DIR:$PATH
|
||||||
|
|
||||||
|
# Remove previously generated artifacts
|
||||||
|
make distclean
|
||||||
|
|
||||||
|
# Create a default configuration file
|
||||||
|
make defconfig
|
||||||
|
|
||||||
|
# Change the configuration, so that busybox is statically compiled
|
||||||
|
# You could do this manually with 'make menuconfig'
|
||||||
|
sed -i "s/.*CONFIG_STATIC.*/CONFIG_STATIC=y/" .config
|
||||||
|
sed -i "s/.*CONFIG_CROSS_COMPILER_PREFIX.*/CONFIG_CROSS_COMPILER_PREFIX=\"musl-\"/" .config
|
||||||
|
sed -i "s/.*CONFIG_IFPLUGD.*/CONFIG_IFPLUGD=n/" .config
|
||||||
|
sed -i "s/.*CONFIG_INETD.*/CONFIG_INETD=n/" .config
|
||||||
|
|
||||||
|
# Compile busybox with optimization for "parallel jobs" = "number of processors"
|
||||||
|
make busybox -j $(grep ^processor /proc/cpuinfo | wc -l)
|
||||||
|
|
||||||
|
# Create the symlinks for busybox
|
||||||
|
# It uses the file 'busybox.links' for this
|
||||||
|
make install
|
||||||
|
|
||||||
|
PATH=$PATH_BACKUP
|
||||||
|
|
||||||
|
cd ../../..
|
||||||
|
|
123
src/experimental/musl/08_generate_rootfs.sh
Executable file
123
src/experimental/musl/08_generate_rootfs.sh
Executable file
@ -0,0 +1,123 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd work
|
||||||
|
|
||||||
|
rm -rf rootfs
|
||||||
|
|
||||||
|
cd busybox
|
||||||
|
cd $(ls -d *)
|
||||||
|
|
||||||
|
# Copy all BusyBox generated stuff to the location of our "initramfs" folder.
|
||||||
|
cp -R _install ../../rootfs
|
||||||
|
cd ../../rootfs
|
||||||
|
|
||||||
|
# Remove "linuxrc" which is used when we boot in "RAM disk" mode.
|
||||||
|
rm -f linuxrc
|
||||||
|
|
||||||
|
# Create root FS folders
|
||||||
|
mkdir dev
|
||||||
|
mkdir etc
|
||||||
|
mkdir proc
|
||||||
|
mkdir root
|
||||||
|
mkdir src
|
||||||
|
mkdir sys
|
||||||
|
mkdir tmp
|
||||||
|
|
||||||
|
# "1" means that only the owner of a file/directory (or root) can remove it.
|
||||||
|
chmod 1777 tmp
|
||||||
|
|
||||||
|
cd etc
|
||||||
|
|
||||||
|
# The script "/etc/bootscript.sh" is automatically executed as part of the
|
||||||
|
# "init" proess. We suppress most kernel messages, mount all crytical file
|
||||||
|
# systems, loop through all available network devices and we configure them
|
||||||
|
# through DHCP.
|
||||||
|
cat > bootscript.sh << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
dmesg -n 1
|
||||||
|
mount -t devtmpfs none /dev
|
||||||
|
mount -t proc none /proc
|
||||||
|
mount -t sysfs none /sys
|
||||||
|
|
||||||
|
for DEVICE in /sys/class/net/* ; do
|
||||||
|
ip link set \${DEVICE##*/} up
|
||||||
|
[ \${DEVICE##*/} != lo ] && udhcpc -b -i \${DEVICE##*/} -s /etc/rc.dhcp
|
||||||
|
done
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x bootscript.sh
|
||||||
|
|
||||||
|
# The script "/etc/rc.dhcp" is automatically invoked for each network device.
|
||||||
|
cat > rc.dhcp << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
ip addr add \$ip/\$mask dev \$interface
|
||||||
|
|
||||||
|
if [ "\$router" ]; then
|
||||||
|
ip route add default via \$router dev \$interface
|
||||||
|
fi
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x rc.dhcp
|
||||||
|
|
||||||
|
# DNS resolving is done by using Google's public DNS servers
|
||||||
|
cat > resolv.conf << EOF
|
||||||
|
nameserver 8.8.8.8
|
||||||
|
nameserver 8.8.4.4
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# The file "/etc/welcome.txt" is displayed on every boot of the system in each
|
||||||
|
# available terminal.
|
||||||
|
cat > welcome.txt << EOF
|
||||||
|
|
||||||
|
#####################################
|
||||||
|
# #
|
||||||
|
# Welcome to "Minimal Linux Live" #
|
||||||
|
# #
|
||||||
|
#####################################
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# The file "/etc/inittab" contains the configuration which defines how the
|
||||||
|
# system will be initialized. Check the following URL for more details:
|
||||||
|
# http://git.busybox.net/busybox/tree/examples/inittab
|
||||||
|
cat > inittab << EOF
|
||||||
|
::sysinit:/etc/bootscript.sh
|
||||||
|
::restart:/sbin/init
|
||||||
|
::ctrlaltdel:/sbin/reboot
|
||||||
|
::once:cat /etc/welcome.txt
|
||||||
|
::respawn:/bin/cttyhack /bin/sh
|
||||||
|
tty2::once:cat /etc/welcome.txt
|
||||||
|
tty2::respawn:/bin/sh
|
||||||
|
tty3::once:cat /etc/welcome.txt
|
||||||
|
tty3::respawn:/bin/sh
|
||||||
|
tty4::once:cat /etc/welcome.txt
|
||||||
|
tty4::respawn:/bin/sh
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# The "/init" script passes the execution to "/sbin/init" which in turn looks
|
||||||
|
# for the configuration file "/etc/inittab".
|
||||||
|
cat > init << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec /sbin/init
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x init
|
||||||
|
|
||||||
|
# Copy all source files to "/src". Note that the scripts won't work there.
|
||||||
|
cp ../../*.sh src
|
||||||
|
cp ../../.config src
|
||||||
|
chmod +r src/*.sh
|
||||||
|
chmod +r src/.config
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
|
14
src/experimental/musl/build_minimal_linux_live.sh
Executable file
14
src/experimental/musl/build_minimal_linux_live.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
sh 00_prepare.sh
|
||||||
|
sh 01_get_kernel.sh
|
||||||
|
sh 02_build_kernel.sh
|
||||||
|
sh 03_get_musl.sh
|
||||||
|
sh 04_build_musl.sh
|
||||||
|
sh 05_prepare_musl.sh
|
||||||
|
sh 06_get_busybox.sh
|
||||||
|
sh 07_build_busybox.sh
|
||||||
|
sh 08_generate_rootfs.sh
|
||||||
|
sh 09_pack_rootfs.sh
|
||||||
|
sh 10_generate_iso.sh
|
||||||
|
|
14
src/experimental/toybox/6_pack_rootfs.sh
Executable file
14
src/experimental/toybox/6_pack_rootfs.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd work
|
||||||
|
|
||||||
|
# Remove the old initramfs archive if it exists.
|
||||||
|
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
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
|
19
src/experimental/toybox/7_generate_iso.sh
Executable file
19
src/experimental/toybox/7_generate_iso.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -f minimal_linux_live.iso
|
||||||
|
|
||||||
|
cd work/kernel
|
||||||
|
cd $(ls -d *)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
cp arch/x86/boot/image.iso ../../../minimal_linux_live.iso
|
||||||
|
|
||||||
|
cd ../../..
|
||||||
|
|
4
src/experimental/toybox/qemu32.sh
Executable file
4
src/experimental/toybox/qemu32.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
qemu-system-i386 -cdrom minimal_linux_live.iso
|
||||||
|
|
4
src/experimental/toybox/qemu64.sh
Executable file
4
src/experimental/toybox/qemu64.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
qemu-system-x86_64 -cdrom minimal_linux_live.iso
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user