Format partition to ext4 & cp packages there & switch_root
This commit is contained in:
parent
f5bf272992
commit
bb4afc18c9
3 changed files with 66 additions and 23 deletions
27
build_utils
Executable file
27
build_utils
Executable file
|
@ -0,0 +1,27 @@
|
|||
|
||||
|
||||
cp_packages (){
|
||||
#IMPORTANT: must be run from the folder where the iglunix repo is.
|
||||
#NOTE: this will assume that there always is a '*-dev'/'*-doc' package,\n this is not true.
|
||||
# That's why the errors are shown to some one who cares.
|
||||
|
||||
echo "Hello this is build-utils"
|
||||
|
||||
|
||||
for pkg in ${packages[@]}
|
||||
do
|
||||
if [ ! -d pkgs/${pkg}/out ]; then
|
||||
echo "NOTE: ${pkg} was not yet build, building it now"
|
||||
cd pkgs/${pkg}/
|
||||
../../iglupkg.sh
|
||||
cd ../..
|
||||
fi
|
||||
|
||||
echo "Going to copy: $pkg to $1"
|
||||
tar -xf pkgs/${pkg}/out/${pkg}.*.tar.xz -C $1
|
||||
tar -xf pkgs/${pkg}/out/${pkg}-dev.*.tar.xz -C $1 2> /dev/null
|
||||
tar -xf pkgs/${pkg}/out/${pkg}-doc.*.tar.xz -C $1 2> /dev/null
|
||||
|
||||
done
|
||||
}
|
||||
|
24
createimg.sh
24
createimg.sh
|
@ -1,9 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
echo "Createimg.sh"
|
||||
|
||||
rm iglunix.img
|
||||
|
||||
dd if=../tiny-linux-bootloader/disk of=iglunix.img
|
||||
|
||||
source build_utils
|
||||
|
||||
FILE_SIZE=$(stat -c %s iglunix.img)
|
||||
echo "FILE_SIZE=${FILE_SIZE}"
|
||||
PARTITION_START=$(($FILE_SIZE / 512))
|
||||
|
@ -24,6 +28,26 @@ ${PARTITION_START}
|
|||
w
|
||||
" | fdisk iglunix.img
|
||||
|
||||
PARTITION_START2=$((${PARTITION_START} * 512))
|
||||
echo "PARTITION_START2: ${PARTITION_START2}"
|
||||
LOOPBACK=$(losetup -o ${PARTITION_START2} -s -f iglunix.img)
|
||||
echo "LOOPBACK: ${LOOPBACK}"
|
||||
mke2fs -t ext4 -L "__IGLUNIX_ROOT" ${LOOPBACK}
|
||||
|
||||
umount /mnt/__IGLUNIX_ROOT
|
||||
rm -rf /mnt/__IGLUNIX_ROOT
|
||||
|
||||
mkdir -p /mnt/__IGLUNIX_ROOT
|
||||
mount ${LOOPBACK} /mnt/__IGLUNIX_ROOT
|
||||
|
||||
packages=(musl mksh bmake gmake libressl cmake curl rsync flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix rust toybox busybox less file pci-ids e2fsprogs)
|
||||
cp_packages /mnt/__IGLUNIX_ROOT
|
||||
|
||||
echo "Unmounting & closing loopback"
|
||||
|
||||
umount /mnt/__IGLUNIX_ROOT
|
||||
|
||||
losetup -d ${LOOPBACK}
|
||||
exit
|
||||
|
||||
# losetup -o 32256 /dev/loop0 iglunix.img
|
||||
|
|
38
geninitrd.sh
38
geninitrd.sh
|
@ -11,37 +11,29 @@
|
|||
|
||||
# Create the root fs dir
|
||||
|
||||
echo "geninitrd.sh"
|
||||
|
||||
source build_utils
|
||||
|
||||
rm -rf isoout isoroot
|
||||
mkdir isoroot
|
||||
mkdir isoout
|
||||
|
||||
|
||||
cp_packages (){
|
||||
#NOTE: this will assume that there always is a '*-dev'/'*-doc' package,\n this is not true.
|
||||
# That's why the errors are shown to some one who cares.
|
||||
for pkg in ${packages[@]}
|
||||
do
|
||||
echo "Going to copy: $pkg to $1"
|
||||
tar -xf pkgs/${pkg}/out/${pkg}.*.tar.xz -C $1
|
||||
tar -xf pkgs/${pkg}/out/${pkg}-dev.*.tar.xz -C $1 2> /dev/null
|
||||
tar -xf pkgs/${pkg}/out/${pkg}-doc.*.tar.xz -C $1 2> /dev/null
|
||||
done
|
||||
}
|
||||
# This should be a minimal number of packages, if we want fast boot times.
|
||||
# The remaining packages are in createimg.sh
|
||||
|
||||
#packages=(musl mksh bmake gmake libressl cmake curl rsync linux flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix)
|
||||
packages=(musl linux mksh busybox toybox iglunix)
|
||||
cp_packages ./isoroot
|
||||
|
||||
#packages=(musl mksh busybox toybox llvm bmake gmake libressl cmake curl rsync linux flex byacc om4 zlib samurai libffi python ca-certificates zlib expat gettext-tiny git kati netbsd-curses kakoune iglunix rust less heirloom-doctools file pci-ids)
|
||||
#cp_packages ./isoroot
|
||||
|
||||
cat >isoroot/init << EOF
|
||||
#!/bin/sh
|
||||
exec /sbin/init
|
||||
EOF
|
||||
|
||||
rm isoroot/sbin/init
|
||||
cat >isoroot/sbin/init << EOF
|
||||
cat >isoroot/sbin/init << 'EOF'
|
||||
#!/bin/sh
|
||||
|
||||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
@ -55,17 +47,17 @@ mount -t tmpfs tmpfs /tmp
|
|||
busybox mdev -s
|
||||
busybox mdev -d
|
||||
|
||||
exec /bin/sh
|
||||
|
||||
mkdir /mnt
|
||||
|
||||
# while not mount $(blkid -L IGLUNIX_BS_MEDIA) /mnt; do
|
||||
# echo "Failed to mount boot disk"
|
||||
# echo "Retrying"
|
||||
# sleep 0.5
|
||||
# done
|
||||
while ! mount $(findfs LABEL=__IGLUNIX_ROOT) /mnt; do
|
||||
echo "Failed to mount boot disk"
|
||||
echo "Retrying"
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
exec switch_root /mnt
|
||||
|
||||
echo "Starting switch_root"
|
||||
exec switch_root /mnt /bin/sh
|
||||
|
||||
EOF
|
||||
|
||||
|
|
Loading…
Reference in a new issue