use docker
This commit is contained in:
parent
a2fe5d5c82
commit
681fc21714
10
Dockerfile
Normal file
10
Dockerfile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from debian:stable
|
||||||
|
|
||||||
|
run apt-get update \
|
||||||
|
&& apt-get install -y grub2 grub-efi-amd64-bin grub-pc-bin gdisk dosfstools parted udev \
|
||||||
|
&& apt-get clean
|
||||||
|
|
||||||
|
volume /output
|
||||||
|
copy assets /assets
|
||||||
|
|
||||||
|
entrypoint ["/assets/build-image"]
|
@ -9,34 +9,35 @@ if [ -e $out ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# create the file
|
# create the file
|
||||||
truncate -s2100M $out
|
truncate -s144M $out
|
||||||
|
|
||||||
# partition it
|
# partition it
|
||||||
sgdisk \
|
sgdisk \
|
||||||
--new=0:4096:+2G --typecode=0:EF00 -c 0:boot \
|
--new=0:4096:+128M --typecode=0:EF00 -c 0:boot \
|
||||||
--new=0:0:+2M --typecode=0:EF02 -c 0:BIOS-BOOT \
|
--new=0:0:+2M --typecode=0:EF02 -c 0:BIOS-BOOT \
|
||||||
--hybrid=1:2 --print $out
|
--hybrid=1:2 --print $out
|
||||||
|
|
||||||
dev=$(losetup --find --show --partscan $out)
|
dev=$(losetup --find --show --partscan $out)
|
||||||
trap "losetup -d $dev" EXIT
|
trap "losetup -d $dev" EXIT
|
||||||
|
|
||||||
devmap=/tmp/devmap
|
|
||||||
cat >$devmap <<EOF
|
|
||||||
(hd0) $dev
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# format filesystems
|
# format filesystems
|
||||||
mkfs.vfat -n BLKBOOT ${dev}p1
|
mkfs.vfat -n BLKBOOT ${dev}p1
|
||||||
|
|
||||||
# mount
|
# mount
|
||||||
mkdir -p /mnt
|
mkdir -p /boot
|
||||||
(
|
|
||||||
mount ${dev}p1 /mnt
|
|
||||||
trap "umount /mnt" EXIT
|
|
||||||
|
|
||||||
mkdir -p /mnt/grub
|
mount ${dev}p1 /boot
|
||||||
cp /assets/grub.cfg /mnt/grub
|
trap "umount /boot" EXIT
|
||||||
|
|
||||||
grub-install --target=i386-pc --boot-directory=/mnt $dev
|
mkdir -p /boot/grub
|
||||||
grub-install --target=x86_64-efi --removable --boot-directory=/mnt --efi-directory=/mnt
|
cp /assets/grub.cfg /boot/grub
|
||||||
)
|
|
||||||
|
devmap=/boot/grub/device.map
|
||||||
|
cat >$devmap <<EOF
|
||||||
|
(hd0) $dev
|
||||||
|
EOF
|
||||||
|
|
||||||
|
grub-install --target=i386-pc $dev
|
||||||
|
grub-install --target=x86_64-efi --removable --efi-directory=/boot
|
||||||
|
|
||||||
|
rm $devmap
|
||||||
|
18
build-chroot
18
build-chroot
@ -1,18 +0,0 @@
|
|||||||
#! /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
|
|
6
build-image
Executable file
6
build-image
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
docker build -t grub-support .
|
||||||
|
docker run --privileged --rm -v $PWD/output:/output --net=host -v /dev:/dev grub-support
|
||||||
|
|
19
enter-chroot
19
enter-chroot
@ -1,19 +0,0 @@
|
|||||||
#! /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 "$@"
|
|
Loading…
Reference in New Issue
Block a user