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 <git@nezmer.info>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Nezmer 2010-10-12 02:23:16 +03:00 committed by Dan McGee
parent bce3c8efc7
commit 05f0a28932
18 changed files with 81 additions and 49 deletions

View file

@ -127,6 +127,7 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
AC_PROG_LIBTOOL AC_PROG_LIBTOOL
AC_CHECK_PROGS([PYTHON], [python2.7 python2.6 python2.5 python2 python], [false]) AC_CHECK_PROGS([PYTHON], [python2.7 python2.6 python2.5 python2 python], [false])
AC_CHECK_PROGS([BASH], [bash bash4 bash3], [false])
# find installed gettext # find installed gettext
AM_GNU_GETTEXT([external]) AM_GNU_GETTEXT([external])

View file

@ -1,4 +1,4 @@
EXTRA_DIST = \ OURFILES = \
PKGBUILD.vim \ PKGBUILD.vim \
bacman \ bacman \
bash_completion \ bash_completion \
@ -9,7 +9,36 @@ EXTRA_DIST = \
pactree \ pactree \
vimprojects \ vimprojects \
wget-xdelta.sh \ 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 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: # vim:set ts=2 sw=2 noet:

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# #
# bacman: recreate a package from a running system # bacman: recreate a package from a running system
# This script rebuilds an already installed package using metadata # This script rebuilds an already installed package using metadata
@ -67,20 +67,20 @@ fi
# #
# Setting environmental variables # Setting environmental variables
# #
if [ ! -r /etc/pacman.conf ]; then if [ ! -r @sysconfdir@/pacman.conf ]; then
echo "ERROR: unable to read /etc/pacman.conf" echo "ERROR: unable to read @sysconfdir@/pacman.conf"
exit 1 exit 1
fi fi
eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
pac_db="${DBPath:-/var/lib/pacman/}/local" pac_db="${DBPath:-@localstatedir@/lib/pacman/}/local"
if [ ! -r /etc/makepkg.conf ]; then if [ ! -r @sysconfdir@/makepkg.conf ]; then
echo "ERROR: unable to read /etc/makepkg.conf" echo "ERROR: unable to read @sysconfdir@/makepkg.conf"
exit 1 exit 1
fi fi
source "/etc/makepkg.conf" source "@sysconfdir@/makepkg.conf"
if [ -r ~/.makepkg.conf ]; then if [ -r ~/.makepkg.conf ]; then
source ~/.makepkg.conf source ~/.makepkg.conf
fi fi

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# pacdiff : a simple pacnew/pacorig/pacsave updater # pacdiff : a simple pacnew/pacorig/pacsave updater
# #
# Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com> # Copyright (c) 2007 Aaron Griffin <aaronmgriffin@gmail.com>

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# #
# pacscripts : tries to print out the {pre,post}_{install,remove,upgrade} # pacscripts : tries to print out the {pre,post}_{install,remove,upgrade}
# scripts of a given package # scripts of a given package
@ -27,7 +27,7 @@ set -o errexit
progname=$(basename $0) progname=$(basename $0)
progver="0.4" progver="0.4"
conf="/etc/pacman.conf" conf="@sysconfdir@/pacman.conf"
if [ ! -r "$conf" ]; then if [ ! -r "$conf" ]; then
echo "ERROR: unable to read $conf" echo "ERROR: unable to read $conf"
@ -36,8 +36,8 @@ fi
eval $(awk '/DBPath/ {print $1$2$3}' "$conf") eval $(awk '/DBPath/ {print $1$2$3}' "$conf")
eval $(awk '/CacheDir/ {print $1$2$3}' "$conf") eval $(awk '/CacheDir/ {print $1$2$3}' "$conf")
pac_db="${DBPath:-/var/lib/pacman}/local" pac_db="${DBPath:-@localstatedir@/lib/pacman}/local"
pac_cache="${CacheDir:-/var/cache/pacman/pkg}" pac_cache="${CacheDir:-@localstatedir@/cache/pacman/pkg}"
error() { error() {
local mesg=$1; shift local mesg=$1; shift

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# pactree : a simple dependency tree viewer # pactree : a simple dependency tree viewer
# #
# Copyright (C) 2008 Carlo "carlocci" Bersani <carlocci@gmail.com> # Copyright (C) 2008 Carlo "carlocci" Bersani <carlocci@gmail.com>
@ -272,14 +272,14 @@ if [ $graphviz -eq 1 ]; then
fi fi
fi fi
if [ ! -r /etc/pacman.conf ]; then if [ ! -r @sysconfdir@/pacman.conf ]; then
echo "ERROR: unable to read /etc/pacman.conf" echo "ERROR: unable to read @sysconfdir@/pacman.conf"
exit 1 exit 1
else else
eval $(awk '/DBPath/ {print $1$2$3}' /etc/pacman.conf) eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
fi fi
pac_db="${DBPath:-/var/lib/pacman}/local" pac_db="${DBPath:-@localstatedir@/lib/pacman}/local"
if [ ! -d "$pac_db" ] ; then if [ ! -d "$pac_db" ] ; then
echo "ERROR: pacman database directory ${pac_db} not found" echo "ERROR: pacman database directory ${pac_db} not found"

View file

@ -1,7 +1,7 @@
#!/bin/bash #!@BASH@
if [ -r "/etc/makepkg.conf" ]; then if [ -r "@sysconfdir@/makepkg.conf" ]; then
source /etc/makepkg.conf source @sysconfdir@/makepkg.conf
else else
echo "wget-xdelta: Unable to find makepkg.conf" echo "wget-xdelta: Unable to find makepkg.conf"
exit 1 exit 1
@ -30,11 +30,11 @@ new_version=$(echo $pkg_data | cut -d ' ' -f 2)
base_url=${file_url%/*} base_url=${file_url%/*}
# Look for the last version # 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="" [[ "$file" =~ "$CARCH" ]] && arch="-$CARCH" || arch=""
check_version=$(echo $file | \ check_version=$(echo $file | \
sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}$PKGEXT$|\1|" | \ sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)${arch}$PKGEXT$|\1|" | \
grep -v "^/var/cache/pacman/pkg") grep -v "^@localstatedir@/cache/pacman/pkg")
[ "$check_version" = "" ] && continue [ "$check_version" = "" ] && continue

View file

@ -222,20 +222,20 @@ _pacman_completions_all_groups() {
_pacman_completions_all_packages() { _pacman_completions_all_packages() {
local -a cmd packages repositories packages_long local -a cmd packages repositories packages_long
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
typeset -U repositories typeset -U repositories
packages_long=(/var/lib/pacman/sync/${^repositories}/*(/)) packages_long=(@localstatedir@/lib/pacman/sync/${^repositories}/*(/))
packages=(${(o)${${packages_long/\/var\/lib\/pacman\/sync\//}#*/}%-*-*} ) packages=(${(o)${${packages_long#@localstatedir@/lib/pacman/sync/}#*/}%-*-*} )
typeset -U packages typeset -U packages
_wanted packages expl "packages" compadd - "${(@)packages}" _wanted packages expl "packages" compadd - "${(@)packages}"
if [[ $PREFIX != */* ]] ; then if [[ $PREFIX != */* ]] ; then
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
typeset -U repositories typeset -U repositories
_wanted repo_packages expl "repository/package" compadd -S "/" $repositories _wanted repo_packages expl "repository/package" compadd -S "/" $repositories
else else
compset -P '*/' compset -P '*/'
packages_long=(/var/lib/pacman/sync/$IPREFIX*(/)) packages_long=(@localstatedir@/lib/pacman/sync/$IPREFIX*(/))
packages=(${(o)${${packages_long/\/var\/lib\/pacman\/sync\//}#*/}%-*-*} ) packages=(${(o)${${packages_long#@localstatedir@/lib/pacman/sync/}#*/}%-*-*} )
typeset -U packages typeset -U packages
_wanted repo_packages expl "repository/package" compadd ${(@)packages} _wanted repo_packages expl "repository/package" compadd ${(@)packages}
fi fi
@ -253,15 +253,15 @@ _pacman_completions_installed_groups() {
# provides completions for installed packages # provides completions for installed packages
_pacman_completions_installed_packages() { _pacman_completions_installed_packages() {
local -a cmd packages packages_long local -a cmd packages packages_long
packages_long=(/var/lib/pacman/local/*(/)) packages_long=(@localstatedir@/lib/pacman/local/*(/))
packages=( ${${packages_long/\/var\/lib\/pacman\/local\//}%-*-*} ) packages=( ${${packages_long#@localstatedir@/lib/pacman/local/}%-*-*} )
compadd "$@" -a packages compadd "$@" -a packages
} }
# provides completions for repository names # provides completions for repository names
_pacman_completions_repositories() { _pacman_completions_repositories() {
local -a cmd repositories local -a cmd repositories
repositories=(${(o)${${${(M)${(f)"$(</etc/pacman.conf)"}:#\[*}/\[/}/\]/}:#options}) repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
# Uniq the array # Uniq the array
typeset -U repositories typeset -U repositories
compadd "$@" -a repositories compadd "$@" -a repositories

View file

@ -96,6 +96,7 @@ ASCIIDOC_OPTS = \
-a pacman_version="$(REAL_PACKAGE_VERSION)" \ -a pacman_version="$(REAL_PACKAGE_VERSION)" \
-a pacman_date="`date +%Y-%m-%d`" \ -a pacman_date="`date +%Y-%m-%d`" \
-a pkgdatadir=$(pkgdatadir) \ -a pkgdatadir=$(pkgdatadir) \
-a localstatedir=$(localstatedir) \
-a sysconfdir=$(sysconfdir) -a sysconfdir=$(sysconfdir)
A2X_OPTS = \ A2X_OPTS = \

View file

@ -53,7 +53,7 @@ Options
in linkman:makepkg.conf[5]. in linkman:makepkg.conf[5].
*--config* <`/path/to/config`>:: *--config* <`/path/to/config`>::
Use an alternate config file instead of the `/etc/makepkg.conf` default; Use an alternate config file instead of the `{sysconfdir}/makepkg.conf` default;
*-d, \--nodeps*:: *-d, \--nodeps*::
Do not perform any dependency checks. This will let you override and Do not perform any dependency checks. This will let you override and

View file

@ -118,7 +118,7 @@ Options
*-b, \--dbpath* <'path'>:: *-b, \--dbpath* <'path'>::
Specify an alternative database location (a typical default is Specify an alternative database location (a typical default is
``/var/lib/pacman''). This should not be used unless you know what you are ``{localstatedir}/lib/pacman''). This should not be used unless you know what you are
doing. *NOTE*: if specified, this is an absolute path and the root path is doing. *NOTE*: if specified, this is an absolute path and the root path is
not automatically prepended. not automatically prepended.
@ -151,7 +151,7 @@ Options
*\--cachedir* <'dir'>:: *\--cachedir* <'dir'>::
Specify an alternative package cache location (a typical default is Specify an alternative package cache location (a typical default is
``/var/cache/pacman/pkg''). Multiple cache directories can be specified, ``{localstatedir}/cache/pacman/pkg''). Multiple cache directories can be specified,
and they are tried in the order they are passed to pacman. *NOTE*: this and they are tried in the order they are passed to pacman. *NOTE*: this
is an absolute path, the root path is not automatically prepended. is an absolute path, the root path is not automatically prepended.

View file

@ -35,7 +35,7 @@ NoUpgrade = etc/passwd etc/group etc/shadow
NoUpgrade = etc/fstab NoUpgrade = etc/fstab
[core] [core]
Include = /etc/pacman.d/core Include = {sysconfdir}/pacman.d/core
[custom] [custom]
Server = file:///home/pkgs Server = file:///home/pkgs
@ -57,13 +57,13 @@ Options
*DBPath =* path/to/db/dir:: *DBPath =* path/to/db/dir::
Overrides the default location of the toplevel database directory. A Overrides the default location of the toplevel database directory. A
typical default is ``/var/lib/pacman/''. Most users will not need to set typical default is ``{localstatedir}/lib/pacman/''. Most users will not need to set
this option. *NOTE*: if specified, this is an absolute path and the root this option. *NOTE*: if specified, this is an absolute path and the root
path is not automatically prepended. path is not automatically prepended.
*CacheDir =* path/to/cache/dir:: *CacheDir =* path/to/cache/dir::
Overrides the default location of the package cache directory. A typical Overrides the default location of the package cache directory. A typical
default is ``/var/cache/pacman/pkg/''. Multiple cache directories can be default is ``{localstatedir}/cache/pacman/pkg/''. Multiple cache directories can be
specified, and they are tried in the order they are listed in the config specified, and they are tried in the order they are listed in the config
file. If a file is not found in any cache directory, it will be downloaded file. If a file is not found in any cache directory, it will be downloaded
to the first cache directory with write access. *NOTE*: this is an absolute to the first cache directory with write access. *NOTE*: this is an absolute
@ -72,7 +72,7 @@ Options
*LogFile =* '/path/to/file':: *LogFile =* '/path/to/file'::
Overrides the default location of the pacman log file. A typical default Overrides the default location of the pacman log file. A typical default
is ``/var/log/pacman.log''. This is an absolute path and the root directory is ``{localstatedir}/log/pacman.log''. This is an absolute path and the root directory
is not prepended. is not prepended.
*HoldPkg =* package ...:: *HoldPkg =* package ...::
@ -147,7 +147,7 @@ Options
*UseSyslog*:: *UseSyslog*::
Log action messages through syslog(). This will insert log entries into Log action messages through syslog(). This will insert log entries into
``/var/log/messages'' or equivalent. ``{localstatedir}/log/messages'' or equivalent.
*ShowSize*:: *ShowSize*::
Display the size of individual packages for '\--sync' and '\--query' modes. Display the size of individual packages for '\--sync' and '\--query' modes.
@ -180,7 +180,7 @@ contain a file that lists the servers for that repository.
# use this repository first # use this repository first
Server = ftp://ftp.archlinux.org/core/os/arch Server = ftp://ftp.archlinux.org/core/os/arch
# next use servers as defined in the mirrorlist below # next use servers as defined in the mirrorlist below
Include = /etc/pacman.d/mirrorlist Include = {sysconfdir}/pacman.d/mirrorlist
-------- --------
During parsing, pacman will define the `$repo` variable to the name of the During parsing, pacman will define the `$repo` variable to the name of the

View file

@ -35,6 +35,7 @@ edit = sed \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \ -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \ -e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@prefix[@]|$(prefix)|g' \ -e 's|@prefix[@]|$(prefix)|g' \
-e 's|@BASH[@]|$(BASH)|g' \
-e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \ -e 's|@PACKAGE_VERSION[@]|$(REAL_PACKAGE_VERSION)|g' \
-e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \ -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \

View file

@ -1,4 +1,4 @@
#!/bin/bash -e #!@BASH@ -e
# #
# makepkg - make packages compatible for use with pacman # makepkg - make packages compatible for use with pacman
# @configure_input@ # @configure_input@

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# #
# pacman-optimize # pacman-optimize
# @configure_input@ # @configure_input@

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# #
# pkgdelta - create delta files for use with pacman and repo-add # pkgdelta - create delta files for use with pacman and repo-add
# @configure_input@ # @configure_input@

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# #
# rankmirrors - read a list of mirrors from a file and rank them by speed # rankmirrors - read a list of mirrors from a file and rank them by speed
# @configure_input@ # @configure_input@
@ -25,7 +25,7 @@ usage() {
echo "Usage: rankmirrors [options] MIRRORFILE | URL" echo "Usage: rankmirrors [options] MIRRORFILE | URL"
echo echo
echo "Ranks pacman mirrors by their connection and opening speed. Pacman mirror" echo "Ranks pacman mirrors by their connection and opening speed. Pacman mirror"
echo "files are located in /etc/pacman.d/. It can also rank one mirror if the URL is" echo "files are located in @sysconfdir@/pacman.d/. It can also rank one mirror if the URL is"
echo "provided." echo "provided."
echo echo
echo "Options:" echo "Options:"

View file

@ -1,4 +1,4 @@
#!/bin/bash #!@BASH@
# #
# repo-add - add a package to a given repo database file # repo-add - add a package to a given repo database file
# repo-remove - remove a package entry from a given repo database file # repo-remove - remove a package entry from a given repo database file