Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xx-info: os-version #75

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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