Skip to content

Commit

Permalink
Add linux distro detection for environmnent and runtime scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jun 6, 2023
1 parent e2b7bad commit a2804eb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/metacall-environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,12 @@ fi
if [ -f /etc/os-release ]; then # Either Debian or Ubuntu
# Cat file | Get the ID field | Remove 'ID=' | Remove leading and trailing spaces
LINUX_DISTRO=$(cat /etc/os-release | grep "^ID=" | cut -f2- -d= | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Cat file | Get the ID field | Remove 'ID=' | Remove leading and trailing spaces | Remove quotes
LINUX_VERSION_ID=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -f2- -d= | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d '"')
else
# TODO: Implement more distros or better detection
LINUX_DISTRO=unknown
LINUX_VERSION_ID=unknown
fi

# Base packages
Expand Down
3 changes: 3 additions & 0 deletions tools/metacall-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ fi
if [ -f /etc/os-release ]; then # Either Debian or Ubuntu
# Cat file | Get the ID field | Remove 'ID=' | Remove leading and trailing spaces
LINUX_DISTRO=$(cat /etc/os-release | grep "^ID=" | cut -f2- -d= | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
# Cat file | Get the ID field | Remove 'ID=' | Remove leading and trailing spaces | Remove quotes
LINUX_VERSION_ID=$(cat /etc/os-release | grep "^VERSION_ID=" | cut -f2- -d= | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d '"')
else
# TODO: Implement more distros or better detection
LINUX_DISTRO=unknown
LINUX_VERSION_ID=unknown
fi

# Install and mark packages to avoid autoremove
Expand Down

0 comments on commit a2804eb

Please sign in to comment.