Skip to content

Commit d4dd146

Browse files
authored
Merge pull request containers#19 from slp/helper_script
Add a helper script for building init/init on krunvm
2 parents cba8784 + 90e1899 commit d4dd146

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

build_on_krunvm.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
# This is a helper script for building init/init (a Linux ELF binary) in
4+
# a lightweight VM using krunvm.
5+
6+
KRUNVM=`which krunvm`
7+
if [ -z "$KRUNVM" ]; then
8+
echo "Couldn't find krunvm binary"
9+
exit -1
10+
fi
11+
12+
SCRIPTPATH=`realpath $0`
13+
WORKDIR=`dirname $SCRIPTPATH`
14+
krunvm create fedora --name libkrun-builder -v $WORKDIR:/work -w /work
15+
if [ $? != 0 ]; then
16+
echo "Error creating lightweight VM"
17+
exit -1
18+
fi
19+
20+
krunvm start libkrun-builder /usr/bin/dnf -- install -y glibc-static gcc make
21+
if [ $? != 0 ]; then
22+
krunvm delete libkrun-builder
23+
echo "Error running command on VM"
24+
exit -1
25+
fi
26+
27+
krunvm start libkrun-builder /usr/bin/make -- init/init
28+
if [ $? != 0 ]; then
29+
krunvm delete libkrun-builder
30+
echo "Error running command on VM"
31+
exit -1
32+
fi
33+
34+
krunvm delete libkrun-builder
35+
36+
if [ ! -e "init/init" ]; then
37+
echo "There was a problem building init/init in the VM"
38+
exit -1
39+
fi
40+
41+
exit 0

0 commit comments

Comments
 (0)