-
Notifications
You must be signed in to change notification settings - Fork 492
/
buildenvadm.sh
executable file
·138 lines (122 loc) · 2.92 KB
/
buildenvadm.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env bash
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <[email protected]>
# @copyright Copyright (c) 2009-2024 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
set -e
BASE_IMAGE=${BASE_IMAGE:-"docker.io/library/debian:bookworm"}
IMAGE_NAME=${IMAGE_NAME:-"omv7-pkgbuildenv"}
usage() {
cat <<EOF
Manage the package build environment.
Usage:
$(basename $0) [options] [command]
Available Commands:
create Create but do not start the build environment
remove Remove the build environment
start Start the build environment
install Install all dependencies to create the build environment
Options:
-h, --help Show this message.
EOF
exit 0
}
check_deps() {
if [ ! $(which buildah) ]; then
echo 'Unable to find "buildah". Please make sure it is installed.'
exit 1
fi
if [ ! $(which podman) ]; then
echo 'Unable to find "podman". Please make sure it is installed.'
exit 1
fi
}
create() {
ctr=$(buildah from ${BASE_IMAGE})
buildah run ${ctr} /bin/sh -c 'apt -y update'
buildah run ${ctr} /bin/sh -c 'apt -y install zsh bash-completion sudo fakeroot debhelper gettext doxygen make npm nano debian-keyring devscripts quilt build-essential'
buildah run ${ctr} /bin/sh -c '
cat <<EOF >> ~/.inputrc
"\C-[OA": history-search-backward
"\C-[[A": history-search-backward
"\C-[OB": history-search-forward
"\C-[[B": history-search-forward
EOF
'
# buildah config --entrypoint '/bin/zsh' ${ctr}
buildah config --workingdir '/srv/openmediavault' ${ctr}
buildah commit --rm ${ctr} ${IMAGE_NAME}
}
remove() {
podman rm --ignore ${IMAGE_NAME}
podman image rm ${IMAGE_NAME}
}
start() {
podman run --interactive --tty --replace \
--hostname ${IMAGE_NAME} \
--volume ./deb/:/srv/openmediavault/ \
--name ${IMAGE_NAME} \
${IMAGE_NAME} \
/bin/zsh
}
install() {
sudo apt-get -y update
sudo apt-get -y install buildah podman
}
while getopts ":h-:" option
do
case ${option} in
-)
case "${OPTARG}" in
help)
usage
;;
*)
echo "Unknown option '${OPTARG}'."
usage
;;
esac
;;
h)
usage
;;
esac
done
shift $((OPTIND-1))
case $@ in
create)
check_deps
create
;;
remove)
check_deps
remove
;;
start)
check_deps
start
;;
install)
install
;;
*)
echo "Unknown command '$@'."
usage
;;
esac
exit 0