On 15 October 2014 17:31, Peter Urbanec <openembedded-de...@urbanec.net> wrote:
> 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 <openembedded-de...@urbanec.net>
> ---
>  .../opkg/opkg/prerm-and-postrm-scripts.patch       | 82
> ++++++++++++++++++++++
>  meta/recipes-devtools/opkg/opkg_0.2.2.bb           |  1 +
>  2 files changed, 83 insertions(+)
>  create mode 100644
> meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch
>
> diff --git a/meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch
> b/meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch
> new file mode 100644
> index 0000000..0d7f726
> --- /dev/null
> +++ b/meta/recipes-devtools/opkg/opkg/prerm-and-postrm-scripts.patch
> @@ -0,0 +1,82 @@
> +Upstream-Status: Submitted [opkg-de...@googlegroups.com]
> +Signed-off-by: Peter Urbanec <openembedded-de...@urbanec.net>
> +
> +From 476965fdb2d6eec559242e6205cbb07d539b80e1 Mon Sep 17 00:00:00 2001
> +From: Peter Urbanec <openembedded-de...@urbanec.net>
> +Date: Wed, 15 Oct 2014 14:32:22 +1100
> +Subject: [PATCH] opkg_install: Call prerm and postrm scripts on package
> upgrade.
> +To: opkg-de...@googlegroups.com
> +Cc: p...@paulbarker.me.uk
> +
> +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.

For the sake of future readers within OpenEmbedded, we need to make
clearer here that this is opkg issue 104, not an OE issue number. This
change isn't needed in the patch to opkg upstream though.

> +
> +Signed-off-by: Peter Urbanec <openembedded-de...@urbanec.net>

Sorry to be pedantic but there's now 2 copies of the Signed-off-by
line. If you resend this, I'd also bring the Upstream-status line down
so that it immediately follows the Signed-off-by line. That's just a
minor cosmetic point though, it may be possible for someone to make
these edits as the patch is merged.

> +
> +---
> + 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
> +

This looks fine. As I've said in reply to the patch on the opkg-devel
mailing list, I'm busy this week but should have time to test this
properly next week. It looks correct to me though, the logic is almost
identical to the patch I prepared which covers prerm only.

It probably doesn't need to wait for my test before going into OE though.

-- 
Paul Barker

Email: p...@paulbarker.me.uk
http://www.paulbarker.me.uk
-- 
_______________________________________________
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to