[pacman-dev] [PATCH 1/4] paccache: read default cachedir from pacman.conf
Implements FS#40738. --- contrib/paccache.sh.in | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in index 039ac8a..57c0458 100644 --- a/contrib/paccache.sh.in +++ b/contrib/paccache.sh.in @@ -25,7 +25,7 @@ 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 -declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch= +declare cachedir= delim=$'\n' keep=3 movedir= scanarch= USE_COLOR='y' @@ -37,6 +37,19 @@ die() { exit 1 } +get_cachedir_from_config() { + local key value + + while IFS=$'= \t' read -r key value _; do + if [[ $key = CacheDir ]]; then + echo "$value" + return 0 + fi + done <"$1" + + return 1 +} + # reads a list of files on stdin and prints out deletion candidates pkgfilter() { # there's whitelist and blacklist parameters passed to this @@ -165,8 +178,7 @@ Usage: ${myname} <operation> [options] [targets...] Options: -a, --arch <arch> scan for "arch" (default: all architectures). - -c, --cachedir <dir> scan "dir" for packages. - (default: @localstatedir@/cache/pacman/pkg). + -c, --cachedir <dir> scan "dir" for packages. (default: $cachedir). -f, --force apply force to mv(1) and rm(1) operations. -h, --help display this help message and exit. -i, --ignore <pkgs> ignore "pkgs", comma-separated. Alternatively, specify @@ -191,6 +203,8 @@ OPT_SHORT=':a:c:dfhi:k:m:rsuVvz' OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move' 'nocolor' 'remove' 'uninstalled' 'version' 'verbose' 'null') +cachedir=$(get_cachedir_from_config "@sysconfdir@/pacman.conf") + if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 fi -- 2.0.4
Since source package creation is architecture independent, we should ignore architecture-dependent behaviors such as the lint check which will halt execution when the host machine is not a supported arch. https://github.com/falconindy/pkgbuild-introspection/issues/15 --- scripts/makepkg.sh.in | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 8e8a64c..cec190b 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -3154,10 +3154,16 @@ fi SRCPKGDEST=${_SRCPKGDEST:-$SRCPKGDEST} SRCPKGDEST=${SRCPKGDEST:-$startdir} #default to $startdir if undefined -if (( SOURCEONLY )) && [[ ! -w $SRCPKGDEST ]]; then - error "$(gettext "You do not have write permission to store source tarballs in %s.")" "$SRCPKGDEST" - plain "$(gettext "Aborting...")" - exit 1 +if (( SOURCEONLY )); then + if [[ ! -w $SRCPKGDEST ]]; then + error "$(gettext "You do not have write permission to store source tarballs in %s.")" "$SRCPKGDEST" + plain "$(gettext "Aborting...")" + exit 1 + fi + + # If we're only making a source tarball, then we need to ignore architecture- + # dependent behavior. + IGNOREARCH=1 fi LOGDEST=${_LOGDEST:-$LOGDEST} -- 2.0.4
Change e10775340 should have included this. --- doc/PKGBUILD.5.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index e2389cb..c653aac 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -213,8 +213,8 @@ underscore and the architecture name e.g., 'checkdepends_x86_64=()'. optdepends=('fakeroot: for makepkg usage as normal user') + -Architecture-specific optdepends can be added by appending an underscore and -the architecture name e.g., 'optdepends_x86_64=()'. +Additional architecture-specific optdepends can be added by appending an +underscore and the architecture name e.g., 'optdepends_x86_64=()'. *conflicts (array)*:: An array of packages that will conflict with this package (i.e. they -- 2.0.4
We rely on values in the arch array to be valid as part of variable names, so extend the arch lint check to catch this. This also cleans up lint_arch to restrict the use of "lint" only to the package-specific architecture checks. It previously had an odd declaration with a conditional expansion that would never be true. --- scripts/makepkg.sh.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cec190b..0ea6d5f 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -2360,13 +2360,21 @@ lint_epoch() { } lint_arch() { - local name list=("${@:-"${arch[@]}"}") + local a name list - if [[ $list == 'any' ]]; then + if [[ $arch == 'any' ]]; then return 0 fi - if ! in_array "$CARCH" "${list[@]}" && (( ! IGNOREARCH )); then + for a in "${arch[@]}"; do + if [[ $a = *[![:alnum:]_]* ]]; then + error "$(gettext "%s contains invalid characters: '%s'")" \ + 'arch' "${a//[[:alnum:]_]}" + ret=1 + fi + done + + if (( ! IGNOREARCH )) && ! in_array "$CARCH" "${arch[@]}"; then error "$(gettext "%s is not available for the '%s' architecture.")" "$pkgbase" "$CARCH" plain "$(gettext "Note that many packages may need a line added to their %s")" "$BUILDSCRIPT" plain "$(gettext "such as %s.")" "arch=('$CARCH')" -- 2.0.4
Implements FS#40738. --- Sorry, last patch is broke when pacman.conf has no CacheDir defined... contrib/paccache.sh.in | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in index 039ac8a..b9620a1 100644 --- a/contrib/paccache.sh.in +++ b/contrib/paccache.sh.in @@ -25,7 +25,7 @@ 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 -declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch= +declare cachedir= delim=$'\n' keep=3 movedir= scanarch= USE_COLOR='y' @@ -37,6 +37,19 @@ die() { exit 1 } +get_cachedir_from_config() { + local key value + + while IFS=$'= \t' read -r key value _; do + if [[ $key = CacheDir ]]; then + echo "$value" + return 0 + fi + done <"$1" + + return 1 +} + # reads a list of files on stdin and prints out deletion candidates pkgfilter() { # there's whitelist and blacklist parameters passed to this @@ -165,8 +178,7 @@ Usage: ${myname} <operation> [options] [targets...] Options: -a, --arch <arch> scan for "arch" (default: all architectures). - -c, --cachedir <dir> scan "dir" for packages. - (default: @localstatedir@/cache/pacman/pkg). + -c, --cachedir <dir> scan "dir" for packages. (default: $cachedir). -f, --force apply force to mv(1) and rm(1) operations. -h, --help display this help message and exit. -i, --ignore <pkgs> ignore "pkgs", comma-separated. Alternatively, specify @@ -191,6 +203,10 @@ OPT_SHORT=':a:c:dfhi:k:m:rsuVvz' OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move' 'nocolor' 'remove' 'uninstalled' 'version' 'verbose' 'null') +if ! cachedir=$(get_cachedir_from_config "@sysconfdir@/pacman.conf"); then + cachedir=@localstatedir@/cache/pacman/pkg +fi + if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 fi -- 2.0.4
On 10/08/14 23:41, Dave Reisner wrote:
Implements FS#40738. --- Sorry, last patch is broke when pacman.conf has no CacheDir defined...
contrib/paccache.sh.in | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in index 039ac8a..b9620a1 100644 --- a/contrib/paccache.sh.in +++ b/contrib/paccache.sh.in @@ -25,7 +25,7 @@ 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 -declare cachedir=@localstatedir@/cache/pacman/pkg delim=$'\n' keep=3 movedir= scanarch= +declare cachedir= delim=$'\n' keep=3 movedir= scanarch=
USE_COLOR='y'
@@ -37,6 +37,19 @@ die() { exit 1 }
+get_cachedir_from_config() { + local key value + + while IFS=$'= \t' read -r key value _; do + if [[ $key = CacheDir ]]; then + echo "$value" + return 0 + fi + done <"$1" + + return 1 +} + # reads a list of files on stdin and prints out deletion candidates pkgfilter() { # there's whitelist and blacklist parameters passed to this @@ -165,8 +178,7 @@ Usage: ${myname} <operation> [options] [targets...]
Options: -a, --arch <arch> scan for "arch" (default: all architectures). - -c, --cachedir <dir> scan "dir" for packages. - (default: @localstatedir@/cache/pacman/pkg). + -c, --cachedir <dir> scan "dir" for packages. (default: $cachedir).
OK - I moved the default: ... back to its own line because this does not wrap in a pretty fashion.
-f, --force apply force to mv(1) and rm(1) operations. -h, --help display this help message and exit. -i, --ignore <pkgs> ignore "pkgs", comma-separated. Alternatively, specify @@ -191,6 +203,10 @@ OPT_SHORT=':a:c:dfhi:k:m:rsuVvz' OPT_LONG=('arch:' 'cachedir:' 'dryrun' 'force' 'help' 'ignore:' 'keep:' 'move' 'nocolor' 'remove' 'uninstalled' 'version' 'verbose' 'null')
+if ! cachedir=$(get_cachedir_from_config "@sysconfdir@/pacman.conf"); then + cachedir=@localstatedir@/cache/pacman/pkg +fi + if ! parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@"; then exit 1 fi
participants (2)
-
Allan McRae
-
Dave Reisner