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 <waddlesplash@gmail.com>
This commit is contained in:
parent
bf551d3889
commit
f1e5a6c914
@ -34,13 +34,13 @@
|
||||
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
|
||||
|
||||
|
||||
Package::Package(const char *folder)
|
||||
Package::Package(const BPath &path)
|
||||
:
|
||||
Group(),
|
||||
fSize(0),
|
||||
fIcon(NULL)
|
||||
{
|
||||
SetFolder(folder);
|
||||
SetPath(path);
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ Package::PackageFromEntry(BEntry &entry)
|
||||
if (info.InitCheck() != B_OK)
|
||||
return NULL;
|
||||
|
||||
Package *package = new Package(path.Path());
|
||||
Package *package = new Package(path);
|
||||
package->fName = info.Name();
|
||||
package->fDescription = info.Summary();
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <CheckBox.h>
|
||||
#include <Entry.h>
|
||||
#include <List.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
#include <StringView.h>
|
||||
|
||||
@ -31,11 +32,11 @@ private:
|
||||
|
||||
class Package : public Group {
|
||||
public:
|
||||
Package(const char* folder);
|
||||
Package(const BPath &path);
|
||||
virtual ~Package();
|
||||
|
||||
void SetFolder(BString folder)
|
||||
{ fFolder = folder; }
|
||||
void SetPath(const BPath &path)
|
||||
{ fPath = path; }
|
||||
void SetName(const BString name)
|
||||
{ fName = name; }
|
||||
void SetDescription(const BString description)
|
||||
@ -48,8 +49,8 @@ public:
|
||||
{ fOnByDefault = onByDefault; }
|
||||
void SetAlwaysOn(bool alwaysOn)
|
||||
{ fAlwaysOn = alwaysOn; }
|
||||
BString Folder() const
|
||||
{ return fFolder; }
|
||||
BPath Path() const
|
||||
{ return fPath; }
|
||||
BString Name() const
|
||||
{ return fName; }
|
||||
BString Description() const
|
||||
@ -68,7 +69,7 @@ public:
|
||||
static Package* PackageFromEntry(BEntry &dir);
|
||||
|
||||
private:
|
||||
BString fFolder;
|
||||
BPath fPath;
|
||||
BString fName;
|
||||
BString fDescription;
|
||||
int32 fSize;
|
||||
|
@ -514,12 +514,14 @@ WorkerThread::_PerformInstall(partition_id sourcePartitionID,
|
||||
|
||||
// Collect selected packages also
|
||||
if (fPackages) {
|
||||
BPath pkgRootDir(srcDirectory.Path(), kPackagesDirectoryPath);
|
||||
int32 count = fPackages->CountItems();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
Package *p = static_cast<Package*>(fPackages->ItemAt(i));
|
||||
BPath packageDir(pkgRootDir.Path(), p->Folder());
|
||||
err = engine.CollectTargets(packageDir.Path(), fCancelSemaphore);
|
||||
const BPath& pkgPath = p->Path();
|
||||
err = pkgPath.InitCheck();
|
||||
if (err != B_OK)
|
||||
return _InstallationError(err);
|
||||
err = engine.CollectTargets(pkgPath.Path(), fCancelSemaphore);
|
||||
if (err != B_OK)
|
||||
return _InstallationError(err);
|
||||
}
|
||||
@ -541,12 +543,24 @@ WorkerThread::_PerformInstall(partition_id sourcePartitionID,
|
||||
|
||||
// copy selected packages
|
||||
if (fPackages) {
|
||||
BPath pkgRootDir(srcDirectory.Path(), kPackagesDirectoryPath);
|
||||
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++) {
|
||||
Package *p = static_cast<Package*>(fPackages->ItemAt(i));
|
||||
BPath packageDir(pkgRootDir.Path(), p->Folder());
|
||||
err = engine.Copy(packageDir.Path(), targetDirectory.Path(),
|
||||
const BPath& pkgPath = p->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);
|
||||
if (err != B_OK)
|
||||
return _InstallationError(err);
|
||||
|
Loading…
Reference in New Issue
Block a user