From 05f0a28932c1acab7a9ddb58435d69626dad54da Mon Sep 17 00:00:00 2001 From: Nezmer Date: Tue, 12 Oct 2010 02:23:16 +0300 Subject: Use sysconfdir, localstatedir, BASH instead of hardcoded values This applies to contrib/ files, our scripts, and the documentation. Dan: fix 'make clean' in contrib/ directory. Signed-off-by: Nezmer Signed-off-by: Dan McGee --- contrib/Makefile.am | 33 +++++++++++++++++++++++++++++++-- contrib/bacman.in | 16 ++++++++-------- contrib/pacdiff.in | 2 +- contrib/pacscripts.in | 8 ++++---- contrib/pactree.in | 10 +++++----- contrib/wget-xdelta.sh.in | 10 +++++----- contrib/zsh_completion.in | 18 +++++++++--------- 7 files changed, 63 insertions(+), 34 deletions(-) (limited to 'contrib') diff --git a/contrib/Makefile.am b/contrib/Makefile.am index c6243b16..dd0b767c 100644 --- a/contrib/Makefile.am +++ b/contrib/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = \ +OURFILES = \ PKGBUILD.vim \ bacman \ bash_completion \ @@ -9,7 +9,36 @@ EXTRA_DIST = \ pactree \ vimprojects \ wget-xdelta.sh \ - zsh_completion \ + zsh_completion + +EXTRA_DIST = \ + PKGBUILD.vim.in \ + bacman.in \ + bash_completion.in \ + pacdiff.in \ + paclist.in \ + pacscripts.in \ + pacsearch.in \ + pactree.in \ + vimprojects.in \ + wget-xdelta.sh.in \ + zsh_completion.in \ README +# Files that should be removed, but which Automake does not know. +MOSTLYCLEANFILES = $(OURFILES) *.tmp + +edit = sed \ + -e 's|@sysconfdir[@]|$(sysconfdir)|g' \ + -e 's|@localstatedir[@]|$(localstatedir)|g' \ + -e 's|@BASH[@]|$(BASH)|g' + +$(OURFILES): Makefile + @rm -f $@ $@.tmp + @cp -a $@.in $@.tmp + $(edit) $@.in >$@.tmp + @mv $@.tmp $@ + +all-am: $(OURFILES) + # vim:set ts=2 sw=2 noet: diff --git a/contrib/bacman.in b/contrib/bacman.in index 6dd78394..2a93f8be 100755 --- a/contrib/bacman.in +++ b/contrib/bacman.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!@BASH@ # # bacman: recreate a package from a running system # This script rebuilds an already installed package using metadata @@ -67,20 +67,20 @@ fi # # Setting environmental variables # -if [ ! -r /etc/pacman.conf ]; then - echo "ERROR: unable to read /etc/pacman.conf" +if [ ! -r @sysconfdir@/pacman.conf ]; then + echo "ERROR: unable to read @sysconfdir@/pacman.conf" exit 1 fi -eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) -pac_db="${DBPath:-/var/lib/pacman/}/local" +eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) +pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local" -if [ ! -r /etc/makepkg.conf ]; then - echo "ERROR: unable to read /etc/makepkg.conf" +if [ ! -r @sysconfdir@/makepkg.conf ]; then + echo "ERROR: unable to read @sysconfdir@/makepkg.conf" exit 1 fi -source "/etc/makepkg.conf" +source "@sysconfdir@/makepkg.conf" if [ -r ~/.makepkg.conf ]; then source ~/.makepkg.conf fi diff --git a/contrib/pacdiff.in b/contrib/pacdiff.in index 3f26f381..716333a0 100755 --- a/contrib/pacdiff.in +++ b/contrib/pacdiff.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!@BASH@ # pacdiff : a simple pacnew/pacorig/pacsave updater # # Copyright (c) 2007 Aaron Griffin diff --git a/contrib/pacscripts.in b/contrib/pacscripts.in index 101fb15f..123c79df 100755 --- a/contrib/pacscripts.in +++ b/contrib/pacscripts.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!@BASH@ # # pacscripts : tries to print out the {pre,post}_{install,remove,upgrade} # scripts of a given package @@ -27,7 +27,7 @@ set -o errexit progname=$(basename $0) progver="0.4" -conf="/etc/pacman.conf" +conf="@sysconfdir@/pacman.conf" if [ ! -r "$conf" ]; then echo "ERROR: unable to read $conf" @@ -36,8 +36,8 @@ fi eval $(awk '/DBPath/ {print $1$2$3}' "$conf") eval $(awk '/CacheDir/ {print $1$2$3}' "$conf") -pac_db="${DBPath:-/var/lib/pacman}/local" -pac_cache="${CacheDir:-/var/cache/pacman/pkg}" +pac_db="${DBPath:-@localstatedir@/lib/pacman}/local" +pac_cache="${CacheDir:-@localstatedir@/cache/pacman/pkg}" error() { local mesg=$1; shift diff --git a/contrib/pactree.in b/contrib/pactree.in index 6051724e..29c6af6c 100755 --- a/contrib/pactree.in +++ b/contrib/pactree.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!@BASH@ # pactree : a simple dependency tree viewer # # Copyright (C) 2008 Carlo "carlocci" Bersani @@ -272,14 +272,14 @@ if [ $graphviz -eq 1 ]; then fi fi -if [ ! -r /etc/pacman.conf ]; then - echo "ERROR: unable to read /etc/pacman.conf" +if [ ! -r @sysconfdir@/pacman.conf ]; then + echo "ERROR: unable to read @sysconfdir@/pacman.conf" exit 1 else - eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) + eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf) fi -pac_db="${DBPath:-/var/lib/pacman}/local" +pac_db="${DBPath:-@localstatedir@/lib/pacman}/local" if [ ! -d "$pac_db" ] ; then echo "ERROR: pacman database directory ${pac_db} not found" diff --git a/contrib/wget-xdelta.sh.in b/contrib/wget-xdelta.sh.in index 4656f4dd..caf0171e 100755 --- a/contrib/wget-xdelta.sh.in +++ b/contrib/wget-xdelta.sh.in @@ -1,7 +1,7 @@ -#!/bin/bash +#!@BASH@ -if [ -r "/etc/makepkg.conf" ]; then - source /etc/makepkg.conf +if [ -r "@sysconfdir@/makepkg.conf" ]; then + source @sysconfdir@/makepkg.conf else echo "wget-xdelta: Unable to find makepkg.conf" exit 1 @@ -30,11 +30,11 @@ new_version=$(echo $pkg_data | cut -d ' ' -f 2) base_url=${file_url%/*} # Look for the last version -for file in $(ls -r /var/cache/pacman/pkg/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do +for file in $(ls -r @localstatedir@/cache/pacman/pkg/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do [[ "$file" =~ "$CARCH" ]] && arch="-$CARCH" || arch="" check_version=$(echo $file | \ sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}$PKGEXT$|\1|" | \ - grep -v "^/var/cache/pacman/pkg") + grep -v "^@localstatedir@/cache/pacman/pkg") [ "$check_version" = "" ] && continue diff --git a/contrib/zsh_completion.in b/contrib/zsh_completion.in index f69fe631..16919134 100644 --- a/contrib/zsh_completion.in +++ b/contrib/zsh_completion.in @@ -222,20 +222,20 @@ _pacman_completions_all_groups() { _pacman_completions_all_packages() { local -a cmd packages repositories packages_long - repositories=(${(o)${${${(M)${(f)"$(