packagefs: system_packages take precedence over non-system packages.

Affects *all* nodes, i.e., both directories and files. It is still possible
to override these, but it must be done in another system_package, not just by
mounting a package with newer datestamps on the conflicting files.

This is the pure version of axeld's proposal 2(d) from #10071. However,
as the haiku_secondary packages contain application mime_db entires and
are also 'system_package's, it does not fully solve that ticket.
This commit is contained in:
Augustin Cavalier 2018-08-05 16:25:54 -04:00
parent 0779294800
commit abf0c2878a
4 changed files with 22 additions and 0 deletions

View File

@ -268,6 +268,10 @@ struct Package::LoaderContentHandler : BPackageContentHandler {
break; break;
} }
case B_PACKAGE_INFO_FLAGS:
fPackage->SetFlags(value.unsignedInt);
break;
case B_PACKAGE_INFO_ARCHITECTURE: case B_PACKAGE_INFO_ARCHITECTURE:
if (value.unsignedInt >= B_PACKAGE_ARCHITECTURE_ENUM_COUNT) if (value.unsignedInt >= B_PACKAGE_ARCHITECTURE_ENUM_COUNT)
RETURN_ERROR(B_BAD_VALUE); RETURN_ERROR(B_BAD_VALUE);
@ -816,6 +820,7 @@ Package::Package(::Volume* volume, PackagesDirectory* directory, dev_t deviceID,
fInstallPath(), fInstallPath(),
fVersionedName(), fVersionedName(),
fVersion(NULL), fVersion(NULL),
fFlags(0),
fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT), fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT),
fLinkDirectory(NULL), fLinkDirectory(NULL),
fFD(-1), fFD(-1),

View File

@ -7,6 +7,7 @@
#include <package/hpkg/DataReader.h> #include <package/hpkg/DataReader.h>
#include <package/PackageFlags.h>
#include <package/PackageArchitecture.h> #include <package/PackageArchitecture.h>
#include <Referenceable.h> #include <Referenceable.h>
@ -69,6 +70,11 @@ public:
::Version* Version() const ::Version* Version() const
{ return fVersion; } { return fVersion; }
void SetFlags(uint32 flags)
{ fFlags = flags; }
uint32 Flags() const
{ return fFlags; }
void SetArchitecture( void SetArchitecture(
BPackageArchitecture architecture) BPackageArchitecture architecture)
{ fArchitecture = architecture; } { fArchitecture = architecture; }
@ -123,6 +129,7 @@ private:
String fInstallPath; String fInstallPath;
String fVersionedName; String fVersionedName;
::Version* fVersion; ::Version* fVersion;
uint32 fFlags;
BPackageArchitecture fArchitecture; BPackageArchitecture fArchitecture;
PackageLinkDirectory* fLinkDirectory; PackageLinkDirectory* fLinkDirectory;
int fFD; int fFD;

View File

@ -17,6 +17,7 @@
PackageNode::PackageNode(Package* package, mode_t mode) PackageNode::PackageNode(Package* package, mode_t mode)
: :
fPackage(package), fPackage(package),
fPackageFlags(package != NULL ? package->Flags() : 0),
fParent(NULL), fParent(NULL),
fName(), fName(),
fMode(mode), fMode(mode),
@ -107,5 +108,13 @@ PackageNode::UnsetIndexCookie(void* attributeCookie)
bool bool
PackageNode::operator<(const PackageNode& other) const PackageNode::operator<(const PackageNode& other) const
{ {
const bool isSystemPkg = (fPackageFlags
& BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE) != 0,
otherIsSystemPkg = (other.fPackageFlags
& BPackageKit::B_PACKAGE_FLAG_SYSTEM_PACKAGE) != 0;
if (isSystemPkg && !otherIsSystemPkg)
return false;
if (!isSystemPkg && otherIsSystemPkg)
return true;
return fModifiedTime < other.fModifiedTime; return fModifiedTime < other.fModifiedTime;
} }

View File

@ -86,6 +86,7 @@ public:
protected: protected:
Package* fPackage; Package* fPackage;
uint32 fPackageFlags;
PackageDirectory* fParent; PackageDirectory* fParent;
String fName; String fName;
mode_t fMode; mode_t fMode;