Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMorten Linderud <foxboron@archlinux.org>2024-02-10 12:46:08 +0100
committerLevente Polyak <anthraxx@archlinux.org>2024-03-09 00:49:24 +0100
commit40f476c649e2c1938c391575f4339c6f50b97e7c (patch)
treefc016d7ab27cfaf0e9a70fdd7a9e57250b198513 /src
parent509dd24bdcd6c45bd86937fcd1de6fd1fa510441 (diff)
fix(pkgctl): skip path arguments that are not directories
Several subcommands accept multiple paths in a way that passing a wildcard is an expected use case. Previously this wasn't possible if the main directory contained any text files or scripts. Fix this by skipping none directory paths for such commands. Component: pkgctl Signed-off-by: Morten Linderud <foxboron@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/lib/aur/drop-from-repo.sh9
-rw-r--r--src/lib/build/build.sh4
-rw-r--r--src/lib/repo/configure.sh7
-rw-r--r--src/lib/repo/switch.sh13
-rw-r--r--src/lib/version/check.sh4
-rw-r--r--src/lib/version/upgrade.sh4
6 files changed, 34 insertions, 7 deletions
diff --git a/src/lib/aur/drop-from-repo.sh b/src/lib/aur/drop-from-repo.sh
index 6ebe12a..1c4f077 100644
--- a/src/lib/aur/drop-from-repo.sh
+++ b/src/lib/aur/drop-from-repo.sh
@@ -92,14 +92,19 @@ pkgctl_aur_drop_from_repo() {
fi
for path in "${paths[@]}"; do
- if ! realpath=$(realpath -e "${path}"); then
+ # resolve symlink for basename
+ if ! realpath=$(realpath --canonicalize-existing -- "${path}"); then
die "No such directory: ${path}"
fi
+ # skip paths that are not directories
+ if [[ ! -d "${realpath}" ]]; then
+ continue
+ fi
pkgbase=$(basename "${realpath}")
pkgbase=${pkgbase%.git}
- if [[ ! -d "${path}/.git" ]]; then
+ if [[ ! -d "${realpath}/.git" ]]; then
die "Not a Git repository: ${path}"
fi
diff --git a/src/lib/build/build.sh b/src/lib/build/build.sh
index 171bb9a..c35d70f 100644
--- a/src/lib/build/build.sh
+++ b/src/lib/build/build.sh
@@ -319,6 +319,10 @@ pkgctl_build() {
fi
for path in "${paths[@]}"; do
+ # skip paths that are not directories
+ if [[ ! -d "${path}" ]]; then
+ continue
+ fi
pushd "${path}" >/dev/null
if [[ ! -f PKGBUILD ]]; then
diff --git a/src/lib/repo/configure.sh b/src/lib/repo/configure.sh
index b3c188c..0980fd1 100644
--- a/src/lib/repo/configure.sh
+++ b/src/lib/repo/configure.sh
@@ -207,9 +207,14 @@ pkgctl_repo_configure() {
fi
for path in "${paths[@]}"; do
- if ! realpath=$(realpath -e "${path}"); then
+ # resolve symlink for basename
+ if ! realpath=$(realpath --canonicalize-existing -- "${path}"); then
die "No such directory: ${path}"
fi
+ # skip paths that aren't directories
+ if [[ ! -d "${realpath}" ]]; then
+ continue
+ fi
pkgbase=$(basename "${realpath}")
pkgbase=${pkgbase%.git}
diff --git a/src/lib/repo/switch.sh b/src/lib/repo/switch.sh
index f411ac2..d8ba9df 100644
--- a/src/lib/repo/switch.sh
+++ b/src/lib/repo/switch.sh
@@ -101,16 +101,21 @@ pkgctl_repo_switch() {
fi
for path in "${paths[@]}"; do
- if ! realpath=$(realpath -e -- "${path}"); then
+ # resolve symlink for basename
+ if ! realpath=$(realpath --canonicalize-existing -- "${path}"); then
die "No such directory: ${path}"
fi
- pkgbase=$(basename "${realpath}")
-
- if [[ ! -d "${path}/.git" ]]; then
+ # skip paths that are not directories
+ if [[ ! -d "${realpath}" ]]; then
+ continue
+ fi
+ # skip paths that are not git repositories
+ if [[ ! -d "${realpath}/.git" ]]; then
error "Not a Git repository: ${path}"
continue
fi
+ pkgbase=$(basename "${realpath}")
if ! git -C "${path}" checkout "${GIT_CHECKOUT_OPTIONS[@]}" "${GIT_REF}"; then
die "Failed to switch ${pkgbase} to version ${VERSION}"
fi
diff --git a/src/lib/version/check.sh b/src/lib/version/check.sh
index 35d07e2..6cd4a5b 100644
--- a/src/lib/version/check.sh
+++ b/src/lib/version/check.sh
@@ -108,6 +108,10 @@ pkgctl_version_check() {
term_spinner_start "${status_dir}"
for path in "${pkgbases[@]}"; do
+ # skip paths that are not directories
+ if [[ ! -d "${path}" ]]; then
+ continue
+ fi
pushd "${path}" >/dev/null
if [[ ! -f "PKGBUILD" ]]; then
diff --git a/src/lib/version/upgrade.sh b/src/lib/version/upgrade.sh
index e217532..df3b77d 100644
--- a/src/lib/version/upgrade.sh
+++ b/src/lib/version/upgrade.sh
@@ -99,6 +99,10 @@ pkgctl_version_upgrade() {
term_spinner_start "${status_dir}"
for path in "${pkgbases[@]}"; do
+ # skip paths that aren't directories
+ if [[ ! -d "${path}" ]]; then
+ continue
+ fi
pushd "${path}" >/dev/null
if [[ ! -f "PKGBUILD" ]]; then