[pacman-dev] [patch] Cleanup makepkg.conf options and loading of makepkg.conf.
Moved the following vars in /etc/makepkg.conf * BUILDSCRIPT * PKGEXT * DB_COMPRESSION * DB_CHECKSUMS Cleaned up sourcing of /etc/makepkg.conf in scripts and source ~/.makepkg.conf if it exists. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> --- etc/makepkg.conf.in | 12 ++++++++++++ scripts/gensync | 11 +++++++---- scripts/makepkg | 23 +++++++++++------------ scripts/repo-add | 11 ++++++++--- scripts/repo-remove | 11 ++++++++--- scripts/updatesync | 11 +++++++---- 6 files changed, 53 insertions(+), 26 deletions(-) Andrew
From f8dde814bd2137659dfca730d2c5a53dc612acd9 Mon Sep 17 00:00:00 2001 From: Andrew Fyfe <andrew@neptune-one.net> Date: Thu, 29 Mar 2007 12:41:47 +0100 Subject: [PATCH 2/2] Cleanup makepkg.conf options and loading of makepkg.conf.
Moved the following vars in /etc/makepkg.conf * BUILDSCRIPT * PKGEXT * DB_COMPRESSION * DB_CHECKSUMS Cleaned up sourcing of /etc/makepkg.conf in scripts and source ~/.makepkg.conf if it exists. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> --- etc/makepkg.conf.in | 12 ++++++++++++ scripts/gensync | 11 +++++++---- scripts/makepkg | 23 +++++++++++------------ scripts/repo-add | 11 ++++++++--- scripts/repo-remove | 11 ++++++++--- scripts/updatesync | 11 +++++++---- 6 files changed, 53 insertions(+), 26 deletions(-) diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 9ac0ef2..6f9e977 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -75,4 +75,16 @@ DOC_DIRS=(usr/{,share/}{info,doc,gtk-doc} opt/gnome/{,share/}{info,doc,gtk-doc}) #-- Packager: name/email of the person or organization building packages #PACKAGER="John Doe <john@doe.com>" +######################################################################### +# BUILDSCRIPT/EXTENSION DEFAULTS +######################################################################### +# +# WARNING: Do NOT modify these variables unless you know what you are +# doing. +# +BUILDSCRIPT="PKGBUILD" +PKGEXT=".pkg.tar.gz" +DB_COMPRESSION="gz" +DB_CHECKSUMS=(md5) + # vim: set ft=sh ts=2 sw=2 et: diff --git a/scripts/gensync b/scripts/gensync index 5a3dab8..7ebf3f0 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -45,10 +45,13 @@ usage() { exit 0 } -BUILDSCRIPT="PKGBUILD" -PKGEXT="pkg.tar.gz" - -source /etc/makepkg.conf +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." + exit 1 # $E_CONFIG_ERROR # TODO: error codes +fi +[ -r ~/.makepkg.conf ] && source ~/.makepkg.conf error () { echo "==> ERROR: $*" >&2 diff --git a/scripts/makepkg b/scripts/makepkg index 92d8ab2..0739204 100755 --- a/scripts/makepkg +++ b/scripts/makepkg @@ -28,11 +28,12 @@ myver='3.0.0' startdir=$(pwd) -BUILDSCRIPT="PKGBUILD" -PKGEXT="pkg.tar.gz" - -source "/etc/abs/abs.conf" -SRCROOT="$ABSROOT" +# Only use ABSROOT if we haven't been passed a SRCROOT on the command line. +if [ -z "$SRCROOT" ]; then + [ -r "/etc/abs/abs.conf" ] && source /etc/abs/abs.conf + [ -r "~/.abs.conf" ] && source ~/.abs.conf + SRCROOT="$ABSROOT" +fi # Options CLEANUP=0 @@ -409,18 +410,16 @@ ARGLIST=$@ _PKGDEST=${PKGDEST} _SRCDEST=${SRCDEST} -#Source makepkg.conf; fail if it is not found -if [ -f /etc/makepkg.conf ]; then +# Source makepkg.conf; fail if it is not found +if [ -r /etc/makepkg.conf ]; then source /etc/makepkg.conf else error "/etc/makepkg.conf not found. cannot continue" - exit 1 + exit 1 # $E_CONFIG_ERROR # TODO: error codes fi -#Source user-specific makepkg.conf overrides -if [ -f ~/.makepkg.conf ]; then - source ~/.makepkg.conf -fi +# Source user-specific makepkg.conf overrides +[ -r ~/.makepkg.conf ] && source ~/.makepkg.conf # override settings with an environment variable for batch processing PKGDEST=${_PKGDEST:-$PKGDEST} diff --git a/scripts/repo-add b/scripts/repo-add index d6e2c5a..213d068 100755 --- a/scripts/repo-add +++ b/scripts/repo-add @@ -23,11 +23,16 @@ myver='3.0.0' FORCE=0 REPO_DB_FILE="" - -DB_COMPRESSION="gz" #TODO this is gross -DB_CHECKSUMS=(md5) TMP_DIR="" +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error codes +fi +[ -r ~/.makepkg.conf ] && source ~/.makepkg.conf + # print usage instructions usage() { echo "repo-add $myver" diff --git a/scripts/repo-remove b/scripts/repo-remove index eeee240..0e8e46d 100755 --- a/scripts/repo-remove +++ b/scripts/repo-remove @@ -23,11 +23,16 @@ myver='3.0.0' FORCE=0 REPO_DB_FILE="" - -DB_COMPRESSION="gz" #TODO this is gross -DB_CHECKSUMS=(md5) TMP_DIR="" +if [ -r /etc/makepkg.conf ]; then + source /etc/makpkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error code +fi +[ -r ~/.makepkg.conf ] && source ~/.makepkg.conf + # print usage instructions usage() { echo "repo-remove $myver" diff --git a/scripts/updatesync b/scripts/updatesync index a4a6847..09c8ca0 100755 --- a/scripts/updatesync +++ b/scripts/updatesync @@ -47,10 +47,13 @@ usage() { exit 0 } -BUILDSCRIPT="PKGBUILD" -PKGEXT="pkg.tar.gz" - -source /etc/makepkg.conf +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error codes +fi +[ -r ~/.makepkg.conf ] && source ~/.makepkg.conf error () { echo "==> ERROR: $*" >&2 -- 1.5.0.6
On 3/29/07, Andrew Fyfe <andrew@neptune-one.net> wrote:
Moved the following vars in /etc/makepkg.conf * BUILDSCRIPT * PKGEXT * DB_COMPRESSION * DB_CHECKSUMS
Cleaned up sourcing of /etc/makepkg.conf in scripts and source ~/.makepkg.conf if it exists.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
-#Source makepkg.conf; fail if it is not found -if [ -f /etc/makepkg.conf ]; then +# Source makepkg.conf; fail if it is not found +if [ -r /etc/makepkg.conf ]; then source /etc/makepkg.conf else error "/etc/makepkg.conf not found. cannot continue" - exit 1 + exit 1 # $E_CONFIG_ERROR # TODO: error codes fi
-#Source user-specific makepkg.conf overrides -if [ -f ~/.makepkg.conf ]; then - source ~/.makepkg.conf -fi +# Source user-specific makepkg.conf overrides +[ -r ~/.makepkg.conf ] && source ~/.makepkg.conf
Quick comments on this. First, great catch on switching from -f to -r. We should do this in all our scripts if necessary, just to catch stupid mistakes. I did have to look up what -r did but now it makes perfect sense (file exists and read permission is granted). Although that one line source of ~/.makepkg.conf is nice, I personally prefer the longer more drawn out way- it is immediately clear what is happening, the second one uses bash semantics a bit too much for my taste. It also doesn't allow for easy addition of an else clause should that ever arise. Basically I'm saying keep it the way it was (besides the -r). -Dan
Moved the following variables into /etc/makepkg.conf * BUILDSCRIPT * PKGEXT * DB_COMPRESSION * DB_CHECKSUMS Cleaned up sourcing of /etc/makepkg.conf in scripts and source ~/.makepkg.conf if it exists. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 9ac0ef2..6f9e977 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -75,4 +75,16 @@ DOC_DIRS=(usr/{,share/}{info,doc,gtk-doc} opt/gnome/{,share/}{info,doc,gtk-doc}) #-- Packager: name/email of the person or organization building packages #PACKAGER="John Doe <john@doe.com>" +######################################################################### +# BUILDSCRIPT/EXTENSION DEFAULTS +######################################################################### +# +# WARNING: Do NOT modify these variables unless you know what you are +# doing. +# +BUILDSCRIPT="PKGBUILD" +PKGEXT=".pkg.tar.gz" +DB_COMPRESSION="gz" +DB_CHECKSUMS=(md5) + # vim: set ft=sh ts=2 sw=2 et: diff --git a/scripts/gensync b/scripts/gensync index 5a3dab8..9c50900 100755 --- a/scripts/gensync +++ b/scripts/gensync @@ -22,6 +22,17 @@ myver='3.0.0' +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error codes +fi + +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + usage() { echo "gensync $myver" echo "usage: $0 <root> <destfile> [package_directory]" @@ -45,11 +56,6 @@ usage() { exit 0 } -BUILDSCRIPT="PKGBUILD" -PKGEXT="pkg.tar.gz" - -source /etc/makepkg.conf - error () { echo "==> ERROR: $*" >&2 } diff --git a/scripts/makepkg.in b/scripts/makepkg.in index 17a500b..62a2a44 100755 --- a/scripts/makepkg.in +++ b/scripts/makepkg.in @@ -36,11 +36,16 @@ export TEXTDOMAINDIR myver='3.0.0' startdir=$(pwd) -BUILDSCRIPT="PKGBUILD" -PKGEXT="pkg.tar.gz" - -source "/etc/abs/abs.conf" -SRCROOT="$ABSROOT" +# Only use ABSROOT if we haven't been passed a SRCROOT on the command line. +if [ -z "$SRCROOT" ]; then + if [ -r /etc/abs/abs.conf ]; then + source /etc/abs/abs.conf + fi + if [ -r ~/.abs.conf ]; then + source ~/.abs.conf + fi + SRCROOT=$ABSROOT +fi # Options CLEANUP=0 @@ -418,16 +423,16 @@ ARGLIST=$@ _PKGDEST=${PKGDEST} _SRCDEST=${SRCDEST} -#Source makepkg.conf; fail if it is not found -if [ -f /etc/makepkg.conf ]; then +# Source makepkg.conf; fail if it is not found +if [ -r /etc/makepkg.conf ]; then source /etc/makepkg.conf else error "$(gettext "/etc/makepkg.conf not found. cannot continue")" - exit 1 + exit 1 # $E_CONFIG_ERROR # TODO: error codes fi -#Source user-specific makepkg.conf overrides -if [ -f ~/.makepkg.conf ]; then +# Source user-specific makepkg.conf overrides +if [ -r ~/.makepkg.conf ]; then source ~/.makepkg.conf fi diff --git a/scripts/repo-add b/scripts/repo-add index dc28016..1854f59 100755 --- a/scripts/repo-add +++ b/scripts/repo-add @@ -21,11 +21,19 @@ myver='3.0.0' +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error codes +fi + +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + FORCE=0 REPO_DB_FILE="" - -DB_COMPRESSION="gz" #TODO this is gross -DB_CHECKSUMS=(md5) TMP_DIR="" # print usage instructions diff --git a/scripts/repo-remove b/scripts/repo-remove index eeee240..7d72e9a 100755 --- a/scripts/repo-remove +++ b/scripts/repo-remove @@ -21,11 +21,18 @@ myver='3.0.0' +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error code +fi +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + FORCE=0 REPO_DB_FILE="" - -DB_COMPRESSION="gz" #TODO this is gross -DB_CHECKSUMS=(md5) TMP_DIR="" # print usage instructions diff --git a/scripts/updatesync b/scripts/updatesync index a4a6847..c988a9b 100755 --- a/scripts/updatesync +++ b/scripts/updatesync @@ -23,6 +23,16 @@ myver='3.0.0' +if [ -r /etc/makepkg.conf ]; then + source /etc/makepkg.conf +else + echo "ERROR: /etc/makepkg.conf not found. Can not continue." >&2 + exit 1 # $E_CONFIG_ERROR # TODO: error codes +fi +if [ -r ~/.makepkg.conf ]; then + source ~/.makepkg.conf +fi + usage() { echo "updatesync $myver" echo "usage: $0 <action> <destfile> <option> [package_directory]" @@ -47,11 +57,6 @@ usage() { exit 0 } -BUILDSCRIPT="PKGBUILD" -PKGEXT="pkg.tar.gz" - -source /etc/makepkg.conf - error () { echo "==> ERROR: $*" >&2 } -- 1.5.0.6
On 4/1/07, Andrew Fyfe <andrew@neptune-one.net> wrote:
Moved the following variables into /etc/makepkg.conf * BUILDSCRIPT * PKGEXT * DB_COMPRESSION * DB_CHECKSUMS
Cleaned up sourcing of /etc/makepkg.conf in scripts and source ~/.makepkg.conf if it exists.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Applied but slightly amended to move makepkg.conf checks after usage instructions (so repo-add --help will work regardless of the existence of makepkg.conf). -Dan
participants (2)
-
Andrew Fyfe
-
Dan McGee