[pacman-dev] [PATCH 2/4] Use localstatedir instead of hardcoded /var

Nezmer git at nezmer.info
Mon Oct 11 15:16:47 EDT 2010


 "/var" was hardcoded in some scripts and manpages. Change this to
 respect localstatedir

Signed-off-by: Nezmer <git at nezmer.info>
---
 contrib/Makefile.am    |    4 +++-
 contrib/bacman         |    2 +-
 contrib/pacscripts     |    4 ++--
 contrib/pactree        |    2 +-
 contrib/wget-xdelta.sh |    4 ++--
 contrib/zsh_completion |   12 ++++++------
 doc/Makefile.am        |    4 +++-
 doc/pacman.8.txt       |    4 ++--
 doc/pacman.conf.5.txt  |    8 ++++----
 9 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index cb2ffc7..337a3f3 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -12,7 +12,9 @@ EXTRA_DIST = \
 	zsh_completion \
 	README
 
-edit = sed -e 's|@sysconfdir[@]|$(sysconfdir)|g'
+edit = sed \
+	-e 's|@localstatedir[@]|$(localstatedir)|g' \
+	-e 's|@sysconfdir[@]|$(sysconfdir)|g'
 
 # Use sysconfdir
 $(EXTRA_DIST): Makefile
diff --git a/contrib/bacman b/contrib/bacman
index dfb0ad9..504ba51 100755
--- a/contrib/bacman
+++ b/contrib/bacman
@@ -73,7 +73,7 @@ if [ ! -r @sysconfdir@/pacman.conf ]; then
 fi
 
 eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
-pac_db="${DBPath:-/var/lib/pacman/}/local"
+pac_db="${DBPath:- at localstatedir@/lib/pacman/}/local"
 
 if [ ! -r @sysconfdir@/makepkg.conf ]; then
     echo "ERROR: unable to read @sysconfdir@/makepkg.conf"
diff --git a/contrib/pacscripts b/contrib/pacscripts
index b4fdf32..3479dc1 100755
--- a/contrib/pacscripts
+++ b/contrib/pacscripts
@@ -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:- at localstatedir@/lib/pacman}/local"
+pac_cache="${CacheDir:- at localstatedir@/cache/pacman/pkg}"
 
 error() {
 	local mesg=$1; shift
diff --git a/contrib/pactree b/contrib/pactree
index ed55a61..8a59a34 100755
--- a/contrib/pactree
+++ b/contrib/pactree
@@ -279,7 +279,7 @@ else
 	eval $(awk '/DBPath/ {print $1$2$3}' @sysconfdir@/pacman.conf)
 fi
 
-pac_db="${DBPath:-/var/lib/pacman}/local"
+pac_db="${DBPath:- at 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 b/contrib/wget-xdelta.sh
index 03b3b6e..a77b2b3 100755
--- a/contrib/wget-xdelta.sh
+++ b/contrib/wget-xdelta.sh
@@ -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 b/contrib/zsh_completion
index 9b67881..1691913 100644
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -224,8 +224,8 @@ _pacman_completions_all_packages() {
 
 	repositories=(${(o)${${${(M)${(f)"$(<@sysconfdir@/pacman.conf)"}:#\[*}/\[/}/\]/}:#options})
 	typeset -U repositories
-	packages_long=(/var/lib/pacman/sync/${^repositories}/*(/))
-	packages=(${(o)${${packages_long/\/var\/lib\/pacman\/sync\//}#*/}%-*-*} )
+	packages_long=(@localstatedir@/lib/pacman/sync/${^repositories}/*(/))
+	packages=(${(o)${${packages_long#@localstatedir@/lib/pacman/sync/}#*/}%-*-*} )
 	typeset -U packages
 	_wanted packages expl "packages" compadd - "${(@)packages}"
 	if [[ $PREFIX != */* ]] ; then
@@ -234,8 +234,8 @@ _pacman_completions_all_packages() {
 		_wanted repo_packages expl "repository/package" compadd -S "/" $repositories
 	else
 		compset -P '*/'
-		packages_long=(/var/lib/pacman/sync/$IPREFIX*(/))
-		packages=(${(o)${${packages_long/\/var\/lib\/pacman\/sync\//}#*/}%-*-*} )
+		packages_long=(@localstatedir@/lib/pacman/sync/$IPREFIX*(/))
+		packages=(${(o)${${packages_long#@localstatedir@/lib/pacman/sync/}#*/}%-*-*} )
 		typeset -U packages
 		_wanted repo_packages expl "repository/package" compadd ${(@)packages}
 	fi
@@ -253,8 +253,8 @@ _pacman_completions_installed_groups() {
 # provides completions for installed packages
 _pacman_completions_installed_packages() {
 	local -a cmd packages packages_long
-	packages_long=(/var/lib/pacman/local/*(/))
-	packages=( ${${packages_long/\/var\/lib\/pacman\/local\//}%-*-*} )
+	packages_long=(@localstatedir@/lib/pacman/local/*(/))
+	packages=( ${${packages_long#@localstatedir@/lib/pacman/local/}%-*-*} )
 	compadd "$@" -a packages
 }
 
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 91a7695..2cc339f 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -66,7 +66,9 @@ else
 REAL_PACKAGE_VERSION = $(PACKAGE_VERSION)
 endif
 
-edit = sed -e 's|@sysconfdir[@]|$(sysconfdir)|g'
+edit = sed \
+	-e 's|@localstatedir[@]|$(localstatedir)|g' \
+	-e 's|@sysconfdir[@]|$(sysconfdir)|g'
 
 man_MANS =
 dist_man_MANS = $(ASCIIDOC_MANS) repo-remove.8
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt
index de1f51f..98922ba 100644
--- a/doc/pacman.8.txt
+++ b/doc/pacman.8.txt
@@ -118,7 +118,7 @@ Options
 
 *-b, \--dbpath* <'path'>::
 	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
 	not automatically prepended.
 
@@ -151,7 +151,7 @@ Options
 
 *\--cachedir* <'dir'>::
 	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
 	is an absolute path, the root path is not automatically prepended.
 
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index f203600..1bd58e8 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -57,13 +57,13 @@ Options
 
 *DBPath =* path/to/db/dir::
 	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
 	path is not automatically prepended.
 
 *CacheDir =* path/to/cache/dir::
 	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
 	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
@@ -72,7 +72,7 @@ Options
 
 *LogFile =* '/path/to/file'::
 	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.
 
 *HoldPkg =* package ...::
@@ -147,7 +147,7 @@ Options
 
 *UseSyslog*::
 	Log action messages through syslog(). This will insert log entries into
-	``/var/log/messages'' or equivalent.
+	``@localstatedir@/log/messages'' or equivalent.
 
 *ShowSize*::
 	Display the size of individual packages for '\--sync' and '\--query' modes.
-- 
1.7.3.1



More information about the pacman-dev mailing list