Skip to content

Commit

Permalink
Merge pull request #75 from crazy-max/os-version
Browse files Browse the repository at this point in the history
xx-info: os-version
  • Loading branch information
tonistiigi committed Sep 21, 2022
2 parents 6dc7893 + d926dd7 commit 5596639
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions base/test-info-common.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ load 'assert'
assert_equal "linux" "$(xx-info os)"
}

@test "os-version" {
run xx-info os-version
assert_success
if grep 'PRETTY_NAME=".*/sid"$' /etc/os-release >/dev/null 2>/dev/null; then
skip "VERSION_ID not set for unstable repo"
fi
[ "$output" != "" ]
}

@test "is-cross" {
run xx-info is-cross
assert_failure
Expand Down
7 changes: 7 additions & 0 deletions base/xx-info
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
: "${XX_DEBIAN_ARCH=unknown}"
# https://docs.fedoraproject.org/ro/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch01s03.html
: "${XX_RHEL_ARCH=unknown}"
: "${XX_OS_VERSION=unknown}"
: "${XX_TRIPLE=unknown-unknown-none}"
: "${XX_VENDOR=unknown}"
: "${XX_LIBC=}"
Expand All @@ -30,6 +31,7 @@ Commands:
libc Print used libc (musl or gnu)
march Print target machine architecture, uname -m
os Print target operating system (linux,darwin,windows,wasi)
os-version Print operating system version
pkg-arch Print either alpine-arch or debian-arch
rhel-arch Print target architecture for RPM package repositories
sysroot Print sysroot directory for target architecture
Expand Down Expand Up @@ -110,6 +112,7 @@ elif [ -f /etc/os-release ]; then
# shellcheck disable=SC1091
if . /etc/os-release 2>/dev/null; then
XX_VENDOR=$ID
XX_OS_VERSION=$VERSION_ID
fi
fi

Expand Down Expand Up @@ -354,6 +357,9 @@ case "$1" in
"os")
echo $TARGETOS # TODO:
;;
"os-version")
echo "$XX_OS_VERSION"
;;
"march")
echo $XX_MARCH
;;
Expand All @@ -380,6 +386,7 @@ case "$1" in
;;
"env")
echo "XX_OS=${TARGETOS}"
echo "XX_OS_VERSION=${XX_OS_VERSION}"
echo "XX_ARCH=${TARGETARCH}"
echo "XX_MARCH=${XX_MARCH}"
echo "XX_VENDOR=${XX_VENDOR}"
Expand Down

0 comments on commit 5596639

Please sign in to comment.