assemble_image.sh 1.76 KB
Newer Older
1 2
#!/bin/bash

OSAK Buildhauer's avatar
OSAK Buildhauer committed
3
set -e
4 5
set -x

OSAK Buildhauer's avatar
OSAK Buildhauer committed
6 7 8
image_size="5G"
kubuntu="kubuntu-18.04.1-desktop-amd64.iso"
xubuntu="xubuntu-18.04.1-desktop-amd64.iso"
9
workspace="/workspace/"
10 11

# mtools, ddrescure, fdisk, grub, 7z
12 13 14 15 16 17 18 19
rm -rf "$workspace/part_files"
mkdir -p "$workspace/part_files"
git -C "$workspace/part_files" clone -b tardis https://git.fsmpi.rwth-aachen.de/osak/lipstick.git .
rsync -av /usr/lib/grub/i386-efi "$workspace/part_files"/grub
rsync -av /usr/lib/grub/i386-pc "$workspace/part_files"/grub
rsync -av /usr/share/grub/themes "$workspace/part_files"/grub
mkdir -p "$workspace/part_files"/grub/fonts/
rsync -av /usr/share/grub/unicode.pf2 "$workspace/part_files"/grub/fonts/
20

OSAK Buildhauer's avatar
OSAK Buildhauer committed
21 22
7z x "$kubuntu" -o"$workspace/part_files" EFI/
7z x "$kubuntu" -o"$workspace/part_files" boot/grub/x86_64-efi
23

24 25
mv "$workspace/part_files"/grub/* "$workspace/part_files"/boot/grub/
rm -rf "$workspace/part_files"/grub
26

OSAK Buildhauer's avatar
OSAK Buildhauer committed
27 28
cp "$kubuntu" "$workspace/part_files/kubuntu.iso"
cp "$xubuntu" "$workspace/part_files/xubuntu.iso"
29 30
./create_offlinerepo.sh "$workspace/part_files/archive" "$kubuntu" $(sed '/^#/d' packages | cut -d'|' -f 2)
cp packages "$workspace/part_files/packages"
31

32
rm -f "$workspace/part.img"
33 34 35 36 37 38 39 40
truncate -s "$image_size" "$workspace/part.img"
mkfs.vfat -n "LIPSTICK" "$workspace/part.img"
MTOOLS_SKIP_CHECK=1 mcopy -i "$workspace/part.img" -b -s -v "$workspace/part_files"/* ::
grub-mkimage --prefix "(hd0,msdos1)/boot/grub" --output "$workspace/grub.i386-pc.img" --format "i386-pc" part_msdos fat ext2 biosdisk
dd if=/usr/lib/grub/i386-pc/boot.img of="$workspace/output.img" bs=446 count=1
dd if="$workspace/grub.i386-pc.img" of="$workspace/output.img" bs=512 seek=1
ddrescue --output-position=2048s --sparse "$workspace/part.img" "$workspace/output.img"
printf "label: dos\nunit: sectors\n2048,+,b,*\n" | sfdisk "$workspace/output.img"