summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@parabola.nu>2018-01-03 14:34:07 -0500
committerLuke Shumaker <lukeshu@parabola.nu>2018-01-03 14:54:57 -0500
commit6e81594d89c30b5d4ce9d74b094396ca26f2e1ae (patch)
tree27822175d5264be58184d109325a4b8afe834bf0 /lib
parent200c5f3d7476e31720fb400fef6f40aff0b5c805 (diff)
parent7a3c5085017987b6ef934cf9d9b098b4994ba21a (diff)
downloaddevtools32-6e81594d89c30b5d4ce9d74b094396ca26f2e1ae.tar.xz
Merge branch 'archlinux'
Diffstat (limited to 'lib')
-rw-r--r--lib/archroot.sh6
-rw-r--r--lib/common.sh100
-rw-r--r--lib/valid-tags.sh19
3 files changed, 20 insertions, 105 deletions
diff --git a/lib/archroot.sh b/lib/archroot.sh
index 98fd2cf..f279603 100644
--- a/lib/archroot.sh
+++ b/lib/archroot.sh
@@ -6,13 +6,15 @@
CHROOT_VERSION='v4'
##
-# usage : check_root
+# usage : check_root $keepenv
##
orig_argv=("$0" "$@")
check_root() {
+ local keepenv=$1
+
(( EUID == 0 )) && return
if type -P sudo >/dev/null; then
- exec sudo -- "${orig_argv[@]}"
+ exec sudo --preserve-env=$keepenv -- "${orig_argv[@]}"
else
exec su root -c "$(printf ' %q' "${orig_argv[@]}")"
fi
diff --git a/lib/common.sh b/lib/common.sh
index 118a06c..a0796bb 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -9,6 +9,9 @@
[[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0
_INCLUDE_COMMON_SH=true
+# shellcheck disable=1091
+. /usr/share/makepkg/util.sh
+
[[ -n ${TEXTDOMAIN:-} ]] || export TEXTDOMAIN='libretools'
[[ -n ${TEXTDOMAINDIR:-} ]] || export TEXTDOMAINDIR='/usr/share/locale'
@@ -25,56 +28,12 @@ _l() {
shopt -s extglob
# check if messages are to be printed using color
-declare ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
if [[ -t 2 ]]; then
- # prefer terminal safe colored and bold text when tput is supported
- if tput setaf 0 &>/dev/null; then
- ALL_OFF="$(tput sgr0)"
- BOLD="$(tput bold)"
- BLUE="${BOLD}$(tput setaf 4)"
- GREEN="${BOLD}$(tput setaf 2)"
- RED="${BOLD}$(tput setaf 1)"
- YELLOW="${BOLD}$(tput setaf 3)"
- else
- ALL_OFF="\e[1;0m"
- BOLD="\e[1;1m"
- BLUE="${BOLD}\e[1;34m"
- GREEN="${BOLD}\e[1;32m"
- RED="${BOLD}\e[1;31m"
- YELLOW="${BOLD}\e[1;33m"
- fi
+ colorize
+else
+ # shellcheck disable=2034
+ declare -gr ALL_OFF='' BOLD='' BLUE='' GREEN='' RED='' YELLOW=''
fi
-readonly ALL_OFF BOLD BLUE GREEN RED YELLOW
-
-plain() {
- local mesg; mesg="$(_ "$1")"; shift
- # shellcheck disable=2059
- printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-msg() {
- local mesg; mesg="$(_ "$1")"; shift
- # shellcheck disable=2059
- printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-msg2() {
- local mesg; mesg="$(_ "$1")"; shift
- # shellcheck disable=2059
- printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-warning() {
- local mesg; mesg="$(_ "$1")"; shift
- # shellcheck disable=2059
- printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
-
-error() {
- local mesg; mesg="$(_ "$1")"; shift
- # shellcheck disable=2059
- printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2
-}
stat_busy() {
local mesg; mesg="$(_ "$1")"; shift
@@ -124,51 +83,6 @@ die() {
}
##
-# usage : in_array( $needle, $haystack )
-# return : 0 - found
-# 1 - not found
-##
-in_array() {
- local needle=$1; shift
- local item
- for item in "$@"; do
- [[ $item = "$needle" ]] && return 0 # Found
- done
- return 1 # Not Found
-}
-
-##
-# usage : get_full_version( [$pkgname] )
-# return : full version spec, including epoch (if necessary), pkgver, pkgrel
-##
-get_full_version() {
- # set defaults if they weren't specified in buildfile
- local pkgbase=${pkgbase:-${pkgname[0]}}
- local epoch=${epoch:-0}
- local pkgver=${pkgver}
- local pkgrel=${pkgrel}
- if [[ -z $1 ]]; then
- if (( ! epoch )); then
- printf '%s\n' "$pkgver-$pkgrel"
- else
- printf '%s\n' "$epoch:$pkgver-$pkgrel"
- fi
- else
- local pkgver_override='' pkgrel_override='' epoch_override=''
- for i in pkgver pkgrel epoch; do
- local indirect="${i}_override"
- eval "$(declare -f "package_$1" | sed -n "s/\(^[[:space:]]*$i=\)/${i}_override=/p")"
- [[ -z ${!indirect} ]] && eval ${indirect}=\"${!i}\"
- done
- if (( ! epoch_override )); then
- printf '%s\n' "$pkgver_override-$pkgrel_override"
- else
- printf '%s\n' "$epoch_override:$pkgver_override-$pkgrel_override"
- fi
- fi
-}
-
-##
# usage : lock( $fd, $file, $message, [ $message_arguments... ] )
##
lock() {
diff --git a/lib/valid-tags.sh b/lib/valid-tags.sh
index 2916dc7..3cfe046 100644
--- a/lib/valid-tags.sh
+++ b/lib/valid-tags.sh
@@ -4,23 +4,22 @@
# shellcheck disable=2034
_arch=(
- i686
x86_64
any
)
# shellcheck disable=2034
_tags=(
- core-i686 core-x86_64 core-any
- extra-i686 extra-x86_64 extra-any
+ core-x86_64 core-any
+ extra-x86_64 extra-any
multilib-x86_64
- staging-i686 staging-x86_64 staging-any
- testing-i686 testing-x86_64 testing-any
+ staging-x86_64 staging-any
+ testing-x86_64 testing-any
multilib-testing-x86_64
multilib-staging-x86_64
- community-i686 community-x86_64 community-any
- community-staging-i686 community-staging-x86_64 community-staging-any
- community-testing-i686 community-testing-x86_64 community-testing-any
- kde-unstable-i686 kde-unstable-x86_64 kde-unstable-any
- gnome-unstable-i686 gnome-unstable-x86_64 gnome-unstable-any
+ community-x86_64 community-any
+ community-staging-x86_64 community-staging-any
+ community-testing-x86_64 community-testing-any
+ kde-unstable-x86_64 kde-unstable-any
+ gnome-unstable-x86_64 gnome-unstable-any
)