libdevuansdk/zlibs/iso

153 lines
3.5 KiB
Plaintext
Raw Permalink Normal View History

2016-10-17 15:52:00 +00:00
#!/usr/bin/env zsh
# shellcheck shell=bash
2020-12-23 08:10:47 +00:00
# Copyright (c) 2016-2021 Ivan J. <parazyd@dyne.org>
2016-10-17 15:52:00 +00:00
# This file is part of libdevuansdk
#
# This source code is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this source code. If not, see <http://www.gnu.org/licenses/>.
vars+=(MKEFI)
2016-10-17 15:52:00 +00:00
iso_prepare_strap()
{
2016-10-17 15:52:00 +00:00
fn iso_prepare_strap
req=(strapdir)
ckreq || return 1
notice "Preparing strapdir for Live CD"
2016-10-17 15:52:00 +00:00
cat <<EOF | sudo tee "$strapdir/isoprep" >/dev/null
2016-10-17 15:52:00 +00:00
#!/bin/sh
apt-get update
apt-get --yes --force-yes install dialog live-boot live-boot-initramfs-tools || exit 1
apt-get --yes --force-yes --purge autoremove || exit 1
2016-10-17 15:52:00 +00:00
EOF
2016-12-18 12:19:45 +00:00
chroot-script -d isoprep || { zerr; return 1; }
2016-10-17 15:52:00 +00:00
}
iso_setup_isolinux()
{
2016-10-17 15:52:00 +00:00
fn iso_setup_isolinux
req=(workdir strapdir)
ckreq || return 1
notice "Setting up isolinux"
2016-10-17 15:52:00 +00:00
pushd "$workdir" || { zerr; return 1; }
2016-10-17 15:52:00 +00:00
sudo mkdir -p binary/{live,isolinux}
act "Copyring kernel and initrd"
sudo cp "$strapdir/boot/"vmlinuz* binary/live/vmlinuz || { zerr; return 1; }
sudo cp "$strapdir/boot/"initrd* binary/live/initrd.img || { zerr; return 1; }
#sudo cp "$strapdir/boot/memtest86+.bin binary/live/memtest || { zerr; return 1; }
sudo cp "$R/extra/syslinux/isolinux.bin" binary/isolinux || { zerr; return 1; }
sudo cp "$R"/extra/syslinux/*.c32 binary/isolinux || { zerr; return 1; }
2016-10-17 15:52:00 +00:00
popd
}
iso_write_isolinux_cfg()
{
2016-10-17 15:52:00 +00:00
fn iso_write_isolinux_cfg
req=(workdir arch os)
ckreq || return 1
notice "Writing isolinux configuration"
cat <<EOF | sudo tee "$workdir/binary/isolinux/isolinux.cfg" >/dev/null
2016-10-19 11:06:57 +00:00
ui vesamenu.c32
2016-10-17 15:52:00 +00:00
prompt 0
menu title ${os} boot menu
timeout 300
label live-${arch}
2017-02-23 14:06:28 +00:00
menu label ^${os} live (${arch})
2016-10-17 15:52:00 +00:00
menu default
linux /live/vmlinuz
append initrd=/live/initrd.img boot=live
2016-10-17 15:52:00 +00:00
endtext
EOF
}
iso_squash_strap()
{
2016-10-17 15:52:00 +00:00
fn iso_squash_strap
req=(workdir strapdir)
ckreq || return 1
notice "Creating squashfs out of strapdir"
2016-10-17 15:52:00 +00:00
2017-12-16 19:35:23 +00:00
case "$arch" in
amd64|i386)
_compfilt="-Xbcj x86"
;;
arm*)
_compfilt="-Xbcj arm"
;;
*)
_compfilt=""
;;
2017-12-16 19:35:23 +00:00
esac
2017-09-25 10:17:36 +00:00
pushd "$workdir" || { zerr; return 1; }
sudo mksquashfs "$strapdir" binary/live/filesystem.squashfs \
-comp xz ${=_compfilt} -noappend || { zerr; return 1; }
2016-10-17 15:52:00 +00:00
popd
}
iso_xorriso_build()
{
2016-10-17 15:52:00 +00:00
fn iso_xorriso_build
req=(workdir image_name)
ckreq || return 1
notice "Building iso..."
2016-10-17 15:52:00 +00:00
isoname="${image_name}-live.iso"
if [[ -n "$MKEFI" ]]; then
uefi_opt="-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot"
fi
isohybrid="$R/extra/syslinux/isohdpfx.bin"
2017-05-15 16:50:57 +00:00
mkdir -p "$R/dist"
pushd "$workdir"
sudo xorriso -as mkisofs -r -J -joliet-long -l \
-isohybrid-mbr "$isohybrid" \
2016-10-17 15:52:00 +00:00
-partition_offset 16 \
-A "${os} Live - ${arch}" \
2016-10-17 15:52:00 +00:00
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
${=uefi_opt} \
-o "$R/dist/$isoname" \
binary || { zerr; return 1; }
2016-10-17 15:52:00 +00:00
popd
act "Calculating sha256 checksums"
pushd "$R/dist" || { zerr; return 1; }
sha256sum "$isoname" > "${isoname}.sha256"
popd
2016-10-19 11:06:57 +00:00
if [[ "$DEBUG" = 1 ]]; then
return
fi
2016-10-19 11:06:57 +00:00
sudo rm -rf "$workdir"
2016-10-19 11:06:57 +00:00
notice "Done! Thanks for being patient!"
2016-10-19 11:06:57 +00:00
}