From cd993acac7d1791130b399add1c236f6d2bb91e0 Mon Sep 17 00:00:00 2001 From: jbj Date: Tue, 26 Nov 2002 22:44:47 +0000 Subject: [PATCH] - bundle libfmagic into librpmbuild for now. CVS patchset: 5881 CVS date: 2002/11/26 22:44:47 --- .lclintrc => .splintrc | 0 Makefile.am | 8 +- build/Makefile.am | 31 +++++-- build/argv.h | 2 + build/rpmfc.c | 225 ++++++++++++++++++++++++------------------------- build/rpmfc.h | 4 + file/.cvsignore | 1 + file/Makefile.am | 2 +- lib/rpmds.h | 1 - rpm.spec.in | 3 + tools/rpmdeps.c | 45 +--------- 11 files changed, 152 insertions(+), 170 deletions(-) rename .lclintrc => .splintrc (100%) diff --git a/.lclintrc b/.splintrc similarity index 100% rename from .lclintrc rename to .splintrc diff --git a/Makefile.am b/Makefile.am index 67a8697..51c2eb2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,6 +2,8 @@ AUTOMAKE_OPTIONS = 1.4 foreign +LINT = splint + EXTRA_DIST = CHANGES CREDITS Doxyheader GROUPS README.amiga INSTALL \ RPM-GPG-KEY RPM-PGP-KEY \ autodeps/none autodeps/*.prov autodeps/*.req autogen.sh \ @@ -114,9 +116,9 @@ splint: -load popt/popt.lcd \ $(DEFS) $(INCLUDES) rpmqv.c $(rpmb_SOURCES) -.PHONY: lclint -lclint: - lclint -Dlint $(DEFS) $(INCLUDES) rpmqv.c $(rpmb_SOURCES) \ +.PHONY: lint +lint: + $(LINT) -Dlint $(DEFS) $(INCLUDES) rpmqv.c $(rpmb_SOURCES) \ `make -s sources -C build` \ `make -s sources -C lib` \ `make -s sources -C rpmdb` \ diff --git a/build/Makefile.am b/build/Makefile.am index ff4a005..1187a62 100644 --- a/build/Makefile.am +++ b/build/Makefile.am @@ -2,6 +2,8 @@ AUTOMAKE_OPTIONS = 1.4 foreign +LINT = splint + INCLUDES = -I. \ -I$(top_srcdir) \ -I$(top_srcdir)/lib \ @@ -13,9 +15,11 @@ INCLUDES = -I. \ LIBS = +FILELOBJS = $(shell cat $(top_builddir)/file/listobjs) + pkgincdir = $(pkgincludedir) -pkginc_HEADERS = rpmbuild.h rpmspec.h -noinst_HEADERS = argv.h buildio.h rpmfc.h +pkginc_HEADERS = argv.h rpmbuild.h rpmfc.h rpmfile.h rpmspec.h +noinst_HEADERS = buildio.h lib_LTLIBRARIES = librpmbuild.la librpmbuild_la_SOURCES = \ @@ -24,6 +28,23 @@ librpmbuild_la_SOURCES = \ parseFiles.c parsePreamble.c parsePrep.c parseReqs.c parseScript.c \ parseSpec.c poptBT.c reqprov.c rpmfc.c spec.c librpmbuild_la_LDFLAGS = -release @VERSION@ +librpmbuild_la_LIBADD = $(FILELOBJS) +librpmbuild_la_DEPENDENCIES = .created + +rpmfile.h: + @ln -sf $(top_builddir)/file/file.h $@ + +$(top_builddir)/file/listobjs: + ${MAKE} -C $(top_builddir)/file listobjs + +.created: rpmfile.h $(top_builddir)/file/listobjs + for lo in $(FILELOBJS); do \ + [ -f $$lo ] || $(LN_S) $(top_builddir)/file/$$lo $$lo ; \ + done + touch $@ + +clean-local: + rm -f $(FILELOBJS) *.o .created rpmfile.h # XXX Add internal libtool dependence install-data-local: @@ -40,6 +61,6 @@ rpmbuild.lcd: Makefile.am ${librpmbuild_la_SOURCES} ${pkginc_HEADERS} ${noinst_H sources: @echo $(librpmbuild_la_SOURCES:%=build/%) -.PHONY: lclint -lclint: - lclint ${DEFS} ${INCLUDES} ${librpmbuild_la_SOURCES} +.PHONY: lint +lint: + $(LINT) ${DEFS} ${INCLUDES} ${librpmbuild_la_SOURCES} diff --git a/build/argv.h b/build/argv.h index f54f0ab..2401cd0 100644 --- a/build/argv.h +++ b/build/argv.h @@ -67,8 +67,10 @@ int argvCount(/*@null@*/ const ARGV_t argv) * @param b 2nd instance address * @return result of comparison */ +/*@-exportlocal@*/ int argvCmp(const void * a, const void * b) /*@*/; +/*@=exportlocal@*/ /** * Sort an argv array. diff --git a/build/rpmfc.c b/build/rpmfc.c index af506ed..d88e56e 100644 --- a/build/rpmfc.c +++ b/build/rpmfc.c @@ -6,6 +6,7 @@ #include #include #include +#include #if HAVE_GELF_H #include @@ -13,7 +14,13 @@ #include "debug.h" -/*@notchecked@*/ +/*@unchecked@*/ +extern fmagic global_fmagic; + +/*@unchecked@*//*@observer@*/ +extern const char * default_magicfile; + +/*@unchecked@*/ int _rpmfc_debug; static int rpmfcExpandAppend(/*@out@*/ ARGV_t * argvp, const ARGV_t av) @@ -708,25 +715,25 @@ static int rpmfcELF(rpmfc fc) soname = xstrdup(s); auxoffset += aux->vda_next; /*@innercontinue@*/ continue; - } - buf[0] = '\0'; - t = buf; - sprintf(t, "%08d%c ", fc->ix, deptype); - t += strlen(t); - depval = t; - t = stpcpy( stpcpy( stpcpy( stpcpy(t, soname), "("), s), ")"); + } else if (soname != NULL) { + buf[0] = '\0'; + t = buf; + sprintf(t, "%08d%c ", fc->ix, deptype); + t += strlen(t); + depval = t; + t = stpcpy( stpcpy( stpcpy( stpcpy(t, soname), "("), s), ")"); #if !defined(__alpha__) - if (isElf64) - t = stpcpy(t, "(64bit)"); + if (isElf64) + t = stpcpy(t, "(64bit)"); #endif - /* Add to package provides. */ - xx = rpmfcSaveArg(&fc->provides, depval); - - /* Add to file dependencies. */ - xx = rpmfcSaveArg(&fc->ddict, buf); + /* Add to package provides. */ + xx = rpmfcSaveArg(&fc->provides, depval); + /* Add to file dependencies. */ + xx = rpmfcSaveArg(&fc->ddict, buf); + } auxoffset += aux->vda_next; } offset += def->vd_next; @@ -759,26 +766,25 @@ static int rpmfcELF(rpmfc fc) s = elf_strptr(elf, shdr->sh_link, aux->vna_name); if (s == NULL) /*@innerbreak@*/ break; -assert(soname != NULL); - - buf[0] = '\0'; - t = buf; - sprintf(t, "%08d%c ", fc->ix, deptype); - t += strlen(t); - depval = t; - t = stpcpy( stpcpy( stpcpy( stpcpy(t, soname), "("), s), ")"); + if (soname != NULL) { + buf[0] = '\0'; + t = buf; + sprintf(t, "%08d%c ", fc->ix, deptype); + t += strlen(t); + depval = t; + t = stpcpy( stpcpy( stpcpy( stpcpy(t, soname), "("), s), ")"); #if !defined(__alpha__) - if (isElf64) - t = stpcpy(t, "(64bit)"); + if (isElf64) + t = stpcpy(t, "(64bit)"); #endif - /* Add to package requires. */ - xx = rpmfcSaveArg(&fc->requires, depval); - - /* Add to file dependencies. */ - xx = rpmfcSaveArg(&fc->ddict, buf); + /* Add to package requires. */ + xx = rpmfcSaveArg(&fc->requires, depval); + /* Add to file dependencies. */ + xx = rpmfcSaveArg(&fc->ddict, buf); + } auxoffset += aux->vna_next; } offset += need->vn_next; @@ -847,93 +853,6 @@ exit: #endif } -int rpmfcClassify(rpmfc fc, ARGV_t argv) -{ - char buf[BUFSIZ]; - ARGV_t dav; - ARGV_t av; - const char * s, * se; - char * t; - int fcolor; - int xx; - - if (fc == NULL || argv == NULL) - return 0; - - fc->nfiles = argvCount(argv); - - xx = argiAdd(&fc->fddictx, fc->nfiles-1, 0); - xx = argiAdd(&fc->fddictn, fc->nfiles-1, 0); - - /* Set up the file class dictionary. */ - xx = argvAdd(&fc->cdict, ""); - xx = argvAdd(&fc->cdict, "directory"); - - av = argv; - while ((s = *av++) != NULL) { - for (se = s; *se; se++) { - if (se[0] == ':' && se[1] == ' ') - /*@innerbreak@*/ break; - } - if (*se == '\0') - return -1; - - for (se++; *se; se++) { - if (!(*se == ' ' || *se == '\t')) - /*@innerbreak@*/ break; - } - if (*se == '\0') - return -1; - - fcolor = rpmfcColoring(se); - if (fcolor == RPMFC_WHITE || !(fcolor & RPMFC_INCLUDE)) - continue; - - xx = rpmfcSaveArg(&fc->cdict, se); - } - - /* Classify files. */ - fc->ix = 0; - fc->fknown = 0; - av = argv; - while ((s = *av++) != NULL) { - for (se = s; *se; se++) { - if (se[0] == ':' && se[1] == ' ') - /*@innerbreak@*/ break; - } - if (*se == '\0') - return -1; - - t = stpncpy(buf, s, (se - s)); - *t = '\0'; - - xx = argvAdd(&fc->fn, buf); - - for (se++; *se; se++) { - if (!(*se == ' ' || *se == '\t')) - /*@innerbreak@*/ break; - } - if (*se == '\0') - return -1; - - dav = argvSearch(fc->cdict, se, NULL); - if (dav) { - xx = argiAdd(&fc->fcdictx, fc->ix, (dav - fc->cdict)); - fc->fknown++; - } else { - xx = argiAdd(&fc->fcdictx, fc->ix, 0); - fc->fwhite++; - } - - fcolor = rpmfcColoring(se); - xx = argiAdd(&fc->fcolor, fc->ix, fcolor); - - fc->ix++; - } - - return 0; -} - typedef struct rpmfcApplyTbl_s { int (*func) (rpmfc fc); int colormask; @@ -1007,4 +926,76 @@ assert(dav != NULL); return 0; } + +int rpmfcClassify(rpmfc fc, ARGV_t argv) +{ + ARGV_t fcav = NULL; + ARGV_t dav; + const char * s, * se; + int fcolor; + int xx; +fmagic fm = global_fmagic; +int action = 0; +int wid = 0; /* XXX don't prepend filename: */ + + if (fc == NULL || argv == NULL) + return 0; + + fc->nfiles = argvCount(argv); + + /* Initialize the per-file dictionary indices. */ + xx = argiAdd(&fc->fddictx, fc->nfiles-1, 0); + xx = argiAdd(&fc->fddictn, fc->nfiles-1, 0); + + /* Build (sorted) file class dictionary. */ + xx = argvAdd(&fc->cdict, ""); + xx = argvAdd(&fc->cdict, "directory"); + + fm->magicfile = default_magicfile; + /* XXX TODO fm->flags = ??? */ + + xx = fmagicSetup(fm, fm->magicfile, action); + for (fc->ix = 0; fc->ix < fc->nfiles; fc->ix++) { + s = argv[fc->ix]; +assert(s != NULL); + fm->obp = fm->obuf; + *fm->obp = '\0'; + fm->nob = sizeof(fm->obuf); + xx = fmagicProcess(fm, s, wid); + se = fm->obuf; + rpmMessage(RPMMESS_DEBUG, "%s: %s\n", s, se); + + xx = argvAdd(&fc->fn, s); + xx = argvAdd(&fcav, se); + + /* Add (filtered) entry to sorted class dictionary. */ + fcolor = rpmfcColoring(se); + xx = argiAdd(&fc->fcolor, fc->ix, fcolor); + + if (fcolor != RPMFC_WHITE && (fcolor & RPMFC_INCLUDE)) + xx = rpmfcSaveArg(&fc->cdict, se); + } + + /* Build per-file class index array. */ + fc->fknown = 0; + for (fc->ix = 0; fc->ix < fc->nfiles; fc->ix++) { + se = fcav[fc->ix]; +assert(se != NULL); + + dav = argvSearch(fc->cdict, se, NULL); + if (dav) { + xx = argiAdd(&fc->fcdictx, fc->ix, (dav - fc->cdict)); + fc->fknown++; + } else { + xx = argiAdd(&fc->fcdictx, fc->ix, 0); + fc->fwhite++; + } + } + + fcav = argvFree(fcav); + /* XXX TODO dump fmagic baggage. */ + + return 0; +} + /*@=bounds@*/ diff --git a/build/rpmfc.h b/build/rpmfc.h index ac0fa82..2609f2e 100644 --- a/build/rpmfc.h +++ b/build/rpmfc.h @@ -2,7 +2,9 @@ #define _H_RPMFC_ /*@notchecked@*/ +/*@-exportlocal@*/ extern int _rpmfc_debug; +/*@=exportlocal@*/ typedef struct rpmfc_s * rpmfc; @@ -88,8 +90,10 @@ int rpmfcExec(ARGV_t av, StringBuf sb_stdin, /*@out@*/ StringBuf * sb_stdoutp, /** */ +/*@-exportlocal@*/ int rpmfcColoring(const char * fmstr) /*@*/; +/*@=exportlocal@*/ /** */ diff --git a/file/.cvsignore b/file/.cvsignore index 5eadb36..74a0840 100644 --- a/file/.cvsignore +++ b/file/.cvsignore @@ -19,6 +19,7 @@ configure depcomp install-sh libtool +listobjs ltconfig ltmain.sh missing diff --git a/file/Makefile.am b/file/Makefile.am index e33be72..883f0ca 100644 --- a/file/Makefile.am +++ b/file/Makefile.am @@ -5,7 +5,7 @@ LINT = splint EXTRA_DIST = LEGAL.NOTICE MAINT Makefile.std magic2mime magic.mime \ Localstuff Header $(magic_FRAGMENTS) file.man magic.man -BUILT_SOURCES = $(man_MANS) magic magic.mgc magic.mime.mgc +BUILT_SOURCES = listobjs $(man_MANS) magic magic.mgc magic.mime.mgc noinst_HEADERS = debug.h names.h patchlevel.h readelf.h system.h tar.h \ file.h diff --git a/lib/rpmds.h b/lib/rpmds.h index 85543f3..1808757 100644 --- a/lib/rpmds.h +++ b/lib/rpmds.h @@ -301,7 +301,6 @@ int rpmdsAnyMatchesDep (const Header h, const rpmds req, int nopromote) /** * Compare package name-version-release from header with a single dependency. - * @deprecated Remove from API when obsoletes is correctly implemented. * @param h header * @param req dependency set * @param nopromote Don't promote Epoch: in comparison? diff --git a/rpm.spec.in b/rpm.spec.in index bb9a9ef..8f4516c 100644 --- a/rpm.spec.in +++ b/rpm.spec.in @@ -493,6 +493,9 @@ exit 0 %{__prefix}/include/popt.h %changelog +* Tue Nov 26 2002 Jeff Johnson 4.2-0.13 +- bundle libfmagic into librpmbuild for now. + * Wed Nov 20 2002 Jeff Johnson 4.2-0.12 - use rpmdeps rather than find-{requires,provides}. diff --git a/tools/rpmdeps.c b/tools/rpmdeps.c index cca7f53..31d4ccc 100644 --- a/tools/rpmdeps.c +++ b/tools/rpmdeps.c @@ -3,17 +3,10 @@ #include #include #include -#include "file.h" #include "debug.h" /*@unchecked@*/ -extern fmagic global_fmagic; - -/*@unchecked@*//*@observer@*/ -extern const char * default_magicfile; - -/*@unchecked@*/ char *progname; /*@unchecked@*/ @@ -45,17 +38,12 @@ int main(int argc, char *const argv[]) { poptContext optCon; - ARGV_t xav; ARGV_t av = NULL; rpmfc fc; int ac = 0; int ec = 1; int xx; char buf[BUFSIZ]; -fmagic fm = global_fmagic; -StringBuf sb_stdout; -int action = 0; -int wid = 1; int i; /*@-modobserver@*/ @@ -85,40 +73,12 @@ int i; ac = argvCount(av); } + /* Make sure file names are sorted. */ xx = argvSort(av, NULL); - wid = 1; - for (i = 0; i < ac; i++) { - size_t nw; - nw = strlen(av[i]); - if (nw > wid) - wid = nw; - } - - /* Output of file(1) in sb_stdout. */ - sb_stdout = newStringBuf(); - fm->magicfile = default_magicfile; - /* XXX TODO fm->flags = ??? */ - - xx = fmagicSetup(fm, fm->magicfile, action); - - for (i = 0; i < ac; i++) { - fm->obp = fm->obuf; - *fm->obp = '\0'; - fm->nob = sizeof(fm->obuf); - xx = fmagicProcess(fm, av[i], wid); - - rpmMessage(RPMMESS_DEBUG, "%s\n", fm->obuf); - - appendLineStringBuf(sb_stdout, fm->obuf); - } - - xx = argvSplit(&xav, getStringBuf(sb_stdout), "\n"); - sb_stdout = freeStringBuf(sb_stdout); - /* Build file class dictionary. */ fc = rpmfcNew(); - xx = rpmfcClassify(fc, xav); + xx = rpmfcClassify(fc, av); /* Build file/package dependency dictionary. */ xx = rpmfcApply(fc); @@ -135,7 +95,6 @@ rpmfcPrint(buf, fc, NULL); fc = rpmfcFree(fc); - xav = argvFree(xav); ec = 0; exit: -- 2.7.4