-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Fix ynh_check_app_version_changed behavior #756
Fix ynh_check_app_version_changed behavior #756
Conversation
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.
LGTM
data/helpers.d/utils
Outdated
@@ -507,7 +511,8 @@ ynh_check_app_version_changed () { | |||
then | |||
ynh_print_info --message="Upgrade forced for package check." | |||
else | |||
ynh_die "Up-to-date, nothing to do" 0 | |||
ynh_print_info -m "Up-to-date, nothing to do" |
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.
-m => --message= to respect the same syntax of this helper
This PR is above all an open question. |
Returning a value seems good to me and allows us not to have too much work on all the packages. BUT, check the version of the package before (in python then?) might be better to get a simpler upgrade script. |
Hum, in both cases we have a value containing the status of the package.
|
And what if in python the upgrade was not launched if the app is up to date? |
You mean before the upgrade script even start ? |
Yeah, the thing is that maybe not all apps currently implement this mechanism (or don't want to have it enabled) We could choose to impose this behavior to all apps though... Or have an option in the manifest like Anyway for the current PR, naively this |
Using |
What I'm thinking about is if people did stuff like
then if this grep doesn't find any match, it would make the whole script crash ...? Are we 100% confident that there's no situation like this in the helpers and app script ? (I really don't know 😅 ) |
58ead9e
to
40f48ff
Compare
I don't think So I'll try it right now |
So... I tried those syntax
None of those tests did trig TRAP, whether the condition was successful or not. |
Implemented in #864 |
Is this PR still relevant ? |
Not sure I get the initial issue ... to me this is addressed by Josue's PR ... Proposing to close except if somebody can explain that it's still relevant ... |
The problem
ynh_check_app_version_changed does not kill the upgrade when the app is up to date.
The script says "Up-to-date, nothing to do" and continue with the upgrade nonetheless.
Solution
A subshell can't exit its parent shell, unless with a kill of the parent. Which would be a parricide, not cool...
As well, trap isn't trigger by a subshell. To fix that, I added
set -o errtrace
About the main issue, there's no proper way to exit the parent.
Either we could use a variable set into the parent script and run the helper directly without a subshell. In that case exit would work. But we would have a variable to set before, which could be done just before the helper is loaded.
Which means we wouldn't use
upgrade_type=$(ynh_check_app_version_changed)
but simplyynh_check_app_version_changed
into the upgrade script and to haveupgrade_type
declare before the helper to be a variable set into the main shell.Or we could use the way I used here, return a value that says that the app is up to date.
That other way implies the upgrade script use that value to not upgrade the app.
Both solutions work, the first one is lighter for the upgrade script, as you can just change the line, but will exit immediately the script, as it was supposed to be.
The second is heavier but allow the upgrade script to deal with the variable, especially to that the upgrade is completed before finishing.
Which solution would you prefer ?
PR Status
Tested with both solutions, only the second one is implement here.
How to test
...
Validation
@YunoHost/apps