2021-01-31 13:41:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-02-15 15:04:25 +00:00
|
|
|
echo "Createimg.sh"
|
2021-02-04 12:02:44 +00:00
|
|
|
|
2021-02-13 12:11:06 +00:00
|
|
|
rm iglunix.img
|
2021-02-13 13:24:03 +00:00
|
|
|
|
2021-02-13 12:11:06 +00:00
|
|
|
dd if=../tiny-linux-bootloader/disk of=iglunix.img
|
2021-02-13 13:24:03 +00:00
|
|
|
|
2021-02-15 15:04:25 +00:00
|
|
|
source build_utils
|
2021-02-04 12:02:44 +00:00
|
|
|
|
2021-02-13 12:11:06 +00:00
|
|
|
FILE_SIZE=$(stat -c %s iglunix.img)
|
|
|
|
echo "FILE_SIZE=${FILE_SIZE}"
|
|
|
|
PARTITION_START=$(($FILE_SIZE / 512))
|
|
|
|
PARTITION_START=$(($PARTITION_START + 1))
|
|
|
|
echo "PARTITION_START=${PARTITION_START}"
|
2021-02-04 12:02:44 +00:00
|
|
|
|
2021-02-13 12:11:06 +00:00
|
|
|
#create room for a partition
|
|
|
|
ls -al iglunix.img -h
|
2021-04-07 19:58:35 +00:00
|
|
|
dd if=/dev/zero bs=1 count=0 seek=2G of=iglunix.img
|
2021-02-13 12:11:06 +00:00
|
|
|
ls -al iglunix.img -h
|
2021-02-04 12:02:44 +00:00
|
|
|
|
2021-03-28 14:15:36 +00:00
|
|
|
echo "n
|
2021-01-30 07:29:13 +00:00
|
|
|
p
|
|
|
|
1
|
2021-02-13 12:11:06 +00:00
|
|
|
${PARTITION_START}
|
2021-03-28 13:59:57 +00:00
|
|
|
|
2021-01-30 07:29:13 +00:00
|
|
|
w
|
2021-02-10 19:00:20 +00:00
|
|
|
" | fdisk iglunix.img
|
2021-02-04 12:02:44 +00:00
|
|
|
|
2021-02-15 15:04:25 +00:00
|
|
|
PARTITION_START2=$((${PARTITION_START} * 512))
|
|
|
|
echo "PARTITION_START2: ${PARTITION_START2}"
|
|
|
|
LOOPBACK=$(losetup -o ${PARTITION_START2} -s -f iglunix.img)
|
2021-04-06 12:52:44 +00:00
|
|
|
echo "loopback interface: ${LOOPBACK}"
|
|
|
|
|
|
|
|
#ERROR IF NO LOOPBACK
|
|
|
|
[ -z "$LOOPBACK" ] && echo "loopback creation failed!" && exit -1
|
|
|
|
|
2021-02-15 15:04:25 +00:00
|
|
|
mke2fs -t ext4 -L "__IGLUNIX_ROOT" ${LOOPBACK}
|
|
|
|
|
|
|
|
ROOT=/mnt/__IGLUNIX_ROOT
|
|
|
|
umount ${ROOT}
|
|
|
|
rm -rf ${ROOT}
|
|
|
|
|
|
|
|
mkdir -p ${ROOT}
|
|
|
|
mount ${LOOPBACK} ${ROOT}
|
|
|
|
|
2021-04-07 19:58:35 +00:00
|
|
|
packages=(musl mksh bmake gmake llvm 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 util-linux linux-pam kbd)
|
2021-02-15 15:04:25 +00:00
|
|
|
cp_packages ${ROOT}
|
|
|
|
|
2021-04-08 10:27:54 +00:00
|
|
|
echo "Linked ld.lld (from llvm) to ld"
|
|
|
|
ln -s /usr/bin/ld.lld /usr/bin/ld
|
|
|
|
|
2021-03-29 18:10:56 +00:00
|
|
|
echo "Copying misc files & creating misc dirs for live-usb"
|
2021-04-07 19:35:24 +00:00
|
|
|
mkdir ${ROOT}/proc/
|
|
|
|
mkdir ${ROOT}/dev/
|
|
|
|
mkdir ${ROOT}/tmp/
|
|
|
|
mkdir ${ROOT}/sys/
|
|
|
|
|
2021-03-27 17:53:32 +00:00
|
|
|
mkdir ${ROOT}/etc/
|
2021-03-29 18:10:56 +00:00
|
|
|
mkdir ${ROOT}/root/
|
2021-03-27 17:53:32 +00:00
|
|
|
cp ./pkgs/tiny-linux-bootloader/fstab ${ROOT}/etc/fstab
|
2021-04-07 19:35:24 +00:00
|
|
|
cp /etc/hostname ${ROOT}/etc/hostname
|
|
|
|
cp /etc/passwd ${ROOT}/etc/passwd
|
2021-04-07 19:39:35 +00:00
|
|
|
touch ${ROOT}/etc/shadow
|
2021-03-27 17:53:32 +00:00
|
|
|
|
2021-02-15 15:04:25 +00:00
|
|
|
echo "Using the host keymap"
|
|
|
|
cp /etc/vconsole.conf ${ROOT}/etc/vconsole.conf
|
2021-04-06 12:52:44 +00:00
|
|
|
#TODO: this is a systemd file,
|
|
|
|
# use udev/kbd
|
2021-02-15 15:04:25 +00:00
|
|
|
|
|
|
|
echo "Unmounting & closing loopback"
|
|
|
|
|
|
|
|
umount ${ROOT}
|
2021-02-13 13:24:03 +00:00
|
|
|
|
2021-02-15 15:04:25 +00:00
|
|
|
losetup -d ${LOOPBACK}
|
2021-02-13 12:11:06 +00:00
|
|
|
exit
|
2021-02-13 13:24:03 +00:00
|
|
|
|
2021-02-10 19:00:20 +00:00
|
|
|
# losetup -o 32256 /dev/loop0 iglunix.img
|
2021-02-04 12:02:44 +00:00
|
|
|
# mkfs.vfat /dev/loop0
|
|
|
|
# mount /dev/loop0 ./isoroot
|
|
|
|
# #rm -r isoroot/*
|
|
|
|
# #cp -r isoout/* isoroot
|
|
|
|
# umount ./isoroot
|