-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix(main/zig): check the Kernel version and stop if unsupported at install #25126
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!@TERMUX_PREFIX@/bin/sh | ||
# shellcheck shell=sh | ||
|
||
echo "Checking that your device meets the" | ||
echo "minimum kernel version for Zig @TERMUX_PKG_VERSION@" | ||
echo | ||
|
||
is_supported() { | ||
_KERNEL_VERSION="$1" | ||
_MINIMUM_VERSION="$2" | ||
# shellcheck disable=SC2194 # We replace this in the build script | ||
case "@TERMUX_PACKAGE_FORMAT@" in | ||
apt) | ||
if dpkg --compare-versions "$_KERNEL_VERSION" lt "$_MINIMUM_VERSION"; then | ||
return 1 | ||
fi | ||
;; | ||
pacman) | ||
if [ "$(vercmp "$_KERNEL_VERSION" "$_MINIMUM_VERSION")" != 1 ]; then | ||
return 1 | ||
fi | ||
;; | ||
esac | ||
return 0 | ||
} | ||
|
||
KERNEL_VERSION="$(uname -r)" | ||
if ! is_supported "$KERNEL_VERSION" "@ZIG_MINIMUM@"; then | ||
echo "Your device's kernel version is too old for Zig @TERMUX_PKG_VERSION@" | ||
if is_supported "$KERNEL_VERSION" "3.16.0"; then | ||
echo "Your device does however support Zig 0.13.0 or earlier." | ||
# uncomment these if/when we move old Zig versions to the TUR. | ||
# echo "You can install it from the TUR." | ||
# echo "" | ||
# echo "pkg up" | ||
# echo "pkg i tur-repo" | ||
# echo "pkg i zig-0.13" | ||
else | ||
echo "Your device does not support any version of Zig" | ||
echo "There's nothing we can do to make it supported." | ||
fi | ||
exit 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Failing in the preinst script is not a good idea, users then manually have to clean up by removing zig. It would be better to have the kernel version check in the actual zig binary. Next best option would be to exit without an error here even if kernel version is not supported by zig, the error/warning is then printed and users might understand why the program does not work There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If stopping meant that it uninstalled itself again and cleaned everything up, then that would work. When preinst script fails it leaves apt unusable though until user manually fixes it, and I don't think that is a situation we should ever create on purpose There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep that's my mistake. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nvm |
||
fi | ||
exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will return 0 if kernel version is 3.16.0, should probably check if it is -1 instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you're right I flipped the condition
3.16.0
would return0
which is fine.