diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2010-08-20 10:41:18 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2010-08-20 10:57:48 +0300 |
commit | 8e9f4a9eeb024deac9106f49309c6dbb58561c6d (patch) | |
tree | 19e719163c762f93378221aacdedeec6a23721b9 /rpmbuild.c | |
parent | af1fbfaca817c8b81dc81f1786cbaeae4c506493 (diff) | |
download | rpm-8e9f4a9eeb024deac9106f49309c6dbb58561c6d.tar.gz rpm-8e9f4a9eeb024deac9106f49309c6dbb58561c6d.tar.bz2 rpm-8e9f4a9eeb024deac9106f49309c6dbb58561c6d.zip |
Test argument count early, avoiding the need to re-check over and over
- Instead of bothering with different error messages for tar/spec/pkg
messages, just dump usage when no arguments present.
- Testing argument file existence for signing is meaningless on build
as we're not signing the specs or tarballs present there but the
build result.
Diffstat (limited to 'rpmbuild.c')
-rw-r--r-- | rpmbuild.c | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/rpmbuild.c b/rpmbuild.c index 8c3af1b6b..e665e7bb4 100644 --- a/rpmbuild.c +++ b/rpmbuild.c @@ -26,8 +26,6 @@ enum modes { MODE_REBUILD = (1 << 5), MODE_RECOMPILE = (1 << 8), MODE_TARBUILD = (1 << 11), - - MODE_UNKNOWN = 0 }; static int quiet; @@ -151,6 +149,11 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + if (argc <= 1 || poptPeekArg(optCon) == NULL) { + printUsage(optCon, stderr, 0); + exit(EXIT_FAILURE); + } + rpmcliConfigured(); switch (ba->buildMode) { @@ -171,27 +174,6 @@ int main(int argc, char *argv[]) if (bigMode == MODE_REBUILD || bigMode == MODE_BUILD || bigMode == MODE_TARBUILD) { - const char ** av; - struct stat sb; - int errors = 0; - - if ((av = poptGetArgs(optCon)) == NULL) { - fprintf(stderr, _("no files to sign\n")); - errors++; - } else - while (*av) { - if (stat(*av, &sb)) { - fprintf(stderr, _("cannot access file %s\n"), *av); - errors++; - } - av++; - } - - if (errors) { - ec = errors; - goto exit; - } - if (poptPeekArg(optCon)) { int sigTag = rpmLookupSignatureType(RPMLOOKUPSIG_QUERY); switch (sigTag) { @@ -256,9 +238,6 @@ int main(int argc, char *argv[]) while (!rpmIsVerbose()) rpmIncreaseVerbosity(); - if (!poptPeekArg(optCon)) - argerror(_("no packages files given for rebuild")); - ba->buildAmount = RPMBUILD_PREP | RPMBUILD_BUILD | RPMBUILD_INSTALL | RPMBUILD_CHECK; if (bigMode == MODE_REBUILD) { @@ -323,13 +302,6 @@ int main(int argc, char *argv[]) break; } - if (!poptPeekArg(optCon)) { - if (bigMode == MODE_BUILD) - argerror(_("no spec files given for build")); - else - argerror(_("no tar files given for build")); - } - while ((pkg = poptGetArg(optCon))) { ba->rootdir = rpmcliRootDir; ba->passPhrase = passPhrase; @@ -341,13 +313,6 @@ int main(int argc, char *argv[]) (void) rpmReadConfigFiles(rpmcliRcfile, NULL); } } break; - - case MODE_UNKNOWN: - if (poptPeekArg(optCon) != NULL || argc <= 1 || rpmIsVerbose()) { - printUsage(optCon, stderr, 0); - ec = argc; - } - break; } exit: |