make it easy to generate hashes for plasma packages

This commit is contained in:
Aaron Seigo 2011-11-09 12:56:49 +01:00
parent c0de261ccc
commit 6a19c2da5b

View File

@ -39,7 +39,7 @@
#include <Plasma/PackageMetadata>
static const char description[] = I18N_NOOP("Install, list, remove Plasma packages");
static const char version[] = "0.1";
static const char version[] = "0.2";
void output(const QString &msg)
{
@ -180,6 +180,8 @@ int main(int argc, char **argv)
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add("h");
options.add("hash <path>", ki18nc("Do not translate <path>", "Generate a SHA1 hash for the package at <path>"));
options.add("g");
options.add("global", ki18n("For install or remove, operates on packages installed for all users."));
options.add("t");
@ -206,6 +208,26 @@ int main(int argc, char **argv)
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if (args->isSet("hash")) {
const QString path = args->getOption("hash");
Plasma::PackageStructure::Ptr structure(new Plasma::PackageStructure);
Plasma::Package package(path, structure);
const QString hash = package.contentsHash();
if (hash.isEmpty()) {
output(i18n("Failed to generate a Package hash for %1", path));
exit(1);
}
output(i18n("SHA1 hash for Package at %1: '%2'", path, hash));
exit(0);
}
if (args->isSet("list-types")) {
listTypes();
exit(0);
}
QString type = args->getOption("type");
QString packageRoot = type;
QString servicePrefix;
@ -214,11 +236,6 @@ int main(int argc, char **argv)
QString package;
QString packageFile;
if (args->isSet("list-types")) {
listTypes();
exit(0);
}
if (args->isSet("remove")) {
package = args->getOption("remove");
} else if (args->isSet("upgrade")) {