[haiku-commits] haiku: hrev53373 - in src: kits/package/hpkg bin/package kits/package

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 13 Aug 2019 22:08:38 -0400 (EDT)

hrev53373 adds 1 changeset to branch 'master'
old head: 7893e1249ef18cf674c249503eea00aaf73d9c7f
new head: 31d70c106be1a8f0f0b50dba3a5020adf6421147
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=31d70c106be1+%5E7893e1249ef1

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

31d70c106be1: package kit: Skip over future package attributes.
  
  Ignore unknown fields (also called attributes) which are from a package
  file with a different minor version number.  Previously it would halt
  with an error when encountering such a field, even though it can safely
  be skipped over (if it was unsafe, we would have incremented the major
  version number).
  
  The use case is a future package attribute for pre-uninstall scripts.
  If they're not run, that just leaves some debris after uninstalling
  (like symbolic link desktop icons).
  
  * Use the B_NOT_SUPPORTED error code when reading unknown package
    attributes.  Don't treat it as an error if the package is a
    different minor version, just skip it.
  * Print unknown package attribute index numbers rather than stopping,
    since they may be from future package file formats and can be safely
    skipped otherwise.  Mention the relevant enum so you can find it in
    the source code.  It's a pity that the previous abstraction layer
    isn't present, since it tells us what data type the attribute is
    (string, number, etc), so we could have printed its value too.
  
  First step of two for enhancement #13427
  
  See https://review.haiku-os.org/c/haiku/+/1504 to generate packages
  with a different minor version number (second step of the enhancement).
  
  Change-Id: I6db1897824a1713b3d5fab6fdfb990ee5923cd52
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1714
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                                 [ Alexander G. M. Smith <agmsmith@xxxxxx> ]

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

Revision:    hrev53373
Commit:      31d70c106be1a8f0f0b50dba3a5020adf6421147
URL:         https://git.haiku-os.org/haiku/commit/?id=31d70c106be1
Author:      Alexander G. M. Smith <agmsmith@xxxxxx>
Date:        Tue Aug 13 23:17:18 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Wed Aug 14 02:08:35 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/13427

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

3 files changed, 8 insertions(+), 2 deletions(-)
src/bin/package/PackageInfoPrinter.h           | 4 +++-
src/kits/package/PackageInfoContentHandler.cpp | 2 +-
src/kits/package/hpkg/ReaderImplBase.cpp       | 4 ++++

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

diff --git a/src/bin/package/PackageInfoPrinter.h 
b/src/bin/package/PackageInfoPrinter.h
index 7284312cb6..8357d90fd6 100644
--- a/src/bin/package/PackageInfoPrinter.h
+++ b/src/bin/package/PackageInfoPrinter.h
@@ -212,7 +212,9 @@ public:
                                break;
 
                        default:
-                               return false;
+                               printf("\tunknown or future attribute: "
+                                       "BPackageInfoAttributeID #%d\n", 
value.attributeID);
+                               return true;
                }
 
                return true;
diff --git a/src/kits/package/PackageInfoContentHandler.cpp 
b/src/kits/package/PackageInfoContentHandler.cpp
index 0e4ad1d5d1..80c552d587 100644
--- a/src/kits/package/PackageInfoContentHandler.cpp
+++ b/src/kits/package/PackageInfoContentHandler.cpp
@@ -155,7 +155,7 @@ BPackageInfoContentHandler::HandlePackageAttribute(
                                        "Invalid package attribute section: 
unexpected package "
                                        "attribute id %d encountered\n", 
value.attributeID);
                        }
-                       return B_BAD_DATA;
+                       return B_NOT_SUPPORTED; // Could be a future attribute 
we can skip.
        }
 
        return B_OK;
diff --git a/src/kits/package/hpkg/ReaderImplBase.cpp 
b/src/kits/package/hpkg/ReaderImplBase.cpp
index 612e132134..b0a647feb8 100644
--- a/src/kits/package/hpkg/ReaderImplBase.cpp
+++ b/src/kits/package/hpkg/ReaderImplBase.cpp
@@ -139,6 +139,8 @@ ReaderImplBase::PackageInfoAttributeHandlerBase::NotifyDone(
 {
        status_t error = context->packageContentHandler->HandlePackageAttribute(
                fPackageInfoValue);
+       if (context->ignoreUnknownAttributes && error == B_NOT_SUPPORTED)
+               error = B_OK; // Safe to skip a future/unknown attribute.
        fPackageInfoValue.Clear();
        return error;
 }
@@ -681,6 +683,8 @@ ReaderImplBase::PackageAttributeHandler::HandleAttribute(
        if (_handler == NULL) {
                status_t error = context->packageContentHandler
                        ->HandlePackageAttribute(fPackageInfoValue);
+               if (context->ignoreUnknownAttributes && error == 
B_NOT_SUPPORTED)
+                       error = B_OK; // Safe to skip a future/unknown 
attribute.
                fPackageInfoValue.Clear();
                if (error != B_OK)
                        return error;


Other related posts:

  • » [haiku-commits] haiku: hrev53373 - in src: kits/package/hpkg bin/package kits/package - waddlesplash