5long / p3wm

Three-way merge .pacnew file
ISC License
13 stars 4 forks source link

pkg_cached: unbound variable #1

Closed arun54321 closed 4 years ago

arun54321 commented 4 years ago
p3wm makepkg.conf.pacnew 
/usr/bin/p3wm: line 156: pkg_cached: unbound variable
tar: : Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
C /etc/makepkg.conf cannot be cleanly merged

I have the pacman.tar.xz file in pacman cache.

5long commented 4 years ago

p3wm looks up pacakge file in cache like this:

  1. get the last time that your package upgrades. On my machine, the pacman pacakge's last upgrade was 5.2.0-2 -> 5.2.1-1
  2. Search the pacman CacheDir, but only for the old version. e.g. only searching for pacman-5.2.0-2-x86_64.pkg.*
  3. If no cached package was found, exit with the error messages you just posted.

So, if the full path of your cached package is literally <CacheDir>/pacman.tar.xz, p3wm would ignore it since it doesn't have the proper version and architechiture name in the full path. The error message could really use some clarity here.

I hope this could explain the problem you're facing. If not, please run p3wm again with the P3WM_DEBUG=1 environment variable and post the full output so I can help debugging it.

arun54321 commented 4 years ago

I have deleted the pacnew and pacsave files. I will report the issue if it happens again.

BrainDamage commented 4 years ago

I am encountering the same problem. I suspect it's related to the locale making the output parsing fail, because if I set locale to C it works properly (EDIT: pacman indeed outputs the data localized so "Architecture" parsing would fail:

