opkg: Call prerm and postrm scripts on package upgrade.
PATCH 1/2 opkg: Call prerm and postrm scripts on package upgrade.
opkg upgrade will now call prerm and postrm scripts from the old package with the "upgrade new-version" arguments, similar to what dpkg does.
Upstream-Status: Submitted [[email protected]]
--- .../opkg/opkg/prerm-and-postrm-scripts.patch | 79 ++++++++++++++++++++++ meta/recipes-devtools/opkg/opkg_0.2.2.bb | 1 + 2 files changed, 80 insertions(+) create mode 100644 meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +76 -0
@@ -0,0 +1,79 @@ +From 476965fdb2d6eec559242e6205cbb07d539b80e1 Mon Sep 17 00:00:00 2001 +From: Peter Urbanec <[email protected]> +Date: Wed, 15 Oct 2014 14:32:22 +1100 +Subject: [PATCH] opkg_install: Call prerm and postrm scripts on package + upgrade. +To: [email protected] +Cc: [email protected] + +When upgrading a package from v1 to v2, run "v1-prerm upgrade v2" and +"v1-postrm upgrade v2", similarly to what dpkg does. + +This patch fixes issue 104. + +Signed-off-by: Peter Urbanec <[email protected]> +--- + libopkg/opkg_install.c | 40 ++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 38 insertions(+), 2 deletions(-) + +diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c +index 4f6fe65..ec0f34a 100644 +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -601,7 +601,25 @@ prerm_upgrade_old_pkg(pkg_t *pkg, pkg_t *old_pkg) + Error unwind, for both the above cases: + old-postinst abort-upgrade new-version + */ +- return 0; ++ int err; ++ char *script_args; ++ char *new_version; ++ ++ if (!old_pkg || !pkg) ++ return 0; ++ ++ new_version = pkg_version_str_alloc(pkg); ++ ++ sprintf_alloc(&script_args, "upgrade %s", new_version); ++ free(new_version); ++ err = pkg_run_script(old_pkg, "prerm", script_args); ++ free(script_args); ++ if (err != 0) { ++ opkg_msg(ERROR, "prerm script for package \"%s\" failed\n", ++ old_pkg->name); ++ return -1; ++ } ++ return 0; + } + + static int +@@ -1001,7 +1019,25 @@ postrm_upgrade_old_pkg(pkg_t *pkg, pkg_t *old_pkg) + new-postrm failed-upgrade old-version + Error unwind, for both cases: + old-preinst abort-upgrade new-version */ +- return 0; ++ int err; ++ char *script_args; ++ char *new_version; ++ ++ if (!old_pkg || !pkg) ++ return 0; ++ ++ new_version = pkg_version_str_alloc(pkg); ++ ++ sprintf_alloc(&script_args, "upgrade %s", new_version); ++ free(new_version); ++ err = pkg_run_script(old_pkg, "postrm", script_args); ++ free(script_args); ++ if (err != 0) { ++ opkg_msg(ERROR, "postrm script for package \"%s\" failed\n", ++ old_pkg->name); ++ return -1; ++ } ++ return 0; + } + + static int +-- +2.1.2 +
meta/recipes-devtools/opkg/opkg_0.2.2.bb +1 -0
@@ -4,6 +4,7 @@ SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz file://no-install-recommends.patch \ file://add-exclude.patch \ file://opkg-configure.service \ + file://prerm-and-postrm-scripts.patch \ " S = "${WORKDIR}/${BPN}-${PV}"
Signature · 1 line
2.1.2
Quoted 21 lines · Peter Urbanec
opkg upgrade will now call prerm and postrm scripts from the old package with the "upgrade new-version" arguments, similar to what dpkg does.
Signed-off-by Peter Urbanec <[email protected]>Upstream-Status: Submitted [[email protected]]
--- .../opkg/opkg/prerm-and-postrm-scripts.patch | 79 ++++++++++++++++++++++ meta/recipes-devtools/opkg/opkg_0.2.2.bb | 1 + 2 files changed, 80 insertions(+) create mode 100644 meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patchmeta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +4
-0@@ -0,0 +1,79 @@ +From 476965fdb2d6eec559242e6205cbb07d539b80e1 Mon Sep 17 00:00:00 2001 +From: Peter Urbanec <[email protected]> +Date: Wed, 15 Oct 2014 14:32:22 +1100 +Subject: [PATCH] opkg_install: Call prerm and postrm scripts on package
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch line 14
Quoted 10 lines
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +10
-0+ upgrade. +To: [email protected] +Cc: [email protected] + +When upgrading a package from v1 to v2, run "v1-prerm upgrade v2" and +"v1-postrm upgrade v2", similarly to what dpkg does. + +This patch fixes issue 104. + +Signed-off-by: Peter Urbanec <[email protected]>
This is still missing "Upstream-status:"
Quoted 24 lines
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +24
-0+--- + libopkg/opkg_install.c | 40 ++++++++++++++++++++++++++++++++++++++-- + 1 file changed, 38 insertions(+), 2 deletions(-) + +diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c +index 4f6fe65..ec0f34a 100644 +--- a/libopkg/opkg_install.c ++++ b/libopkg/opkg_install.c +@@ -601,7 +601,25 @@ prerm_upgrade_old_pkg(pkg_t *pkg, pkg_t *old_pkg) + Error unwind, for both the above cases: + old-postinst abort-upgrade new-version + */ +- return 0; ++ int err; ++ char *script_args; ++ char *new_version; ++ ++ if (!old_pkg || !pkg) ++ return 0; ++ ++ new_version = pkg_version_str_alloc(pkg); ++ ++ sprintf_alloc(&script_args, "upgrade %s", new_version); ++ free(new_version);
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch line 48
Quoted 10 lines
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +10
-0++ err = pkg_run_script(old_pkg, "prerm", script_args); ++ free(script_args); ++ if (err != 0) { ++ opkg_msg(ERROR, "prerm script for package \"%s\" failed\n", ++ old_pkg->name); ++ return -1; ++ } ++ return 0; + } + + static int
I don't think the patch has been generated properly here. There shouldn't be a change to this line.
Quoted 16 lines
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +16
-0+@@ -1001,7 +1019,25 @@ postrm_upgrade_old_pkg(pkg_t *pkg, pkg_t *old_pkg) + new-postrm failed-upgrade old-version + Error unwind, for both cases: + old-preinst abort-upgrade new-version */ +- return 0; ++ int err; ++ char *script_args; ++ char *new_version; ++ ++ if (!old_pkg || !pkg) ++ return 0; ++ ++ new_version = pkg_version_str_alloc(pkg); ++ ++ sprintf_alloc(&script_args, "upgrade %s", new_version); ++ free(new_version);
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch line 74
Quoted 10 lines
meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch new file +10
-0++ err = pkg_run_script(old_pkg, "postrm", script_args); ++ free(script_args); ++ if (err != 0) { ++ opkg_msg(ERROR, "postrm script for package \"%s\" failed\n", ++ old_pkg->name); ++ return -1; ++ } ++ return 0; + } + + static int
Again, I'm not sure why this line is listed with a '+'.
Cheers,
Signature · 4 lines
Paul Barker Email: [email protected] http://www.paulbarker.me.uk
Quoted 2 lines · Paul Barker
This is still missing "Upstream-status:"
...
Quoted 5 lines
Quoted 2 lines
+ }
+ + static intI don't think the patch has been generated properly here. There shouldn't be a change to this line.
Patch resent. I moved the Upstream-status: from the header of the patch, into the header of the embedded patch. I hope I got it right!
As far as the patch corruption is concerned, that's Thunderbird 31 being helpful, even though I asked it not to interfere. I resent the patch using a webmail client, which seems to have done a better job.
Cheers,
Peter