initial commit

This commit is contained in:
Mikaël Cluseau 2019-02-06 14:34:03 +11:00
commit 169edc5c49
5 changed files with 92 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/output
/chroot

42
assets/build-image Executable file
View File

@ -0,0 +1,42 @@
#! /bin/bash
set -ex
out=/output/grub-intel.raw
if [ -e $out ]; then
rm $out
fi
# create the file
truncate -s2100M $out
# partition it
sgdisk \
--new=0:4096:+2G --typecode=0:EF00 -c 0:boot \
--new=0:0:+2M --typecode=0:EF02 -c 0:BIOS-BOOT \
--hybrid=1:2 --print $out
dev=$(losetup --find --show --partscan $out)
trap "losetup -d $dev" EXIT
devmap=/tmp/devmap
cat >$devmap <<EOF
(hd0) $dev
EOF
# format filesystems
mkfs.vfat -n BLKBOOT ${dev}p1
# mount
mkdir -p /mnt
(
mount ${dev}p1 /mnt
trap "umount /mnt" EXIT
mkdir -p /mnt/grub
cp /assets/grub.cfg /mnt/grub
grub-install --target=i386-pc --boot-directory=/mnt $dev
grub-install --target=x86_64-efi --removable --boot-directory=/mnt --efi-directory=/mnt
)

11
assets/grub.cfg Normal file
View File

@ -0,0 +1,11 @@
search --no-floppy --set=root --part-label boot --hint $root
insmod all_video
set timeout=3
set bootdev=PARTNAME=boot
menuentry "Direktil" {
linux /current/vmlinuz direktil.boot=$bootdev
initrd /current/initrd
}

18
build-chroot Executable file
View File

@ -0,0 +1,18 @@
#! /bin/bash
set -ex
if ! [ -d chroot ]; then
mkdir chroot
debootstrap --arch amd64 testing chroot http://http.debian.net/debian/
fi
if ! [ -e chroot/usr/sbin/grub-mkconfig ]; then
chroot chroot <<EOF
set -ex
apt-get update
yes |apt-get install -y grub2 grub-efi-amd64-bin grub-pc-bin gdisk dosfstools
EOF
fi
rsync -av --delete assets chroot

19
enter-chroot Executable file
View File

@ -0,0 +1,19 @@
#! /bin/bash
cleanup() {
umount -R chroot
}
set -ex
mkdir -p chroot/{dev,proc,sys,output} output
mount --bind chroot chroot
mount --bind output chroot/output
mount --bind /dev chroot/dev
mount --bind /proc chroot/proc
mount --bind /sys chroot/sys
trap cleanup EXIT
chroot chroot "$@"