[root@cloud-laptop ~]# P3WM_DEBUG=1
[root@cloud-laptop ~]# p3wm /etc/sudoers.pacnew 
+ set_shopts
+ set -e
+ shopt -s nullglob
+ create_tmp_root
+ mkdir -p /tmp/p3wm
+ find_merge_tool
+ [[ -n '' ]]
+ has_bin git
+ type -p git
+ P3WM_MERGE_TOOL=builtin_merge_git
+ find_resolve_tool
+ [[ -n '' ]]
+ has_bin kdiff3
+ type -p kdiff3
+ has_bin meld
+ type -p meld
+ has_bin vim
+ type -p vim
+ P3WM_RESOLVE_TOOL=builtin_resolve_vim
+ verify_args /etc/sudoers.pacnew
+ [[ 1 != 1 ]]
+ [[ ! -f /etc/sudoers.pacnew ]]
+ set -u
++ realpath /etc/sudoers.pacnew
+ bf_pacnew=/etc/sudoers.pacnew
+ bf_local=/etc/sudoers
+ verify_bf_files /etc/sudoers.pacnew /etc/sudoers
+ local bf_pacnew=/etc/sudoers.pacnew bf_local=/etc/sudoers
+ [[ /etc/sudoers.pacnew = \/\e\t\c\/\s\u\d\o\e\r\s ]]
+ [[ ! -f /etc/sudoers.pacnew ]]
+ [[ ! -f /etc/sudoers ]]
++ prepare_bf_base /etc/sudoers
++ bf_local=/etc/sudoers
+++ pacman -Qoq /etc/sudoers
++ pkg_name=sudo
+++ get_ver_tuple sudo
+++ tac /var/log/pacman.log
+++ sed -Ene '/\[ALPM\] upgraded sudo / !d' -e 's/.*\(([^ ]+) -> ([^)]+).*/\1 \2/p' -e q
++ ver_tuple='1.9.3-1 1.9.3.p1-1'
++ oldver=1.9.3-1
+++ find_cached_pkg sudo 1.9.3-1
+++ local pkg_name=sudo ver=1.9.3-1
++++ get_pkg_arch sudo
++++ pacman -Qi sudo
++++ awk '$1 == "Architecture" {print $3}'
+++ arch=
+++ mapfile -t cache_dirs
++++ pacman-conf CacheDir
+++ for cache_dir in "${cache_dirs[@]}"
/usr/bin/p3wm: riga 156: pkg_cached: variabile non assegnata
++ pkg_cached=
+++ basename /etc/sudoers
++ basename_=sudoers
+++ mktmp .base.sudoers
+++ mktemp -p /tmp/p3wm --suffix .base.sudoers
++ bf_base=/tmp/p3wm/tmp.NdI5Tp2F4g.base.sudoers
++ bf_id=etc/sudoers
++ tar xOf '' etc/sudoers --
tar: : funzione "open" non riuscita: File o directory non esistente
tar: Error is not recoverable: exiting now
++ echo -n /tmp/p3wm/tmp.NdI5Tp2F4g.base.sudoers
+ bf_base=/tmp/p3wm/tmp.NdI5Tp2F4g.base.sudoers
++ prepare_bf_merged /etc/sudoers
++ local bf_local=/etc/sudoers
+++ basename /etc/sudoers
++ basename_=sudoers
+++ mktmp .merged.sudoers
+++ mktemp -p /tmp/p3wm --suffix .merged.sudoers
++ bf_merged=/tmp/p3wm/tmp.MY8cBSk7NR.merged.sudoers
++ chmod --reference=/etc/sudoers /tmp/p3wm/tmp.MY8cBSk7NR.merged.sudoers
++ echo -n /tmp/p3wm/tmp.MY8cBSk7NR.merged.sudoers
+ bf_merged=/tmp/p3wm/tmp.MY8cBSk7NR.merged.sudoers
+ builtin_merge_git /etc/sudoers /tmp/p3wm/tmp.NdI5Tp2F4g.base.sudoers /etc/sudoers.pacnew
+ git merge-file -p /etc/sudoers /tmp/p3wm/tmp.NdI5Tp2F4g.base.sudoers /etc/sudoers.pacnew
+ echo C /etc/sudoers 'cannot be cleanly merged'
C /etc/sudoers cannot be cleanly merged
+ ask_for_action
+ printf '(V)iew diff, (D)elete .pacnew, (A)ccept merge, (R)un resolve tool, (Q)uit? '
(V)iew diff, (D)elete .pacnew, (A)ccept merge, (R)un resolve tool, (Q)uit? + read -r answer
^C
[root@cloud-laptop ~]# LANG=C
[root@cloud-laptop ~]# p3wm /etc/sudoers.pacnew 
+ set_shopts
+ set -e
+ shopt -s nullglob
+ create_tmp_root
+ mkdir -p /tmp/p3wm
+ find_merge_tool
+ [[ -n '' ]]
+ has_bin git
+ type -p git
+ P3WM_MERGE_TOOL=builtin_merge_git
+ find_resolve_tool
+ [[ -n '' ]]
+ has_bin kdiff3
+ type -p kdiff3
+ has_bin meld
+ type -p meld
+ has_bin vim
+ type -p vim
+ P3WM_RESOLVE_TOOL=builtin_resolve_vim
+ verify_args /etc/sudoers.pacnew
+ [[ 1 != 1 ]]
+ [[ ! -f /etc/sudoers.pacnew ]]
+ set -u
++ realpath /etc/sudoers.pacnew
+ bf_pacnew=/etc/sudoers.pacnew
+ bf_local=/etc/sudoers
+ verify_bf_files /etc/sudoers.pacnew /etc/sudoers
+ local bf_pacnew=/etc/sudoers.pacnew bf_local=/etc/sudoers
+ [[ /etc/sudoers.pacnew = \/\e\t\c\/\s\u\d\o\e\r\s ]]
+ [[ ! -f /etc/sudoers.pacnew ]]
+ [[ ! -f /etc/sudoers ]]
++ prepare_bf_base /etc/sudoers
++ bf_local=/etc/sudoers
+++ pacman -Qoq /etc/sudoers
++ pkg_name=sudo
+++ get_ver_tuple sudo
+++ tac /var/log/pacman.log
+++ sed -Ene '/\[ALPM\] upgraded sudo / !d' -e 's/.*\(([^ ]+) -> ([^)]+).*/\1 \2/p' -e q
++ ver_tuple='1.9.3-1 1.9.3.p1-1'
++ oldver=1.9.3-1
+++ find_cached_pkg sudo 1.9.3-1
+++ local pkg_name=sudo ver=1.9.3-1
++++ get_pkg_arch sudo
++++ pacman -Qi sudo
++++ awk '$1 == "Architecture" {print $3}'
+++ arch=x86_64
+++ mapfile -t cache_dirs
++++ pacman-conf CacheDir
+++ for cache_dir in "${cache_dirs[@]}"
+++ for f in "$cache_dir/$pkg_name-$ver-$arch".pkg.*
+++ pkg_cached=/var/cache/pacman/pkg//sudo-1.9.3-1-x86_64.pkg.tar.zst
+++ [[ -z /var/cache/pacman/pkg//sudo-1.9.3-1-x86_64.pkg.tar.zst ]]
+++ echo -n /var/cache/pacman/pkg//sudo-1.9.3-1-x86_64.pkg.tar.zst
++ pkg_cached=/var/cache/pacman/pkg//sudo-1.9.3-1-x86_64.pkg.tar.zst
+++ basename /etc/sudoers
++ basename_=sudoers
+++ mktmp .base.sudoers
+++ mktemp -p /tmp/p3wm --suffix .base.sudoers
++ bf_base=/tmp/p3wm/tmp.7WJFkDSc6I.base.sudoers
++ bf_id=etc/sudoers
++ tar xOf /var/cache/pacman/pkg//sudo-1.9.3-1-x86_64.pkg.tar.zst etc/sudoers --
++ echo -n /tmp/p3wm/tmp.7WJFkDSc6I.base.sudoers
+ bf_base=/tmp/p3wm/tmp.7WJFkDSc6I.base.sudoers
++ prepare_bf_merged /etc/sudoers
++ local bf_local=/etc/sudoers
+++ basename /etc/sudoers
++ basename_=sudoers
+++ mktmp .merged.sudoers
+++ mktemp -p /tmp/p3wm --suffix .merged.sudoers
++ bf_merged=/tmp/p3wm/tmp.UK73QHeV5m.merged.sudoers
++ chmod --reference=/etc/sudoers /tmp/p3wm/tmp.UK73QHeV5m.merged.sudoers
++ echo -n /tmp/p3wm/tmp.UK73QHeV5m.merged.sudoers
+ bf_merged=/tmp/p3wm/tmp.UK73QHeV5m.merged.sudoers
+ builtin_merge_git /etc/sudoers /tmp/p3wm/tmp.7WJFkDSc6I.base.sudoers /etc/sudoers.pacnew
+ git merge-file -p /etc/sudoers /tmp/p3wm/tmp.7WJFkDSc6I.base.sudoers /etc/sudoers.pacnew
+ echo M /etc/sudoers 'can be cleanly merged'
M /etc/sudoers can be cleanly merged
+ ask_for_action
+ printf '(V)iew diff, (D)elete .pacnew, (A)ccept merge, (R)un resolve tool, (Q)uit? '
(V)iew diff, (D)elete .pacnew, (A)ccept merge, (R)un resolve tool, (Q)uit? + read -r answer