aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Gorski <jonas.gorski@gmail.com>2016-11-21 15:20:32 +0100
committerJonas Gorski <jonas.gorski@gmail.com>2016-11-21 18:40:15 +0100
commit88a14bfd1da55bbddf5a86b3c452f1d8b1c46a60 (patch)
tree6ebb66959b16464b7f29fced8e1fe1219a73e431
parentafaa34ccd7343e478df8c0cd49019363692bcd16 (diff)
downloadupstream-88a14bfd1da55bbddf5a86b3c452f1d8b1c46a60.tar.gz
upstream-88a14bfd1da55bbddf5a86b3c452f1d8b1c46a60.tar.bz2
upstream-88a14bfd1da55bbddf5a86b3c452f1d8b1c46a60.zip
opkg: run prerm scripts for the old version also on upgrade
To make sure we properly restart services on upgrade we need to call the prerm script of the old package, in case the init script changes (or vanishes). Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com> Acked-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--package/system/opkg/Makefile2
-rw-r--r--package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch73
2 files changed, 74 insertions, 1 deletions
diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile
index 5b96fea004..2a04c4d247 100644
--- a/package/system/opkg/Makefile
+++ b/package/system/opkg/Makefile
@@ -13,7 +13,7 @@ include $(INCLUDE_DIR)/feeds.mk
PKG_NAME:=opkg
PKG_REV:=9c97d5ecd795709c8584e972bfdf3aee3a5b846d
PKG_VERSION:=$(PKG_REV)
-PKG_RELEASE:=14
+PKG_RELEASE:=15
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=$(PKG_REV)
diff --git a/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch b/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch
new file mode 100644
index 0000000000..6abbd5df8e
--- /dev/null
+++ b/package/system/opkg/patches/280-call-prerm-and-postrm-scripts-on-upgrade.patch
@@ -0,0 +1,73 @@
+From a8555d352d2851ee1482b74b57ba9eacfb354c18 Mon Sep 17 00:00:00 2001
+From: Peter Urbanec <peteru@urbanec.net>
+Date: Thu, 23 Oct 2014 01:05:35 +1100
+Subject: [PATCH] opkg_install: Call prerm and postrm scripts on package
+ upgrade
+
+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 <openembedded-devel@urbanec.net>
+Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
+---
+ libopkg/opkg_install.c | 40 ++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 38 insertions(+), 2 deletions(-)
+
+--- a/libopkg/opkg_install.c
++++ b/libopkg/opkg_install.c
+@@ -528,7 +528,25 @@ prerm_upgrade_old_pkg(pkg_t *pkg, pkg_t
+ 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
+@@ -925,7 +943,25 @@ postrm_upgrade_old_pkg(pkg_t *pkg, pkg_t
+ 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