X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 2CA47DC7BFA for ; Fri, 5 Jul 2013 04:21:56 +0000 (UTC) Received: from compute2.internal (compute2.nyi.mail.srv.osa [10.202.2.42]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 799C6204EC for ; Fri, 5 Jul 2013 00:21:55 -0400 (EDT) Received: from frontend2.nyi.mail.srv.osa ([10.202.2.161]) by compute2.internal (MEProxy); Fri, 05 Jul 2013 00:21:55 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:subject:date:message-id :in-reply-to:references; s=smtpout; bh=C7aYqqPQPr+6vJFCVBi63DOnV oY=; b=tUyR3+UV+thR2WshWu2E9JVxiS1bnxR//FYcIhvkIdeUdbN8RhnSnNMmD B6XzYSJTH90G0l1MlfdGlbwPXl0m3eAHB6pPCY6LE7tpBSxXJU3TnNHrzcVMBGPl 5+5YaXRzzkFGlYJJCBJ+ZeO0PsIA4jhTupADB6SofDF3tvQfPk= X-Sasl-enc: qpEcBcE9/oxaeOxafQhxDrJfREuL389NpzxLCQT5CkG/ 1372998115 Received: from localhost (unknown [69.86.161.244]) by mail.messagingengine.com (Postfix) with ESMTPA id 3FC60680204 for ; Fri, 5 Jul 2013 00:21:55 -0400 (EDT) From: Dubiousjim To: alpine-devel@lists.alpinelinux.org Subject: [alpine-devel] [PATCH 30/31] various: fancier readconfig, permit env overrides Date: Fri, 5 Jul 2013 00:21:39 -0400 Message-Id: <554586ead423a074781d03fa52a32e494fe29a37.1372997335.git.dubiousjim@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: --- abuild-keygen.in | 14 +++++------ abuild-sign.in | 4 +-- checkapk.in | 2 +- functions.sh.in | 75 +++++++++++++++++++++++++++++++++++++++++++++----------- 4 files changed, 71 insertions(+), 24 deletions(-) diff --git a/abuild-keygen.in b/abuild-keygen.in index dbedad1..c02ad82 100644 --- a/abuild-keygen.in +++ b/abuild-keygen.in @@ -30,7 +30,7 @@ get_privkey_file() { default_name="${emailaddr:-$USER}-$(printf "%x" $(date +%s))" - privkey="$abuild_home/$default_name.rsa" + privkey="$ABUILD_USERDIR/$default_name.rsa" [ -n "$non_interactive" ] && return 0 msg "Generating public/private rsa key pair for abuild" echo -n "Enter file in which to save the key [$privkey]: " @@ -42,7 +42,7 @@ get_privkey_file() { } do_keygen() { - mkdir -p "$abuild_home" + mkdir -p "$ABUILD_USERDIR" get_privkey_file pubkey="$privkey.pub" @@ -68,14 +68,14 @@ do_keygen() { fi if [ -n "$append_config" ]; then - if [ -f "$abuild_userconf" ]; then + if [ -f "$ABUILD_USERCONF" ]; then # comment out the existing values - sed -i -e 's/^PACKAGER_PRIVKEY=/\#&/' "$abuild_userconf" + sed -i -e 's/^PACKAGER_PRIVKEY=/\#&/' "$ABUILD_USERCONF" fi - echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$abuild_userconf" + echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$ABUILD_USERCONF" else msg "" - msg "You might want add following line to $abuild_userconf:" + msg "You might want add following line to $ABUILD_USERCONF:" msg "" msg "PACKAGER_PRIVKEY=\"$privkey\"" msg "" @@ -92,7 +92,7 @@ usage() { $prog $abuild_ver - generate signing keys Usage: $prog [-a|--append] [-i|--install] [-n] Options: - -a, --append Set PACKAGER_PRIVKEY= in $abuild_userconf + -a, --append Set PACKAGER_PRIVKEY= in $ABUILD_USERCONF -i, --install Install public key into /etc/apk/keys using sudo -n Non-interactive. Use defaults -q, --quiet diff --git a/abuild-sign.in b/abuild-sign.in index c1a0c77..f00c0a1 100644 --- a/abuild-sign.in +++ b/abuild-sign.in @@ -85,9 +85,9 @@ if [ -z "$privkey" ]; then cat >&2 << __EOF__ No private key found. Use 'abuild-keygen' to generate the keys. Then you can either: - * set the PACKAGER_PRIVKEY in $abuild_userconf + * set the PACKAGER_PRIVKEY in $ABUILD_USERCONF ('abuild-keygen -a' does this for you) - * set the PACKAGER_PRIVKEY in $abuild_conf + * set the PACKAGER_PRIVKEY in $ABUILD_CONF * specify the key with the -k option to $prog __EOF__ diff --git a/checkapk.in b/checkapk.in index d3e2988..0d31a0c 100644 --- a/checkapk.in +++ b/checkapk.in @@ -31,7 +31,7 @@ if [ $# -gt 0 ]; then exit 2 fi -if ! [ -f "$abuild_conf" ] && ! [ -f "$abuild_userconf" ]; then +if ! [ -f "$ABUILD_CONF" ] && ! [ -f "$ABUILD_USERCONF" ]; then die "no abuild.conf found" fi diff --git a/functions.sh.in b/functions.sh.in index ab4dff5..0b0bc3b 100644 --- a/functions.sh.in +++ b/functions.sh.in @@ -3,20 +3,67 @@ sysconfdir=@sysconfdir@ prog=${0##*/} - -abuild_conf=${ABUILD_CONF:-"$sysconfdir/abuild.conf"} -abuild_home=${ABUILD_USERDIR:-"$HOME/.abuild"} -abuild_userconf=${ABUILD_USERCONF:-"$abuild_home/abuild.conf"} - -# read config -if [ -f "$abuild_conf" ]; then - . "$abuild_conf" || abuild_conf= -fi - -# read user config if exists -if [ -f "$abuild_userconf" ]; then - . "$abuild_userconf" || abuild_userconf= -fi +readconfig() { + local _APORTSDIR _BUILDDIR _PKGDEST _SRCPKGDEST _REPODEST _SRCDEST + local _CARCH _CHOST _CTARGET _CPPFLAGS _CFLAGS _CXXFLAGS _LDFLAGS + local _JOBS _MAKEFLAGS _PACKAGER _USE_COLORS + local gitbase= + [ -n "${APORTSDIR+x}" ] && _APORTSDIR=$APORTSDIR + [ -n "${BUILDDIR+x}" ] && _BUILDDIR=$BUILDDIR + [ -n "${PKGDEST+x}" ] && _PKGDEST=$PKGDEST + [ -n "${SRCPKGDEST+x}" ] && _SRCPKGDEST=$SRCPKGDEST + [ -n "${REPODEST+x}" ] && _REPODEST=$REPODEST + [ -n "${SRCDEST+x}" ] && _SRCDEST=$SRCDEST + [ -n "${CARCH+x}" ] && _CARCH=$CARCH + [ -n "${CHOST+x}" ] && _CHOST=$CHOST + [ -n "${CTARGET+x}" ] && _CTARGET=$CTARGET + [ -n "${CPPFLAGS+x}" ] && _CPPFLAGS=$CPPFLAGS + [ -n "${CFLAGS+x}" ] && _CFLAGS=$CFLAGS + [ -n "${CXXFLAGS+x}" ] && _CXXFLAGS=$CXXFLAGS + [ -n "${LDFLAGS+x}" ] && _LDFLAGS=$LDFLAGS + [ -n "${JOBS+x}" ] && _JOBS=$JOBS + [ -n "${MAKEFLAGS+x}" ] && _MAKEFLAGS=$MAKEFLAGS + [ -n "${PACKAGER+x}" ] && _PACKAGER=$PACKAGER + [ -n "${USE_COLORS+x}" ] && _USE_COLORS="$USE_COLORS" + : ${ABUILD_CONF:=$sysconfdir/abuild.conf} + : ${ABUILD_USERDIR:=$HOME/.abuild} + : ${ABUILD_USERCONF:=$ABUILD_USERDIR/abuild.conf} + [ -f "$ABUILD_CONF" ] && . "$ABUILD_CONF" + [ -f "$ABUILD_USERCONF" ] && . "$ABUILD_USERCONF" + APORTSDIR=${_APORTSDIR-$APORTSDIR} + gitbase=$(git rev-parse --show-toplevel 2>/dev/null) # already is -P + if [ -d "$APORTSDIR" ]; then + APORTSDIR=$(cd "$APORTSDIR"; pwd -P) + elif [ -z "$APORTSDIR" ] && [ -d "$HOME/aports" ]; then + APORTSDIR=$(cd "$HOME/aports"; pwd -P) + else + if [ -n "$gitbase" ]; then + case $(git config remote.origin.url) in + */aports) APORTSDIR=$gitbase ;; + *) APORTSDIR= ;; + esac + else + APORTSDIR= + fi + fi + BUILDDIR=${_BUILDDIR-$BUILDDIR} + PKGDEST=${_PKGDEST-$PKGDEST} + SRCPKGDEST=${_SRCPKGDEST-$SRCPKGDEST} + REPODEST=${_REPODEST-$REPODEST} + SRCDEST=${_SRCDEST-$SRCDEST} + CARCH=${_CARCH-$CARCH} + CHOST=${_CHOST-$CHOST} + CTARGET=${_CTARGET-$CTARGET} + CPPFLAGS=${_CPPFLAGS-$CPPFLAGS} + CFLAGS=${_CFLAGS-$CFLAGS} + CXXFLAGS=${_CXXFLAGS-$CXXFLAGS} + LDFLAGS=${_LDFLAGS-$LDFLAGS} + JOBS=${_JOBS-$JOBS} + MAKEFLAGS=${_MAKEFLAGS-$MAKEFLAGS} + PACKAGER=${_PACKAGER-$PACKAGER} + USE_COLORS=${_USE_COLORS-$USE_COLORS} +} +readconfig # expects $1 to be a package directory in the aports tree ('foo' or 'main/foo') -- 1.8.3.1 --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---