Skip to content

include/package-pack: actually call default_postinist/prerm with APK #17023

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

Merged
merged 2 commits into from
Nov 21, 2024

Conversation

robimarko
Copy link
Contributor

Currently, when you install a package that ships uci-defaults scripts they are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script to add it to the UCI LuCI config so the theme is actually selectable but that does not happen until the device is rebooted so that uci-defaults script is actually executed.

It turns out that the recipe for post-install is the issue since it will include contents of postinst-pkg before the call to default_postinist. This is an issue since postinst-pkg will exit with code 0 before we ever reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit since we dont seem to be actually even generating prerm-pkg scripts but lets fix this theoretical issue as well.

Fixes: #16987
Fixes: d788ab3 ("build: add APK package build capabilities")

@github-actions github-actions bot added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Nov 20, 2024
@robimarko
Copy link
Contributor Author

@ynezz @aparcar For OPKG we rely on default_prerm and default_postinst to call the relevant prerm-pkg and postinst-pkg scripts instead of calling them directly in pre-deinstall and post-install but I guess that this is a APK limitation.

@vernesong
Copy link

postrm seems also not work

@robimarko
Copy link
Contributor Author

@vernesong Why do you think so?
I just tested removing an LuCI theme and it runs postrm just fine since its removing the UCI entries like stated in its postrm script

@vernesong
Copy link

vernesong commented Nov 20, 2024

@vernesong Why do you think so? I just tested removing an LuCI theme and it runs postrm just fine since its removing the UCI entries like stated in its postrm script

I installed a build here : https://downloads.immortalwrt.org/snapshots/targets/x86/64/
and I test a luci package by compile with the codes below

define Package/$(PKG_NAME)/postrm
#!/bin/sh
  echo "123" >>/tmp/1
  exit 0
endef

After I use the apk del command there is no file named 1 find in /tmp

@robimarko
Copy link
Contributor Author

No idea, but postrm works for me, it clearly gets executed upon removal of for example luci-theme-material, it did not work before this PR though so you cannot just prebuilts.

@robimarko
Copy link
Contributor Author

Hm, now I am wondering how it works for luci-theme-material but for my for test virtual package it doesn't get included at all, there is literally no postrm script.

@robimarko
Copy link
Contributor Author

Ok, so APK properly supports post install, post deinstall etc states, but make is driving me nuts as I cannot figure out how to make it add the appropriate --script argument to APK only if the file actually exists, it either doesn't add the argument or always evaluates true

@robimarko
Copy link
Contributor Author

postrm should also work now with the last push

@aparcar
Copy link
Member

aparcar commented Nov 21, 2024

Awesome thanks for taking care!

@efahl
Copy link
Contributor

efahl commented Nov 21, 2024

I just tested by adding postinst and postrm to an existing package, rebuilding all and examining the contents of the apk. All looked correct to me with the script contents in the right places. scped the apk to my test VM, did a couple successive add and del sequences, output was generated correctly from both:

define Package/$(PKG_NAME)/postrm
#!/bin/sh
  echo "postrm"
  exit 0
endef
define Package/$(PKG_NAME)/postinst
	echo "postinst"
endef

…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
@openwrt-bot openwrt-bot merged commit fc2ba10 into openwrt:main Nov 21, 2024
1 check passed
@robimarko
Copy link
Contributor Author

Thanks! Rebased on top of main and merged!

@robimarko robimarko deleted the apk-install-remove branch November 21, 2024 16:21
vincejv pushed a commit to vincejv/openwrt that referenced this pull request Nov 23, 2024
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
vincejv pushed a commit to vincejv/openwrt that referenced this pull request Nov 23, 2024
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
vincejv pushed a commit to vincejv/openwrt that referenced this pull request Nov 23, 2024
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
vincejv pushed a commit to vincejv/openwrt that referenced this pull request Nov 23, 2024
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
liudf0716 pushed a commit to liudf0716/openwrt that referenced this pull request Dec 5, 2024
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
liudf0716 pushed a commit to liudf0716/openwrt that referenced this pull request Dec 5, 2024
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Dec 11, 2024
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Dec 11, 2024
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
rmandrad pushed a commit to rmandrad/openwrt that referenced this pull request Dec 30, 2024
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
rmandrad pushed a commit to rmandrad/openwrt that referenced this pull request Dec 30, 2024
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
M3m3M4n pushed a commit to M3m3M4n/openwrt that referenced this pull request Feb 16, 2025
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
M3m3M4n pushed a commit to M3m3M4n/openwrt that referenced this pull request Feb 16, 2025
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
HateTM pushed a commit to HateTM/tplink_archer-ax80-v1 that referenced this pull request Mar 31, 2025
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
HateTM pushed a commit to HateTM/tplink_archer-ax80-v1 that referenced this pull request Mar 31, 2025
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
maurerr pushed a commit to maurerr/openwrt that referenced this pull request Apr 9, 2025
…g APK

Currently, when you install a package that ships uci-defaults scripts they
are not getting executed during package installation.

For example, if you install a new LuCI theme it ships a uci-defaults script
to add it to the UCI LuCI config so the theme is actually selectable but
that does not happen until the device is rebooted so that uci-defaults
script is actually executed.

It turns out that the recipe for post-install is the issue since it will
include contents of postinst-pkg before the call to default_postinist.
This is an issue since postinst-pkg will exit with code 0 before we ever
reach the call to default_postinist.

So, lets simply make the call to default_postinist before postinst-pkg
inclusion which is what OPKG based installation does.

The same issue affects pre-deinstall script but its not actually being hit
since we dont seem to be actually even generating prerm-pkg scripts but
lets fix this theoretical issue as well.

Fixes: openwrt#16987
Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
maurerr pushed a commit to maurerr/openwrt that referenced this pull request Apr 9, 2025
Currently, postrm scripts are not being executed when package is removed
with APK since they are not being included at all.

So, lets use APK-s support for post-deinstall scripts and ship our postrm
scripts if packages define them.

Fixes: d788ab3 ("build: add APK package build capabilities")
Link: openwrt#17023
Signed-off-by: Robert Marko <robimarko@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/scripts/tools pull request/issues for build, scripts and tools related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apk: package uci-defaults script may not get run in runtime installation
5 participants