-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·82 lines (63 loc) · 1.81 KB
/
build.sh
File metadata and controls
executable file
·82 lines (63 loc) · 1.81 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
#!/bin/bash
function delete {
echo "[BUILD SCRIPT] Delete build directory"
rm -rf build
}
build=1
function nobuild {
echo "[BUILD SCRIPT] Running without build"
build=
}
run=1
function norun {
echo "[BUILD SCRIPT] Building without run"
run=
}
sudo="sudo"
function nosudo {
echo "[BUILD SCRIPT] Building without sudo"
sudo=
}
function help {
printf \
"Usage: ./build.sh [ARGUMENT ...]\n"\
"Arguments:\n"\
" -d, --delete - Delete build directory\n"\
" -D, --delandexit - Delete build directory and exit\n"\
" -B, --nobuild - Run without build\n"\
" -R, --norun - Build without run\n"\
" -S, --nosudo - Build without sudo (useful with docker user group)\n"\
" -h, --help - Print this page\n"\
"Example:\n"\
" ./build.sh - Build and run\n"\
" ./build.sh -R - Only build\n"\
" ./build.sh -d -R - Delete and build without run\n"
}
while [ -n "$1" ]; do
case "$1" in
-d | --delete) delete ;;
-D | --delandexit) delete
exit ;;
-B | --nobuild) nobuild ;;
-R | --norun) norun ;;
-S | --nosudo) nosudo ;;
-h | --help) help
exit ;;
*) echo "[BUILD SCRIPT] Unknown argument: $1"
help
exit ;;
esac
shift
done
if [[ $build ]]; then
echo "[BUILD SCRIPT] Building PRosBSD"
docker build --build-arg HOST_UID=$(id -u) --build-arg HOST_GID=$(id -g) -t prosbsd-builder .
$sudo docker run --privileged --rm -v "$(pwd):/prosbsd" --mount type=tmpfs,destination=/tmp/image/ -w /prosbsd prosbsd-builder
if [ "$?" -ne 0 ]; then
exit 1
fi
fi
if [[ $run ]]; then
echo "[BUILD SCRIPT] Running PRosBSD"
qemu-system-i386 -drive file=build/prosbsd.img,format=raw,if=ide,index=0
fi