bootloader: Display the system package version with the latest state.
We can't easily fetch its timestamp, but we can at least display the version of the "haiku" package here.
This commit is contained in:
@@ -104,7 +104,7 @@ PackageVolumeState::Unset()
|
|||||||
const char*
|
const char*
|
||||||
PackageVolumeState::DisplayName() const
|
PackageVolumeState::DisplayName() const
|
||||||
{
|
{
|
||||||
return fDisplayName != NULL ? fDisplayName : "Latest state";
|
return fDisplayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -115,7 +115,34 @@ PackageVolumeState::SetSystemPackage(const char* package)
|
|||||||
free(fSystemPackage);
|
free(fSystemPackage);
|
||||||
|
|
||||||
fSystemPackage = strdup(package);
|
fSystemPackage = strdup(package);
|
||||||
return fSystemPackage != NULL ? B_OK : B_NO_MEMORY;
|
if (fSystemPackage == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
if (fName == NULL) {
|
||||||
|
free(fDisplayName);
|
||||||
|
fDisplayName = NULL;
|
||||||
|
|
||||||
|
const char* packageVersion = strchr(package, '-');
|
||||||
|
if (packageVersion == NULL) {
|
||||||
|
fDisplayName = strdup("Latest state");
|
||||||
|
} else {
|
||||||
|
ArrayDeleter<char> newDisplayName(new(std::nothrow) char[B_FILE_NAME_LENGTH]);
|
||||||
|
if (!newDisplayName.IsSet())
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
packageVersion++;
|
||||||
|
const char* packageVersionEnd = strchr(packageVersion, '-');
|
||||||
|
int length = -1;
|
||||||
|
if (packageVersionEnd != NULL)
|
||||||
|
length = packageVersionEnd - packageVersion;
|
||||||
|
|
||||||
|
snprintf(newDisplayName.Get(), B_FILE_NAME_LENGTH,
|
||||||
|
"Latest state (%.*s)", length, packageVersion);
|
||||||
|
fDisplayName = newDisplayName.Detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -231,7 +258,7 @@ PackageVolumeInfo::LoadOldStates()
|
|||||||
status_t error;
|
status_t error;
|
||||||
for (state = fStates.GetNext(state); state != NULL;) {
|
for (state = fStates.GetNext(state); state != NULL;) {
|
||||||
PackageVolumeState* nextState = fStates.GetNext(state);
|
PackageVolumeState* nextState = fStates.GetNext(state);
|
||||||
if (state->Name()) {
|
if (state->Name() != NULL) {
|
||||||
error = _InitState(packagesDirectory, fPackagesDir, state);
|
error = _InitState(packagesDirectory, fPackagesDir, state);
|
||||||
if (error != B_OK) {
|
if (error != B_OK) {
|
||||||
TRACE("PackageVolumeInfo::LoadOldStates(): failed to "
|
TRACE("PackageVolumeInfo::LoadOldStates(): failed to "
|
||||||
@@ -277,9 +304,8 @@ PackageVolumeInfo::_InitState(Directory* packagesDirectory, DIR* dir,
|
|||||||
if (!systemPackageName.IsSet())
|
if (!systemPackageName.IsSet())
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
ArrayDeleter<char> packagePath(new(std::nothrow) char[B_PATH_NAME_LENGTH]);
|
ArrayDeleter<char> packagePath(new(std::nothrow) char[B_PATH_NAME_LENGTH]);
|
||||||
if (!packagePath.IsSet()) {
|
if (!packagePath.IsSet())
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
|
||||||
|
|
||||||
status_t error = _ParseActivatedPackagesFile(packagesDirectory, state,
|
status_t error = _ParseActivatedPackagesFile(packagesDirectory, state,
|
||||||
systemPackageName.Get(), B_FILE_NAME_LENGTH);
|
systemPackageName.Get(), B_FILE_NAME_LENGTH);
|
||||||
|
|||||||
Reference in New Issue
Block a user