HaikuDepot: Support installing local package files
* Give the PackageManager either the package name, or the path to a local .hpkg package to Install(). * Implement Warn() to at least print something to the command line. Change the TODO to show the warning to the user instead.
This commit is contained in:
parent
9002c94345
commit
24e3b35816
@ -109,17 +109,25 @@ public:
|
|||||||
| BPackageManager::B_REFRESH_REPOSITORIES);
|
| BPackageManager::B_REFRESH_REPOSITORIES);
|
||||||
PackageInfoRef ref(Package());
|
PackageInfoRef ref(Package());
|
||||||
ref->SetState(PENDING);
|
ref->SetState(PENDING);
|
||||||
|
|
||||||
fPackageManager->SetCurrentActionPackage(ref, true);
|
fPackageManager->SetCurrentActionPackage(ref, true);
|
||||||
fPackageManager->AddProgressListener(this);
|
fPackageManager->AddProgressListener(this);
|
||||||
const char* packageName = ref->Title().String();
|
|
||||||
|
BString packageName;
|
||||||
|
if (ref->IsLocalFile())
|
||||||
|
packageName = ref->LocalFilePath();
|
||||||
|
else
|
||||||
|
packageName = ref->Title();
|
||||||
|
|
||||||
|
const char* packageNameString = packageName.String();
|
||||||
try {
|
try {
|
||||||
fPackageManager->Install(&packageName, 1);
|
fPackageManager->Install(&packageNameString, 1);
|
||||||
} catch (BFatalErrorException ex) {
|
} catch (BFatalErrorException ex) {
|
||||||
_SetDownloadedPackagesState(NONE);
|
_SetDownloadedPackagesState(NONE);
|
||||||
BString errorString;
|
BString errorString;
|
||||||
errorString.SetToFormat(
|
errorString.SetToFormat(
|
||||||
"Fatal error occurred while installing package %s: "
|
"Fatal error occurred while installing package %s: "
|
||||||
"%s (%s)\n", packageName, ex.Message().String(),
|
"%s (%s)\n", packageNameString, ex.Message().String(),
|
||||||
ex.Details().String());
|
ex.Details().String());
|
||||||
BAlert* alert(new(std::nothrow) BAlert(B_TRANSLATE("Fatal error"),
|
BAlert* alert(new(std::nothrow) BAlert(B_TRANSLATE("Fatal error"),
|
||||||
errorString, B_TRANSLATE("Close")));
|
errorString, B_TRANSLATE("Close")));
|
||||||
@ -128,16 +136,17 @@ public:
|
|||||||
return ex.Error();
|
return ex.Error();
|
||||||
} catch (BAbortedByUserException ex) {
|
} catch (BAbortedByUserException ex) {
|
||||||
fprintf(stderr, "Installation of package "
|
fprintf(stderr, "Installation of package "
|
||||||
"%s aborted by user: %s\n", packageName, ex.Message().String());
|
"%s aborted by user: %s\n", packageNameString,
|
||||||
|
ex.Message().String());
|
||||||
_SetDownloadedPackagesState(NONE);
|
_SetDownloadedPackagesState(NONE);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} catch (BNothingToDoException ex) {
|
} catch (BNothingToDoException ex) {
|
||||||
fprintf(stderr, "Nothing to do while installing package "
|
fprintf(stderr, "Nothing to do while installing package "
|
||||||
"%s: %s\n", packageName, ex.Message().String());
|
"%s: %s\n", packageNameString, ex.Message().String());
|
||||||
return B_OK;
|
return B_OK;
|
||||||
} catch (BException ex) {
|
} catch (BException ex) {
|
||||||
fprintf(stderr, "Exception occurred while installing package "
|
fprintf(stderr, "Exception occurred while installing package "
|
||||||
"%s: %s\n", packageName, ex.Message().String());
|
"%s: %s\n", packageNameString, ex.Message().String());
|
||||||
_SetDownloadedPackagesState(NONE);
|
_SetDownloadedPackagesState(NONE);
|
||||||
return B_ERROR;;
|
return B_ERROR;;
|
||||||
}
|
}
|
||||||
@ -440,7 +449,17 @@ PackageManager::ConfirmChanges(bool fromMostSpecific)
|
|||||||
void
|
void
|
||||||
PackageManager::Warn(status_t error, const char* format, ...)
|
PackageManager::Warn(status_t error, const char* format, ...)
|
||||||
{
|
{
|
||||||
// TODO: implement
|
// TODO: Show alert to user
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
vfprintf(stderr, format, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if (error == B_OK)
|
||||||
|
printf("\n");
|
||||||
|
else
|
||||||
|
printf(": %s\n", strerror(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user