From c3a07a5aedcf284c361a5dd2fd3247e60b00b8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 28 May 2014 23:04:41 +0200 Subject: [PATCH] PackageInstaller: Added -v/--verbose option 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... --- src/apps/packageinstaller/PackageItem.cpp | 17 ++++++++++++----- src/apps/packageinstaller/main.cpp | 8 ++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/apps/packageinstaller/PackageItem.cpp b/src/apps/packageinstaller/PackageItem.cpp index eec65655c48..71dfe842632 100644 --- a/src/apps/packageinstaller/PackageItem.cpp +++ b/src/apps/packageinstaller/PackageItem.cpp @@ -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 @@ -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; @@ -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()); } } @@ -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) diff --git a/src/apps/packageinstaller/main.cpp b/src/apps/packageinstaller/main.cpp index 6fc9128ff9b..4bafeb8e522 100644 --- a/src/apps/packageinstaller/main.cpp +++ b/src/apps/packageinstaller/main.cpp @@ -27,6 +27,9 @@ #define B_TRANSLATION_CONTEXT "Packageinstaller main" +bool gVerbose = false; + + class PackageInstaller : public BApplication { public: PackageInstaller(); @@ -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"),