From 0f1bb057ddace0df80f4bd57852ce9cb1fc005cf Mon Sep 17 00:00:00 2001 From: dcjud <80610250+dcjud@users.noreply.github.com> Date: Tue, 2 Jun 2026 02:52:34 -0400 Subject: [PATCH 1/3] Deal with package name ambiguity If multiple packages match $PKG, "ls" will return one per line, causing script to fail. For example: vim and vim-gvim; man-db and man-pages. Use sed to take only the first line from the "ls" stdout. Can always provide full name of package e.g. "vim-gvim" if that's the one desired. --- addchroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addchroot b/addchroot index 6a1dca8..28d6fe2 100755 --- a/addchroot +++ b/addchroot @@ -30,7 +30,7 @@ while [ $# -gt 1 ] do shift PKG=$1 - P=$(ls /var/log/packages/$PKG* | + P=$(ls /var/log/packages/$PKG* | sed -n '1 p' | grep -E "$PKG-[rv]{0,1}[0-9][^-]*-([^-]*-){0,1}($ARCH|noarch)") [ -f "$P" ] || { echo "$PKG finds only $P" >&2; exit 1; } From b1afff7c951a95da0707c1ae9e460022a7ddbe65 Mon Sep 17 00:00:00 2001 From: dcjud <80610250+dcjud@users.noreply.github.com> Date: Wed, 3 Jun 2026 00:48:55 -0400 Subject: [PATCH 2/3] Use head instead of sed to get a first line Per request of author, use "head -n 1" instead of "sed -n '1 p'" --- addchroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addchroot b/addchroot index 28d6fe2..4803c6f 100755 --- a/addchroot +++ b/addchroot @@ -30,7 +30,7 @@ while [ $# -gt 1 ] do shift PKG=$1 - P=$(ls /var/log/packages/$PKG* | sed -n '1 p' | + P=$(ls /var/log/packages/$PKG* | head -n 1 | grep -E "$PKG-[rv]{0,1}[0-9][^-]*-([^-]*-){0,1}($ARCH|noarch)") [ -f "$P" ] || { echo "$PKG finds only $P" >&2; exit 1; } From d0bb4f68349dbaeab295331c836251795a31a5ae Mon Sep 17 00:00:00 2001 From: dcjud <80610250+dcjud@users.noreply.github.com> Date: Thu, 4 Jun 2026 00:08:53 -0400 Subject: [PATCH 3/3] Update addchroot head -n1 without the space per author request. --- addchroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addchroot b/addchroot index 4803c6f..3917bff 100755 --- a/addchroot +++ b/addchroot @@ -30,7 +30,7 @@ while [ $# -gt 1 ] do shift PKG=$1 - P=$(ls /var/log/packages/$PKG* | head -n 1 | + P=$(ls /var/log/packages/$PKG* | head -n1 | grep -E "$PKG-[rv]{0,1}[0-9][^-]*-([^-]*-){0,1}($ARCH|noarch)") [ -f "$P" ] || { echo "$PKG finds only $P" >&2; exit 1; }