summaryrefslogtreecommitdiff
path: root/src/lib/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/common.sh')
-rw-r--r--src/lib/common.sh39
1 files changed, 35 insertions, 4 deletions
diff --git a/src/lib/common.sh b/src/lib/common.sh
index 3d1ee56..ff767c6 100644
--- a/src/lib/common.sh
+++ b/src/lib/common.sh
@@ -13,7 +13,7 @@ set +u +o posix
$DEVTOOLS_INCLUDE_COMMON_SH
# Avoid any encoding problems
-export LANG=C
+export LANG=C.UTF-8
# Set buildtool properties
export BUILDTOOL=devtools
@@ -22,19 +22,33 @@ export BUILDTOOLVER=@buildtoolver@
# Set common properties
export PACMAN_KEYRING_DIR=/etc/pacman.d/gnupg
export GITLAB_HOST=gitlab.archlinux.org
-export GIT_REPO_SPEC_VERSION=1
+export GIT_REPO_SPEC_VERSION=2
export GIT_PACKAGING_NAMESPACE=archlinux/packaging/packages
export GIT_PACKAGING_NAMESPACE_ID=11323
export GIT_PACKAGING_URL_SSH="git@${GITLAB_HOST}:${GIT_PACKAGING_NAMESPACE}"
export GIT_PACKAGING_URL_HTTPS="https://${GITLAB_HOST}/${GIT_PACKAGING_NAMESPACE}"
export PACKAGING_REPO_RELEASE_HOST=repos.archlinux.org
+export PKGBASE_MAINTAINER_URL=https://archlinux.org/packages/pkgbase-maintainer
+export AUR_URL_SSH=aur@aur.archlinux.org
+
+# ensure TERM is set with a fallback to dumb
+export TERM=${TERM:-dumb}
# check if messages are to be printed using color
if [[ -t 2 && "$TERM" != dumb ]] || [[ ${DEVTOOLS_COLOR} == always ]]; then
colorize
+ if tput setaf 0 &>/dev/null; then
+ PURPLE="$(tput setaf 5)"
+ DARK_GREEN="$(tput setaf 2)"
+ UNDERLINE="$(tput smul)"
+ else
+ PURPLE="\e[35m"
+ DARK_GREEN="\e[32m"
+ UNDERLINE="\e[4m"
+ fi
else
# shellcheck disable=2034
- declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
+ declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW='' PURPLE='' DARK_GREEN='' UNDERLINE=''
fi
stat_busy() {
@@ -53,6 +67,11 @@ stat_done() {
printf "${BOLD}done${ALL_OFF}\n" >&2
}
+stat_failed() {
+ # shellcheck disable=2059
+ printf "${BOLD}${RED}failed${ALL_OFF}\n" >&2
+}
+
msg_success() {
local msg=$1
local padding
@@ -77,6 +96,15 @@ msg_warn() {
printf "%s %s\n" "${padding}${YELLOW}!${ALL_OFF}" "${msg}" >&2
}
+print_workdir_error() {
+ if [[ ! -f "${WORKDIR}"/error ]]; then
+ return
+ fi
+ while read -r LINE; do
+ error '%s' "${LINE}"
+ done < "${WORKDIR}/error"
+}
+
_setup_workdir=false
setup_workdir() {
[[ -z ${WORKDIR:-} ]] && WORKDIR=$(mktemp -d --tmpdir "${0##*/}.XXXXXXXXXX")
@@ -89,6 +117,9 @@ cleanup() {
if [[ -n ${WORKDIR:-} ]] && $_setup_workdir; then
rm -rf "$WORKDIR"
fi
+ if tput setaf 0 &>/dev/null; then
+ tput cnorm >&2
+ fi
exit "${1:-0}"
}
@@ -120,7 +151,7 @@ lock() {
# Only reopen the FD if it wasn't handed to us
if ! [[ "/dev/fd/$1" -ef "$2" ]]; then
mkdir -p -- "$(dirname -- "$2")"
- eval "exec $1>"'"$2"'
+ eval "exec $1>>"'"$2"'
fi
if ! flock -n "$1"; then