Skip to content

Commit

Permalink
PackageInstaller: Added -v/--verbose option
Browse files Browse the repository at this point in the history
It enables just a few printf()s in PackageItem.cpp.
I went with a quick solution using a global variable
instead of using/writing some nice logging framework which
could even generate install logs... but it helps in tracking
down some package problems without first having to uncomment
some printf()s...
  • Loading branch information
stippi committed May 28, 2014
1 parent ecf119c commit c3a07a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/apps/packageinstaller/PackageItem.cpp
Expand Up @@ -36,6 +36,8 @@ enum {
static const uint32 kDefaultMode = 0777;
static const uint8 padding[7] = { 0, 0, 0, 0, 0, 0, 0 };

extern bool gVerbose;

enum {
P_DATA = 0,
P_ATTRIBUTE
Expand Down Expand Up @@ -175,17 +177,20 @@ PackageItem::InitPath(const char* path, BPath* destination)
status_t ret = B_OK;

if (fPathType == P_INSTALL_PATH) {
// printf("InitPath - relative: %s + %s\n", path, fPath.String());
if (gVerbose)
printf("InitPath - relative: %s + %s\n", path, fPath.String());
if (path == NULL) {
parser_debug("InitPath path is NULL\n");
return B_ERROR;
}
ret = destination->SetTo(path, fPath.String());
} else if (fPathType == P_SYSTEM_PATH) {
// printf("InitPath - absolute: %s\n", fPath.String());
if (gVerbose)
printf("InitPath - absolute: %s\n", fPath.String());
ret = destination->SetTo(fPath.String());
} else {
// printf("InitPath - volume: %s + %s\n", path, fPath.String());
if (gVerbose)
printf("InitPath - volume: %s + %s\n", path, fPath.String());
if (path == NULL) {
parser_debug("InitPath path is NULL\n");
return B_ERROR;
Expand Down Expand Up @@ -237,7 +242,8 @@ PackageItem::InitPath(const char* path, BPath* destination)
}

if (wasRewritten) {
// printf("rewritten: %s\n", pathString.String());
if (gVerbose)
printf("rewritten: %s\n", pathString.String());
destination->SetTo(pathString.String());
}
}
Expand Down Expand Up @@ -620,7 +626,8 @@ PackageScript::DoInstall(const char* path, ItemState* state)
// that's more fragile... but a common source for
// the rewriting of BeOS paths is needed.

// printf("%s\n", script.String());
if (gVerbose)
printf("%s\n", script.String());

BPath workingDirectory;
if (path != NULL)
Expand Down
8 changes: 8 additions & 0 deletions src/apps/packageinstaller/main.cpp
Expand Up @@ -27,6 +27,9 @@
#define B_TRANSLATION_CONTEXT "Packageinstaller main"


bool gVerbose = false;


class PackageInstaller : public BApplication {
public:
PackageInstaller();
Expand Down Expand Up @@ -84,6 +87,11 @@ void
PackageInstaller::ArgvReceived(int32 argc, char** argv)
{
for (int i = 1; i < argc; i++) {
if (strcmp("--verbose", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
gVerbose = true;
continue;
}

BPath path;
if (path.SetTo(argv[i]) != B_OK) {
fprintf(stderr, B_TRANSLATE("Error! \"%s\" is not a valid path.\n"),
Expand Down

0 comments on commit c3a07a5

Please sign in to comment.