summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2010-08-20 12:08:10 +0300
committerPanu Matilainen <pmatilai@redhat.com>2010-08-20 13:49:18 +0300
commitb217529967f972225dc9b7d2e37860885fde1ee1 (patch)
tree8697d585eb08ca8a692c313540f47359d24a1e27
parent04b1816f008d465ea5d7fa686e092280c3f104c3 (diff)
downloadlibrpm-tizen-b217529967f972225dc9b7d2e37860885fde1ee1.tar.gz
librpm-tizen-b217529967f972225dc9b7d2e37860885fde1ee1.tar.bz2
librpm-tizen-b217529967f972225dc9b7d2e37860885fde1ee1.zip
Add a convenience library for stuff common cli-bits into
-rw-r--r--Makefile.am12
-rw-r--r--cliutils.c36
-rw-r--r--cliutils.h13
-rw-r--r--po/POTFILES.in1
-rw-r--r--rpmbuild.c31
-rw-r--r--rpmqv.c31
6 files changed, 62 insertions, 62 deletions
diff --git a/Makefile.am b/Makefile.am
index 21a5663c5..2b56df7c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
index 000000000..b1ffd2465
--- /dev/null
+++ b/cliutils.c
@@ -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
index 000000000..15979dc66
--- /dev/null
+++ b/cliutils.h
@@ -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 */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 958155073..8976807af 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@
# Package source files
+cliutils.c
rpm2cpio.c
rpmqv.c
rpmbuild.c
diff --git a/rpmbuild.c b/rpmbuild.c
index 60310ff1e..af3039358 100644
--- a/rpmbuild.c
+++ b/rpmbuild.c
@@ -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 9277ca5a2..dd6b86380 100644
--- 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;