Skip to content

Commit

Permalink
Add distro_is function stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-revay committed Oct 16, 2023
1 parent 3bdee8b commit deaad01
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion WSL_Ubuntu_22.04/run_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

. ../prelude.sh

# TODO use distro_is function from prelude.sh everywhere
# TODO Ubuntu 23.04 works, hence it can be allowed, make this official
# TODO try enabling 2x in general - this did not work - some packages are not available on 20.04
# TODO try enabling 22.04 + (ideally by explicit naming)
if [[ "$(lsb_release --description --short)" != 'Ubuntu 22.04'* &&
"$(lsb_release --description --short)" != 'Ubuntu 23.04'* ]]; then
echo 'Error: The base image does not match "Ubuntu 22.04"! Aborting.' >&2
echo 'Error: The base image does not match "Ubuntu 22.04"! Aborting.'
exit ${EXIT_INCORRECT_PLATFORM}
fi

Expand Down
12 changes: 11 additions & 1 deletion prelude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ if [[ "${__INITPC_PRELUDE_SOURCED__}" != "true" ]]; then
# TODO - consider even better error code number (guaranteed to be unique)
# apt-get install returns 100 if a package was not found... 100 is not a good error code. >IMPORTANT<
# shellcheck disable=SC2034
readonly EXIT_INCORRECT_PLATFORM=100
readonly EXIT_INCORRECT_PLATFORM=99
# shellcheck disable=SC2034
readonly EXIT_INVALID_ARGUMENT=10
# TODO - finish
#

function distro_is {
source /etc/os-release

if [[ "${PRETTY_NAME}" != "$1" ]]; then
echo "Error: The OS is ${PRETTY_NAME} but should be $1! Aborting."
exit ${EXIT_INCORRECT_PLATFORM}
fi
}
fi

0 comments on commit deaad01

Please sign in to comment.