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

Allan McRae allan at archlinux.org
Sun Oct 5 04:25:05 UTC 2014


On 03/10/14 06:35, 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.
> 
>  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)
> +						} else if (file && $0 == file) {

Are these changes are unrelated to the issue?  Or am I missing something?

>  							# 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"

So we get duplicate directories in our file list now?  I know we sort
within pacman, so the order is not an issue.

Can we detect when parents/newdir is printed and avoid printing it again?

>  				mv "$f.tmp" "$f"
>  			done
>  		done
> 


More information about the pacman-dev mailing list