-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchbuilder
More file actions
157 lines (137 loc) · 3.88 KB
/
archbuilder
File metadata and controls
157 lines (137 loc) · 3.88 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
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
readonly archbuilder_version='v0.9.6'
readonly lib_dir='/usr/lib/archbuilder'
readonly conf_dir='/etc/archbuilder'
. "${lib_dir}/ext/slog.sh"
. "${lib_dir}/ext/bash_log_internals.inc.sh"
. "${conf_dir}/archbuilder.env"
. "${lib_dir}/archbuilder.inc.sh"
. "${lib_dir}/buildah.inc.sh"
test_file "${HOME}/.archbuilder/archbuilder.env" &&
. "${HOME}/.archbuilder/archbuilder.env"
test_null "ARCHBUILDER_UID" "${ARCHBUILDER_UID}" &&
ARCHBUILDER_UID="$(id -u)"
# internal params
unset _FLAG_KEEP
unset _FLAG_SILENT
_OPT_MODE="build"
_OPT_KEYS=()
_OPT_CON_BUILD_USER="archbuilder"
_OPT_CON_LOG_LEVEL=""
_OPT_CON_COPTIONS=""
# actions to initialize runtime
unset _ACT_CREATE_IMAGE
unset _ACT_CREATE_BASE_DIR
unset _ACT_CREATE_CACHE_REPO_PATH
unset _ACT_CREATE_LOG_PATH
function usage() {
echo "archbuilder is a makepkg wrapper that uses buildah for the build process."
echo "That will lead to a very clean build, where the PKGBUILD and the dependencies,"
echo "have to be 100% correct and nothing will pollute the host system."
echo
echo "Usage:"
echo " archbuilder [options] -- <coptions>"
echo
echo "Options:"
echo -e " -h, --help\t\t\t\t\tPrint this help"
echo -e " -i, --interactive\t\t\t\t\tRun the build container in interactive mode"
echo -e " -k, --keep\t\t\t\t\tKeep the working container that is used for the build"
echo -e " -n, --name <string>\t\t\t\tImage name that is used to spin up the container (default: ${INAME})"
echo -e " -m, --mode <create | update | build>\t\tRun mode: (default: ${MODE})"
echo -e " \t\tcreate will setup the base image"
echo -e " \t\tupdate will update the base image"
echo -e " \t\tbuild will build the PKGBUILD"
echo -e " -e, --key <string>\t\t\t\tPublic signing keys that should be trusted by for the build. (Can be added multiple times)"
echo -e " -r, --repo <string>\t\t\t\tHost path to use as repository inside the container. This can be used to avoid"
echo -e " \t\t\t\thanding over dependencies via command line arguments as they will be added to this repo"
echo -e " -s, --silent <string>\t\t\t\tMake container silent: No output from container commands will be send to shell."
echo -e " -l, --level <string>\t\t\t\tLog level to use: Possible values are DEBUG, INFO, WARN, SUCCESS or ERROR"
echo -e " --version <string>\t\t\t\tPrint version information."
echo
echo "coptions:"
echo -e " These options will be handed over directly to makepkg inside the buildah container to build the package."
echo -e " coptions has to be added ater the double dash -- to work."
}
options=$(getopt \
-o hikn:m:p:r:e:sl: \
-l "help" \
-l interactive \
-l keep \
-l name: \
-l mode: \
-l repo: \
-l silent: \
-l level: \
-l version \
-l key: -- "$@" 2>/dev/null)
eval set -- "${options}"
while true; do
case "${1}" in
-i | --interactive)
ARCHBUILDER_INTERACTIVE=1
;;
-k | --keep)
_FLAG_KEEP=1
;;
-n | --name)
shift
ARCHBUILDER_IMAGE_NAME=${1}
;;
-m | --mode)
shift
_OPT_MODE="${1}"
;;
-e | --key)
shift
_OPT_KEYS[${#_OPT_KEYS[*]}]="${1}"
;;
-r | --repo)
shift
ARCHBUILDER_CACHE_REPO="${1}"
;;
-s | --silent)
_FLAG_SILENT=1
;;
-l | --level)
shift
check_log_level "${1}" ||
exit_error "${err}"
LOG_LEVEL_STDOUT="${1}"
LOG_LEVEL_LOG="${1}"
;;
--version)
echo -e "archbuilder v${archbuilder_version}"
exit 0
;;
--)
shift
break
;;
-h | --help | *)
usage
exit 0
;;
esac
shift
done
_OPT_CON_COPTIONS=$@
set_env
init_env
buildah_prepare_params
function exit_trap() {
buildah_exit
}
trap exit_trap EXIT
buildah_create
case "${_OPT_MODE}" in
"create")
buildah_create
;;
"update")
buildah_update
;;
"build")
buildah_build
;;
esac
exit 0