Skip to content

Conversation

@matteodelabre
Copy link
Member

toltecctl uninstall will now try to uninstall packages in the reverse order of their dependencies, so that a package can use binaries it depends on during its removal scripts (see #448). Packages in a dependency cycle are removed in an unspecified order.

Test plan: Upgrade toltec-bootstrap, install some packages, then run toltecctl uninstall. You should see packages removed in reverse dependency order, so for example:

  • libc, libpthread, libgcc should generally be the last removed packages
  • graphical apps should get removed before display
  • toltec-bootstrap should get removed before coreutils-tsort

`toltecctl uninstall` will now try to uninstall packages in the reverse order of their dependencies, so that a package can use binaries it depends on during its removal scripts (see #448). Packages in a dependency cycle are removed in an unspecified order.

Test plan: Upgrade `toltec-bootstrap`, install some packages, then run `toltecctl uninstall`. You should see packages removed in reverse dependency order, so for example:

* `libc`, `libpthread`, `libgcc` should generally be the last removed packages
* graphical apps should get removed before `display`
* `toltec-bootstrap` should get removed before `coreutils-tsort`
@matteodelabre matteodelabre added the install Installation scripts label Oct 6, 2021
raisjn
raisjn previously approved these changes Oct 10, 2021
Copy link
Contributor

@raisjn raisjn left a comment

Choose a reason for hiding this comment

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

looks cool! is this much slower than normal opkg uninstall because its doing the listing of dependencies for each package?

@matteodelabre
Copy link
Member Author

matteodelabre commented Oct 11, 2021

Thanks for the review! From my tests, having installed the base Entware distribution + around 10 extra packages, the dependency ordering step took around 10 seconds. The opkg depends command can take up to 200–300 ms per invocation (because it’s unzipping and reading the full package list to memory each time), and makes up for much of this time since I call it once per installed package.

Your message prompted me to think about how to cut this time. It turns out opkg depends can list the dependencies of several packages, not just one, and even accepts wildcards. So by doing opkg depends '*' we get a complete list of dependencies with only one invocation of opkg depends (and only one full read of the package list).

$ opkg depends '*'
terminfo depends on:
	libc
	libssp
	librt
	libpthread
libc depends on:
	libgcc
locales depends on:
	libc
	libssp
	librt
	libpthread
	grep
entware-upgrade depends on:
...

We should be just a simple awk script away from turning this into a dependency-ordered list of packages. I’m going to take a look into this and will report on the time saved by this approach.

EDIT: The following awk script and Bash pipeline produce the expected ordered list of packages in about 400 ms.

/^.* depends on:$/{
    from=$1;
    print from " " from;
}

/^\t/{
    print from " " $1;
}
opkg depends '*' | awk "$awk_script" | tsort

@matteodelabre matteodelabre marked this pull request as draft October 11, 2021 20:03
@Eeems
Copy link
Member

Eeems commented Oct 12, 2021

Looks good to me, what else is it waiting on?

@matteodelabre
Copy link
Member Author

I haven't replaced the package ordering code with the faster version yet. I'll take care of it tomorrow.

@matteodelabre matteodelabre marked this pull request as ready for review October 13, 2021 19:22
@matteodelabre
Copy link
Member Author

I added the new (faster) code for ordering packages. I executed the test plan again on rM2 and it’s working fine, there is no longer a noticeable delay during the package ordering step.

@matteodelabre matteodelabre merged commit 51a4d27 into testing Oct 15, 2021
@matteodelabre matteodelabre deleted the package/toltec-bootstrap/uninstall-package-ordering branch October 15, 2021 20:28
Eeems pushed a commit that referenced this pull request Oct 22, 2021
`toltecctl uninstall` will now try to uninstall packages in the reverse order of their dependencies, so that a package can use binaries it depends on during its removal scripts (see #448). Packages in a dependency cycle are removed in an unspecified order.
Eeems pushed a commit that referenced this pull request Oct 22, 2021
`toltecctl uninstall` will now try to uninstall packages in the reverse order of their dependencies, so that a package can use binaries it depends on during its removal scripts (see #448). Packages in a dependency cycle are removed in an unspecified order.
Eeems added a commit that referenced this pull request Nov 20, 2021
* toltecctl: Honour dependencies when uninstalling (#456)

`toltecctl uninstall` will now try to uninstall packages in the reverse order of their dependencies, so that a package can use binaries it depends on during its removal scripts (see #448). Packages in a dependency cycle are removed in an unspecified order.

* [rmkit] upgrade remux with rM1 support on 2.9 (#450)

this brings remux up to date with rmkit-dev/rmkit@8254893

major improvement is proper support for touch gestures in remux on rM1 after rebooting. the main issue was the display was resizing after remux started, so the touch gestures were using the wrong display size. holding the center button on rM1 would cause remux to restart (and fix this problem), so there is a workaround available.

* Update KOReader to 2021.10 (#467)

Co-authored-by: raisjn <70462544+raisjn@users.noreply.github.com>

* Add cache for dependencies install (#473)

* Add cache for dependencies install

Co-authored-by: Mattéo Delabre <1370040+matteodelabre@users.noreply.github.com>
Co-authored-by: raisjn <70462544+raisjn@users.noreply.github.com>
Co-authored-by: Mattéo Delabre <spam@delab.re>
matteodelabre added a commit that referenced this pull request Nov 21, 2021
Following #456, a dependency on coreutils-tsort was added to the toltec-bootstrap package. That dependency is only needed during uninstall and is used to sort the packages in reverse dependency order.

The bootstrap script does an initial temporary install of toltec-bootstrap in order to use the toltecctl definitions. It does not expect the package to have dependencies. As a consequence, the script fails to perform installs in its current state.

This fix makes the script ignore dependencies for the temporary install. The dependencies do get installed at the end of the install procedure. I also added a warning above the dependency list in toltec-bootstrap to inform future contributors that those dependencies will not be honored in the initial temporary install of toltec-bootstrap.

Sorry that I missed this when writing #456!
matteodelabre added a commit that referenced this pull request Nov 21, 2021
Following #456, a dependency on coreutils-tsort was added to the toltec-bootstrap package. That dependency is only needed during uninstall and is used to sort the packages in reverse dependency order.

The bootstrap script does an initial temporary install of toltec-bootstrap in order to use the toltecctl definitions. It does not expect the package to have dependencies. As a consequence, the script fails to perform installs in its current state.

This fix makes the script ignore dependencies for the temporary install. The dependencies do get installed at the end of the install procedure. I also added a warning above the dependency list in toltec-bootstrap to inform future contributors that those dependencies will not be honored in the initial temporary install of toltec-bootstrap.

Sorry that I missed this when writing #456!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

install Installation scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants