forked from SFSLiveBoot/LiveBootUtils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-iso.sh
More file actions
executable file
·85 lines (73 loc) · 2.16 KB
/
Copy pathbuild-iso.sh
File metadata and controls
executable file
·85 lines (73 loc) · 2.16 KB
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
#!/bin/sh
set -e
: ${lbu:=/opt/LiveBootUtils}
: ${lbu:=$(dirname "$0")}
: ${arch:=$(uname -m)}
while true;do
case "$1" in
--pause|-p) pause=1;;
--append) append="$2"; shift;;
--serial-console) ser_cons="$2"; shift;;
*) break;;
esac
shift
done
iso="$1"
test -n "$2" || {
cat >&2 <<EOF
Usage: ${0##*/} [<options..>] <out.iso> <sources.sfs..>
Options:
-p (or --pause) Pause before build, allowing changes to be made
--append <string> Append to kernel commandline (in grub.cfg)
--serial-console <digit> Define serial console to use during boot
EOF
exit 1
}
shift 1
test ! -e "$iso" || {
echo "$iso already exists, aborting" >&2
exit 1
}
iso_d=$(mktemp -d /tmp/build-iso.XXXXXX)
rm_tmp() { echo -n "Removing '$iso_d' .. "; rm -r "$iso_d"; echo "done."; }
trap rm_tmp EXIT
for fname;do
: ${files_top:=$(dirname "$fname")}
: ${dist:=$(basename "$files_top")}
dest_name="${fname#$files_top/}"
mkdir -p "$(dirname "$iso_d/$dist/$dest_name")"
case "$dest_name" in
$arch/[0-9][0-9]-kernel-*.sfs)
kver="${dest_name#$arch/[0-9][0-9]-kernel-}"
kver="${kver%.sfs}"
dst="$iso_d/$dist/$arch" find "$(readlink -f "$(dirname "$fname")")" -maxdepth 1 \( -name "vmlinuz-$kver" -o -name "ramdisk*$kver" \) -exec sh -c 'for f;do ln -vs "$f" "$dst";done' _ {} +
;;
*/*)
dname="${dest_name%/*}"
case " $extras " in
*" $dname "*) ;;
*) extras="${extras+$extras }$dname";;
esac
;;
esac
ln -vs "$(readlink -f "$fname")" "$iso_d/$dist/$dest_name"
done
for comp in vmlinuz ramdisk;do
test -e "$iso_d/$dist/$arch/$comp-$kver" || {
echo "Required file $comp-$kver not found, aborting. Did you specify correct XX-kernel-KVER.sfs in commandline?" >&2
exit 1
}
done
dq='"'
cat >"$iso_d/grubvars.cfg" <<EOF
set dist="$dist"
set arch="$arch"
set kver="$kver"
${extras+set extras=$dq$extras$dq}
${ser_cons+set ser_cons=$dq$ser_cons$dq}
${append+set append=$dq$append$dq}
EOF
mkdir -p "$iso_d/boot/grub"
ln -s "$lbu/scripts/grub.cfg" "$iso_d/boot/grub"
test -z "$pause" || { echo -n "Press ENTER to build '$iso' from '$iso_d' .. "; read x; }
grub-mkrescue -o "$iso" "$iso_d" -- -f -v