Add a convenience library for stuff common cli-bits into
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 20 Aug 2010 09:08:10 +0000 (12:08 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 20 Aug 2010 10:49:18 +0000 (13:49 +0300)
Makefile.am
cliutils.c [new file with mode: 0644]
cliutils.h [new file with mode: 0644]
po/POTFILES.in
rpmbuild.c
rpmqv.c

index 21a5663..2b56df7 100644 (file)
@@ -84,14 +84,22 @@ rpmconfig_SCRIPTS = find-provides find-requires mkinstalldirs \
 DISTCLEANFILES = find-provides
 DISTCLEANFILES += find-requires
 
+noinst_LTLIBRARIES =           libcliutils.la
+libcliutils_la_SOURCES =       cliutils.h cliutils.c
+libcliutils_la_CPPFLAGS =      $(AM_CPPFLAGS)
+libcliutils_la_LIBADD =        lib/librpm.la rpmio/librpmio.la
+libcliutils_la_LIBADD +=       @WITH_POPT_LIB@
+
 rpm_SOURCES =          rpmqv.c debug.h system.h
 rpm_CPPFLAGS =         $(AM_CPPFLAGS) -DIAM_RPMDB -DIAM_RPMEIU -DIAM_RPMK -DIAM_RPMQV
-rpm_LDADD =            build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
+rpm_LDADD =            libcliutils.la
+rpm_LDADD +=           build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
 rpm_LDADD +=           @WITH_NSS_LIB@ @WITH_POPT_LIB@ @WITH_ZLIB_LIB@
 
 rpmbuild_SOURCES =     rpmbuild.c debug.h system.h
 rpmbuild_CPPFLAGS =    $(AM_CPPFLAGS)
-rpmbuild_LDADD =       build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
+rpmbuild_LDADD =       libcliutils.la
+rpmbuild_LDADD +=      build/librpmbuild.la lib/librpm.la rpmio/librpmio.la
 rpmbuild_LDADD +=      @WITH_NSS_LIB@ @WITH_POPT_LIB@ @WITH_ZLIB_LIB@
 
 rpm2cpio_SOURCES =     rpm2cpio.c debug.h system.h
diff --git a/cliutils.c b/cliutils.c
new file mode 100644 (file)
index 0000000..b1ffd24
--- /dev/null
@@ -0,0 +1,36 @@
+#include "system.h"
+#include <rpm/rpmlog.h>
+#include <rpm/rpmlib.h>
+#include "cliutils.h"
+#include "debug.h"
+
+RPM_GNUC_NORETURN
+void argerror(const char * desc)
+{
+    fprintf(stderr, _("%s: %s\n"), __progname, desc);
+    exit(EXIT_FAILURE);
+}
+
+static void printVersion(FILE * fp)
+{
+    fprintf(fp, _("RPM version %s\n"), rpmEVR);
+}
+
+static void printBanner(FILE * fp)
+{
+    fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
+    fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
+}
+
+void printUsage(poptContext con, FILE * fp, int flags)
+{
+    printVersion(fp);
+    printBanner(fp);
+    fprintf(fp, "\n");
+
+    if (rpmIsVerbose())
+       poptPrintHelp(con, fp, flags);
+    else
+       poptPrintUsage(con, fp, flags);
+}
+
diff --git a/cliutils.h b/cliutils.h
new file mode 100644 (file)
index 0000000..15979dc
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _CLIUTIL_H
+#define _CLIUTIL_H
+
+#include <stdio.h>
+#include <popt.h>
+#include <rpm/rpmutil.h>
+
+RPM_GNUC_NORETURN
+void argerror(const char * desc);
+
+void printUsage(poptContext con, FILE * fp, int flags);
+
+#endif /* _CLIUTIL_H */
index 9581550..8976807 100644 (file)
@@ -2,6 +2,7 @@
 
 # Package source files
 
+cliutils.c
 rpm2cpio.c
 rpmqv.c
 rpmbuild.c
index 60310ff..af30393 100644 (file)
@@ -20,6 +20,7 @@ const char *__progname;
 #include <rpm/rpmps.h>
 #include <rpm/rpmts.h>
 #include "lib/signature.h"
+#include "cliutils.h"
 
 #include "debug.h"
 
@@ -50,36 +51,6 @@ static struct poptOption optionsTable[] = {
    POPT_TABLEEND
 };
 
-RPM_GNUC_NORETURN
-static void argerror(const char * desc)
-{
-    fprintf(stderr, _("%s: %s\n"), __progname, desc);
-    exit(EXIT_FAILURE);
-}
-
-static void printVersion(FILE * fp)
-{
-    fprintf(fp, _("RPM version %s\n"), rpmEVR);
-}
-
-static void printBanner(FILE * fp)
-{
-    fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
-    fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
-}
-
-static void printUsage(poptContext con, FILE * fp, int flags)
-{
-    printVersion(fp);
-    printBanner(fp);
-    fprintf(fp, "\n");
-
-    if (rpmIsVerbose())
-       poptPrintHelp(con, fp, flags);
-    else
-       poptPrintUsage(con, fp, flags);
-}
-
 static int checkSpec(rpmts ts, Header h)
 {
     rpmps ps;
diff --git a/rpmqv.c b/rpmqv.c
index 9277ca5..dd6b863 100644 (file)
--- a/rpmqv.c
+++ b/rpmqv.c
@@ -20,6 +20,7 @@ const char *__progname;
 #if defined(IAM_RPMK)
 #include "lib/signature.h"
 #endif
+#include "cliutils.h"
 
 #include "debug.h"
 
@@ -97,36 +98,6 @@ static struct poptOption optionsTable[] = {
    POPT_TABLEEND
 };
 
-RPM_GNUC_NORETURN
-static void argerror(const char * desc)
-{
-    fprintf(stderr, _("%s: %s\n"), __progname, desc);
-    exit(EXIT_FAILURE);
-}
-
-static void printVersion(FILE * fp)
-{
-    fprintf(fp, _("RPM version %s\n"), rpmEVR);
-}
-
-static void printBanner(FILE * fp)
-{
-    fprintf(fp, _("Copyright (C) 1998-2002 - Red Hat, Inc.\n"));
-    fprintf(fp, _("This program may be freely redistributed under the terms of the GNU GPL\n"));
-}
-
-static void printUsage(poptContext con, FILE * fp, int flags)
-{
-    printVersion(fp);
-    printBanner(fp);
-    fprintf(fp, "\n");
-
-    if (rpmIsVerbose())
-       poptPrintHelp(con, fp, flags);
-    else
-       poptPrintUsage(con, fp, flags);
-}
-
 int main(int argc, char *argv[])
 {
     rpmts ts = NULL;