Skip to content

Commit

Permalink
support tests.pkgs download
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiocazzolato committed Sep 12, 2024
1 parent 1e39b30 commit ab1fa59
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions tests/tests.pkgs/task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ execute: |
not tests.pkgs is-installed test-snapd-pkg-1
not tests.pkgs is-installed test-snapd-pkg-2
# Download curl package, trusty does not support apt download
if not os.query is-trusty; then
tests.pkgs download curl
if os.query is-opensuse; then
find . -maxdepth 4 -name curl.*
else
find . -maxdepth 1 -name curl.*
fi
fi
# Check the message when a command is not supported
tests.pkgs noexist test-snapd-pkg-1 2>&1 | MATCH 'tests.pkgs: unknown command noexist'
tests.pkgs -install test-snapd-pkg-1 2>&1 | MATCH 'tests.pkgs: unknown option -install'
Expand Down
11 changes: 10 additions & 1 deletion tools/tests.pkgs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
show_help() {
echo "usage: tests.pkgs install [--no-install-recommends] [PACKAGE...]"
echo " tests.pkgs remove [PACKAGE...]"
echo " tests.pkgs download [PACKAGE...]"
echo " tests.pkgs is-installed [PACKAGE]"
echo " tests.pkgs query [PACKAGE]"
echo " tests.pkgs list-installed"
Expand All @@ -27,6 +28,11 @@ cmd_install_local() {
unsupported
}

cmd_download() {
# This is re-defined by the backend file.
unsupported
}

cmd_is_installed() {
# This is re-defined by the backend file.
unsupported
Expand Down Expand Up @@ -120,7 +126,7 @@ main() {
shift
break
;;
install|remove|query|is-installed|list-installed)
install|remove|query|is-installed|list-installed|download)
action="$1"
shift
break # consume remaining arguments
Expand Down Expand Up @@ -154,6 +160,9 @@ main() {
# shellcheck disable=SC2046
cmd_remove $(remap_many "$@")
;;
download)
cmd_download "$(remap_many "$@")"
;;
*)
echo "tests.pkgs: unknown action $action" >&2
exit 1
Expand Down
4 changes: 4 additions & 0 deletions tools/tests.pkgs.apt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ cmd_remove() {
# shellcheck disable=SC2086
apt-get remove --yes $REMOVE_FLAGS "$@"
}

cmd_download() {
apt download $@ >/dev/null 2>&1
}
9 changes: 9 additions & 0 deletions tools/tests.pkgs.dnf-yum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,12 @@ cmd_remove() {
yum remove -y $@
fi
}

cmd_download() {
# shellcheck disable=SC2068
if [ "$(command -v dnf)" != "" ]; then
dnf download $@ >/dev/null 2>&1
else
yum reinstall --downloadonly $@ >/dev/null 2>&1
fi
}
4 changes: 4 additions & 0 deletions tools/tests.pkgs.pacman.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ cmd_remove() {
# shellcheck disable=SC2068
pacman -Rnsc --noconfirm $@
}

cmd_download() {
pacman -Sw --noconfirm --cachedir "${PWD:-.}" $@ >/dev/null 2>&1
}
4 changes: 4 additions & 0 deletions tools/tests.pkgs.zypper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ cmd_remove() {
# shellcheck disable=SC2068
zypper remove -y $@
}

cmd_download() {
zypper --pkg-cache-dir "${PWD:-.}" download $@ >/dev/null 2>&1
}

0 comments on commit ab1fa59

Please sign in to comment.