Skip to content

Commit

Permalink
apt: fix package check
Browse files Browse the repository at this point in the history
`apt-get info` does not exist and `apt info` is missing in ubuntu 18.04

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
  • Loading branch information
tonistiigi committed Nov 10, 2021
1 parent b42b6ac commit 6b38e1c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions base/test-apt.bats
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,10 @@ load 'assert'
unset TARGETOS
unset TARGETARCH
}

@test "checkpkg" {
run apt show wget
assert_success
run apt show wget-notexist
assert_failure
}
8 changes: 6 additions & 2 deletions base/xx-apt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ for l in $(xx-info env); do
export "${l?}"
done

checkpkg() {
apt show "$@"
}

if [ "${TARGETOS}" != "linux" ]; then
echo >&2 "skipping packages installation on ${XX_OS}"
exit 0
Expand Down Expand Up @@ -128,9 +132,9 @@ for p in ${packages2}; do
n=
if [ -n "$nocross" ]; then
n=${p}
elif "$arg0" info "${p}-${suffix}" >/dev/null 2>/dev/null; then
elif checkpkg "${p}-${suffix}" >/dev/null 2>/dev/null; then
n="${p}-${suffix}"
elif [ -n "${XX_APT_PREFER_CROSS}" ] && apt info "${p}-${XX_PKG_ARCH}-cross" >/dev/null 2>/dev/null; then
elif [ -n "${XX_APT_PREFER_CROSS}" ] && checkpkg "${p}-${XX_PKG_ARCH}-cross" >/dev/null 2>/dev/null; then
n="${p}-${XX_PKG_ARCH}-cross"
else
n="${p}:${XX_PKG_ARCH}"
Expand Down

0 comments on commit 6b38e1c

Please sign in to comment.