[pacman-dev] [PATCH 1/3] contrib/*: Hardcode program names
Add a read-only variable "$myname" to every contrib script and hardcode program names instead of relying on "$0". The variable name "$myname" was chosen because it is already used in pacman and because we use "$myver" to specify the program version in the official scripts. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- contrib/bacman.in | 14 +++++++------- contrib/paccache.in | 6 ++++-- contrib/pacdiff.in | 10 ++++++---- contrib/paclist.in | 8 +++++--- contrib/paclog-pkglist.in | 6 ++++-- contrib/pacscripts.in | 10 +++++----- contrib/pacsearch.in | 10 +++++----- 7 files changed, 36 insertions(+), 28 deletions(-) diff --git a/contrib/bacman.in b/contrib/bacman.in index c55d716..00d0691 100755 --- a/contrib/bacman.in +++ b/contrib/bacman.in @@ -23,7 +23,7 @@ shopt -s extglob shopt -s nullglob -readonly progname="bacman" +declare -r myname='bacman' readonly progver="0.2.1" # @@ -31,8 +31,8 @@ readonly progver="0.2.1" # usage() { echo "This program recreates a package using pacman's db and system files" - echo "Usage: $progname <installed package name>" - echo "Example: $progname kernel26" + echo "Usage: $myname <installed package name>" + echo "Example: $myname kernel26" } if (( $# != 1 )); then @@ -46,7 +46,7 @@ if [[ $1 == "--help" || $1 == "-h" ]]; then fi if [[ $1 == "--version" || $1 == "-v" ]]; then - echo "$progname version $progver" + echo "$myname version $progver" echo "Copyright (C) 2008 locci" exit 0 fi @@ -61,7 +61,7 @@ if (( EUID )); then /usr/bin/fakeroot -u -- "$0" "$@" exit $? else - echo "WARNING: installing fakeroot or running ${progname} as root is required to" + echo "WARNING: installing fakeroot or running $myname as root is required to" echo " preserve the ownership permissions of files in some packages" echo "" fi @@ -151,7 +151,7 @@ while read i; do echo "" echo "ERROR: unable to add /$i to the package" echo " If your user does not have permssion to read this file then" - echo " you will need to run $progname as root" + echo " you will need to run $myname as root" rm -rf "$work_dir" exit 1 fi @@ -177,7 +177,7 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}') # TODO adopt makepkg's write_pkginfo() into this or scripts/library # echo Generating .PKGINFO metadata... -echo "# Generated by $progname $progver" > .PKGINFO +echo "# Generated by $myname $progver" > .PKGINFO if [[ $INFAKEROOT == "1" ]]; then echo "# Using $(fakeroot -v)" >> .PKGINFO fi diff --git a/contrib/paccache.in b/contrib/paccache.in index eae547d..847d44f 100755 --- a/contrib/paccache.in +++ b/contrib/paccache.in @@ -20,6 +20,8 @@ shopt -s extglob +declare -r myname='paccache' + declare -a candidates=() cmdopts=() whitelist=() blacklist=() declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0 declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch= @@ -174,9 +176,9 @@ summarize() { usage() { cat <<EOF -usage: ${0##*/} <operation> [options] [targets...] +usage: $myname <operation> [options] [targets...] -${0##*/} is a flexible pacman cache cleaning utility, which has numerous +$myname is a flexible pacman cache cleaning utility, which has numerous options to help control how much, and what, is deleted from any directory containing pacman package tarballs. diff --git a/contrib/pacdiff.in b/contrib/pacdiff.in index 3f26f38..79cf809 100755 --- a/contrib/pacdiff.in +++ b/contrib/pacdiff.in @@ -17,17 +17,19 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # +declare -r myname='pacdiff' + diffprog=${DIFFPROG:-vimdiff} diffsearchpath=${DIFFSEARCHPATH:-/etc} locate=0 usage() { - echo "pacdiff : a simple pacnew/pacorig/pacsave updater" - echo "Usage : pacdiff [-l]" - echo " -l/--locate makes pacdiff use locate rather than find" + echo "$myname : a simple pacnew/pacorig/pacsave updater" + echo "Usage : $myname [-l]" + echo " -l/--locate makes $myname use locate rather than find" echo " DIFFPROG variable allows to override the default vimdiff" echo " DIFFSEARCHPATH allows to override the default /etc path" - echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" pacdiff" + echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" $myname" } cmd() { diff --git a/contrib/paclist.in b/contrib/paclist.in index 06b06f2..8623049 100755 --- a/contrib/paclist.in +++ b/contrib/paclist.in @@ -17,6 +17,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +declare -r myname='paclist' + export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='/usr/share/locale' @@ -28,9 +30,9 @@ if ! type gettext &>/dev/null; then fi if [[ -z $1 || $1 = -@(h|-help) ]]; then - printf '%s - List all packages installed from a given repo\n' "${0##*/}" - printf 'Usage: %s <repo>\n' "${0##*/}" - printf 'Example: %s testing\n' "${0##*/}" + printf '%s - List all packages installed from a given repo\n' "$myname" + printf 'Usage: %s <repo>\n' "$myname" + printf 'Example: %s testing\n' "$myname" exit 1 fi diff --git a/contrib/paclog-pkglist.in b/contrib/paclog-pkglist.in index 27dfd30..0b27bf3 100755 --- a/contrib/paclog-pkglist.in +++ b/contrib/paclog-pkglist.in @@ -17,14 +17,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +declare -r myname='paclog-pkglist' + export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='/usr/share/locale' declare logfile=${1:-@localstatedir@/log/pacman.log} if [[ $1 ]]; then if [[ $1 = -@(h|-help) ]]; then - printf 'usage: %s [pacman log]\n' "${0##*/}" - printf 'example: %s @localstatedir@/log/pacman.log\n' "${0##*/}" + printf 'usage: %s [pacman log]\n' "$myname" + printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname" printf '\ndefaults to: @localstatedir@/log/pacman.log\n' exit 0 elif [[ ! -e $logfile ]]; then diff --git a/contrib/pacscripts.in b/contrib/pacscripts.in index 37d3fea..967f782 100755 --- a/contrib/pacscripts.in +++ b/contrib/pacscripts.in @@ -24,7 +24,7 @@ set -o nounset set -o errexit -progname=$(basename $0) +declare -r myname='pacscripts' progver="0.4" conf="@sysconfdir@/pacman.conf" @@ -47,14 +47,14 @@ error() { usage() { echo "This program prints out the {pre,post}_{install,remove,upgrade} scripts" echo "of a given package." - echo "Usage: $progname pkgname|pkgfile" + echo "Usage: $myname pkgname|pkgfile" echo echo " OPTIONS:" echo " -h, --help Print this help message" echo " -v, --version Print program name and version" echo - echo "Example: $progname gconf-editor" - echo "Example: $progname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" + echo "Example: $myname gconf-editor" + echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" } spacman() { @@ -127,6 +127,6 @@ fi case "$1" in --help|-h) usage; exit 0 ;; - --version|-v) echo "$progname version $progver"; exit 0 ;; + --version|-v) echo "$myname version $progver"; exit 0 ;; *) print_scriptlet $1 ;; esac diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in index db9d6ad..794110e 100755 --- a/contrib/pacsearch.in +++ b/contrib/pacsearch.in @@ -24,13 +24,13 @@ use strict; use warnings; -my $progname = "pacsearch"; +my $myname = 'pacsearch'; my $version = "2.0"; if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { - print "$progname - Add color and install information to a pacman -Ss search\n"; - print "Usage: $progname <pattern>\n"; - print "Example: $progname ^gnome\n"; + print "$myname - Add color and install information to a pacman -Ss search\n"; + print "Usage: $myname <pattern>\n"; + print "Example: $myname ^gnome\n"; if ($#ARGV lt 0) { exit 1; } @@ -38,7 +38,7 @@ if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { } if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") { - print "$progname version $version\n"; + print "$myname version $version\n"; print "Copyright (C) 2006-2011 Dan McGee\n"; exit 0; } -- 1.7.8
Be more semantically accurate and avoid accidental overwriting of some configuration variables that are considered to be constant. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- scripts/makepkg.sh.in | 8 ++++---- scripts/pacman-db-upgrade.sh.in | 2 +- scripts/pacman-key.sh.in | 2 +- scripts/pacman-optimize.sh.in | 2 +- scripts/pkgdelta.sh.in | 2 +- scripts/repo-add.sh.in | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0fa05dc..a0a94fe 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -37,10 +37,10 @@ export TEXTDOMAINDIR='@localedir@' # file -i does not work on Mac OSX unless legacy mode is set export COMMAND_MODE='legacy' -myver='@PACKAGE_VERSION@' -confdir='@sysconfdir@' -BUILDSCRIPT='@BUILDSCRIPT@' -startdir="$PWD" +declare -r myver='@PACKAGE_VERSION@' +declare -r confdir='@sysconfdir@' +declare -r BUILDSCRIPT='@BUILDSCRIPT@' +declare -r startdir="$PWD" packaging_options=('strip' 'docs' 'libtool' 'emptydirs' 'zipman' 'purge' 'upx') other_options=('ccache' 'distcc' 'buildflags' 'makeflags') diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in index 3e0d702..402a319 100644 --- a/scripts/pacman-db-upgrade.sh.in +++ b/scripts/pacman-db-upgrade.sh.in @@ -23,7 +23,7 @@ export TEXTDOMAIN='pacman-scripts' export TEXTDOMAINDIR='@localedir@' -myver='@PACKAGE_VERSION@' +declare -r myver='@PACKAGE_VERSION@' eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) dbroot="${DBPath:-@localstatedir@/lib/pacman/}" diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in index ee43dde..e0f48f5 100644 --- a/scripts/pacman-key.sh.in +++ b/scripts/pacman-key.sh.in @@ -24,7 +24,7 @@ export TEXTDOMAIN='pacman-scripts' export TEXTDOMAINDIR='@localedir@' -myver="@PACKAGE_VERSION@" +declare -r myver="@PACKAGE_VERSION@" # Options ADD=0 diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in index 154f982..7e9d7bb 100644 --- a/scripts/pacman-optimize.sh.in +++ b/scripts/pacman-optimize.sh.in @@ -24,7 +24,7 @@ export TEXTDOMAIN='pacman-scripts' export TEXTDOMAINDIR='@localedir@' -myver='@PACKAGE_VERSION@' +declare -r myver='@PACKAGE_VERSION@' eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) dbroot="${DBPath:-@localstatedir@/lib/pacman/}" diff --git a/scripts/pkgdelta.sh.in b/scripts/pkgdelta.sh.in index ef34c5b..22a3cd2 100644 --- a/scripts/pkgdelta.sh.in +++ b/scripts/pkgdelta.sh.in @@ -26,7 +26,7 @@ set -o errexit export TEXTDOMAIN='pacman-scripts' export TEXTDOMAINDIR='@localedir@' -myver='@PACKAGE_VERSION@' +declare -r myver='@PACKAGE_VERSION@' QUIET=0 diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in index 8fa3b72..bd7b8a2 100644 --- a/scripts/repo-add.sh.in +++ b/scripts/repo-add.sh.in @@ -25,8 +25,8 @@ shopt -s extglob export TEXTDOMAIN='pacman-scripts' export TEXTDOMAINDIR='@localedir@' -myver='@PACKAGE_VERSION@' -confdir='@sysconfdir@' +declare -r myver='@PACKAGE_VERSION@' +declare -r confdir='@sysconfdir@' QUIET=0 DELTA=0 -- 1.7.8
Add "--help"/"-h" and "--version"/"-V" support to all contrib scripts. Also, update scripts that used "-v" as a short option for "--version" and use "-V" for the sake of consistency. Additionally: * Move version and usage messages to separate convenience functions in all scripts. * Add a workaround to paccache to support "--help" and "--version". This should be replaced by a proper POSIX-compliant command line parser that supports long options in a future patch. * Add a "$myver" variable to all scripts and use it whenever we refer to the program version (e.g. in version messages). Also, use the pacman version number everywhere instead of using a different versioning scheme for each contrib script. This is achieved by adding a "PACKAGE_VERSION" placeholder that is replaced by sed(1) when the script is built. * Ensure we always return with exit status 0 if "--help" is used and return with exit status 1 if we display the usage message due to invalid arguments. * Add "AUTOMAKE_OPTIONS = std-options" and add all scripts to "bin_SCRIPTS" to make `make installcheck` check that installed scripts actually support the "--help" and "--version" options. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :) contrib/Makefile.am | 14 ++++++++++++++ contrib/bacman.in | 16 +++++++++------- contrib/paccache.in | 20 +++++++++++++++++--- contrib/pacdiff.in | 12 +++++++++++- contrib/paclist.in | 21 ++++++++++++++++++++- contrib/paclog-pkglist.in | 19 ++++++++++++++++--- contrib/pacscripts.in | 10 ++++++++-- contrib/pacsearch.in | 20 +++++++++++++++----- 8 files changed, 110 insertions(+), 22 deletions(-) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index be0a4ba..b3f5bda 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,3 +1,9 @@ +# enforce that all scripts have a --help and --version option +AUTOMAKE_OPTIONS = std-options + +bin_SCRIPTS = \ + $(OURSCRIPTS) + OURSCRIPTS = \ bacman \ paccache \ @@ -28,9 +34,17 @@ EXTRA_DIST = \ # Files that should be removed, but which Automake does not know. MOSTLYCLEANFILES = $(OURSCRIPTS) $(OURFILES) *.tmp +if USE_GIT_VERSION +GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//') +REAL_PACKAGE_VERSION = $(GIT_VERSION) +else +REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) +endif + edit = sed \ -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@localstatedir[@]|$(localstatedir)|g' \ + -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \ -e 's|@SIZECMD[@]|$(SIZECMD)|g' \ -e '1s|!/bin/bash|!$(BASH_SHELL)|g' diff --git a/contrib/bacman.in b/contrib/bacman.in index 00d0691..4e7d38c 100755 --- a/contrib/bacman.in +++ b/contrib/bacman.in @@ -24,7 +24,7 @@ shopt -s extglob shopt -s nullglob declare -r myname='bacman' -readonly progver="0.2.1" +declare -r myver='@PACKAGE_VERSION@' # # User Friendliness @@ -35,6 +35,11 @@ usage() { echo "Example: $myname kernel26" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>' +} + if (( $# != 1 )); then usage exit 1 @@ -43,11 +48,8 @@ fi if [[ $1 == "--help" || $1 == "-h" ]]; then usage exit 0 -fi - -if [[ $1 == "--version" || $1 == "-v" ]]; then - echo "$myname version $progver" - echo "Copyright (C) 2008 locci" +elif [[ $1 == "--version" || $1 == "-V" ]]; then + version exit 0 fi @@ -177,7 +179,7 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}') # TODO adopt makepkg's write_pkginfo() into this or scripts/library # echo Generating .PKGINFO metadata... -echo "# Generated by $myname $progver" > .PKGINFO +echo "# Generated by $myname $myver" > .PKGINFO if [[ $INFAKEROOT == "1" ]]; then echo "# Using $(fakeroot -v)" >> .PKGINFO fi diff --git a/contrib/paccache.in b/contrib/paccache.in index 847d44f..1178fc6 100755 --- a/contrib/paccache.in +++ b/contrib/paccache.in @@ -21,6 +21,7 @@ shopt -s extglob declare -r myname='paccache' +declare -r myver='@PACKAGE_VERSION@' declare -a candidates=() cmdopts=() whitelist=() blacklist=() declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0 @@ -202,19 +203,32 @@ containing pacman package tarballs. EOF } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>' +} + if (( ! UID )); then error "Do not run this script as root. You will be prompted for privilege escalation." exit 42 fi -while getopts ':a:c:dfhi:k:m:rsuvz' opt; do +# TODO: remove this workaround and use a sane command line parser (like the +# parse_options library from scripts/) here +if [[ $1 = -@(h|-help) ]]; then + usage + exit 0 +elif [[ $1 = -@(V|-version) ]]; then + version + exit 0 +fi + +while getopts ':a:c:dfi:k:m:rsuvz' opt; do case $opt in a) scanarch=$OPTARG ;; c) cachedir=$OPTARG ;; d) dryrun=1 ;; f) cmdopts=(-f) ;; - h) usage - exit 0 ;; i) if [[ $OPTARG = '-' ]]; then [[ ! -t 0 ]] && IFS=$'\n' read -r -d '' -a ign else diff --git a/contrib/pacdiff.in b/contrib/pacdiff.in index 79cf809..bfafda2 100755 --- a/contrib/pacdiff.in +++ b/contrib/pacdiff.in @@ -18,6 +18,7 @@ # declare -r myname='pacdiff' +declare -r myver='@PACKAGE_VERSION@' diffprog=${DIFFPROG:-vimdiff} diffsearchpath=${DIFFSEARCHPATH:-/etc} @@ -32,6 +33,11 @@ usage() { echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" $myname" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>' +} + cmd() { if [ $locate -eq 1 ]; then locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave @@ -44,8 +50,12 @@ if [ $# -gt 0 ]; then case $1 in -l|--locate) locate=1;; - *) + -V|--version) + version; exit 0;; + -h|--help) usage; exit 0;; + *) + usage; exit 1;; esac fi diff --git a/contrib/paclist.in b/contrib/paclist.in index 8623049..7883e21 100755 --- a/contrib/paclist.in +++ b/contrib/paclist.in @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. declare -r myname='paclist' +declare -r myver='@PACKAGE_VERSION@' export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='/usr/share/locale' @@ -29,13 +30,31 @@ if ! type gettext &>/dev/null; then } fi -if [[ -z $1 || $1 = -@(h|-help) ]]; then +usage() { printf '%s - List all packages installed from a given repo\n' "$myname" printf 'Usage: %s <repo>\n' "$myname" printf 'Example: %s testing\n' "$myname" +} + +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>' + echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>' +} + +if [[ -z $1 ]]; then + usage exit 1 fi +if [[ $1 = -@(h|-help) ]]; then + usage + exit 0 +elif [[ $1 = -@(V|-version) ]]; then + version + exit 0 +fi + printf -v installed '[%s]' "$(gettext installed)" pacman -Sl $1 | awk -v i="$installed" '$NF == i { print $2,$3 }' diff --git a/contrib/paclog-pkglist.in b/contrib/paclog-pkglist.in index 0b27bf3..222bbc4 100755 --- a/contrib/paclog-pkglist.in +++ b/contrib/paclog-pkglist.in @@ -18,16 +18,29 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. declare -r myname='paclog-pkglist' +declare -r myver='@PACKAGE_VERSION@' export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='/usr/share/locale' declare logfile=${1:-@localstatedir@/log/pacman.log} +usage() { + printf 'usage: %s [pacman log]\n' "$myname" + printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname" + printf '\ndefaults to: @localstatedir@/log/pacman.log\n' +} + +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2011 Dave Reisner <dave@archlinux.org>' +} + if [[ $1 ]]; then if [[ $1 = -@(h|-help) ]]; then - printf 'usage: %s [pacman log]\n' "$myname" - printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname" - printf '\ndefaults to: @localstatedir@/log/pacman.log\n' + usage + exit 0 + elif [[ $1 = -@(V|-version) ]]; then + version exit 0 elif [[ ! -e $logfile ]]; then printf $"target not found: %s\n" "$1" diff --git a/contrib/pacscripts.in b/contrib/pacscripts.in index 967f782..8468714 100755 --- a/contrib/pacscripts.in +++ b/contrib/pacscripts.in @@ -25,7 +25,7 @@ set -o nounset set -o errexit declare -r myname='pacscripts' -progver="0.4" +declare -r myver='@PACKAGE_VERSION@' conf="@sysconfdir@/pacman.conf" @@ -57,6 +57,12 @@ usage() { echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>' + echo 'Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>' +} + spacman() { if [ $EUID -eq 0 ]; then pacman "$@" @@ -127,6 +133,6 @@ fi case "$1" in --help|-h) usage; exit 0 ;; - --version|-v) echo "$myname version $progver"; exit 0 ;; + --version|-V) version; exit 0 ;; *) print_scriptlet $1 ;; esac diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in index 794110e..b1db8ab 100755 --- a/contrib/pacsearch.in +++ b/contrib/pacsearch.in @@ -25,21 +25,31 @@ use strict; use warnings; my $myname = 'pacsearch'; -my $version = "2.0"; +my $myver = '@PACKAGE_VERSION@'; -if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { +sub usage { print "$myname - Add color and install information to a pacman -Ss search\n"; print "Usage: $myname <pattern>\n"; print "Example: $myname ^gnome\n"; +} + +sub version { + printf "%s %s\n", $myname, $myver; + print "Copyright (C) 2008-2011 Dan McGee <dan\@archlinux.org>\n\n"; + print "Based off original shell script version:\n"; + print "Copyright (C) 2006-2007 Dan McGee <dan\@archlinux.org>\n"; +} + +if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { + usage; if ($#ARGV lt 0) { exit 1; } exit 0; } -if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") { - print "$myname version $version\n"; - print "Copyright (C) 2006-2011 Dan McGee\n"; +if ($ARGV[0] eq "--version" || $ARGV[0] eq "-V") { + version; exit 0; } -- 1.7.8
On Tue, Dec 6, 2011 at 3:29 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :)
Before: `make install` does not install contrib/. After: `make install` installs contrib/. So probably not what we want, at least recursively or by default. It would be nice that if you were actually in contrib, `make install` would do what one expected (and kill the ugly hardcoding of each script needed to currently install [1]). Autotools probably makes a setup like this a bitch though. Thoughts from anyone else? -Dan [1] http://projects.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/pacman-contrib&id=375c3222509ba830de48a3365ceb8ae72d491a7c
On Tue, Dec 06, 2011 at 04:38:41PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 3:29 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :)
Before: `make install` does not install contrib/. After: `make install` installs contrib/. So probably not what we want, at least recursively or by default. It would be nice that if you were actually in contrib, `make install` would do what one expected (and kill the ugly hardcoding of each script needed to currently install [1]). Autotools probably makes a setup like this a bitch though. Thoughts from anyone else?
How about removing "contrib" from "SUBDIRS" in our main Makefile.am and adding something like "DIST_SUBDIRS = $(SUBDIRS) contrib"? This way, contrib scripts won't be installed when running `make install` in the top level source directory but can be easily installed by running `make install` in "contrib/"...
-Dan
On Tue, Dec 6, 2011 at 4:58 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Tue, Dec 06, 2011 at 04:38:41PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 3:29 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :)
Before: `make install` does not install contrib/. After: `make install` installs contrib/. So probably not what we want, at least recursively or by default. It would be nice that if you were actually in contrib, `make install` would do what one expected (and kill the ugly hardcoding of each script needed to currently install [1]). Autotools probably makes a setup like this a bitch though. Thoughts from anyone else?
How about removing "contrib" from "SUBDIRS" in our main Makefile.am and adding something like "DIST_SUBDIRS = $(SUBDIRS) contrib"? This way, contrib scripts won't be installed when running `make install` in the top level source directory but can be easily installed by running `make install` in "contrib/"...
The problem there is it completely stops make from descending in there, and as I've seen many times before (namely with docs), it gets ugly when I have to package it. I think you'd be out of luck because your Makefile wouldn't even be generated in there, and thus *.in never gets converted to the scripts and other files. -Dan
On Tue, Dec 06, 2011 at 05:05:20PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 4:58 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Tue, Dec 06, 2011 at 04:38:41PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 3:29 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :)
Before: `make install` does not install contrib/. After: `make install` installs contrib/. So probably not what we want, at least recursively or by default. It would be nice that if you were actually in contrib, `make install` would do what one expected (and kill the ugly hardcoding of each script needed to currently install [1]). Autotools probably makes a setup like this a bitch though. Thoughts from anyone else?
How about removing "contrib" from "SUBDIRS" in our main Makefile.am and adding something like "DIST_SUBDIRS = $(SUBDIRS) contrib"? This way, contrib scripts won't be installed when running `make install` in the top level source directory but can be easily installed by running `make install` in "contrib/"...
The problem there is it completely stops make from descending in there, and as I've seen many times before (namely with docs), it gets ugly when I have to package it. I think you'd be out of luck because your Makefile wouldn't even be generated in there, and thus *.in never gets converted to the scripts and other files.
It doesn't completely stop make from descending in there. As discussed on IRC, directories listed in "DIST_SUBDIRS" will still be honored when running `make dist`. The only difference is that we would have to run `make` and `make install` separately in "contrib/". This makes sense to me because: * I consider contrib scripts a sub-project of (and not part of) pacman. If you say that they actually do belong to pacman, there should be a possibility to install contrib scripts when using make(1) (e.g. by introducing a configure option like "--with-contrib"). This seems very natural, at least. Given that we probably do not want to install contrib scripts together with pacman and prefer separate install trees/procedures, it doesn't make any sense to build contrib scripts in the same procedure we use for building pacman, also. Basically, saying that you will have to run `make install` separately since it's a different sub-project but build it when building the main project feels a bit obscure... tl;dr: To me, only one of these options make sense: - Make contrib scripts optional but build *and* install them together with pacman (that means "introduce a configure option"). - Use a different build *and* install procedure for contrib scripts (that means "use DIST_SUBDIRS"!). * "I am used to run `make` in the top level source directory to build everything." might be a valid reason for you but isn't a valid point for me. We should do things right and look at things from a user perspective, laziness doesn't count :p * This makes the pacman-contrib PKGBUILD damn easy (just cd(1) to the "contrib/" directory instead of the pacman top level source directory and run the usual `make` in build(), `make install` in package()). Just my two cents...
On 08/12/11 02:49, Lukas Fleischer wrote:
On Tue, Dec 06, 2011 at 05:05:20PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 4:58 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Tue, Dec 06, 2011 at 04:38:41PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 3:29 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :)
Before: `make install` does not install contrib/. After: `make install` installs contrib/. So probably not what we want, at least recursively or by default. It would be nice that if you were actually in contrib, `make install` would do what one expected (and kill the ugly hardcoding of each script needed to currently install [1]). Autotools probably makes a setup like this a bitch though. Thoughts from anyone else?
How about removing "contrib" from "SUBDIRS" in our main Makefile.am and adding something like "DIST_SUBDIRS = $(SUBDIRS) contrib"? This way, contrib scripts won't be installed when running `make install` in the top level source directory but can be easily installed by running `make install` in "contrib/"...
The problem there is it completely stops make from descending in there, and as I've seen many times before (namely with docs), it gets ugly when I have to package it. I think you'd be out of luck because your Makefile wouldn't even be generated in there, and thus *.in never gets converted to the scripts and other files.
It doesn't completely stop make from descending in there. As discussed on IRC, directories listed in "DIST_SUBDIRS" will still be honored when running `make dist`. The only difference is that we would have to run `make` and `make install` separately in "contrib/". This makes sense to me because:
* I consider contrib scripts a sub-project of (and not part of) pacman. If you say that they actually do belong to pacman, there should be a possibility to install contrib scripts when using make(1) (e.g. by introducing a configure option like "--with-contrib"). This seems very natural, at least.
Given that we probably do not want to install contrib scripts together with pacman and prefer separate install trees/procedures, it doesn't make any sense to build contrib scripts in the same procedure we use for building pacman, also. Basically, saying that you will have to run `make install` separately since it's a different sub-project but build it when building the main project feels a bit obscure...
tl;dr: To me, only one of these options make sense:
- Make contrib scripts optional but build *and* install them together with pacman (that means "introduce a configure option").
- Use a different build *and* install procedure for contrib scripts (that means "use DIST_SUBDIRS"!).
This option makes sense to me (and I have seen that sort of idea used elsewhere). One query about this approach... Will running ./configure still generate the Makefile in contrib/ when doing this? Because having to maintain a separate configure script that does the same substitutions as the main one would be annoying. Allan
On Sat, Dec 10, 2011 at 09:28:03PM +1000, Allan McRae wrote:
On 08/12/11 02:49, Lukas Fleischer wrote:
On Tue, Dec 06, 2011 at 05:05:20PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 4:58 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
On Tue, Dec 06, 2011 at 04:38:41PM -0600, Dan McGee wrote:
On Tue, Dec 6, 2011 at 3:29 PM, Lukas Fleischer <archlinux@cryptocrack.de> wrote:
Can some autotools wizard please check if I broke anything here? `make distcheck` still looks good to me but I'm not 100% sure what I broke by adding all scripts to "bin_SCRIPTS" :)
Before: `make install` does not install contrib/. After: `make install` installs contrib/. So probably not what we want, at least recursively or by default. It would be nice that if you were actually in contrib, `make install` would do what one expected (and kill the ugly hardcoding of each script needed to currently install [1]). Autotools probably makes a setup like this a bitch though. Thoughts from anyone else?
How about removing "contrib" from "SUBDIRS" in our main Makefile.am and adding something like "DIST_SUBDIRS = $(SUBDIRS) contrib"? This way, contrib scripts won't be installed when running `make install` in the top level source directory but can be easily installed by running `make install` in "contrib/"...
The problem there is it completely stops make from descending in there, and as I've seen many times before (namely with docs), it gets ugly when I have to package it. I think you'd be out of luck because your Makefile wouldn't even be generated in there, and thus *.in never gets converted to the scripts and other files.
It doesn't completely stop make from descending in there. As discussed on IRC, directories listed in "DIST_SUBDIRS" will still be honored when running `make dist`. The only difference is that we would have to run `make` and `make install` separately in "contrib/". This makes sense to me because:
* I consider contrib scripts a sub-project of (and not part of) pacman. If you say that they actually do belong to pacman, there should be a possibility to install contrib scripts when using make(1) (e.g. by introducing a configure option like "--with-contrib"). This seems very natural, at least.
Given that we probably do not want to install contrib scripts together with pacman and prefer separate install trees/procedures, it doesn't make any sense to build contrib scripts in the same procedure we use for building pacman, also. Basically, saying that you will have to run `make install` separately since it's a different sub-project but build it when building the main project feels a bit obscure...
tl;dr: To me, only one of these options make sense:
- Make contrib scripts optional but build *and* install them together with pacman (that means "introduce a configure option").
- Use a different build *and* install procedure for contrib scripts (that means "use DIST_SUBDIRS"!).
This option makes sense to me (and I have seen that sort of idea used elsewhere).
One query about this approach... Will running ./configure still generate the Makefile in contrib/ when doing this? Because having to maintain a separate configure script that does the same substitutions as the main one would be annoying.
Yeah, it will still generate the Makefile. I tested this running `./autoclean.sh; ./autogen.sh; ./configure`.
Allan
This implies following changes: * contrib scripts can be built and installed easily by running make(1) in "contrib/". This removes the need to pick all contrib scripts manually when packaging pacman-contrib. * contrib scripts will no longer be built when running make(1) in the top level source directory. This seems like the most natural approach. We install those separately and should act the same when building stuff. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- Yes, I'm starting to become pushy! :) Seriously - this should do what we discussed earlier. Dan, you can still hold it back... Makefile.am | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6b24a4a..a024a2e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,10 @@ -SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/pacman test/util contrib +SUBDIRS = lib/libalpm src/util src/pacman scripts etc test/pacman test/util if WANT_DOC SUBDIRS += doc endif +DIST_SUBDIRS = $(SUBDIRS) contrib + ACLOCAL_AMFLAGS = -I m4 --install # Make sure we test and build manpages when doing distcheck -- 1.7.8
Add "--help"/"-h" and "--version"/"-V" support to all contrib scripts. Also, update scripts that used "-v" as a short option for "--version" and use "-V" for the sake of consistency. Additionally: * Move version and usage messages to separate convenience functions in all scripts. * Add a workaround to paccache to support "--help" and "--version". This should be replaced by a proper POSIX-compliant command line parser that supports long options in a future patch. * Add a "$myver" variable to all scripts and use it whenever we refer to the program version (e.g. in version messages). Also, use the pacman version number everywhere instead of using a different versioning scheme for each contrib script. This is achieved by adding a "PACKAGE_VERSION" placeholder that is replaced by sed(1) when the script is built. * Ensure we always return with exit status 0 if "--help" is used and return with exit status 1 if we display the usage message due to invalid arguments. * Add "AUTOMAKE_OPTIONS = std-options" and add all scripts to "bin_SCRIPTS" to make `make installcheck` check that installed scripts actually support the "--help" and "--version" options. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- * Use "[[ $1 = -@(h|-help) ]]" instead of "[[ $1 == "--help" || $1 == "-h" ]]" everywhere. * Deal with new contrib script pacsysclean. contrib/Makefile.am | 14 ++++++++++++++ contrib/bacman.in | 18 ++++++++++-------- contrib/paccache.in | 20 +++++++++++++++++--- contrib/pacdiff.in | 12 +++++++++++- contrib/paclist.in | 21 ++++++++++++++++++++- contrib/paclog-pkglist.in | 19 ++++++++++++++++--- contrib/pacscripts.in | 10 ++++++++-- contrib/pacsearch.in | 20 +++++++++++++++----- contrib/pacsysclean.in | 13 +++++++++++-- 9 files changed, 122 insertions(+), 25 deletions(-) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index c9f6365..8751fd9 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,3 +1,9 @@ +# enforce that all scripts have a --help and --version option +AUTOMAKE_OPTIONS = std-options + +bin_SCRIPTS = \ + $(OURSCRIPTS) + OURSCRIPTS = \ bacman \ paccache \ @@ -30,9 +36,17 @@ EXTRA_DIST = \ # Files that should be removed, but which Automake does not know. MOSTLYCLEANFILES = $(OURSCRIPTS) $(OURFILES) *.tmp +if USE_GIT_VERSION +GIT_VERSION := $(shell sh -c 'git describe --abbrev=4 --dirty | sed s/^v//') +REAL_PACKAGE_VERSION = $(GIT_VERSION) +else +REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) +endif + edit = sed \ -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@localstatedir[@]|$(localstatedir)|g' \ + -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \ -e 's|@SIZECMD[@]|$(SIZECMD)|g' \ -e '1s|!/bin/bash|!$(BASH_SHELL)|g' diff --git a/contrib/bacman.in b/contrib/bacman.in index 00d0691..9362356 100755 --- a/contrib/bacman.in +++ b/contrib/bacman.in @@ -24,7 +24,7 @@ shopt -s extglob shopt -s nullglob declare -r myname='bacman' -readonly progver="0.2.1" +declare -r myver='@PACKAGE_VERSION@' # # User Friendliness @@ -35,19 +35,21 @@ usage() { echo "Example: $myname kernel26" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2008 locci <carlocci_at_gmail_dot_com>' +} + if (( $# != 1 )); then usage exit 1 fi -if [[ $1 == "--help" || $1 == "-h" ]]; then +if [[ $1 = -@(h|-help) ]]; then usage exit 0 -fi - -if [[ $1 == "--version" || $1 == "-v" ]]; then - echo "$myname version $progver" - echo "Copyright (C) 2008 locci" +elif [[ $1 = -@(V|-version) ]]; then + version exit 0 fi @@ -177,7 +179,7 @@ pkg_size=$(du -sk | awk '{print $1 * 1024}') # TODO adopt makepkg's write_pkginfo() into this or scripts/library # echo Generating .PKGINFO metadata... -echo "# Generated by $myname $progver" > .PKGINFO +echo "# Generated by $myname $myver" > .PKGINFO if [[ $INFAKEROOT == "1" ]]; then echo "# Using $(fakeroot -v)" >> .PKGINFO fi diff --git a/contrib/paccache.in b/contrib/paccache.in index b95b964..da65f47 100755 --- a/contrib/paccache.in +++ b/contrib/paccache.in @@ -21,6 +21,7 @@ shopt -s extglob declare -r myname='paccache' +declare -r myver='@PACKAGE_VERSION@' declare -a candidates=() cmdopts=() whitelist=() blacklist=() declare -i delete=0 dryrun=0 filecount=0 move=0 needsroot=0 totalsaved=0 verbose=0 @@ -202,19 +203,32 @@ containing pacman package tarballs. EOF } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>' +} + if (( ! UID )); then error "Do not run this script as root. You will be prompted for privilege escalation." exit 42 fi -while getopts ':a:c:dfhi:k:m:rsuvz' opt; do +# TODO: remove this workaround and use a sane command line parser (like the +# parse_options library from scripts/) here +if [[ $1 = -@(h|-help) ]]; then + usage + exit 0 +elif [[ $1 = -@(V|-version) ]]; then + version + exit 0 +fi + +while getopts ':a:c:dfi:k:m:rsuvz' opt; do case $opt in a) scanarch=$OPTARG ;; c) cachedir=$OPTARG ;; d) dryrun=1 ;; f) cmdopts=(-f) ;; - h) usage - exit 0 ;; i) if [[ $OPTARG = '-' ]]; then [[ ! -t 0 ]] && IFS=$'\n' read -r -d '' -a ign else diff --git a/contrib/pacdiff.in b/contrib/pacdiff.in index 79cf809..bfafda2 100755 --- a/contrib/pacdiff.in +++ b/contrib/pacdiff.in @@ -18,6 +18,7 @@ # declare -r myname='pacdiff' +declare -r myver='@PACKAGE_VERSION@' diffprog=${DIFFPROG:-vimdiff} diffsearchpath=${DIFFSEARCHPATH:-/etc} @@ -32,6 +33,11 @@ usage() { echo "Example : DIFFPROG=meld DIFFSEARCHPATH=\"/boot /etc /usr\" $myname" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2007 Aaron Griffin <aaronmgriffin@gmail.com>' +} + cmd() { if [ $locate -eq 1 ]; then locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave @@ -44,8 +50,12 @@ if [ $# -gt 0 ]; then case $1 in -l|--locate) locate=1;; - *) + -V|--version) + version; exit 0;; + -h|--help) usage; exit 0;; + *) + usage; exit 1;; esac fi diff --git a/contrib/paclist.in b/contrib/paclist.in index 8623049..7883e21 100755 --- a/contrib/paclist.in +++ b/contrib/paclist.in @@ -18,6 +18,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. declare -r myname='paclist' +declare -r myver='@PACKAGE_VERSION@' export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='/usr/share/locale' @@ -29,13 +30,31 @@ if ! type gettext &>/dev/null; then } fi -if [[ -z $1 || $1 = -@(h|-help) ]]; then +usage() { printf '%s - List all packages installed from a given repo\n' "$myname" printf 'Usage: %s <repo>\n' "$myname" printf 'Example: %s testing\n' "$myname" +} + +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2008 Dan McGee <dpmcgee@gmail.com>' + echo 'Copyright (C) 2011 Dave Reisner <dreisner@archlinux.org>' +} + +if [[ -z $1 ]]; then + usage exit 1 fi +if [[ $1 = -@(h|-help) ]]; then + usage + exit 0 +elif [[ $1 = -@(V|-version) ]]; then + version + exit 0 +fi + printf -v installed '[%s]' "$(gettext installed)" pacman -Sl $1 | awk -v i="$installed" '$NF == i { print $2,$3 }' diff --git a/contrib/paclog-pkglist.in b/contrib/paclog-pkglist.in index 0b27bf3..222bbc4 100755 --- a/contrib/paclog-pkglist.in +++ b/contrib/paclog-pkglist.in @@ -18,16 +18,29 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. declare -r myname='paclog-pkglist' +declare -r myver='@PACKAGE_VERSION@' export TEXTDOMAIN='pacman' export TEXTDOMAINDIR='/usr/share/locale' declare logfile=${1:-@localstatedir@/log/pacman.log} +usage() { + printf 'usage: %s [pacman log]\n' "$myname" + printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname" + printf '\ndefaults to: @localstatedir@/log/pacman.log\n' +} + +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2011 Dave Reisner <dave@archlinux.org>' +} + if [[ $1 ]]; then if [[ $1 = -@(h|-help) ]]; then - printf 'usage: %s [pacman log]\n' "$myname" - printf 'example: %s @localstatedir@/log/pacman.log\n' "$myname" - printf '\ndefaults to: @localstatedir@/log/pacman.log\n' + usage + exit 0 + elif [[ $1 = -@(V|-version) ]]; then + version exit 0 elif [[ ! -e $logfile ]]; then printf $"target not found: %s\n" "$1" diff --git a/contrib/pacscripts.in b/contrib/pacscripts.in index 967f782..8468714 100755 --- a/contrib/pacscripts.in +++ b/contrib/pacscripts.in @@ -25,7 +25,7 @@ set -o nounset set -o errexit declare -r myname='pacscripts' -progver="0.4" +declare -r myver='@PACKAGE_VERSION@' conf="@sysconfdir@/pacman.conf" @@ -57,6 +57,12 @@ usage() { echo "Example: $myname gconf-editor-2.24.1-1-x86_64.pkg.tar.gz" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (c) 2009 Giulio "giulivo" Fidente <giulivo.navigante@gmail.com>' + echo 'Copyright (c) 2009 Xavier Chantry <shiningxc@gmail.com>' +} + spacman() { if [ $EUID -eq 0 ]; then pacman "$@" @@ -127,6 +133,6 @@ fi case "$1" in --help|-h) usage; exit 0 ;; - --version|-v) echo "$myname version $progver"; exit 0 ;; + --version|-V) version; exit 0 ;; *) print_scriptlet $1 ;; esac diff --git a/contrib/pacsearch.in b/contrib/pacsearch.in index 794110e..b1db8ab 100755 --- a/contrib/pacsearch.in +++ b/contrib/pacsearch.in @@ -25,21 +25,31 @@ use strict; use warnings; my $myname = 'pacsearch'; -my $version = "2.0"; +my $myver = '@PACKAGE_VERSION@'; -if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { +sub usage { print "$myname - Add color and install information to a pacman -Ss search\n"; print "Usage: $myname <pattern>\n"; print "Example: $myname ^gnome\n"; +} + +sub version { + printf "%s %s\n", $myname, $myver; + print "Copyright (C) 2008-2011 Dan McGee <dan\@archlinux.org>\n\n"; + print "Based off original shell script version:\n"; + print "Copyright (C) 2006-2007 Dan McGee <dan\@archlinux.org>\n"; +} + +if ($#ARGV lt 0 || $ARGV[0] eq "--help" || $ARGV[0] eq "-h") { + usage; if ($#ARGV lt 0) { exit 1; } exit 0; } -if ($ARGV[0] eq "--version" || $ARGV[0] eq "-v") { - print "$myname version $version\n"; - print "Copyright (C) 2006-2011 Dan McGee\n"; +if ($ARGV[0] eq "--version" || $ARGV[0] eq "-V") { + version; exit 0; } diff --git a/contrib/pacsysclean.in b/contrib/pacsysclean.in index c87082e..17f7681 100755 --- a/contrib/pacsysclean.in +++ b/contrib/pacsysclean.in @@ -2,23 +2,32 @@ # pacsysclean - Sort installed packages by decreasing installed size. Useful for system clean-up. +declare -r myname='pacsysclean' +declare -r myver='@PACKAGE_VERSION@' + PACMAN_OPTS= usage() { - echo "pacsysclean - Sort installed packages by decreasing installed size." + echo "$myname - Sort installed packages by decreasing installed size." echo - echo "Usage: pacsysclean [options]" + echo "Usage: $myname [options]" echo echo "Options:" echo " -o <options> Specify custom pacman query options (e.g., dt)" echo " -h, --help Show this help message and exit" } +version() { + printf "%s %s\n" "$myname" "$myver" + echo 'Copyright (C) 2011 Eric BĂ©langer <snowmaniscool@gmail.com>' +} + if [ -n "$1" ]; then case "$1" in -o) PACMAN_OPTS="${2}" ;; -h|--help) usage; exit 0 ;; + -V|--version) version; exit 0 ;; *) usage; exit 1 ;; esac fi -- 1.7.8
On 13/12/11 07:36, Lukas Fleischer wrote:
This implies following changes:
* contrib scripts can be built and installed easily by running make(1) in "contrib/". This removes the need to pick all contrib scripts manually when packaging pacman-contrib.
* contrib scripts will no longer be built when running make(1) in the top level source directory. This seems like the most natural approach. We install those separately and should act the same when building stuff.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Looks good to me Allan
participants (3)
-
Allan McRae
-
Dan McGee
-
Lukas Fleischer