Updated to new aurutils, added flags, using uid (ae. nfs)
This commit is contained in:
parent
76457c6428
commit
b4010624c4
|
@ -80,7 +80,7 @@ Create a repository, that is owned by this user for using [aurutils](https://git
|
||||||
|
|
||||||
To use now archbuilder as building backend inside aurutils, just add the following to your shell:
|
To use now archbuilder as building backend inside aurutils, just add the following to your shell:
|
||||||
|
|
||||||
export MAKEPKG="/usr/bin/archbuilderwrap"
|
export AUR_MAKEPKG="/usr/bin/archbuilderwrap"
|
||||||
|
|
||||||
This script will wrap everything correct to archbuilder and run the makepkg inside the buildah container.
|
This script will wrap everything correct to archbuilder and run the makepkg inside the buildah container.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,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
|
|
@ -6,6 +6,7 @@ ARCHBUILDER_CACHE_REPO="${ARCHBUILDER_BASE_DIR}/crepo"
|
||||||
ARCHBUILDER_LOG_PATH="${ARCHBUILDER_BASE_DIR}/logs"
|
ARCHBUILDER_LOG_PATH="${ARCHBUILDER_BASE_DIR}/logs"
|
||||||
ARCHBUILDER_LOG_TO_FILE=1
|
ARCHBUILDER_LOG_TO_FILE=1
|
||||||
|
|
||||||
|
ARCHBUILDER_INTERACTIVE=0
|
||||||
|
|
||||||
LOG_LEVEL_STDOUT="INFO"
|
LOG_LEVEL_STDOUT="INFO"
|
||||||
LOG_LEVEL_LOG="INFO"
|
LOG_LEVEL_LOG="INFO"
|
||||||
|
|
||||||
|
|
189
archbuilder.in
189
archbuilder.in
|
@ -12,8 +12,11 @@ readonly conf_dir='ARCHBUILDER_CONF_DIR'
|
||||||
. "${lib_dir}/archbuilder.inc.sh"
|
. "${lib_dir}/archbuilder.inc.sh"
|
||||||
. "${lib_dir}/buildah.inc.sh"
|
. "${lib_dir}/buildah.inc.sh"
|
||||||
|
|
||||||
test_file "${HOME}/.archbuilder/archbuilder.env" \
|
test_file "${HOME}/.archbuilder/archbuilder.env" &&
|
||||||
&& . "${HOME}/.archbuilder/archbuilder.env"
|
. "${HOME}/.archbuilder/archbuilder.env"
|
||||||
|
|
||||||
|
test_null "ARCHBUILDER_UID" "${ARCHBUILDER_UID}" &&
|
||||||
|
ARCHBUILDER_UID="$(id -u)"
|
||||||
|
|
||||||
# internal params
|
# internal params
|
||||||
unset _FLAG_KEEP
|
unset _FLAG_KEEP
|
||||||
|
@ -33,91 +36,96 @@ unset _ACT_CREATE_CACHE_REPO_PATH
|
||||||
unset _ACT_CREATE_LOG_PATH
|
unset _ACT_CREATE_LOG_PATH
|
||||||
|
|
||||||
function usage() {
|
function usage() {
|
||||||
echo "archbuilder is a makepkg wrapper that uses buildah for the build process."
|
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 "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 "have to be 100% correct and nothing will pollute the host system."
|
||||||
echo
|
echo
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " archbuilder [options] -- <coptions>"
|
echo " archbuilder [options] -- <coptions>"
|
||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo -e " -h, --help\t\t\t\t\tPrint this help"
|
echo -e " -h, --help\t\t\t\t\tPrint this help"
|
||||||
echo -e " -k, --keep\t\t\t\t\tKeep the working container that is used for the build"
|
echo -e " -i, --interactive\t\t\t\t\tRun the build container in interactive mode"
|
||||||
echo -e " -n, --name <string>\t\t\t\tImage name that is used to spin up the container (default: ${INAME})"
|
echo -e " -k, --keep\t\t\t\t\tKeep the working container that is used for the build"
|
||||||
echo -e " -m, --mode <create | update | build>\t\tRun mode: (default: ${MODE})"
|
echo -e " -n, --name <string>\t\t\t\tImage name that is used to spin up the container (default: ${INAME})"
|
||||||
echo -e " \t\tcreate will setup the base image"
|
echo -e " -m, --mode <create | update | build>\t\tRun mode: (default: ${MODE})"
|
||||||
echo -e " \t\tupdate will update the base image"
|
echo -e " \t\tcreate will setup the base image"
|
||||||
echo -e " \t\tbuild will build the PKGBUILD"
|
echo -e " \t\tupdate will update the base image"
|
||||||
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 " \t\tbuild will build the PKGBUILD"
|
||||||
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 " -e, --key <string>\t\t\t\tPublic signing keys that should be trusted by for the build. (Can be added multiple times)"
|
||||||
echo -e " \t\t\t\thanding over dependencies via command line arguments as they will be added to this repo"
|
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 " -s, --silent <string>\t\t\t\tMake container silent: No output from container commands will be send to shell."
|
echo -e " \t\t\t\thanding over dependencies via command line arguments as they will be added to this repo"
|
||||||
echo -e " -l, --level <string>\t\t\t\tLog level to use: Possible values are DEBUG, INFO, WARN, SUCCESS or ERROR"
|
echo -e " -s, --silent <string>\t\t\t\tMake container silent: No output from container commands will be send to shell."
|
||||||
echo -e " --version <string>\t\t\t\tPrint version information."
|
echo -e " -l, --level <string>\t\t\t\tLog level to use: Possible values are DEBUG, INFO, WARN, SUCCESS or ERROR"
|
||||||
echo
|
echo -e " --version <string>\t\t\t\tPrint version information."
|
||||||
echo "coptions:"
|
echo
|
||||||
echo -e " These options will be handed over directly to makepkg inside the buildah container to build the package."
|
echo "coptions:"
|
||||||
echo -e " coptions has to be added ater the double dash -- to work."
|
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 \
|
options=$(getopt \
|
||||||
-o hkn:m:p:r:e:sl: \
|
-o hikn:m:p:r:e:sl: \
|
||||||
-l "help" \
|
-l "help" \
|
||||||
-l keep \
|
-l interactive \
|
||||||
-l name: \
|
-l keep \
|
||||||
-l mode: \
|
-l name: \
|
||||||
-l repo: \
|
-l mode: \
|
||||||
-l silent: \
|
-l repo: \
|
||||||
-l level: \
|
-l silent: \
|
||||||
-l version \
|
-l level: \
|
||||||
-l key: -- "$@" 2>/dev/null)
|
-l version \
|
||||||
|
-l key: -- "$@" 2>/dev/null)
|
||||||
|
|
||||||
eval set -- "${options}"
|
eval set -- "${options}"
|
||||||
while true; do
|
while true; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
-k|--keep)
|
-i | --interactive)
|
||||||
_FLAG_KEEP=1
|
ARCHBUILDER_INTERACTIVE=1
|
||||||
;;
|
;;
|
||||||
-n|--name)
|
-k | --keep)
|
||||||
shift
|
_FLAG_KEEP=1
|
||||||
ARCHBUILDER_IMAGE_NAME=${1}
|
;;
|
||||||
;;
|
-n | --name)
|
||||||
-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
|
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
|
done
|
||||||
|
|
||||||
_OPT_CON_COPTIONS=$@
|
_OPT_CON_COPTIONS=$@
|
||||||
|
@ -127,24 +135,23 @@ init_env
|
||||||
|
|
||||||
buildah_prepare_params
|
buildah_prepare_params
|
||||||
|
|
||||||
|
|
||||||
function exit_trap() {
|
function exit_trap() {
|
||||||
buildah_exit
|
buildah_exit
|
||||||
}
|
}
|
||||||
trap exit_trap EXIT
|
trap exit_trap EXIT
|
||||||
|
|
||||||
buildah_create
|
buildah_create
|
||||||
|
|
||||||
case "${_OPT_MODE}" in
|
case "${_OPT_MODE}" in
|
||||||
"create")
|
"create")
|
||||||
buildah_create
|
buildah_create
|
||||||
;;
|
;;
|
||||||
"update")
|
"update")
|
||||||
buildah_update
|
buildah_update
|
||||||
;;
|
;;
|
||||||
"build")
|
"build")
|
||||||
buildah_build
|
buildah_build
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -13,161 +13,160 @@ _BUILDAH_MOUNTS=()
|
||||||
|
|
||||||
_BUILDAH_PARAMS=""
|
_BUILDAH_PARAMS=""
|
||||||
_BUILDAH_MAKEPKG_ENV=""
|
_BUILDAH_MAKEPKG_ENV=""
|
||||||
_BUILDAH_MAKEPKG_FLAGS=" --noconfirm" # always noconfirm to avoid hanging
|
_BUILDAH_MAKEPKG_FLAGS="" # always noconfirm to avoid hanging
|
||||||
|
|
||||||
function buildah_exists() {
|
function buildah_exists() {
|
||||||
log_debug "Checking if buildah image '${1}' exists"
|
log_debug "Checking if buildah image '${1}' exists"
|
||||||
|
|
||||||
if buildah inspect "${1}" > /dev/null 2>&1
|
if buildah inspect "${1}" >/dev/null 2>&1; then
|
||||||
then
|
log_debug "Buildah image '${1}' exists"
|
||||||
log_debug "Buildah image '${1}' exists"
|
return 0
|
||||||
return 0
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
log_debug "Buildah image '${1}' does not exist"
|
log_debug "Buildah image '${1}' does not exist"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildah_prepare_params() {
|
function buildah_prepare_params() {
|
||||||
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v ${ARCHBUILDER_CACHE_REPO}:${_BUILDAH_CACHE_REPO_PATH}:rw,U"
|
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -t -v ${ARCHBUILDER_CACHE_REPO}:${_BUILDAH_CACHE_REPO_PATH}:rw,U"
|
||||||
|
|
||||||
# adding working directory to container
|
# adding working directory to container
|
||||||
# TODO: param -> req for aurutils
|
# TODO: param -> req for aurutils
|
||||||
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v $(pwd):${_BUILDAH_MKPKG_PATH}:rw,U"
|
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v $(pwd):${_BUILDAH_MKPKG_PATH}:rw,U"
|
||||||
|
|
||||||
log_info "Preparing makepkg environment"
|
test_null "ARCHBUILDER_INTERACTIVE" "${ARCHBUILDER_INTERACTIVE}" && {
|
||||||
test_null "PKGDEST" "${PKGDEST}" || {
|
_BUILDAH_MAKEPKG_FLAGS="--noconfirm"
|
||||||
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v ${PKGDEST}:${_BUILDAH_PKGDEST_PATH}:rw,U"
|
}
|
||||||
_BUILDAH_MAKEPKG_ENV="${_BUILDAH_MAKEPKG_ENV} PKGDEST=${_BUILDAH_PKGDEST_PATH}"
|
log_info "Preparing makepkg environment"
|
||||||
}
|
test_null "PKGDEST" "${PKGDEST}" || {
|
||||||
|
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v ${PKGDEST}:${_BUILDAH_PKGDEST_PATH}:rw,U"
|
||||||
|
_BUILDAH_MAKEPKG_ENV="${_BUILDAH_MAKEPKG_ENV} PKGDEST=${_BUILDAH_PKGDEST_PATH}"
|
||||||
|
}
|
||||||
|
|
||||||
log_debug "Final _BUILDAH_PARAMS '${_BUILDAH_PARAMS}'"
|
log_debug "Final _BUILDAH_PARAMS '${_BUILDAH_PARAMS}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildah_exit() {
|
function buildah_exit() {
|
||||||
# fix permissions in any case
|
# fix permissions in any case
|
||||||
log_info "Cleaning up buildah stuff"
|
log_info "Cleaning up buildah stuff"
|
||||||
test_null "_BUILDAH_CONT" "${_BUILDAH_CONT}" || {
|
test_null "_BUILDAH_CONT" "${_BUILDAH_CONT}" || {
|
||||||
exec_cmd buildah run ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "exit 0"
|
exec_cmd buildah run ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "exit 0"
|
||||||
|
|
||||||
test_null "_FLAG_KEEP" "${_FLAG_KEEP}" && {
|
test_null "_FLAG_KEEP" "${_FLAG_KEEP}" && {
|
||||||
log_info "Deleting working container '${_BUILDAH_CONT}'"
|
log_info "Deleting working container '${_BUILDAH_CONT}'"
|
||||||
exec_cmd buildah rm "${_BUILDAH_CONT}"
|
exec_cmd buildah rm "${_BUILDAH_CONT}"
|
||||||
}
|
|
||||||
unset _BUILDAH_CONT
|
|
||||||
}
|
}
|
||||||
|
unset _BUILDAH_CONT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildah_create() {
|
function buildah_create() {
|
||||||
# checking if base image is existing
|
# checking if base image is existing
|
||||||
buildah_exists "${_BUILDAH_BASE_IMAGE}" || {
|
buildah_exists "${_BUILDAH_BASE_IMAGE}" || {
|
||||||
log_info "Trying to fetch base image '${_BUILDAH_BASE_IMAGE}'"
|
log_info "Trying to fetch base image '${_BUILDAH_BASE_IMAGE}'"
|
||||||
exec_cmd buildah pull "${_BUILDAH_BASE_IMAGE}"
|
exec_cmd buildah pull "${_BUILDAH_BASE_IMAGE}"
|
||||||
}
|
}
|
||||||
|
|
||||||
test_null "_ACT_CREATE_IMAGE" "${_ACT_CREATE_IMAGE}" \
|
test_null "_ACT_CREATE_IMAGE" "${_ACT_CREATE_IMAGE}" &&
|
||||||
&& return 0
|
return 0
|
||||||
|
|
||||||
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${_BUILDAH_BASE_IMAGE}'"
|
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${_BUILDAH_BASE_IMAGE}'"
|
||||||
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${_BUILDAH_BASE_IMAGE}")
|
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${_BUILDAH_BASE_IMAGE}")
|
||||||
|
|
||||||
log_info "Updating working container '${ARCHBUILDER_IMAGE_NAME}'"
|
log_info "Updating working container '${ARCHBUILDER_IMAGE_NAME}'"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -Syu
|
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -Syu
|
||||||
|
|
||||||
log_info "Installing devel packages"
|
log_info "Installing devel packages"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -S base-devel sudo vim git
|
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -S base-devel sudo vim git
|
||||||
|
|
||||||
log_info "Creating user '${_OPT_CON_BUILD_USER}'"
|
log_info "Creating user '${_OPT_CON_BUILD_USER}'"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" useradd -m -s /bin/bash -U -u 1000 "${_OPT_CON_BUILD_USER}"
|
exec_cmd buildah run "${_BUILDAH_CONT}" useradd -m -s /bin/bash -U -u "${ARCHBUILDER_UID}" "${_OPT_CON_BUILD_USER}"
|
||||||
|
|
||||||
log_info "Setting up sudo for user '${_OPT_CON_BUILD_USER}'"
|
log_info "Setting up sudo for user '${_OPT_CON_BUILD_USER}'"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo '${_OPT_CON_BUILD_USER} ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/${_OPT_CON_BUILD_USER}"
|
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo '${_OPT_CON_BUILD_USER} ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/${_OPT_CON_BUILD_USER}"
|
||||||
|
|
||||||
log_info "Creating container folder '${_BUILDAH_MKPKG_PATH}'"
|
log_info "Creating container folder '${_BUILDAH_MKPKG_PATH}'"
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_BUILDAH_MKPKG_PATH}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_BUILDAH_MKPKG_PATH}"
|
||||||
|
|
||||||
log_info "Creating container folder '${_BUILDAH_PKGDEST_PATH}'"
|
log_info "Creating container folder '${_BUILDAH_PKGDEST_PATH}'"
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_BUILDAH_PKGDEST_PATH}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_BUILDAH_PKGDEST_PATH}"
|
||||||
|
|
||||||
log_info "Creating container folder '${_BUILDAH_CACHE_REPO_PATH}'"
|
log_info "Creating container folder '${_BUILDAH_CACHE_REPO_PATH}'"
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_BUILDAH_CACHE_REPO_PATH}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_BUILDAH_CACHE_REPO_PATH}"
|
||||||
|
|
||||||
log_info "Adding repository '${_BUILDAH_CACHE_REPO} 'to container"
|
log_info "Adding repository '${_BUILDAH_CACHE_REPO} 'to container"
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" repo-add "${_BUILDAH_CACHE_REPO}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" repo-add "${_BUILDAH_CACHE_REPO}"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"\n\" >> /etc/pacman.conf"
|
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"\n\" >> /etc/pacman.conf"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"[${_BUILDAH_CACHE_REPO_NAME}]\" >> /etc/pacman.conf"
|
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"[${_BUILDAH_CACHE_REPO_NAME}]\" >> /etc/pacman.conf"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"SigLevel = Optional TrustAll\" >> /etc/pacman.conf"
|
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"SigLevel = Optional TrustAll\" >> /etc/pacman.conf"
|
||||||
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"Server = file://${_BUILDAH_CACHE_REPO_PATH}\" >> /etc/pacman.conf"
|
exec_cmd buildah run "${_BUILDAH_CONT}" bash -c "echo -e \"Server = file://${_BUILDAH_CACHE_REPO_PATH}\" >> /etc/pacman.conf"
|
||||||
|
|
||||||
log_info "Copying host makepkg.conf to container"
|
log_info "Copying host makepkg.conf to container"
|
||||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||||
|
|
||||||
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
||||||
exec_cmd buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
exec_cmd buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
||||||
|
|
||||||
buildah_exit
|
buildah_exit
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildah_update() {
|
function buildah_update() {
|
||||||
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" \
|
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" ||
|
||||||
|| exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
||||||
|
|
||||||
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${ARCHBUILDER_IMAGE_NAME}'"
|
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${ARCHBUILDER_IMAGE_NAME}'"
|
||||||
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${ARCHBUILDER_IMAGE_NAME}")
|
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${ARCHBUILDER_IMAGE_NAME}")
|
||||||
|
|
||||||
log_info "Copying host makepkg.conf to container"
|
log_info "Copying host makepkg.conf to container"
|
||||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||||
|
|
||||||
log_info "Updating container system"
|
log_info "Updating container system"
|
||||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
||||||
|
|
||||||
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
||||||
buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
||||||
|
|
||||||
buildah_exit
|
buildah_exit
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildah_prepare_build() {
|
function buildah_prepare_build() {
|
||||||
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" \
|
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" ||
|
||||||
|| exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
||||||
|
|
||||||
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${ARCHBUILDER_IMAGE_NAME}'"
|
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${ARCHBUILDER_IMAGE_NAME}'"
|
||||||
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${ARCHBUILDER_IMAGE_NAME}")
|
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${ARCHBUILDER_IMAGE_NAME}")
|
||||||
|
|
||||||
log_info "Copying host makepkg.conf to container"
|
log_info "Copying host makepkg.conf to container"
|
||||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||||
|
|
||||||
log_info "Updating container system"
|
log_info "Updating container system"
|
||||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
||||||
|
|
||||||
for k in "${_OPT_KEYS[@]}"
|
for k in "${_OPT_KEYS[@]}"; do
|
||||||
do
|
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" gpg --receive-keys "${k}"
|
||||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" gpg --receive-keys "${k}"
|
done
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildah_build() {
|
function buildah_build() {
|
||||||
buildah_prepare_build
|
buildah_prepare_build
|
||||||
|
|
||||||
arrExt=$(grep PKGEXT /etc/makepkg.conf)
|
arrExt=$(grep PKGEXT /etc/makepkg.conf)
|
||||||
arrExt=(${arrExt//=/ })
|
arrExt=(${arrExt//=/ })
|
||||||
ext=$(echo "${arrExt[1]}" | cut -d "'" -f 2)
|
ext=$(echo "${arrExt[1]}" | cut -d "'" -f 2)
|
||||||
|
|
||||||
log_debug "Running makepkg"
|
log_debug "Running makepkg"
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" \
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" \
|
||||||
bash -c "cd ${_BUILDAH_MKPKG_PATH} && ${_BUILDAH_MAKEPKG_ENV} makepkg ${_BUILDAH_MAKEPKG_FLAGS} ${_OPT_CON_COPTIONS}"
|
bash -c "cd ${_BUILDAH_MKPKG_PATH} && ${_BUILDAH_MAKEPKG_ENV} makepkg ${_BUILDAH_MAKEPKG_FLAGS} ${_OPT_CON_COPTIONS}"
|
||||||
|
|
||||||
log_debug "Copying to cache repo"
|
log_debug "Copying to cache repo"
|
||||||
test_null "PKGDEST" "${PKGDEST}" && {
|
test_null "PKGDEST" "${PKGDEST}" && {
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "cp ${_BUILDAH_MKPKG_PATH}/*${ext} ${_BUILDAH_CACHE_REPO_PATH}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "cp ${_BUILDAH_MKPKG_PATH}/*${ext} ${_BUILDAH_CACHE_REPO_PATH}"
|
||||||
} || {
|
} || {
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "cp ${_BUILDAH_PKGDEST_PATH}/*${ext} ${_BUILDAH_CACHE_REPO_PATH}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "cp ${_BUILDAH_PKGDEST_PATH}/*${ext} ${_BUILDAH_CACHE_REPO_PATH}"
|
||||||
}
|
}
|
||||||
|
|
||||||
log_debug "Updating cache repo"
|
log_debug "Updating cache repo"
|
||||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "repo-add -n ${_BUILDAH_CACHE_REPO} ${_BUILDAH_CACHE_REPO_PATH}/*${ext}"
|
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "repo-add -n ${_BUILDAH_CACHE_REPO} ${_BUILDAH_CACHE_REPO_PATH}/*${ext}"
|
||||||
|
|
||||||
buildah_exit
|
buildah_exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue