forked from theforeman/foreman-discovery-image
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-livecd
executable file
·40 lines (32 loc) · 1.01 KB
/
build-livecd
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
#!/bin/bash
[[ -z "$1" ]] && echo "Usage: $0 fdi-name.ks [RELEASE_NUMBER] [VERSION]" && exit 1
which git date base64 ksflatten >/dev/null || ( echo "Command(s) missing, install required tools" && exit 2 )
RELEASE=$(date +%Y%m%d).${2:-1}
VERSION=${3:-$(git describe --abbrev=0 --tags)}
KS_INSTALL=fdi-install.ks
KS_TARGET=fdi-image.ks
# prepare version and release files
echo "$VERSION" > root/usr/share/fdi/VERSION
echo "$RELEASE" > root/usr/share/fdi/RELEASE
OVERLAY=$(find root -type f | cut -c 5-)
# generate install overlay
echo "# <generated by build-livecd>" > $KS_INSTALL
for FILE in $OVERLAY; do
cat >> $KS_INSTALL <<EOF
%post
mkdir -p \$(dirname $FILE)
base64 -d - >$FILE <<'CODE'
$(cat root$FILE | base64 -w79)
CODE
%end
EOF
done
cat >> $KS_INSTALL <<KS
%post
chmod +x $(find root -type f -executable | cut -c 5- | xargs echo)
%end
KS
echo "# </generated by build-livecd>" >> $KS_INSTALL
# prepare result kickstart
ksflatten -c "$1" -o $KS_TARGET
echo "Now run as root ./build-livecd-root or submit $KS_TARGET into koji"