All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] opkg: add strict package matching on removal patch
@ 2018-09-05 17:08 Alejandro del Castillo
  2018-09-05 17:33 ` ✗ patchtest: failure for " Patchwork
  2018-09-05 18:16 ` [PATCH v2] " Alejandro del Castillo
  0 siblings, 2 replies; 3+ messages in thread
From: Alejandro del Castillo @ 2018-09-05 17:08 UTC (permalink / raw)
  To: openembedded-core, raj.khem, christophevr

During removal, opkg is using globs to select which metadata files to
remove. The glob is too broad and sometimes can result in a package
removing the metadata from a package with a close name. Make the
matching more strict.

Fixes bugzilla 12905

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
---
 ...intainer_scripts-use-strict-matching.patch | 55 +++++++++++++++++++
 meta/recipes-devtools/opkg/opkg_0.3.6.bb      |  1 +
 2 files changed, 56 insertions(+)
 create mode 100644 meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch

diff --git a/meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch b/meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch
new file mode 100644
index 0000000000..193c2b326c
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch
@@ -0,0 +1,55 @@
+From 55c4ad666e76281bdd0db55fa6f4ab2744fea7e4 Mon Sep 17 00:00:00 2001
+From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
+Date: Tue, 4 Sep 2018 18:06:00 -0500
+Subject: [PATCH] remove_maintainer_scripts: use strict matching
+
+The function is using a glob to select which metadata files needs to be
+deleted during package removal, on the info_dir. However, the glob may
+match metadata files from packages with similar names. For example,
+during removal of package glibc-binary-localedata-de-at, the current
+logic was also removing the metadata for
+glibc-binary-localedata-de-at.iso-8859-1. Add check for an exact match
+before deletion.
+
+Fixes bugzilla: 12905
+
+Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
+---
+ libopkg/opkg_remove.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
+index 82125fa..3936628 100644
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -137,7 +137,7 @@ void remove_maintainer_scripts(pkg_t * pkg)
+ {
+     unsigned int i;
+     int err;
+-    char *globpattern;
++    char *globpattern, *filename, *lastdot;
+     glob_t globbuf;
+ 
+     if (opkg_config->noaction)
+@@ -151,8 +151,16 @@ void remove_maintainer_scripts(pkg_t * pkg)
+         return;
+ 
+     for (i = 0; i < globbuf.gl_pathc; i++) {
+-        opkg_msg(INFO, "Deleting %s.\n", globbuf.gl_pathv[i]);
+-        unlink(globbuf.gl_pathv[i]);
++        filename = xstrdup(basename(globbuf.gl_pathv[i]));
++        lastdot = strrchr(filename, '.');
++        *lastdot = '\0';
++        // Only delete files that match the package name (the glob may match files
++        // with similar names)
++        if (!strcmp(filename, pkg->name)) {
++            opkg_msg(INFO, "Deleting %s.\n", globbuf.gl_pathv[i]);
++            unlink(globbuf.gl_pathv[i]);
++        }
++        free(filename);
+     }
+     globfree(&globbuf);
+ }
+-- 
+2.18.0
+
diff --git a/meta/recipes-devtools/opkg/opkg_0.3.6.bb b/meta/recipes-devtools/opkg/opkg_0.3.6.bb
index 579b51166c..6ebd58b967 100644
--- a/meta/recipes-devtools/opkg/opkg_0.3.6.bb
+++ b/meta/recipes-devtools/opkg/opkg_0.3.6.bb
@@ -14,6 +14,7 @@ PE = "1"
 SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz \
            file://opkg.conf \
            file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \
+           file://0001-remove_maintainer_scripts-use-strict-matching.patch \
 "
 
 SRC_URI[md5sum] = "79e04307f6f54db431c251772d7d987c"
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* ✗ patchtest: failure for opkg: add strict package matching on removal patch
  2018-09-05 17:08 [PATCH] opkg: add strict package matching on removal patch Alejandro del Castillo
@ 2018-09-05 17:33 ` Patchwork
  2018-09-05 18:16 ` [PATCH v2] " Alejandro del Castillo
  1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2018-09-05 17:33 UTC (permalink / raw)
  To: Alejandro del Castillo; +Cc: openembedded-core

== Series Details ==

Series: opkg: add strict package matching on removal patch
Revision: 1
URL   : https://patchwork.openembedded.org/series/13905/
State : failure

== Summary ==


Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:



* Issue             Added patch file is missing Upstream-Status in the header [test_upstream_status_presence_format] 
  Suggested fix    Add Upstream-Status: <Valid status> to the header of meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch
  Standard format  Upstream-Status: <Valid status>
  Valid status     Pending, Accepted, Backport, Denied, Inappropriate [reason], Submitted [where]



