2021-06-29 20:01:25 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
readonly archbuilder_version='ARCHBUILDER_VERSION'
|
|
|
|
readonly lib_dir='ARCHBUILDER_LIB_DIR'
|
|
|
|
readonly conf_dir='ARCHBUILDER_CONF_DIR'
|
|
|
|
|
|
|
|
. "${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"
|
|
|
|
|
2024-10-13 03:42:43 +02:00
|
|
|
test_file "${HOME}/.archbuilder/archbuilder.env" &&
|
|
|
|
. "${HOME}/.archbuilder/archbuilder.env"
|
|
|
|
|
|
|
|
test_null "ARCHBUILDER_UID" "${ARCHBUILDER_UID}" &&
|
|
|
|
ARCHBUILDER_UID="$(id -u)"
|
2021-06-29 20:01:25 +02:00
|
|
|
|
|
|
|
# internal params
|
|
|
|
unset _FLAG_KEEP
|
|
|
|
unset _FLAG_SILENT
|
|
|
|
|
|
|
|
_OPT_MODE="build"
|
|
|
|
_OPT_KEYS=()
|
|
|
|
|
|
|
|
_OPT_CON_BUILD_USER="archbuilder"
|
2021-07-01 12:20:37 +02:00
|
|
|
_OPT_CON_LOG_LEVEL=""
|
2021-06-29 20:01:25 +02:00
|
|
|
_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() {
|
2024-10-13 03:42:43 +02:00
|
|
|
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."
|
2021-06-29 20:01:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
options=$(getopt \
|
2024-10-13 03:42:43 +02:00
|
|
|
-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)
|
2021-06-29 20:01:25 +02:00
|
|
|
|
|
|
|
eval set -- "${options}"
|
|
|
|
while true; do
|
2024-10-13 03:42:43 +02:00
|
|
|
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)
|
2021-06-29 20:01:25 +02:00
|
|
|
shift
|
2024-10-13 03:42:43 +02:00
|
|
|
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
|
2021-06-29 20:01:25 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
_OPT_CON_COPTIONS=$@
|
|
|
|
|
|
|
|
set_env
|
|
|
|
init_env
|
|
|
|
|
|
|
|
buildah_prepare_params
|
|
|
|
|
|
|
|
function exit_trap() {
|
2024-10-13 03:42:43 +02:00
|
|
|
buildah_exit
|
2021-06-29 20:01:25 +02:00
|
|
|
}
|
|
|
|
trap exit_trap EXIT
|
|
|
|
|
|
|
|
buildah_create
|
|
|
|
|
|
|
|
case "${_OPT_MODE}" in
|
2024-10-13 03:42:43 +02:00
|
|
|
"create")
|
|
|
|
buildah_create
|
|
|
|
;;
|
|
|
|
"update")
|
|
|
|
buildah_update
|
|
|
|
;;
|
|
|
|
"build")
|
|
|
|
buildah_build
|
|
|
|
;;
|
2021-06-29 20:01:25 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|