forked from theforeman/foreman-discovery-image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-livecd
executable file
·50 lines (41 loc) · 1.34 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
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
[[ -z "$1" ]] && echo "Usage: $0 fdi-name.ks [FOREMAN_VERSION] [RELEASE_NUMBER] [VERSION]" && exit 1
which git date base64 ksflatten >/dev/null || ( echo "Command(s) missing, install required tools" && exit 2 )
FOREMAN_VERSION=${2:-nightly}
RELEASE=$(date +%Y%m%d).${3:-1}
VERSION=${4:-$(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 | sort | cut -c 5-)
# generate install overlay
echo "# <generated by build-livecd>" > $KS_INSTALL
cat >> $KS_INSTALL <<EOF
%pre
# VERSION=$VERSION
# RELEASE=$RELEASE
%end
EOF
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 755 $(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
sed "s|yum.theforeman.org/nightly|yum.theforeman.org/releases/$FOREMAN_VERSION|" -i $KS_TARGET
sed "s|yum.theforeman.org/plugins/nightly|yum.theforeman.org/plugins/$FOREMAN_VERSION|" -i $KS_TARGET
echo "Now run as root ./build-livecd-root or submit $KS_TARGET into koji"