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

Provide better output on toltecctl uninstall #692

Open
wants to merge 36 commits into
base: testing
Choose a base branch
from
Open

Conversation

Eeems
Copy link
Member

@Eeems Eeems commented May 10, 2023

  • Provide output right at the end if a removal fails due to a preremove script. That way, the user can double-check the output to see if there is something bad. For example, kernelctl failed to revert to the stock kernel.
  • Make changes to toltecctl to get closer to allowing the installation to be somewhere other than /opt, not that entware supports that yet.
  • Make toltecctl uninstall handle unexpected states like partial uninstall a lot better.
  • Backup toltecctl on uninstall to continue allowing users to uninstall if something goes wrong.
  • Fix issues with installdepends not properly being set for several packages that caused them to be removed after their dependencies were removed, thus breaking uninstall.

Provide output right at the end if a removal fails due to a preremove script. That way, the user can double-check the output to see if there is something bad. For example, kernelctl failed to revert to the stock kernel.
@Eeems Eeems added the packages Add or improve packages of the repository label May 10, 2023
@Eeems Eeems requested a review from matteodelabre May 10, 2023 18:29
@Eeems Eeems marked this pull request as ready for review May 10, 2023 18:33
@Eeems Eeems added this to the 2023-W31 merge window milestone Jul 26, 2023
@rM-self-serve
Copy link
Contributor

I created a test package that will fail during preremove.
Do you have any tips on restoring /opt after uninstalling?

@Eeems
Copy link
Member Author

Eeems commented Dec 8, 2023

I created a test package that will fail during preremove.
Do you have any tips on restoring /opt after uninstalling?

Uninstall removes /opt, which is actually /home/root/.entware. you will have to install again with bootstrap. If you want to avoid doing so, you can copy the .entware folder before doing the uninstall, rename the copy to .entware after uninstalling and then re-enable.

@Eeems

This comment was marked as resolved.

@@ -806,6 +808,14 @@ uninstall() {
}
set -o functrace
trap 'handle-error ${LINENO}' ERR
handle-exit() {
if ! $completed && $success && $clean; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

completed vs complete, wrong variable names

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You seem to be reviewing an outdated version, this is $complete for me when I look

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm reviewing patches in order, not a full diff. I'm more used to a workflow where a PR is force updated instead of incremental patches and a squash afterwards.

Copy link

@Havner Havner Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think there is operator order issue here:

$ export VAR1=true
$ export VAR2=true
$ export VAR3=true
$ if ! $VAR1 && $VAR2 && $VAR3; then echo failed; fi
$ export VAR2=false
$ if ! $VAR1 && $VAR2 && $VAR3; then echo failed; fi
$ if ! ($VAR1 && $VAR2 && $VAR3); then echo failed; fi
failed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since they are declared as local it could be that they aren't working as expected. Although when I tested this originally it was working as I expected.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think local makes any difference here, ! has higher priority than && hence it applies only to VAR1 and from the look of it you wanted to apply it to the whole expression (V1 && V2 && V3)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have wrapped it in ( and ) if I was trying to apply it to all of them, I'm checking if not complete, and success and clean. success/clean are true by default and get changed to false when something else handles reporting an error.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok then. From reading the code it looked to me like you are looking for a failure scenario (e.g. at least one of those vars is false).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I'm only wanting to handle the error if the error handler is triggered and we did not complete the uninstall, and nothing set success or clean to false due to their own error handling.

It is less than ideal, thus the extra comments on the variable declarations. I couldn't really come up with a cleaner way to handle this with the limitations bash has on error handling.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to analyze this fully to check the logic completely. I'm too tired now.

What I did find though is that you make a dep between clean and success so checking both in this line might be at least redundant.

https://github.com/toltec-dev/toltec/blob/Eeems-patch-10/package/toltec-bootstrap/toltecctl#L885

But I'm not able to check the logic fully now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Add or improve packages of the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants