-
Notifications
You must be signed in to change notification settings - Fork 1
/
iso
152 lines (125 loc) · 3.53 KB
/
iso
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/env zsh
# shellcheck shell=bash
# Copyright (c) 2016-2021 Ivan J. <parazyd@dyne.org>
# 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)
iso_prepare_strap()
{
fn iso_prepare_strap
req=(strapdir)
ckreq || return 1
notice "Preparing strapdir for Live CD"
cat <<EOF | sudo tee "$strapdir/isoprep" >/dev/null
#!/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
EOF
chroot-script -d isoprep || { zerr; return 1; }
}
iso_setup_isolinux()
{
fn iso_setup_isolinux
req=(workdir strapdir)
ckreq || return 1
notice "Setting up isolinux"
pushd "$workdir" || { zerr; return 1; }
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; }
popd
}
iso_write_isolinux_cfg()
{
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
ui vesamenu.c32
prompt 0
menu title ${os} boot menu
timeout 300
label live-${arch}
menu label ^${os} live (${arch})
menu default
linux /live/vmlinuz
append initrd=/live/initrd.img boot=live
endtext
EOF
}
iso_squash_strap()
{
fn iso_squash_strap
req=(workdir strapdir)
ckreq || return 1
notice "Creating squashfs out of strapdir"
case "$arch" in
amd64|i386)
_compfilt="-Xbcj x86"
;;
arm*)
_compfilt="-Xbcj arm"
;;
*)
_compfilt=""
;;
esac
pushd "$workdir" || { zerr; return 1; }
sudo mksquashfs "$strapdir" binary/live/filesystem.squashfs \
-comp xz ${=_compfilt} -noappend || { zerr; return 1; }
popd
}
iso_xorriso_build()
{
fn iso_xorriso_build
req=(workdir image_name)
ckreq || return 1
notice "Building iso..."
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"
mkdir -p "$R/dist"
pushd "$workdir"
sudo xorriso -as mkisofs -r -J -joliet-long -l \
-isohybrid-mbr "$isohybrid" \
-partition_offset 16 \
-A "${os} Live - ${arch}" \
-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; }
popd
act "Calculating sha256 checksums"
pushd "$R/dist" || { zerr; return 1; }
sha256sum "$isoname" > "${isoname}.sha256"
popd
if [[ "$DEBUG" = 1 ]]; then
return
fi
sudo rm -rf "$workdir"
notice "Done! Thanks for being patient!"
}