fix: avoid segfault using --prefix until ewt fixes.
add --define "%foo %bar" option. dump macros to same fd as --showrc uses. add %GNUconfigure for full-blown package regeneration. fix: RPM_ARCH/RPM_OS had wrong values. fix: create ppc directories correctly. CVS patchset: 2922 CVS date: 1999/03/28 00:47:40
This commit is contained in:
parent
6147ae7995
commit
9b94f186e6
6
CHANGES
6
CHANGES
|
@ -6,6 +6,12 @@
|
|||
- more DU 4.0D fiddles (Shing-Gene Yung).
|
||||
- fix: segfault from unknown uid/gid -- use builder's uid/gid instead.
|
||||
- autoReq/autoProv now per-package.
|
||||
- fix: avoid segfault using --prefix until ewt fixes.
|
||||
- add --define "%foo %bar" option.
|
||||
- dump macros to same fd as --showrc uses.
|
||||
- add %GNUconfigure for full-blown package regeneration.
|
||||
- fix: RPM_ARCH/RPM_OS had wrong values.
|
||||
- fix: create ppc directories correctly.
|
||||
|
||||
2.91 -> 2.92
|
||||
- update with libtool-2.4f.
|
||||
|
|
|
@ -63,6 +63,7 @@ install-data-local:
|
|||
*86) $(mkinstalldirs) $(DESTDIR)/$(prefix)/src/redhat/RPMS/i386 ;;\
|
||||
alpha*) $(mkinstalldirs) $(DESTDIR)/$(prefix)/src/redhat/RPMS/alpha ;;\
|
||||
sparc*) $(mkinstalldirs) $(DESTDIR)/$(prefix)/src/redhat/RPMS/sparc ;;\
|
||||
powerpc*) $(mkinstalldirs) $(DESTDIR)/$(prefix)/src/redhat/RPMS/ppc ;;\
|
||||
esac
|
||||
@$(mkinstalldirs) $(DESTDIR)/$(prefix)/src/redhat/RPMS/@build_cpu@
|
||||
@$(mkinstalldirs) $(DESTDIR)/$(prefix)/src/redhat/RPMS/noarch
|
||||
|
|
|
@ -624,6 +624,7 @@ case "${build_cpu}" in
|
|||
i386|i486|i586|i686|ix86) RPMCANONARCH=i386 ;;
|
||||
alpha*) RPMCANONARCH=alpha ;;
|
||||
sparc*) RPMCANONARCH=sparc ;;
|
||||
powerpc*) RPMCANONARCH=ppc ;;
|
||||
*) RPMCANONARCH=unknown ;;
|
||||
esac
|
||||
RPMCANONVENDOR="$build_vendor"
|
||||
|
|
146
lib/macro.c
146
lib/macro.c
|
@ -1,6 +1,7 @@
|
|||
#include "system.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define isblank(_c) ((_c) == ' ' || (_c) == '\t')
|
||||
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
|
||||
|
@ -10,6 +11,7 @@
|
|||
#define rpmError fprintf
|
||||
#define RPMERR_BADSPEC stderr
|
||||
#define _(x) x
|
||||
#define xfree(_p) free((void *)_p)
|
||||
#else
|
||||
#include "rpmlib.h"
|
||||
#endif
|
||||
|
@ -89,29 +91,32 @@ sortMacroTable(MacroContext *mc)
|
|||
}
|
||||
|
||||
void
|
||||
dumpMacroTable(MacroContext *mc)
|
||||
dumpMacroTable(MacroContext *mc, FILE *f)
|
||||
{
|
||||
int i;
|
||||
int nempty = 0;
|
||||
int nactive = 0;
|
||||
|
||||
fprintf(stderr, "========================\n");
|
||||
if (f == NULL)
|
||||
f = stderr;
|
||||
|
||||
fprintf(f, "========================\n");
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry *me;
|
||||
if ((me = mc->macroTable[i]) == NULL) {
|
||||
nempty++;
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr, "%3d%c %s", me->level,
|
||||
fprintf(f, "%3d%c %s", me->level,
|
||||
(me->used > 0 ? '=' : ':'), me->name);
|
||||
if (me->opts)
|
||||
fprintf(stderr, "(%s)", me->opts);
|
||||
if (me->body)
|
||||
fprintf(stderr, "\t%s", me->body);
|
||||
fprintf(stderr, "\n");
|
||||
if (me->opts && *me->opts)
|
||||
fprintf(f, "(%s)", me->opts);
|
||||
if (me->body && *me->body)
|
||||
fprintf(f, "\t%s", me->body);
|
||||
fprintf(f, "\n");
|
||||
nactive++;
|
||||
}
|
||||
fprintf(stderr, _("======================== active %d empty %d\n"),
|
||||
fprintf(f, _("======================== active %d empty %d\n"),
|
||||
nactive, nempty);
|
||||
}
|
||||
|
||||
|
@ -505,7 +510,7 @@ pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int lev
|
|||
me->prev = prev;
|
||||
me->name = (prev ? prev->name : strdup(n));
|
||||
me->opts = (o ? strdup(o) : NULL);
|
||||
me->body = (b ? strdup(b) : NULL);
|
||||
me->body = strdup(b ? b : "");
|
||||
me->used = 0;
|
||||
me->level = level;
|
||||
*mep = me;
|
||||
|
@ -939,7 +944,7 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
if (STREQ("dump", f, fn)) {
|
||||
dumpMacroTable(mb->mc);
|
||||
dumpMacroTable(mb->mc, NULL);
|
||||
if (*se == '\n')
|
||||
se++;
|
||||
s = se;
|
||||
|
@ -1029,10 +1034,12 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
/* Recursively expand body of macro */
|
||||
mb->s = me->body;
|
||||
rc = expandMacro(mb);
|
||||
if (rc == 0)
|
||||
me->used++; /* Mark macro as used */
|
||||
if (me->body && *me->body) {
|
||||
mb->s = me->body;
|
||||
rc = expandMacro(mb);
|
||||
if (rc == 0)
|
||||
me->used++; /* Mark macro as used */
|
||||
}
|
||||
|
||||
/* Free args for "%name " macros with opts */
|
||||
if (me->opts != NULL)
|
||||
|
@ -1050,6 +1057,7 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* XXX this is used only in build/expression.c and will go away. */
|
||||
const char *
|
||||
getMacroBody(MacroContext *mc, const char *name)
|
||||
{
|
||||
|
@ -1059,6 +1067,7 @@ getMacroBody(MacroContext *mc, const char *name)
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
int
|
||||
expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
||||
{
|
||||
|
@ -1123,6 +1132,17 @@ delMacro(MacroContext *mc, const char *name)
|
|||
popMacro(mep);
|
||||
}
|
||||
|
||||
int
|
||||
rpmDefineMacro(MacroContext *mc, const char *macro, int level)
|
||||
{
|
||||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
/* XXX just enough to get by */
|
||||
mb->mc = (mc ? mc : &globalMacroContext);
|
||||
(void)doDefine(mb, macro, level, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
initMacros(MacroContext *mc, const char *macrofile)
|
||||
{
|
||||
|
@ -1143,7 +1163,6 @@ initMacros(MacroContext *mc, const char *macrofile)
|
|||
for (mfile = m = strdup(macrofile); *mfile; mfile = me) {
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
if ((me = strchr(mfile, ':')) != NULL)
|
||||
*me++ = '\0';
|
||||
|
@ -1164,9 +1183,8 @@ initMacros(MacroContext *mc, const char *macrofile)
|
|||
|
||||
if (c != '%')
|
||||
continue;
|
||||
n++;
|
||||
mb->mc = mc; /* XXX just enough to get by */
|
||||
(void)doDefine(mb, n, RMIL_MACROFILES, 0);
|
||||
n++; /* skip % */
|
||||
(void)rpmDefineMacro(NULL, n, RMIL_MACROFILES);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
@ -1194,7 +1212,6 @@ freeMacros(MacroContext *mc)
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
int isCompressed(const char *file, int *compressed)
|
||||
{
|
||||
FD_t fd;
|
||||
|
@ -1237,6 +1254,93 @@ int isCompressed(const char *file, int *compressed)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* Return concatenated and expanded macro list */
|
||||
char *
|
||||
rpmExpand(const char *arg, ...)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *pe;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
if (arg == NULL)
|
||||
return strdup("");
|
||||
|
||||
p = buf;
|
||||
strcpy(p, arg);
|
||||
pe = p + strlen(p);
|
||||
*pe = '\0';
|
||||
|
||||
va_start(ap, arg);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
strcpy(pe, s);
|
||||
pe += strlen(pe);
|
||||
*pe = '\0';
|
||||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
int
|
||||
rpmExpandNumeric(const char *arg)
|
||||
{
|
||||
const char *val;
|
||||
int rc;
|
||||
|
||||
if (arg == NULL)
|
||||
return 0;
|
||||
|
||||
val = rpmExpand(arg, NULL);
|
||||
if (!(val && *val != '%'))
|
||||
rc = 0;
|
||||
else if (*val == 'Y' || *val == 'y')
|
||||
rc = 1;
|
||||
else if (*val == 'N' || *val == 'n')
|
||||
rc = 0;
|
||||
else {
|
||||
char *end;
|
||||
rc = strtol(val, &end, 0);
|
||||
if (!(end && *end == '\0'))
|
||||
rc = 0;
|
||||
}
|
||||
xfree(val);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Return concatenated and expanded path with multiple /'s removed */
|
||||
const char *
|
||||
rpmGetPath(const char *path, ...)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *pe;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
if (path == NULL)
|
||||
return strdup("");
|
||||
|
||||
p = buf;
|
||||
strcpy(p, path);
|
||||
pe = p + strlen(p);
|
||||
*pe = '\0';
|
||||
|
||||
va_start(ap, path);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
/* XXX FIXME: this fixes only some of the "...//..." problems */
|
||||
if (pe > p && pe[-1] == '/')
|
||||
while(*s && *s == '/') s++;
|
||||
if (*s != '\0') {
|
||||
strcpy(pe, s);
|
||||
pe += strlen(pe);
|
||||
*pe = '\0';
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
#ifdef DEBUG_MACROS
|
||||
|
@ -1253,7 +1357,7 @@ main(int argc, char *argv[])
|
|||
int x;
|
||||
|
||||
initMacros(&mc, macrofile);
|
||||
dumpMacroTable(&mc);
|
||||
dumpMacroTable(&mc, NULL);
|
||||
|
||||
if ((fp = fopen(testfile, "r")) != NULL) {
|
||||
while(fgets(buf, sizeof(buf), fp)) {
|
||||
|
|
|
@ -243,9 +243,6 @@ extern const struct headerSprintfExtension rpmHeaderFormats[];
|
|||
#define RPMVAR_NUM 55 /* number of RPMVAR entries */
|
||||
|
||||
#define xfree(_p) free((void *)_p)
|
||||
char *rpmExpand(const char *arg, ...);
|
||||
const char *rpmGetPath(const char *path, ...);
|
||||
int rpmExpandNumeric(const char *arg);
|
||||
|
||||
char * rpmGetVar(int var);
|
||||
int rpmGetBooleanVar(int var);
|
||||
|
|
|
@ -43,22 +43,27 @@ extern MacroContext globalMacroContext;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define COMPRESSED_NOT 0
|
||||
#define COMPRESSED_OTHER 1
|
||||
#define COMPRESSED_BZIP2 2
|
||||
void dumpMacroTable __P((MacroContext *mc, FILE *f));
|
||||
|
||||
int isCompressed(const char *file, int *compressed);
|
||||
/* XXX this is used only in build/expression.c and will go away. */
|
||||
const char *getMacroBody __P((MacroContext *mc, const char *name));
|
||||
|
||||
void dumpMacroTable __P((MacroContext *mc));
|
||||
int expandMacros __P((void *spec, MacroContext *mc, char *sbuf, size_t sbuflen));
|
||||
void addMacro __P((MacroContext *mc, const char *n, const char *o, const char *b, int depth));
|
||||
void delMacro __P((MacroContext *mc, const char *n));
|
||||
|
||||
int rpmDefineMacro __P((MacroContext *mc, const char *macro, int level));
|
||||
void initMacros __P((MacroContext *mc, const char *macrofile));
|
||||
void freeMacros __P((MacroContext *mc));
|
||||
|
||||
void addMacro __P((MacroContext *mc, const char *n, const char *o, const char *b, int depth));
|
||||
void delMacro __P((MacroContext *mc, const char *n));
|
||||
int expandMacros __P((void *spec, MacroContext *mc, char *sbuf, size_t sbuflen));
|
||||
#define COMPRESSED_NOT 0
|
||||
#define COMPRESSED_OTHER 1
|
||||
#define COMPRESSED_BZIP2 2
|
||||
int isCompressed __P((const char *file, int *compressed));
|
||||
|
||||
const char *getMacroBody __P((MacroContext *mc, const char *name));
|
||||
char * rpmExpand __P((const char *arg, ...));
|
||||
const char *rpmGetPath __P((const char *path, ...));
|
||||
int rpmExpandNumeric __P((const char *arg));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
85
lib/rpmrc.c
85
lib/rpmrc.c
|
@ -534,89 +534,6 @@ static void setDefaults(void) {
|
|||
|
||||
}
|
||||
|
||||
/* Return concatenated and expanded macro list */
|
||||
char * rpmExpand(const char *arg, ...)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *pe;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
if (arg == NULL)
|
||||
return strdup("");
|
||||
|
||||
p = buf;
|
||||
strcpy(p, arg);
|
||||
pe = p + strlen(p);
|
||||
*pe = '\0';
|
||||
|
||||
va_start(ap, arg);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
strcpy(pe, s);
|
||||
pe += strlen(pe);
|
||||
*pe = '\0';
|
||||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
int rpmExpandNumeric(const char *arg)
|
||||
{
|
||||
const char *val;
|
||||
int rc;
|
||||
|
||||
if (arg == NULL)
|
||||
return 0;
|
||||
|
||||
val = rpmExpand(arg, NULL);
|
||||
if (!(val && *val != '%'))
|
||||
rc = 0;
|
||||
else if (*val == 'Y' || *val == 'y')
|
||||
rc = 1;
|
||||
else if (*val == 'N' || *val == 'n')
|
||||
rc = 0;
|
||||
else {
|
||||
char *end;
|
||||
rc = strtol(val, &end, 0);
|
||||
if (!(end && *end == '\0'))
|
||||
rc = 0;
|
||||
}
|
||||
xfree(val);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Return concatenated and expanded path with multiple /'s removed */
|
||||
const char * rpmGetPath(const char *path, ...)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *pe;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
if (path == NULL)
|
||||
return strdup("");
|
||||
|
||||
p = buf;
|
||||
strcpy(p, path);
|
||||
pe = p + strlen(p);
|
||||
*pe = '\0';
|
||||
|
||||
va_start(ap, path);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
/* XXX FIXME: this fixes only some of the "...//..." problems */
|
||||
if (pe > p && pe[-1] == '/')
|
||||
while(*s && *s == '/') s++;
|
||||
if (*s != '\0') {
|
||||
strcpy(pe, s);
|
||||
pe += strlen(pe);
|
||||
*pe = '\0';
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
int rpmReadRC(const char * rcfiles)
|
||||
{
|
||||
char *myrcfiles, *r, *re;
|
||||
|
@ -1323,7 +1240,7 @@ int rpmShowRC(FILE *f)
|
|||
fprintf(f, "%-21s : %s\n", opt->name, s ? s : "(not set)");
|
||||
}
|
||||
|
||||
dumpMacroTable(&globalMacroContext);
|
||||
dumpMacroTable(&globalMacroContext, f);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
58
macros.in
58
macros.in
|
@ -1,4 +1,4 @@
|
|||
# $Id: macros.in,v 1.18 1999/03/27 21:40:56 jbj Exp $
|
||||
# $Id: macros.in,v 1.19 1999/03/28 00:47:43 jbj Exp $
|
||||
#==============================================================================
|
||||
# Macro naming conventions (preliminary):
|
||||
#
|
||||
|
@ -18,22 +18,30 @@
|
|||
|
||||
#==============================================================================
|
||||
# ---- path macros
|
||||
# XXX The use of which here is overly simple.
|
||||
#
|
||||
%__bzip2 %(which bzip2)
|
||||
%__cat %(which cat)
|
||||
%__chgrp %(which chgrp)
|
||||
%__chmod %(which chmod)
|
||||
%__chown %(which chown)
|
||||
%__gzip %(which gzip)
|
||||
%__install %(which install)
|
||||
%__libtoolize %(which libtoolize)
|
||||
%__make %(which make)
|
||||
%__mkdir %(which mkdir)
|
||||
%__patch %(which patch)
|
||||
%__ranlib %(which ranlib)
|
||||
%__rm %(which rm)
|
||||
%__strip %(which strip)
|
||||
%__tar %(which tar)
|
||||
%__bzip2 %(which bzip2)
|
||||
%__cat %(which cat)
|
||||
%__chgrp %(which chgrp)
|
||||
%__chmod %(which chmod)
|
||||
%__chown %(which chown)
|
||||
%__cpio %(which cpio)
|
||||
%__gzip %(which gzip)
|
||||
%__install %(which install)
|
||||
%__make %(which make)
|
||||
%__mkdir %(which mkdir)
|
||||
%__patch %(which patch)
|
||||
%__ranlib %(which ranlib)
|
||||
%__rm %(which rm)
|
||||
%__strip %(which strip)
|
||||
%__tar %(which tar)
|
||||
|
||||
# XXX avoid weird failures from which if tools are not installed
|
||||
%__libtoolize libtoolize
|
||||
%__aclocal aclocal
|
||||
%__autoheader autoheader
|
||||
%__automake automake
|
||||
%__autoconf autoconf
|
||||
|
||||
#==============================================================================
|
||||
# ---- Required rpmrc macros.
|
||||
|
@ -111,8 +119,8 @@
|
|||
RPM_SOURCE_DIR=\"%{_sourcedir}\"\
|
||||
RPM_BUILD_DIR=\"%{_builddir}\"\
|
||||
RPM_OPT_FLAGS=\"%{optflags}\"\
|
||||
RPM_ARCH=\"%{_target_cpu}\"\
|
||||
RPM_OS=\"%{_target_os}\"\
|
||||
RPM_ARCH=\"%{_arch}\"\
|
||||
RPM_OS=\"%{_os}\"\
|
||||
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS\
|
||||
RPM_DOC_DIR=\"%{_docdir}\"\
|
||||
export RPM_DOC_DIR\
|
||||
|
@ -163,3 +171,17 @@
|
|||
%configure \
|
||||
%{?__libtoolize:[ -f configure.in ] && %{__libtoolize} --copy --force} \
|
||||
CFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{_prefix}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# The GNUconfigure macro does the following:
|
||||
# update config.guess and config.sub.
|
||||
# regenerate all autoconf/automake files
|
||||
# run configure with correct prefix, platform, and CFLAGS.
|
||||
#
|
||||
%GNUconfigure \
|
||||
%{__libtoolize} --copy --force} \
|
||||
%{__aclocal} \
|
||||
%{__autoheader} \
|
||||
%{__automake} \
|
||||
%{__autoconf} \
|
||||
CFLAGS="%{optflags}" ./configure %{_target_platform} --prefix=%{_prefix}
|
||||
|
|
651
po/rpm.pot
651
po/rpm.pot
File diff suppressed because it is too large
Load Diff
17
rpm.c
17
rpm.c
|
@ -20,6 +20,8 @@
|
|||
#define GETOPT_RELOCATE 1016
|
||||
#define GETOPT_SHOWRC 1018
|
||||
#define GETOPT_EXCLUDEPATH 1019
|
||||
#define GETOPT_DEFINEMACRO 1020
|
||||
#define GETOPT_PREFIX 1021 /* XXX hack to avoid prefix dump */
|
||||
|
||||
char * version = VERSION;
|
||||
|
||||
|
@ -85,6 +87,7 @@ static struct poptOption optionsTable[] = {
|
|||
{ "build", 'b', POPT_ARG_STRING, 0, 'b', NULL, NULL},
|
||||
{ "checksig", 'K', 0, 0, 'K', NULL, NULL},
|
||||
{ "dbpath", '\0', POPT_ARG_STRING, 0, GETOPT_DBPATH, NULL, NULL},
|
||||
{ "define", '\0', POPT_ARG_STRING, 0, GETOPT_DEFINEMACRO, NULL, NULL},
|
||||
{ "erase", 'e', 0, 0, 'e', NULL, NULL},
|
||||
{ "excludedocs", '\0', 0, &excldocs, 0, NULL, NULL},
|
||||
{ "excludepath", '\0', POPT_ARG_STRING, 0, GETOPT_EXCLUDEPATH, NULL, NULL},
|
||||
|
@ -115,7 +118,7 @@ static struct poptOption optionsTable[] = {
|
|||
{ "oldpackage", '\0', 0, &oldPackage, 0, NULL, NULL},
|
||||
{ "percent", '\0', 0, &showPercents, 0, NULL, NULL},
|
||||
{ "pipe", '\0', POPT_ARG_STRING, &pipeOutput, 0, NULL, NULL},
|
||||
{ "prefix", '\0', POPT_ARG_STRING, &prefix, 0, NULL, NULL},
|
||||
{ "prefix", '\0', POPT_ARG_STRING, &prefix, GETOPT_PREFIX, NULL, NULL},
|
||||
{ "query", 'q', 0, NULL, 'q', NULL, NULL},
|
||||
{ "querytags", '\0', 0, &queryTags, 0, NULL, NULL},
|
||||
{ "quiet", '\0', 0, &quiet, 0, NULL, NULL},
|
||||
|
@ -819,10 +822,18 @@ int main(int argc, char ** argv) {
|
|||
case GETOPT_DBPATH:
|
||||
if (optArg[0] != '/')
|
||||
argerror(_("arguments to --dbpath must begin with a /"));
|
||||
addMacro(&globalMacroContext, "_dbpath", NULL, optArg, RMIL_CMDLINE);
|
||||
addMacro(&globalMacroContext,"_dbpath", NULL, optArg, RMIL_CMDLINE);
|
||||
gotDbpath = 1;
|
||||
break;
|
||||
|
||||
case GETOPT_DEFINEMACRO:
|
||||
rpmDefineMacro(&globalMacroContext, optArg, RMIL_CMDLINE);
|
||||
break;
|
||||
|
||||
case GETOPT_PREFIX: /* XXX FIXME */
|
||||
argerror(_("--prefix is broke, use --relocate /oldpath=/newpath instead"));
|
||||
break;
|
||||
|
||||
case GETOPT_TIMECHECK:
|
||||
tce = NULL;
|
||||
timeCheck = strtoul(optArg, &tce, 10);
|
||||
|
@ -988,7 +999,7 @@ int main(int argc, char ** argv) {
|
|||
"installation"));
|
||||
|
||||
if (bigMode != MODE_INSTALL && ignoreSize)
|
||||
argerror(_("--ignoreos may only be specified during package "
|
||||
argerror(_("--ignoresize may only be specified during package "
|
||||
"installation"));
|
||||
|
||||
if (allMatches && bigMode != MODE_UNINSTALL)
|
||||
|
|
146
rpmio/macro.c
146
rpmio/macro.c
|
@ -1,6 +1,7 @@
|
|||
#include "system.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#define isblank(_c) ((_c) == ' ' || (_c) == '\t')
|
||||
#define STREQ(_t, _f, _fn) ((_fn) == (sizeof(_t)-1) && !strncmp((_t), (_f), (_fn)))
|
||||
|
@ -10,6 +11,7 @@
|
|||
#define rpmError fprintf
|
||||
#define RPMERR_BADSPEC stderr
|
||||
#define _(x) x
|
||||
#define xfree(_p) free((void *)_p)
|
||||
#else
|
||||
#include "rpmlib.h"
|
||||
#endif
|
||||
|
@ -89,29 +91,32 @@ sortMacroTable(MacroContext *mc)
|
|||
}
|
||||
|
||||
void
|
||||
dumpMacroTable(MacroContext *mc)
|
||||
dumpMacroTable(MacroContext *mc, FILE *f)
|
||||
{
|
||||
int i;
|
||||
int nempty = 0;
|
||||
int nactive = 0;
|
||||
|
||||
fprintf(stderr, "========================\n");
|
||||
if (f == NULL)
|
||||
f = stderr;
|
||||
|
||||
fprintf(f, "========================\n");
|
||||
for (i = 0; i < mc->firstFree; i++) {
|
||||
MacroEntry *me;
|
||||
if ((me = mc->macroTable[i]) == NULL) {
|
||||
nempty++;
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr, "%3d%c %s", me->level,
|
||||
fprintf(f, "%3d%c %s", me->level,
|
||||
(me->used > 0 ? '=' : ':'), me->name);
|
||||
if (me->opts)
|
||||
fprintf(stderr, "(%s)", me->opts);
|
||||
if (me->body)
|
||||
fprintf(stderr, "\t%s", me->body);
|
||||
fprintf(stderr, "\n");
|
||||
if (me->opts && *me->opts)
|
||||
fprintf(f, "(%s)", me->opts);
|
||||
if (me->body && *me->body)
|
||||
fprintf(f, "\t%s", me->body);
|
||||
fprintf(f, "\n");
|
||||
nactive++;
|
||||
}
|
||||
fprintf(stderr, _("======================== active %d empty %d\n"),
|
||||
fprintf(f, _("======================== active %d empty %d\n"),
|
||||
nactive, nempty);
|
||||
}
|
||||
|
||||
|
@ -505,7 +510,7 @@ pushMacro(MacroEntry **mep, const char *n, const char *o, const char *b, int lev
|
|||
me->prev = prev;
|
||||
me->name = (prev ? prev->name : strdup(n));
|
||||
me->opts = (o ? strdup(o) : NULL);
|
||||
me->body = (b ? strdup(b) : NULL);
|
||||
me->body = strdup(b ? b : "");
|
||||
me->used = 0;
|
||||
me->level = level;
|
||||
*mep = me;
|
||||
|
@ -939,7 +944,7 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
if (STREQ("dump", f, fn)) {
|
||||
dumpMacroTable(mb->mc);
|
||||
dumpMacroTable(mb->mc, NULL);
|
||||
if (*se == '\n')
|
||||
se++;
|
||||
s = se;
|
||||
|
@ -1029,10 +1034,12 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
/* Recursively expand body of macro */
|
||||
mb->s = me->body;
|
||||
rc = expandMacro(mb);
|
||||
if (rc == 0)
|
||||
me->used++; /* Mark macro as used */
|
||||
if (me->body && *me->body) {
|
||||
mb->s = me->body;
|
||||
rc = expandMacro(mb);
|
||||
if (rc == 0)
|
||||
me->used++; /* Mark macro as used */
|
||||
}
|
||||
|
||||
/* Free args for "%name " macros with opts */
|
||||
if (me->opts != NULL)
|
||||
|
@ -1050,6 +1057,7 @@ expandMacro(MacroBuf *mb)
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* XXX this is used only in build/expression.c and will go away. */
|
||||
const char *
|
||||
getMacroBody(MacroContext *mc, const char *name)
|
||||
{
|
||||
|
@ -1059,6 +1067,7 @@ getMacroBody(MacroContext *mc, const char *name)
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
int
|
||||
expandMacros(void *spec, MacroContext *mc, char *s, size_t slen)
|
||||
{
|
||||
|
@ -1123,6 +1132,17 @@ delMacro(MacroContext *mc, const char *name)
|
|||
popMacro(mep);
|
||||
}
|
||||
|
||||
int
|
||||
rpmDefineMacro(MacroContext *mc, const char *macro, int level)
|
||||
{
|
||||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
/* XXX just enough to get by */
|
||||
mb->mc = (mc ? mc : &globalMacroContext);
|
||||
(void)doDefine(mb, macro, level, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
initMacros(MacroContext *mc, const char *macrofile)
|
||||
{
|
||||
|
@ -1143,7 +1163,6 @@ initMacros(MacroContext *mc, const char *macrofile)
|
|||
for (mfile = m = strdup(macrofile); *mfile; mfile = me) {
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
MacroBuf macrobuf, *mb = ¯obuf;
|
||||
|
||||
if ((me = strchr(mfile, ':')) != NULL)
|
||||
*me++ = '\0';
|
||||
|
@ -1164,9 +1183,8 @@ initMacros(MacroContext *mc, const char *macrofile)
|
|||
|
||||
if (c != '%')
|
||||
continue;
|
||||
n++;
|
||||
mb->mc = mc; /* XXX just enough to get by */
|
||||
(void)doDefine(mb, n, RMIL_MACROFILES, 0);
|
||||
n++; /* skip % */
|
||||
(void)rpmDefineMacro(NULL, n, RMIL_MACROFILES);
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
|
@ -1194,7 +1212,6 @@ freeMacros(MacroContext *mc)
|
|||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
int isCompressed(const char *file, int *compressed)
|
||||
{
|
||||
FD_t fd;
|
||||
|
@ -1237,6 +1254,93 @@ int isCompressed(const char *file, int *compressed)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
/* Return concatenated and expanded macro list */
|
||||
char *
|
||||
rpmExpand(const char *arg, ...)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *pe;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
if (arg == NULL)
|
||||
return strdup("");
|
||||
|
||||
p = buf;
|
||||
strcpy(p, arg);
|
||||
pe = p + strlen(p);
|
||||
*pe = '\0';
|
||||
|
||||
va_start(ap, arg);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
strcpy(pe, s);
|
||||
pe += strlen(pe);
|
||||
*pe = '\0';
|
||||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
int
|
||||
rpmExpandNumeric(const char *arg)
|
||||
{
|
||||
const char *val;
|
||||
int rc;
|
||||
|
||||
if (arg == NULL)
|
||||
return 0;
|
||||
|
||||
val = rpmExpand(arg, NULL);
|
||||
if (!(val && *val != '%'))
|
||||
rc = 0;
|
||||
else if (*val == 'Y' || *val == 'y')
|
||||
rc = 1;
|
||||
else if (*val == 'N' || *val == 'n')
|
||||
rc = 0;
|
||||
else {
|
||||
char *end;
|
||||
rc = strtol(val, &end, 0);
|
||||
if (!(end && *end == '\0'))
|
||||
rc = 0;
|
||||
}
|
||||
xfree(val);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Return concatenated and expanded path with multiple /'s removed */
|
||||
const char *
|
||||
rpmGetPath(const char *path, ...)
|
||||
{
|
||||
char buf[BUFSIZ], *p, *pe;
|
||||
const char *s;
|
||||
va_list ap;
|
||||
|
||||
if (path == NULL)
|
||||
return strdup("");
|
||||
|
||||
p = buf;
|
||||
strcpy(p, path);
|
||||
pe = p + strlen(p);
|
||||
*pe = '\0';
|
||||
|
||||
va_start(ap, path);
|
||||
while ((s = va_arg(ap, const char *)) != NULL) {
|
||||
/* XXX FIXME: this fixes only some of the "...//..." problems */
|
||||
if (pe > p && pe[-1] == '/')
|
||||
while(*s && *s == '/') s++;
|
||||
if (*s != '\0') {
|
||||
strcpy(pe, s);
|
||||
pe += strlen(pe);
|
||||
*pe = '\0';
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
expandMacros(NULL, &globalMacroContext, buf, sizeof(buf));
|
||||
return strdup(buf);
|
||||
}
|
||||
|
||||
/* =============================================================== */
|
||||
|
||||
#ifdef DEBUG_MACROS
|
||||
|
@ -1253,7 +1357,7 @@ main(int argc, char *argv[])
|
|||
int x;
|
||||
|
||||
initMacros(&mc, macrofile);
|
||||
dumpMacroTable(&mc);
|
||||
dumpMacroTable(&mc, NULL);
|
||||
|
||||
if ((fp = fopen(testfile, "r")) != NULL) {
|
||||
while(fgets(buf, sizeof(buf), fp)) {
|
||||
|
|
|
@ -43,22 +43,27 @@ extern MacroContext globalMacroContext;
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define COMPRESSED_NOT 0
|
||||
#define COMPRESSED_OTHER 1
|
||||
#define COMPRESSED_BZIP2 2
|
||||
void dumpMacroTable __P((MacroContext *mc, FILE *f));
|
||||
|
||||
int isCompressed(const char *file, int *compressed);
|
||||
/* XXX this is used only in build/expression.c and will go away. */
|
||||
const char *getMacroBody __P((MacroContext *mc, const char *name));
|
||||
|
||||
void dumpMacroTable __P((MacroContext *mc));
|
||||
int expandMacros __P((void *spec, MacroContext *mc, char *sbuf, size_t sbuflen));
|
||||
void addMacro __P((MacroContext *mc, const char *n, const char *o, const char *b, int depth));
|
||||
void delMacro __P((MacroContext *mc, const char *n));
|
||||
|
||||
int rpmDefineMacro __P((MacroContext *mc, const char *macro, int level));
|
||||
void initMacros __P((MacroContext *mc, const char *macrofile));
|
||||
void freeMacros __P((MacroContext *mc));
|
||||
|
||||
void addMacro __P((MacroContext *mc, const char *n, const char *o, const char *b, int depth));
|
||||
void delMacro __P((MacroContext *mc, const char *n));
|
||||
int expandMacros __P((void *spec, MacroContext *mc, char *sbuf, size_t sbuflen));
|
||||
#define COMPRESSED_NOT 0
|
||||
#define COMPRESSED_OTHER 1
|
||||
#define COMPRESSED_BZIP2 2
|
||||
int isCompressed __P((const char *file, int *compressed));
|
||||
|
||||
const char *getMacroBody __P((MacroContext *mc, const char *name));
|
||||
char * rpmExpand __P((const char *arg, ...));
|
||||
const char *rpmGetPath __P((const char *path, ...));
|
||||
int rpmExpandNumeric __P((const char *arg));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue