[pacman-dev] [PATCH] replace --reference on chmod/chown commands

Dave Reisner d at falconindy.com
Mon Aug 11 09:01:09 EDT 2014


On Sun, Aug 10, 2014 at 07:39:12PM +1000, Allan McRae wrote:
> From: Wolfgang Bumiller <wry.git at bumiller.com>
> 
> ---

Can we just get rid of this script? It was mostly placebo when it was
first written and it's even less useful now (well, since sync DBs became
tarballs).

I strongly suspect that if someone submitted a patch replacing 99% of
this with "du -sh /var/lib/pacman &>/dev/null", no one would complain.

>  configure.ac                  | 10 ++++++++++
>  scripts/Makefile.am           |  2 ++
>  scripts/pacman-optimize.sh.in |  4 ++--
>  3 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/configure.ac b/configure.ac
> index 45f40f0..0a7b254 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -319,6 +319,8 @@ GCC_VISIBILITY_CC
>  
>  # Host-dependant definitions
>  INODECMD="stat -c '%i %n'"
> +OWNERCMD="stat -c '%u:%g'"
> +MODECMD="stat -c '%a'"
>  SIZECMD="stat -c %s"
>  SEDINPLACE="sed --follow-symlinks -i"
>  DUFLAGS="-sk --apparent-size"
> @@ -328,6 +330,8 @@ STRIP_STATIC="--strip-debug"
>  case "${host_os}" in
>  	*bsd*)
>  		INODECMD="stat -f '%i %N'"
> +		OWNERCMD="stat -f '%u:%g'"
> +		MODECMD="stat -f '%Lp'"
>  		SIZECMD="stat -f %z"
>  		SEDINPLACE="sed -i \"\""
>  		DUFLAGS="-sk"
> @@ -335,6 +339,8 @@ case "${host_os}" in
>  	darwin*)
>  		host_os_darwin=yes
>  		INODECMD="/usr/bin/stat -f '%i %N'"
> +		OWNERCMD="/usr/bin/stat -f '%u:%g'"
> +		MODECMD="/usr/bin/stat -f '%Lp'"
>  		SIZECMD="/usr/bin/stat -f %z"
>  		SEDINPLACE="/usr/bin/sed -i ''"
>  		DUFLAGS="-sk"
> @@ -347,6 +353,8 @@ esac
>  AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
>  AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
>  AC_SUBST(INODECMD)
> +AC_SUBST(OWNERCMD)
> +AC_SUBST(MODECMD)
>  AC_SUBST(SIZECMD)
>  AC_SUBST(SEDINPLACE)
>  AC_SUBST(DUFLAGS)
> @@ -528,6 +536,8 @@ ${PACKAGE_NAME}:
>      Architecture           : ${CARCH}
>      Host Type              : ${CHOST}
>      File inode command     : ${INODECMD}
> +    File owner command     : ${OWNERCMD}
> +    File mode command      : ${MODECMD}
>      Filesize command       : ${SIZECMD}
>      In-place sed command   : ${SEDINPLACE}
>  
> diff --git a/scripts/Makefile.am b/scripts/Makefile.am
> index 0b756ad..e8f3afa 100644
> --- a/scripts/Makefile.am
> +++ b/scripts/Makefile.am
> @@ -68,6 +68,8 @@ edit = sed \
>  	-e 's|@TEMPLATE_DIR[@]|$(TEMPLATE_DIR)|g' \
>  	-e 's|@DEBUGSUFFIX[@]|$(DEBUGSUFFIX)|g' \
>  	-e "s|@INODECMD[@]|$(INODECMD)|g" \
> +	-e "s|@OWNERCMD[@]|$(OWNERCMD)|g" \
> +	-e "s|@MODECMD[@]|$(MODECMD)|g" \
>  	-e 's|@SIZECMD[@]|$(SIZECMD)|g' \
>  	-e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \
>  	-e 's|@DUFLAGS[@]|$(DUFLAGS)|g' \
> diff --git a/scripts/pacman-optimize.sh.in b/scripts/pacman-optimize.sh.in
> index 9374269..7c80919 100644
> --- a/scripts/pacman-optimize.sh.in
> +++ b/scripts/pacman-optimize.sh.in
> @@ -168,8 +168,8 @@ msg "$(gettext "Rotating database into place...")"
>  fail=0
>  mv "$localdb" "$localdb.old" || fail=1
>  mv "$localdb.new" "$localdb" || fail=1
> -chmod --reference="$localdb.old" "$localdb" || fail=1
> -chown --reference="$localdb.old" "$localdb" || fail=1
> +chmod $(@MODECMD@ "$localdb.old") "$localdb" || fail=1
> +chown $(@OWNERCMD@ "$localdb.old") "$localdb" || fail=1
>  if (( fail )); then
>  	# failure with our directory shuffle
>  	die_r "$(gettext "New database substitution failed. Check for %s, %s, and %s directories.")" "$localdb" "$localdb.old" "$localdb.new"
> -- 
> 1.9.1
> 


More information about the pacman-dev mailing list