If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).

---
Guidelines:     https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite:     http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] opkg: add strict package matching on removal patch
  2018-09-05 17:08 [PATCH] opkg: add strict package matching on removal patch Alejandro del Castillo
  2018-09-05 17:33 ` ✗ patchtest: failure for " Patchwork
@ 2018-09-05 18:16 ` Alejandro del Castillo
  1 sibling, 0 replies; 3+ messages in thread
From: Alejandro del Castillo @ 2018-09-05 18:16 UTC (permalink / raw)
  To: openembedded-core, raj.khem

During removal, opkg is using globs to select which metadata files to
remove. The glob is too broad and sometimes can result in a package
removing the metadata from a package with a close name. Make the
matching more strict.

Fixes bugzilla 12905

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
---

Changes since v1
 * Add Upstream-Status tag
  
 ...intainer_scripts-use-strict-matching.patch | 56 +++++++++++++++++++
 meta/recipes-devtools/opkg/opkg_0.3.6.bb      |  1 +
 2 files changed, 57 insertions(+)
 create mode 100644 meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch

diff --git a/meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch b/meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch
new file mode 100644
index 0000000000..ec160290be
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0001-remove_maintainer_scripts-use-strict-matching.patch
@@ -0,0 +1,56 @@
+From 55c4ad666e76281bdd0db55fa6f4ab2744fea7e4 Mon Sep 17 00:00:00 2001
+From: Alejandro del Castillo <alejandro.delcastillo@ni.com>
+Date: Tue, 4 Sep 2018 18:06:00 -0500
+Subject: [PATCH] remove_maintainer_scripts: use strict matching
+
+The function is using a glob to select which metadata files needs to be
+deleted during package removal, on the info_dir. However, the glob may
+match metadata files from packages with similar names. For example,
+during removal of package glibc-binary-localedata-de-at, the current
+logic was also removing the metadata for
+glibc-binary-localedata-de-at.iso-8859-1. Add check for an exact match
+before deletion.
+
+Fixes bugzilla: 12905
+
+Upstream-Status: Submitted [https://groups.google.com/forum/#!topic/opkg-devel/Fr40Yt0NBno]
+Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
+---
+ libopkg/opkg_remove.c | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
+index 82125fa..3936628 100644
+--- a/libopkg/opkg_remove.c
++++ b/libopkg/opkg_remove.c
+@@ -137,7 +137,7 @@ void remove_maintainer_scripts(pkg_t * pkg)
+ {
+     unsigned int i;
+     int err;
+-    char *globpattern;
++    char *globpattern, *filename, *lastdot;
+     glob_t globbuf;
+ 
+     if (opkg_config->noaction)
+@@ -151,8 +151,16 @@ void remove_maintainer_scripts(pkg_t * pkg)
+         return;
+ 
+     for (i = 0; i < globbuf.gl_pathc; i++) {
+-        opkg_msg(INFO, "Deleting %s.\n", globbuf.gl_pathv[i]);
+-        unlink(globbuf.gl_pathv[i]);
++        filename = xstrdup(basename(globbuf.gl_pathv[i]));
++        lastdot = strrchr(filename, '.');
++        *lastdot = '\0';
++        // Only delete files that match the package name (the glob may match files
++        // with similar names)
++        if (!strcmp(filename, pkg->name)) {
++            opkg_msg(INFO, "Deleting %s.\n", globbuf.gl_pathv[i]);
++            unlink(globbuf.gl_pathv[i]);
++        }
++        free(filename);
+     }
+     globfree(&globbuf);
+ }
+-- 
+2.18.0
+
diff --git a/meta/recipes-devtools/opkg/opkg_0.3.6.bb b/meta/recipes-devtools/opkg/opkg_0.3.6.bb
index 579b51166c..6ebd58b967 100644
--- a/meta/recipes-devtools/opkg/opkg_0.3.6.bb
+++ b/meta/recipes-devtools/opkg/opkg_0.3.6.bb
@@ -14,6 +14,7 @@ PE = "1"
 SRC_URI = "http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz \
            file://opkg.conf \
            file://0001-opkg_conf-create-opkg.lock-in-run-instead-of-var-run.patch \
+           file://0001-remove_maintainer_scripts-use-strict-matching.patch \
 "
 
 SRC_URI[md5sum] = "79e04307f6f54db431c251772d7d987c"
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-05 18:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05 17:08 [PATCH] opkg: add strict package matching on removal patch Alejandro del Castillo
2018-09-05 17:33 ` ✗ patchtest: failure for " Patchwork
2018-09-05 18:16 ` [PATCH v2] " Alejandro del Castillo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.