#!/bin/bash set -e set -x image_size="7G" kubuntu="kubuntu-19.10-beta-desktop-amd64.iso" xubuntu="xubuntu-19.10-beta-desktop-amd64.iso" old_buntu="xubuntu-18.04.3-desktop-amd64.iso" workspace="/workspace" # mtools, ddrescure, fdisk, grub, 7z 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/ 7z x "$old_buntu" -o"$workspace/part_files" EFI/ 7z x "$old_buntu" -o"$workspace/part_files" boot/grub/x86_64-efi mv "$workspace/part_files"/grub/* "$workspace/part_files"/boot/grub/ rm -rf "$workspace/part_files"/grub rsync --size-only --checksum "$kubuntu" "$workspace/part_files/" rsync --size-only --checksum "$xubuntu" "$workspace/part_files/" source ./grub_config.sh # functions to fill grub_template.cfg cp grub_template.cfg "$workspace/part_files/boot/grub/grub.cfg" fill_grub_config_template "$kubuntu" "KDE" "$workspace/part_files/boot/grub/grub.cfg" fill_grub_config_template "$xubuntu" "XFCE" "$workspace/part_files/boot/grub/grub.cfg" wget -nc -P "$workspace/part_files/" https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.0.5/linux-headers-5.0.5-050005_5.0.5-050005.201903271212_all.deb wget -nc -P "$workspace/part_files/" https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.0.5/linux-image-unsigned-5.0.5-050005-generic_5.0.5-050005.201903271212_amd64.deb wget -nc -P "$workspace/part_files/" https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.0.5/linux-modules-5.0.5-050005-generic_5.0.5-050005.201903271212_amd64.deb ./create_offlinerepo.sh "$workspace/part_files/archives" "$kubuntu" $(grep '^[^#]' packages | cut -d'|' -f 2) ./create_offlinerepo.sh "$workspace/part_files/archives" "$xubuntu" $(grep '^[^#]' packages | cut -d'|' -f 2) cp packages "$workspace/part_files/packages" echo "ubiquity ubiquity/keep-installed string $(grep '^[^#]' packages | cut -d'|' -f 2 | tr '\n' ' ')" >> "$workspace/part_files/preseed/lip.seed" rm -f "$workspace/part.img" 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"/* "$workspace/part_files"/.git :: 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" echo "Used $(du -s -h "$workspace/part_files" | cut -f1) of ${image_size}"