Installer: supports installing .hpkg-based optional packages

Most of Installer was designed for old-style optional packages (files in
a folder that's copied to the target volume). This commit modifies
Installer so that it can process and install .hpkg packages.

Change-Id: Ib7d69a04ccb7879b956b5c3f0df1241c56e4987d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2400
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Leorize
2020-03-22 20:40:21 +00:00
committed by Adrien Destugues
parent bf551d3889
commit f1e5a6c914
3 changed files with 30 additions and 15 deletions
+3 -3
View File
@@ -34,13 +34,13 @@
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON" #define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
Package::Package(const char *folder) Package::Package(const BPath &path)
: :
Group(), Group(),
fSize(0), fSize(0),
fIcon(NULL) fIcon(NULL)
{ {
SetFolder(folder); SetPath(path);
} }
@@ -62,7 +62,7 @@ Package::PackageFromEntry(BEntry &entry)
if (info.InitCheck() != B_OK) if (info.InitCheck() != B_OK)
return NULL; return NULL;
Package *package = new Package(path.Path()); Package *package = new Package(path);
package->fName = info.Name(); package->fName = info.Name();
package->fDescription = info.Summary(); package->fDescription = info.Summary();
+7 -6
View File
@@ -12,6 +12,7 @@
#include <CheckBox.h> #include <CheckBox.h>
#include <Entry.h> #include <Entry.h>
#include <List.h> #include <List.h>
#include <Path.h>
#include <String.h> #include <String.h>
#include <StringView.h> #include <StringView.h>
@@ -31,11 +32,11 @@ private:
class Package : public Group { class Package : public Group {
public: public:
Package(const char* folder); Package(const BPath &path);
virtual ~Package(); virtual ~Package();
void SetFolder(BString folder) void SetPath(const BPath &path)
{ fFolder = folder; } { fPath = path; }
void SetName(const BString name) void SetName(const BString name)
{ fName = name; } { fName = name; }
void SetDescription(const BString description) void SetDescription(const BString description)
@@ -48,8 +49,8 @@ public:
{ fOnByDefault = onByDefault; } { fOnByDefault = onByDefault; }
void SetAlwaysOn(bool alwaysOn) void SetAlwaysOn(bool alwaysOn)
{ fAlwaysOn = alwaysOn; } { fAlwaysOn = alwaysOn; }
BString Folder() const BPath Path() const
{ return fFolder; } { return fPath; }
BString Name() const BString Name() const
{ return fName; } { return fName; }
BString Description() const BString Description() const
@@ -68,7 +69,7 @@ public:
static Package* PackageFromEntry(BEntry &dir); static Package* PackageFromEntry(BEntry &dir);
private: private:
BString fFolder; BPath fPath;
BString fName; BString fName;
BString fDescription; BString fDescription;
int32 fSize; int32 fSize;
+20 -6
View File
@@ -514,12 +514,14 @@ WorkerThread::_PerformInstall(partition_id sourcePartitionID,
// Collect selected packages also // Collect selected packages also
if (fPackages) { if (fPackages) {
BPath pkgRootDir(srcDirectory.Path(), kPackagesDirectoryPath);
int32 count = fPackages->CountItems(); int32 count = fPackages->CountItems();
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
Package *p = static_cast<Package*>(fPackages->ItemAt(i)); Package *p = static_cast<Package*>(fPackages->ItemAt(i));
BPath packageDir(pkgRootDir.Path(), p->Folder()); const BPath& pkgPath = p->Path();
err = engine.CollectTargets(packageDir.Path(), fCancelSemaphore); err = pkgPath.InitCheck();
if (err != B_OK)
return _InstallationError(err);
err = engine.CollectTargets(pkgPath.Path(), fCancelSemaphore);
if (err != B_OK) if (err != B_OK)
return _InstallationError(err); return _InstallationError(err);
} }
@@ -541,12 +543,24 @@ WorkerThread::_PerformInstall(partition_id sourcePartitionID,
// copy selected packages // copy selected packages
if (fPackages) { if (fPackages) {
BPath pkgRootDir(srcDirectory.Path(), kPackagesDirectoryPath);
int32 count = fPackages->CountItems(); int32 count = fPackages->CountItems();
// FIXME: find_directory doesn't return the folder in the target volume,
// so we are hard coding this for now.
BPath targetPkgDir(targetDirectory.Path(), "system/packages");
err = targetPkgDir.InitCheck();
if (err != B_OK)
return _InstallationError(err);
for (int32 i = 0; i < count; i++) { for (int32 i = 0; i < count; i++) {
Package *p = static_cast<Package*>(fPackages->ItemAt(i)); Package *p = static_cast<Package*>(fPackages->ItemAt(i));
BPath packageDir(pkgRootDir.Path(), p->Folder()); const BPath& pkgPath = p->Path();
err = engine.Copy(packageDir.Path(), targetDirectory.Path(), err = pkgPath.InitCheck();
if (err != B_OK)
return _InstallationError(err);
BPath targetPath(targetPkgDir.Path(), pkgPath.Leaf());
err = targetPath.InitCheck();
if (err != B_OK)
return _InstallationError(err);
err = engine.Copy(pkgPath.Path(), targetPath.Path(),
fCancelSemaphore); fCancelSemaphore);
if (err != B_OK) if (err != B_OK)
return _InstallationError(err); return _InstallationError(err);