From patchwork Sun Sep 24 22:56:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Shumaker X-Patchwork-Id: 260 Return-Path: Delivered-To: patchwork@archlinux.org Received: from apollo.archlinux.org (localhost.localdomain [127.0.0.1]) by apollo.archlinux.org (Postfix) with ESMTP id 9A7DF14B0EF7 for ; Sun, 24 Sep 2017 22:57:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on apollo.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=2.5 tests=RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.1 Received: from orion.archlinux.org (orion.archlinux.org [88.198.91.70]) by apollo.archlinux.org (Postfix) with ESMTPS for ; Sun, 24 Sep 2017 22:57:07 +0000 (UTC) Received: from orion.archlinux.org (localhost.localdomain [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id E6C6D692C7F80; Sun, 24 Sep 2017 22:57:04 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [5.9.250.164]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS; Sun, 24 Sep 2017 22:57:04 +0000 (UTC) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id CE8852BEC3; Sun, 24 Sep 2017 22:57:04 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 488A02BEBF for ; Sun, 24 Sep 2017 22:57:02 +0000 (UTC) Received: from orion.archlinux.org (orion.archlinux.org [IPv6:2a01:4f8:160:6087::1]) by luna.archlinux.org (Postfix) with ESMTPS for ; Sun, 24 Sep 2017 22:57:02 +0000 (UTC) Received: from orion.archlinux.org (localhost.localdomain [127.0.0.1]) by orion.archlinux.org (Postfix) with ESMTP id 428B4692C7F7C for ; Sun, 24 Sep 2017 22:57:01 +0000 (UTC) Received: from mav.lukeshu.com (mav.lukeshu.com [IPv6:2001:19f0:5c00:8069:5400:ff:fe26:6a86]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by orion.archlinux.org (Postfix) with ESMTPS for ; Sun, 24 Sep 2017 22:57:01 +0000 (UTC) Received: from build64-par (unknown [IPv6:2601:803:202:9275:21f:e2ff:fe4d:191b]) by mav.lukeshu.com (Postfix) with ESMTPSA id 58DC583CF1; Sun, 24 Sep 2017 18:56:59 -0400 (EDT) From: Luke Shumaker To: arch-projects@archlinux.org Date: Sun, 24 Sep 2017 18:56:32 -0400 Message-Id: <20170924225632.7084-1-lukeshu@parabola.nu> X-Mailer: git-send-email 2.14.1 Subject: [arch-projects] [devtools][PATCH 1/1] use makepkg library instead of local function copies X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Cc: Luke Shumaker Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" This mirrors dbscripts commit 625fa02 by Pierre Schmitz at 2017-04-18 14:20:49 --- lib/common.sh | 100 ++++------------------------------------------------------ 1 file changed, 7 insertions(+), 93 deletions(-) diff --git a/lib/common.sh b/lib/common.sh index 0fb93d9..a3c2ec2 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -6,62 +6,21 @@ [[ -z ${_INCLUDE_COMMON_SH:-} ]] || return 0 _INCLUDE_COMMON_SH=true +# shellcheck disable=1091 +. /usr/share/makepkg/util.sh + # Avoid any encoding problems export LANG=C 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=$1; shift - # shellcheck disable=2059 - printf "${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -msg() { - local mesg=$1; shift - # shellcheck disable=2059 - printf "${GREEN}==>${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -msg2() { - local mesg=$1; shift - # shellcheck disable=2059 - printf "${BLUE} ->${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -warning() { - local mesg=$1; shift - # shellcheck disable=2059 - printf "${YELLOW}==> WARNING:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} - -error() { - local mesg=$1; shift - # shellcheck disable=2059 - printf "${RED}==> ERROR:${ALL_OFF}${BOLD} ${mesg}${ALL_OFF}\n" "$@" >&2 -} stat_busy() { local mesg=$1; shift @@ -110,51 +69,6 @@ die() { cleanup 255 } -## -# 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... ] ) ##