forked from warewulf/warewulf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ipxe-update.sh
executable file
·111 lines (91 loc) · 2.13 KB
/
ipxe-update.sh
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
#!/bin/sh
# Builds ipxe binaries from github sources or given tarball
VERSION=v1.21.1
ARCH=x86_64
PCBIOS=bin-${ARCH}-pcbios/undionly.kpxe
EFI=bin-${ARCH}-efi/ipxe.efi
PCBIOS_output=`pwd`/staticfiles/${ARCH}.kpxe
EFI_output=`pwd`/staticfiles/${ARCH}.efi
SYSBIOS="/usr/share/ipxe/undionly.kpxe"
SYSEFI="/usr/share/ipxe/ipxe-${ARCH}.efi"
TMPDIR=`mktemp -d /tmp/ipxebuild.XXXXXX`
usage() {
echo "Usage: $(basename $0)
[-s] (install efi and bios from system location)
[-g] (build from git repo and install built efi and bios)
[-h] (help)
[-f] ipxe_source_gz_file (build from given tar.gz ipxe file and install built efi and bios)
"
exit 1
}
sysbuild() {
if [ -f "${SYSEFI}" ] ; then
cp $SYSEFI $EFI_output
else
echo "No such file or directory: ${SYSEFI}, try 'dnf install ipxe-bootimgs-x86'"
exit 1
fi
if [ -f "${SYSBIOS}" ] ; then
cp $SYSBIOS $PCBIOS_output
else
echo "No such file or directory: ${SYSBIOS}, try 'dnf install ipxe-bootimgs-x86'"
exit 1
fi
echo "copy ${SYSEFI} and ${SYSBIOS} done"
}
gitbuild() {
cd "$TMPDIR"
git clone --depth 1 --branch $VERSION https://github.com/ipxe/ipxe.git
build
}
filebuild() {
TARGET_PATH=$1
case $TARGET_PATH in
/*) ;;
*)
TARGET_PATH=`pwd`/$TARGET_PATH
;;
esac
if [ -f "${TARGET_PATH}" ] ; then
cd "$TMPDIR"
tar xzf $TARGET_PATH
build $TARGET_PATH
else
echo "No such file $TARGET_PATH"
exit 1
fi
}
build() {
cd ipxe*/src
sed -i.bak \
-e 's,//\(#define.*CONSOLE_SERIAL.*\),\1,' \
-e 's,//\(#define.*CONSOLE_FRAMEBUFFER.*\),\1,' \
config/console.h
sed -i.bak \
-e 's,//\(#define.*IMAGE_ZLIB.*\),\1,' \
-e 's,//\(#define.*IMAGE_GZIP.*\),\1,' \
-e 's,//\(#define.*VLAN_CMD.*\),\1,' \
config/general.h
make -j 8 $PCBIOS "$@"
make -j 8 $EFI "$@"
cp $PCBIOS $PCBIOS_output
cp $EFI $EFI_output
echo "copy ${PCBIOS} and ${EFI} done"
}
while getopts 'sghdf:' c
do
case $c in
s) sysbuild
break
;;
g) gitbuild
break
;;
f) filebuild $OPTARG
break
;;
h|*) usage
;;
esac
done
rm -rf "$TMPDIR"