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:
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
@ -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_TO_FILE=1
|
||||
|
||||
ARCHBUILDER_INTERACTIVE=0
|
||||
|
||||
LOG_LEVEL_STDOUT="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}/buildah.inc.sh"
|
||||
|
||||
test_file "${HOME}/.archbuilder/archbuilder.env" \
|
||||
&& . "${HOME}/.archbuilder/archbuilder.env"
|
||||
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
|
||||
|
@ -33,91 +36,96 @@ 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 " -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."
|
||||
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 hkn:m:p:r:e:sl: \
|
||||
-l "help" \
|
||||
-l keep \
|
||||
-l name: \
|
||||
-l mode: \
|
||||
-l repo: \
|
||||
-l silent: \
|
||||
-l level: \
|
||||
-l version \
|
||||
-l key: -- "$@" 2>/dev/null)
|
||||
-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
|
||||
-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
|
||||
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=$@
|
||||
|
@ -127,24 +135,23 @@ init_env
|
|||
|
||||
buildah_prepare_params
|
||||
|
||||
|
||||
function exit_trap() {
|
||||
buildah_exit
|
||||
buildah_exit
|
||||
}
|
||||
trap exit_trap EXIT
|
||||
|
||||
buildah_create
|
||||
|
||||
case "${_OPT_MODE}" in
|
||||
"create")
|
||||
buildah_create
|
||||
;;
|
||||
"update")
|
||||
buildah_update
|
||||
;;
|
||||
"build")
|
||||
buildah_build
|
||||
;;
|
||||
"create")
|
||||
buildah_create
|
||||
;;
|
||||
"update")
|
||||
buildah_update
|
||||
;;
|
||||
"build")
|
||||
buildah_build
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -13,161 +13,160 @@ _BUILDAH_MOUNTS=()
|
|||
|
||||
_BUILDAH_PARAMS=""
|
||||
_BUILDAH_MAKEPKG_ENV=""
|
||||
_BUILDAH_MAKEPKG_FLAGS=" --noconfirm" # always noconfirm to avoid hanging
|
||||
_BUILDAH_MAKEPKG_FLAGS="" # always noconfirm to avoid hanging
|
||||
|
||||
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
|
||||
then
|
||||
log_debug "Buildah image '${1}' exists"
|
||||
return 0
|
||||
fi
|
||||
if buildah inspect "${1}" >/dev/null 2>&1; then
|
||||
log_debug "Buildah image '${1}' exists"
|
||||
return 0
|
||||
fi
|
||||
|
||||
log_debug "Buildah image '${1}' does not exist"
|
||||
return 1
|
||||
log_debug "Buildah image '${1}' does not exist"
|
||||
return 1
|
||||
}
|
||||
|
||||
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
|
||||
# TODO: param -> req for aurutils
|
||||
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v $(pwd):${_BUILDAH_MKPKG_PATH}:rw,U"
|
||||
# adding working directory to container
|
||||
# TODO: param -> req for aurutils
|
||||
_BUILDAH_PARAMS="${_BUILDAH_PARAMS} -v $(pwd):${_BUILDAH_MKPKG_PATH}:rw,U"
|
||||
|
||||
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}"
|
||||
}
|
||||
test_null "ARCHBUILDER_INTERACTIVE" "${ARCHBUILDER_INTERACTIVE}" && {
|
||||
_BUILDAH_MAKEPKG_FLAGS="--noconfirm"
|
||||
}
|
||||
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() {
|
||||
# fix permissions in any case
|
||||
log_info "Cleaning up buildah stuff"
|
||||
test_null "_BUILDAH_CONT" "${_BUILDAH_CONT}" || {
|
||||
exec_cmd buildah run ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "exit 0"
|
||||
# fix permissions in any case
|
||||
log_info "Cleaning up buildah stuff"
|
||||
test_null "_BUILDAH_CONT" "${_BUILDAH_CONT}" || {
|
||||
exec_cmd buildah run ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" bash -c "exit 0"
|
||||
|
||||
test_null "_FLAG_KEEP" "${_FLAG_KEEP}" && {
|
||||
log_info "Deleting working container '${_BUILDAH_CONT}'"
|
||||
exec_cmd buildah rm "${_BUILDAH_CONT}"
|
||||
}
|
||||
unset _BUILDAH_CONT
|
||||
test_null "_FLAG_KEEP" "${_FLAG_KEEP}" && {
|
||||
log_info "Deleting working container '${_BUILDAH_CONT}'"
|
||||
exec_cmd buildah rm "${_BUILDAH_CONT}"
|
||||
}
|
||||
unset _BUILDAH_CONT
|
||||
}
|
||||
}
|
||||
|
||||
function buildah_create() {
|
||||
# checking if base image is existing
|
||||
buildah_exists "${_BUILDAH_BASE_IMAGE}" || {
|
||||
log_info "Trying to fetch base image '${_BUILDAH_BASE_IMAGE}'"
|
||||
exec_cmd buildah pull "${_BUILDAH_BASE_IMAGE}"
|
||||
}
|
||||
# checking if base image is existing
|
||||
buildah_exists "${_BUILDAH_BASE_IMAGE}" || {
|
||||
log_info "Trying to fetch base image '${_BUILDAH_BASE_IMAGE}'"
|
||||
exec_cmd buildah pull "${_BUILDAH_BASE_IMAGE}"
|
||||
}
|
||||
|
||||
test_null "_ACT_CREATE_IMAGE" "${_ACT_CREATE_IMAGE}" \
|
||||
&& return 0
|
||||
test_null "_ACT_CREATE_IMAGE" "${_ACT_CREATE_IMAGE}" &&
|
||||
return 0
|
||||
|
||||
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${_BUILDAH_BASE_IMAGE}'"
|
||||
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${_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}")
|
||||
|
||||
log_info "Updating working container '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -Syu
|
||||
log_info "Updating working container '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -Syu
|
||||
|
||||
log_info "Installing devel packages"
|
||||
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -S base-devel sudo vim git
|
||||
log_info "Installing devel packages"
|
||||
exec_cmd buildah run "${_BUILDAH_CONT}" pacman --noconfirm -S base-devel sudo vim git
|
||||
|
||||
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}"
|
||||
log_info "Creating user '${_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}'"
|
||||
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 "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}"
|
||||
|
||||
log_info "Creating container folder '${_BUILDAH_MKPKG_PATH}'"
|
||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_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}"
|
||||
|
||||
log_info "Creating container folder '${_BUILDAH_PKGDEST_PATH}'"
|
||||
exec_cmd buildah run --user "${_OPT_CON_BUILD_USER}" "${_BUILDAH_CONT}" mkdir "${_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}"
|
||||
|
||||
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}"
|
||||
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}"
|
||||
|
||||
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 "${_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 \"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"
|
||||
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 "${_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 \"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"
|
||||
|
||||
log_info "Copying host makepkg.conf to container"
|
||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||
log_info "Copying host makepkg.conf to container"
|
||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||
|
||||
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
exec_cmd buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
||||
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
exec_cmd buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
||||
|
||||
buildah_exit
|
||||
buildah_exit
|
||||
}
|
||||
|
||||
function buildah_update() {
|
||||
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" \
|
||||
|| exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
||||
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" ||
|
||||
exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
||||
|
||||
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${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}")
|
||||
|
||||
log_info "Copying host makepkg.conf to container"
|
||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||
log_info "Copying host makepkg.conf to container"
|
||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||
|
||||
log_info "Updating container system"
|
||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
||||
log_info "Updating container system"
|
||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
||||
|
||||
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
||||
log_info "Finalizing image '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
buildah commit "${_BUILDAH_CONT}" "${ARCHBUILDER_IMAGE_NAME}"
|
||||
|
||||
buildah_exit
|
||||
buildah_exit
|
||||
}
|
||||
|
||||
function buildah_prepare_build() {
|
||||
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" \
|
||||
|| exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
||||
buildah_exists "${ARCHBUILDER_IMAGE_NAME}" ||
|
||||
exit_error "Build image '${ARCHBUILDER_IMAGE_NAME}' does not exist" 1
|
||||
|
||||
log_info "Creating working container '${ARCHBUILDER_IMAGE_NAME}' from '${ARCHBUILDER_IMAGE_NAME}'"
|
||||
_BUILDAH_CONT=$(buildah from --name "${ARCHBUILDER_IMAGE_NAME}" "${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}")
|
||||
|
||||
log_info "Copying host makepkg.conf to container"
|
||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||
log_info "Copying host makepkg.conf to container"
|
||||
exec_cmd buildah copy --chown root:root "${_BUILDAH_CONT}" "/etc/makepkg.conf" "/etc/makepkg.conf"
|
||||
|
||||
log_info "Updating container system"
|
||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
||||
log_info "Updating container system"
|
||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" sudo pacman --noconfirm -Syu
|
||||
|
||||
for k in "${_OPT_KEYS[@]}"
|
||||
do
|
||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" gpg --receive-keys "${k}"
|
||||
done
|
||||
for k in "${_OPT_KEYS[@]}"; do
|
||||
exec_cmd buildah run --user ${_OPT_CON_BUILD_USER} ${_BUILDAH_PARAMS} "${_BUILDAH_CONT}" gpg --receive-keys "${k}"
|
||||
done
|
||||
}
|
||||
|
||||
function buildah_build() {
|
||||
buildah_prepare_build
|
||||
buildah_prepare_build
|
||||
|
||||
arrExt=$(grep PKGEXT /etc/makepkg.conf)
|
||||
arrExt=(${arrExt//=/ })
|
||||
ext=$(echo "${arrExt[1]}" | cut -d "'" -f 2)
|
||||
arrExt=$(grep PKGEXT /etc/makepkg.conf)
|
||||
arrExt=(${arrExt//=/ })
|
||||
ext=$(echo "${arrExt[1]}" | cut -d "'" -f 2)
|
||||
|
||||
log_debug "Running makepkg"
|
||||
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}"
|
||||
log_debug "Running makepkg"
|
||||
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}"
|
||||
|
||||
log_debug "Copying to cache repo"
|
||||
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_PKGDEST_PATH}/*${ext} ${_BUILDAH_CACHE_REPO_PATH}"
|
||||
}
|
||||
log_debug "Copying to cache repo"
|
||||
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_PKGDEST_PATH}/*${ext} ${_BUILDAH_CACHE_REPO_PATH}"
|
||||
}
|
||||
|
||||
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}"
|
||||
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}"
|
||||
|
||||
buildah_exit
|
||||
buildah_exit
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue