More specific exit codes for plasmapkg2

This commit is contained in:
Sebastian Kügler 2014-03-25 22:22:59 +01:00
parent 9aabcbe067
commit 71976aec92
2 changed files with 26 additions and 8 deletions

View File

@ -18,6 +18,24 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
/**
* plasmapkg2 exit codes used in this program
0 No error
1 Unspecified error
2 Plugin is not installed
3 Plugin or package invalid
4 Installation failed, see stderr for reason
5 Could not find a suitable installer for package type
6 No install option given
7 Conflicting arguments supplied
8 Uninstallation failed, see stderr for reason
9 Failed to generate package hash
*/
#include <klocalizedstring.h> #include <klocalizedstring.h>
#include <qcommandlineparser.h> #include <qcommandlineparser.h>
#include <qcommandlineoption.h> #include <qcommandlineoption.h>

View File

@ -92,7 +92,7 @@ void PlasmaPkg::runMain()
const QString hash = package.contentsHash(); const QString hash = package.contentsHash();
if (hash.isEmpty()) { if (hash.isEmpty()) {
d->coutput(i18n("Failed to generate a Package hash for %1", path)); d->coutput(i18n("Failed to generate a Package hash for %1", path));
exit(1); exit(9);
} else { } else {
d->coutput(i18n("SHA1 hash for Package at %1: '%2'", package.path(), hash)); d->coutput(i18n("SHA1 hash for Package at %1: '%2'", package.path(), hash));
exit(0); exit(0);
@ -255,7 +255,7 @@ void PlasmaPkg::runMain()
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint); KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure", constraint);
if (offers.isEmpty()) { if (offers.isEmpty()) {
d->coutput(i18n("Could not find a suitable installer for package of type %1", type)); d->coutput(i18n("Could not find a suitable installer for package of type %1", type));
exit(1); exit(5);
return; return;
} }
qWarning() << "custom PackageStructure plugins not ported"; qWarning() << "custom PackageStructure plugins not ported";
@ -355,7 +355,7 @@ void PlasmaPkg::runMain()
return; return;
} else { } else {
d->coutput(i18n("Error: Plugin %1 is not installed.", pluginName)); d->coutput(i18n("Error: Plugin %1 is not installed.", pluginName));
exit(1); exit(2);
} }
} }
if (d->parser->isSet("install")) { if (d->parser->isSet("install")) {
@ -365,7 +365,7 @@ void PlasmaPkg::runMain()
} }
if (d->package.isEmpty()) { if (d->package.isEmpty()) {
qWarning() << i18nc("No option was given, this is the error message telling the user he needs at least one, do not translate install, remove, upgrade nor list", "One of install, remove, upgrade or list is required."); qWarning() << i18nc("No option was given, this is the error message telling the user he needs at least one, do not translate install, remove, upgrade nor list", "One of install, remove, upgrade or list is required.");
exit(1); exit(6);
} else { } else {
d->runKbuildsycoca(); d->runKbuildsycoca();
} }
@ -469,7 +469,7 @@ void PlasmaPkg::showPackageInfo(const QString& pluginName)
KPluginInfo i = pkg.metadata(); KPluginInfo i = pkg.metadata();
if (!i.isValid()) { if (!i.isValid()) {
d->coutput(i18n("Error: Can't find plugin metadata: %1", pluginName)); d->coutput(i18n("Error: Can't find plugin metadata: %1", pluginName));
exit(1); exit(3);
} }
d->coutput(i18n("Showing info for package: %1", pluginName)); d->coutput(i18n("Showing info for package: %1", pluginName));
d->coutput(i18n(" Name : %1", i.name())); d->coutput(i18n(" Name : %1", i.name()));
@ -486,7 +486,7 @@ QString PlasmaPkg::findPackageRoot(const QString& pluginName, const QString& pre
QString packageRoot; QString packageRoot;
if (d->parser->isSet("packageroot") && d->parser->isSet("global")) { if (d->parser->isSet("packageroot") && d->parser->isSet("global")) {
qWarning() << i18nc("The user entered conflicting options packageroot and global, this is the error message telling the user he can use only one", "The packageroot and global options conflict each other, please select only one."); qWarning() << i18nc("The user entered conflicting options packageroot and global, this is the error message telling the user he can use only one", "The packageroot and global options conflict each other, please select only one.");
::exit(1); ::exit(7);
} else if (d->parser->isSet("packageroot")) { } else if (d->parser->isSet("packageroot")) {
packageRoot = d->parser->value("packageroot"); packageRoot = d->parser->value("packageroot");
//qDebug() << "(set via arg) d->packageRoot is: " << d->packageRoot; //qDebug() << "(set via arg) d->packageRoot is: " << d->packageRoot;
@ -635,7 +635,7 @@ void PlasmaPkg::packageInstalled(KJob *job)
} }
} else { } else {
d->coutput(i18n("Error: Installation of %1 failed: %2", d->packageFile, job->errorText())); d->coutput(i18n("Error: Installation of %1 failed: %2", d->packageFile, job->errorText()));
exitcode = 1; exitcode = 4;
} }
exit(exitcode); exit(exitcode);
} }
@ -654,7 +654,7 @@ void PlasmaPkg::packageUninstalled(KJob *job)
d->coutput(i18n("Successfully uninstalled %1", d->packageFile)); d->coutput(i18n("Successfully uninstalled %1", d->packageFile));
} else { } else {
d->coutput(i18n("Error: Uninstallation of %1 failed: %2", d->packageFile, job->errorText())); d->coutput(i18n("Error: Uninstallation of %1 failed: %2", d->packageFile, job->errorText()));
exitcode = 1; exitcode = 7;
} }
exit(exitcode); exit(exitcode);
} }