[haiku-commits] BRANCH HaikuPM-github.package-management [e2732c0] src/bin/package

  • From: HaikuPM-github.package-management <community@xxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 25 Jul 2013 23:00:35 +0200 (CEST)

added 1 changeset to branch 'refs/remotes/HaikuPM-github/package-management'
old head: 5bb173cf50029056151c04016af2793a6ec26596
new head: e2732c07a833f2fd3bfe38a285202f4f0d501abd
overview: https://github.com/haiku/HaikuPM/compare/5bb173c...e2732c0

----------------------------------------------------------------------------

e2732c0: Fix 'package extract' with multiple explicit entries
  
  * before adding a child to a parent entry, we need to check if the
    parent already contains that child, as otherwise duplicate children 
    with identical names would be added, which in turn messes up the
    handling of the entries that are to be extracted

                                    [ Oliver Tappe <zooey@xxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Commit:      e2732c07a833f2fd3bfe38a285202f4f0d501abd
Author:      Oliver Tappe <zooey@xxxxxxxxxxxxxxx>
Date:        Thu Jul 25 20:52:09 2013 UTC

----------------------------------------------------------------------------

1 file changed, 9 insertions(+), 2 deletions(-)
src/bin/package/command_extract.cpp | 11 +++++++++--

----------------------------------------------------------------------------

diff --git a/src/bin/package/command_extract.cpp 
b/src/bin/package/command_extract.cpp
index 41d7fb8..4c083dc 100644
--- a/src/bin/package/command_extract.cpp
+++ b/src/bin/package/command_extract.cpp
@@ -185,6 +185,14 @@ struct Entry {
        static status_t Create(Entry* parent, const char* name, bool implicit,
                Entry*& _entry)
        {
+               if (parent != NULL) {
+                       Entry* entryInParent = parent->FindChild(name);
+                       if (entryInParent != NULL) {
+                               _entry = entryInParent;
+                               return B_OK;
+                       }
+               }
+
                char* clonedName = strdup(name);
                if (clonedName == NULL)
                        return B_NO_MEMORY;
@@ -804,7 +812,6 @@ do_extract(const char* packageFileName, const char* 
changeToDirectory,
                                        entryName);
                                exit(1);
                        }
-
                        if (handler.AddFilterEntry(entryName) != B_OK)
                                exit(1);
                }
@@ -836,6 +843,7 @@ do_extract(const char* packageFileName, const char* 
changeToDirectory,
        // check whether all explicitly specified entries have been extracted
        if (explicitEntryCount > 0) {
                for (int i = 0; i < explicitEntryCount; i++) {
+                       printf("check...en:%s\n", explicitEntries[i]);
                        if (Entry* entry = 
handler.FindFilterEntry(explicitEntries[i])) {
                                if (!entry->Seen()) {
                                        fprintf(stderr, "Warning: Entry \"%s\" 
not found.\n",
@@ -893,7 +901,6 @@ command_extract(int argc, const char* const* argv)
        const char* packageFileName = argv[optind++];
        const char* const* explicitEntries = argv + optind;
        int explicitEntryCount = argc - optind;
-
        do_extract<VersionPolicyV2>(packageFileName, changeToDirectory,
                packageInfoFileName, explicitEntries, explicitEntryCount, true);
        do_extract<VersionPolicyV1>(packageFileName, changeToDirectory,


Other related posts: