[pacman-dev] [PATCH] pacman-db-upgrade: do not mangle file lists

Dave Reisner d at falconindy.com
Fri Oct 3 12:48:51 UTC 2014


On Thu, Oct 02, 2014 at 04:35:52PM -0400, Andrew Gregory wrote:
> grep'ing out blank lines and sorting output thoroughly breaks any file
> lists with %BACKUP% entries which must be separated from the file list
> by a blank line.
> 
> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> ---
> 
> Anybody who has replaced an owned directory with a symlink and run
> pacman-db-upgrade has mangled the file list for all packages with backup files.
> To check for broken file lists run:
> `grep -xA1 %BACKUP% /var/lib/pacman/local/*/files | grep -B1 %FILES%`
> Any file lists with output are broken.  Broken file lists can be repaired by
> reinstalling the affected packages with --dbonly.  After repairing, users
> should remove /var/lib/pacman/local/ALPM_DB_VERSION and run the fixed version
> of pacman-db-upgrade.

Tested this since I was affected -- I don't know what the script did
this time, but it *didn't* destroy my local DB. So, +1.

>  scripts/pacman-db-upgrade.sh.in | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/pacman-db-upgrade.sh.in b/scripts/pacman-db-upgrade.sh.in
> index d2d317b..d7e34bd 100644
> --- a/scripts/pacman-db-upgrade.sh.in
> +++ b/scripts/pacman-db-upgrade.sh.in
> @@ -211,9 +211,9 @@ if [[ -z "$db_version" ]]; then
>  					{
>  						if ($0 == olddir) {
>  							# replace symlink with its target, including parents
> -							printf("%s", parents)
> -							printf("%s\n", newdir)
> -						} else if ($0 == file) {
> +							if (parents) printf("%s", parents)
> +							if (newdir) printf("%s\n", newdir)

parents and newdir are invariants for the duration of the awk program.
Why not skip the whole for loop when [[ -z $parents$newdir ]] ? If you
do that, I think your printf here simply becomes:

  printf("%s%s\n", parents, newdir)

> +						} else if (file && $0 == file) {
>  							# newdir already existed as a file, skip it
>  						} else if (index($0, olddir) == 1) {
>  							# update paths that were under olddir
> @@ -222,7 +222,7 @@ if [[ -z "$db_version" ]]; then
>  							# print everything else as-is
>  							print
>  						}
> -					}' "$f" | grep . | LC_ALL=C sort -u > "$f.tmp"
> +					}' "$f" > "$f.tmp"
>  				mv "$f.tmp" "$f"
>  			done
>  		done
> -- 
> 2.1.1


More information about the pacman-dev mailing list