11 #define _MIRE_INTERNAL 15 #define _RPMEVR_INTERNAL 18 #define _RPMNS_INTERNAL 21 #define _RPMFC_INTERNAL 24 #define _RPMDS_INTERNAL 56 for (i = 0; i < ac; i++)
58 argv[argc + ac] = NULL;
64 #if defined(HAVE_SIG_T) && !defined(SIGHANDLER_T) 65 typedef sig_t sighandler_t;
80 const char * writePtr,
size_t writeBytesLeft,
89 sighandler_t oldhandler = signal(SIGPIPE, SIG_IGN);
93 toProg[0] = toProg[1] = 0;
94 fromProg[0] = fromProg[1] = 0;
95 if (pipe(toProg) < 0 || pipe(fromProg) < 0) {
100 if (!(child = fork())) {
101 (void) close(toProg[1]);
102 (void) close(fromProg[0]);
104 (void) dup2(toProg[0], STDIN_FILENO);
105 (void) dup2(fromProg[1], STDOUT_FILENO);
107 (void) close(toProg[0]);
108 (void) close(fromProg[1]);
115 argv[0], (
unsigned)getpid());
118 (void) execvp(argv[0], (
char *
const *)argv);
121 argv[0], strerror(
errno));
126 argv[0], strerror(
errno));
130 (void) close(toProg[0]);
131 (void) close(fromProg[1]);
134 (void) fcntl(fromProg[0], F_SETFL, O_NONBLOCK);
135 (void) fcntl(toProg[1], F_SETFL, O_NONBLOCK);
151 if (fromProg[0] >= 0) {
152 FD_SET(fromProg[0], &ibits);
154 if (toProg[1] >= 0) {
155 FD_SET(toProg[1], &obits);
160 nfd = ((fromProg[0] > toProg[1]) ? fromProg[0] : toProg[1]);
161 if ((rc = select(nfd, &ibits, &obits, NULL, &tv)) < 0) {
168 if (toProg[1] >= 0 && FD_ISSET(toProg[1], &obits)) {
169 if (writePtr && writeBytesLeft > 0) {
170 if ((nbw = write(toProg[1], writePtr,
171 ((
size_t)1024<writeBytesLeft) ? (
size_t)1024 : writeBytesLeft)) < 0)
173 if (
errno != EAGAIN) {
174 perror(
"getOutputFrom()");
179 writeBytesLeft -= nbw;
181 }
else if (toProg[1] >= 0) {
182 (void) close(toProg[1]);
188 {
char buf[BUFSIZ+1];
189 while ((nbr = read(fromProg[0], buf,
sizeof(buf)-1)) > 0) {
196 done = (nbr == 0 || (nbr < 0 &&
errno != EAGAIN));
202 (void) close(toProg[1]);
203 if (fromProg[0] >= 0)
204 (void) close(fromProg[0]);
205 (void) signal(SIGPIPE, oldhandler);
208 reaped = waitpid(child, &status, 0);
210 (
unsigned)child, (
unsigned)reaped, status);
212 if (failNonZero && (!WIFEXITED(status) || WEXITSTATUS(status))) {
213 const char *cmd =
argvJoin(argv,
' ');
214 int rc = (WIFEXITED(status) ? WEXITSTATUS(status) : -1);
221 if (writeBytesLeft) {
232 const char * s = NULL;
238 const char * buf_stdin = NULL;
239 size_t buf_stdin_len = 0;
254 xx = poptParseArgvString(s, &pac, (
const char ***)&pav);
255 if (!(xx == 0 && pac > 0 && pav != NULL))
264 if (iob_stdin != NULL) {
270 iob =
getOutputFrom(NULL, xav, buf_stdin, buf_stdin_len, failnonzero);
272 if (iob_stdoutp != NULL) {
327 sprintf(buf,
"%08u%c %s %s 0x%08x", (
unsigned)ix, deptype,
348 xx = poptParseArgvString(s, &ac, (
const char ***)&av);
351 if (ac == 0 || av == NULL || *av == NULL) {
356 for (i = 0; i < ac; i++) {
361 _(
"Compilation of pattern '%s'" 362 " (expanded from '%s') failed. Skipping ...\n"),
378 const char * str,
char deptype)
385 for (i = 0; i < nmire; i++) {
420 const char * fn = fc->fn[fc->ix];
444 xx =
snprintf(buf,
sizeof(buf),
"%%{?__%s_provides}", nsdep);
445 depsp = &fc->provides;
446 dsContext = RPMSENSE_FIND_PROVIDES;
448 mire = (
miRE) fc->Pmires;
454 xx =
snprintf(buf,
sizeof(buf),
"%%{?__%s_requires}", nsdep);
455 depsp = &fc->requires;
456 dsContext = RPMSENSE_FIND_REQUIRES;
458 mire = (
miRE) fc->Rmires;
462 buf[
sizeof(buf)-1] =
'\0';
469 xx =
rpmfcExec(av, iob_stdin, &iob_stdout, 0);
472 if (xx == 0 && iob_stdout != NULL) {
477 for (i = 0; i < pac; i++) {
481 if (pav[i+1] && strchr(
"=<>", *pav[i+1])) {
483 for (s = pav[i]; *s; s++) {
510 #if defined(RPM_VENDOR_MANDRIVA) 521 #define RPMSENSE_SCRIPTS (RPMSENSE_SCRIPT_PRE|RPMSENSE_SCRIPT_POST|RPMSENSE_SCRIPT_PREUN|RPMSENSE_SCRIPT_POSTUN|RPMSENSE_SCRIPT_VERIFY) 526 (((*depsp)->Flags[(*depsp)->i] & RPMSENSE_GREATER) && (Flags &
RPMSENSE_LESS))) &&
528 !(((Flags & RPMSENSE_SCRIPTS) && !((*depsp)->Flags[(*depsp)->i] & RPMSENSE_SCRIPTS)) ||
529 (((*depsp)->Flags[(*depsp)->i] & RPMSENSE_SCRIPTS) && !(Flags & RPMSENSE_SCRIPTS))))
531 #undef RPMSENSE_SCRIPTS 539 if (!(Flags & RPMSENSE_MISSINGOK) || !((*depsp)->Flags[(*depsp)->i] & RPMSENSE_MISSINGOK)) {
540 (*depsp)->Flags[(*depsp)->i] &= ~RPMSENSE_MISSINGOK;
541 Flags &= ~RPMSENSE_MISSINGOK;
545 newflags = (((*depsp)->Flags[(*depsp)->i]| Flags) & _ALL_REQUIRES_MASK);
552 rEVR->Flags = (*depsp)->Flags[(*depsp)->i];
560 (*depsp)->Flags[(*depsp)->i] = Flags;
561 (*depsp)->EVR[(*depsp)->i] = strdup(EVR);
565 else if ((*depsp)->Flags[(*depsp)->i] != Flags) {
567 (*depsp)->Flags[(*depsp)->i] &= ~(RPMSENSE_GREATER|
RPMSENSE_LESS);
571 (*depsp)->Flags[(*depsp)->i] |= newflags;
574 for (ix = 0; ix <
argvCount(fc->ddict); ix++) {
575 if (!strcmp(strchr(fc->ddict[ix],
' '), oldVal)) {
576 size_t fcix = atol(fc->ddict[ix]);
577 _free(fc->ddict[ix]);
725 for (fct = rpmfcTokens; fct->token != NULL; fct++) {
726 if (strstr(fmstr, fct->token) == NULL)
728 fcolor |= fct->colors;
746 if (fp == NULL) fp = stderr;
749 fprintf(fp,
"===================================== %s\n", msg);
755 for (fx = 0; fx < fc->nfiles; fx++) {
756 assert(fx < fc->fcdictx->nvals);
757 cx = fc->fcdictx->vals[fx];
758 assert(fx < fc->fcolor->nvals);
759 fcolor = fc->fcolor->vals[fx];
761 fprintf(fp,
"%3d %s", (
int)fx, fc->fn[fx]);
762 if (fcolor != RPMFC_BLACK)
763 fprintf(fp,
"\t0x%x", fc->fcolor->vals[fx]);
765 fprintf(fp,
"\t%s", fc->cdict[cx]);
768 if (fc->fddictx == NULL || fc->fddictn == NULL)
771 assert(fx < fc->fddictx->nvals);
772 dx = fc->fddictx->vals[fx];
773 assert(fx < fc->fddictn->nvals);
774 ndx = fc->fddictn->vals[fx];
778 unsigned char deptype;
781 ix = fc->ddictx->vals[dx++];
782 deptype = ((ix >> 24) & 0xff);
787 assert(depval != NULL);
791 assert(ix < nprovides);
799 assert(ix < nrequires);
807 fprintf(fp,
"\t%s\n", depval);
821 const char * fn = fc->fn[fc->ix];
833 const char * defaultdocdir =
rpmExpand(
"%{?_defaultdocdir}", NULL);
834 if (defaultdocdir == NULL || *defaultdocdir ==
'\0')
835 defaultdocdir = strdup(
"/usr/share/doc");
836 xx = !strncmp(fn+fc->brlen, defaultdocdir, strlen(defaultdocdir));
837 defaultdocdir =
_free(defaultdocdir) ;
843 {
struct stat sb, * st = &sb;
844 if (stat(fn, st) != 0)
846 is_executable = (int)(st->st_mode & (S_IXUSR|S_IXGRP|S_IXOTH));
850 if (fp == NULL || ferror(fp)) {
851 if (fp) (void) fclose(fp);
856 for (i = 0; i < 10; i++) {
858 s = fgets(buf,
sizeof(buf) - 1, fp);
859 if (s == NULL || ferror(fp) || feof(fp))
861 s[
sizeof(buf)-1] =
'\0';
862 if (!(s[0] ==
'#' && s[1] ==
'!'))
866 while (*s && strchr(
" \t\n\r", *s) != NULL)
873 for (se = s+1; *se; se++) {
874 if (strchr(
" \t\n\r", *se) != NULL)
887 strncmp(bn,
"bash",
sizeof(
"bash")-1) &&
889 strncmp(bn,
"perl",
sizeof(
"perl")-1) &&
890 strncmp(bn,
"python",
sizeof(
"python")-1) &&
891 strncmp(bn,
"ruby",
sizeof(
"ruby")-1) &&
902 }
else if (!strcmp(bn,
"env") && strlen(se)) {
904 strsep(&se,
" \t\n\r");
911 if (!strcmp(bn,
"perl"))
913 else if (!strncmp(bn,
"python",
sizeof(
"python")-1))
915 else if (!strncmp(bn,
"php",
sizeof(
"php")-1))
917 else if (!strncmp(bn,
"json",
sizeof(
"json")-1))
919 else if (!strncmp(bn,
"ruby",
sizeof(
"ruby")-1))
930 if (is_executable || (fc->fcolor->vals[fc->ix] &
RPMFC_MODULE))
936 if (is_executable || (fc->fcolor->vals[fc->ix] &
RPMFC_MODULE))
957 if (fc->fcolor->vals[fc->ix] &
RPMFC_QML) {
968 if (fc->fcolor->vals[fc->ix] &
RPMFC_PHP) {
983 if (is_executable || (fc->fcolor->vals[fc->ix] &
RPMFC_MODULE))
1003 strstr(fn,
"/gstreamer")) {
1007 #if defined(RPM_VENDOR_MANDRIVA) 1011 if (!
mireRegcomp(mire,
"^.*((/lib/modules/|/var/lib/dkms/).*\\.ko(\\.gz|\\.xz)?|(/var/lib/dkms-binary/[^/]+/[^/]+|/usr/src)/[^/]+/dkms.conf)$"))
1012 if (
mireRegexec(mire, fc->fn[fc->ix], (
size_t) 0) >= 0) {
1022 if (!
mireRegcomp(mire,
"^.*/usr/share/applications/.*\\.desktop$"))
1023 if (
mireRegexec(mire, fc->fn[fc->ix], (
size_t) 0) >= 0) {
1052 fprintf(stderr,
"*** rpmfcMergePR(%p, %p) %s\n", context, ds,
tagName(
rpmdsTagN(ds)));
1096 const char * fn = fc->fn[fc->ix];
1107 #if defined(RPM_VENDOR_MANDRIVA) 1117 extern int rpmdsSymlink(
const char * fn,
int flags,
1118 int (*add) (
void * context,
rpmds ds),
void * context)
1122 static int rpmfcSYMLINK(
rpmfc fc)
1126 const char * fn = fc->fn[fc->ix];
1173 unsigned char deptype;
1184 int skipProv = fc->skipProv;
1185 int skipReq = fc->skipReq;
1188 if (_filter_execs) {
1191 if (fc->PFnmire > 0)
1196 if (fc->RFnmire > 0)
1212 assert(fc->fn != NULL);
1214 for (fc->ix = 0; fc->fn[fc->ix] != NULL; fc->ix++) {
1218 { fn = strstr(fc->fn[fc->ix],
"/usr/lib");
1220 fn +=
sizeof(
"/usr/lib")-1;
1221 if ((fn[0] ==
'3' && fn[1] ==
'2') ||
1222 (fn[0] ==
'6' && fn[1] ==
'4'))
1224 if (!strncmp(fn,
"/python",
sizeof(
"/python")-1)) {
1226 if (strstr(fn,
"site-packages"))
1228 else if (strstr(fn,
".egg")) {
1230 if (!
mireRegcomp(mire,
".*/.*\\.egg(|-info|-link)(|/.*)$"))
1231 if (
mireRegexec(mire, fc->fn[fc->ix], (
size_t) 0) >= 0)
1236 else if (!strncmp(fn,
"/ruby",
sizeof(
"/ruby")-1)) {
1238 if ((strstr(fn,
".gemspec") || strstr(fn,
"rbconfig.rb"))) {
1240 if (!
mireRegcomp(mire,
".*/(specifications/.*\\.gemspec|rbconfig\\.rb)$"))
1241 if (
mireRegexec(mire, fc->fn[fc->ix], (
size_t) 0) >= 0)
1247 else if (!strncmp(fn,
"/gstreamer",
sizeof(
"/gstreamer")-1) &&
1250 #if defined(RPM_VENDOR_MANDRIVA) 1253 if (!
mireRegcomp(mire,
"^.*((/lib/modules/|/var/lib/dkms/).*\\.ko(\\.gz|\\.xz)?|(/var/lib/dkms-binary/[^/]+/[^/]+|/usr/src)/[^/]+/dkms.conf)$"))
1254 if (
mireRegexec(mire, fc->fn[fc->ix], (
size_t) 0) >= 0)
1259 if (!
mireRegcomp(mire,
"^.*/usr/share/applications/.*\\.desktop$"))
1260 if (
mireRegexec(mire, fc->fn[fc->ix], (
size_t) 0) >= 0)
1268 { fn = strstr(fc->fn[fc->ix],
"/usr/share/haskell-deps");
1273 if (fc->fcolor->vals[fc->ix])
1274 for (fcat = rpmfcApplyTable; fcat->
func != NULL; fcat++) {
1275 if (!(fc->fcolor->vals[fc->ix] & fcat->
colormask))
1278 if (_filter_execs) {
1279 fc->skipProv = skipProv;
1280 fc->skipReq = skipReq;
1281 if ((mire = (
miRE)fc->PFmires) != NULL)
1282 for (j = 0; j < fc->PFnmire; j++, mire++) {
1283 fn = fc->fn[fc->ix] + fc->brlen;
1291 if ((mire = (
miRE)fc->RFmires) != NULL)
1292 for (j = 0; j < fc->RFnmire; j++, mire++) {
1293 fn = fc->fn[fc->ix] + fc->brlen;
1303 struct stat sb, * st = &sb;
1304 if (stat(fc->fn[fc->ix], st) == 0 && !(st->st_mode & (S_IFBLK|S_IFCHR)))
1305 xx = (*fcat->
func) (fc);
1309 if (_filter_execs) {
1315 fc->skipProv = skipProv;
1316 fc->skipReq = skipReq;
1321 for (i = 0; i < nddict; i++) {
1325 ix = strtol(s, &se, 10);
1330 while (*se && *se !=
' ')
1334 while (*se && *se !=
' ')
1337 Flags = (
evrFlags) strtol(se, NULL, 16);
1345 skipping = fc->skipProv;
1352 skipping = fc->skipReq;
1368 val = (deptype << 24) | (dix & 0x00ffffff);
1369 xx =
argiAdd(&fc->ddictx, -1, val);
1375 if (fc->fddictn && fc->fddictn->vals && !skipping)
1376 fc->fddictn->vals[ix]++;
1387 const char * s, * se;
1391 const char * magicfile = NULL;
1393 if (fc == NULL || argv == NULL)
1396 magicfile =
rpmExpand(
"%{?_rpmfc_magic_path}", NULL);
1397 if (magicfile == NULL || *magicfile ==
'\0')
1398 magicfile =
_free(magicfile);
1406 xx =
argiAdd(&fc->fddictx, fc->nfiles-1, 0);
1407 xx =
argiAdd(&fc->fddictn, fc->nfiles-1, 0);
1411 xx =
argvAdd(&fc->cdict,
"directory");
1413 for (fc->ix = 0; fc->ix < fc->nfiles; fc->ix++) {
1419 ftype =
""; freeftype = 0;
1420 urltype =
urlPath(argv[fc->ix], &s);
1421 assert(s != NULL && *s ==
'/');
1424 switch (mode & S_IFMT) {
1425 case S_IFCHR: ftype =
"character special";
break;
1426 case S_IFBLK: ftype =
"block special";
break;
1427 #if defined(S_IFIFO) 1428 case S_IFIFO: ftype =
"fifo (named pipe)";
break;
1430 #if defined(S_IFSOCK) 1432 case S_IFSOCK: ftype =
"socket";
break;
1440 #define _suffix(_s, _x) \ 1441 (slen >= sizeof(_x) && !strcmp((_s)+slen-(sizeof(_x)-1), (_x))) 1445 ftype =
"Perl5 module source text";
1449 ftype =
"Java archive file";
1452 else if (
_suffix(s,
".class"))
1453 ftype =
"Java class file";
1457 ftype =
"libtool library file";
1461 ftype =
"pkgconfig file";
1468 else if (
_suffix(s,
"qmldir"))
1473 ftype =
"PHP script text";
1477 ftype =
"NodeJS script text";
1480 else if (
_suffix(s,
".typelib"))
1481 ftype =
"G-IR binary database";
1485 ftype =
"G-IR binary database";
1488 else if (slen >= fc->brlen+
sizeof(
"/dev/") && !strncmp(s+fc->brlen,
"/dev/",
sizeof(
"/dev/")-1))
1490 else if (magicfile) {
1492 assert(ftype != NULL);
1515 #if defined(RPM_VENDOR_MANDRIVA) 1519 if ((fn = strrchr(s,
'.')) && !strcmp(fn,
".so")) {
1520 FILE * fp = fopen(s,
"r");
1523 if (fp == NULL || ferror(fp)) {
1524 if (fp) (void) fclose(fp);
1526 while ((in = fgets(buf,
sizeof(buf) - 1, fp))) {
1527 in[
sizeof(buf)-1] =
'\0';
1528 if (ferror(fp) || feof(fp))
1530 if ((fn = strstr(in,
"GROUP")) &&
1531 (fn = strchr(fn,
'(')) && (fn = strchr(in,
'/'))) {
1541 xx =
argiAdd(&fc->fcolor, (
int)fc->ix, fcolor);
1548 ftype =
_free(ftype);
1554 for (fc->ix = 0; fc->ix < fc->nfiles; fc->ix++) {
1560 xx =
argiAdd(&fc->fcdictx, (
int)fc->ix, (dav - fc->cdict));
1563 xx =
argiAdd(&fc->fcdictx, (
int)fc->ix, 0);
1572 D_(
"categorized %d files into %u classes (using %s).\n"),
1573 (
unsigned)fc->nfiles,
argvCount(fc->cdict), magicfile);
1574 magicfile =
_free(magicfile);
1589 const char * argv[4];
1602 {
"Provides", {
"%{?__find_provides}", NULL, NULL, NULL },
1605 {
"Requires(interp)", { NULL,
"interp", NULL, NULL },
1607 _notpre(RPMSENSE_INTERP), 0 },
1608 {
"Requires(rpmlib)", { NULL,
"rpmlib", NULL, NULL },
1610 _notpre(RPMSENSE_RPMLIB), 0 },
1611 {
"Requires(verify)", { NULL,
"verify", NULL, NULL },
1613 RPMSENSE_SCRIPT_VERIFY, 0 },
1614 {
"Requires(pre)", { NULL,
"pre", NULL, NULL },
1616 _notpre(RPMSENSE_SCRIPT_PRE), 0 },
1617 {
"Requires(post)", { NULL,
"post", NULL, NULL },
1619 _notpre(RPMSENSE_SCRIPT_POST), 0 },
1620 {
"Requires(preun)", { NULL,
"preun", NULL, NULL },
1622 _notpre(RPMSENSE_SCRIPT_PREUN), 0 },
1623 {
"Requires(postun)", { NULL,
"postun", NULL, NULL },
1625 _notpre(RPMSENSE_SCRIPT_POSTUN), 0 },
1626 {
"Requires", {
"%{?__find_requires}", NULL, NULL, NULL },
1628 RPMSENSE_FIND_REQUIRES|RPMSENSE_TRIGGERIN|RPMSENSE_TRIGGERUN|RPMSENSE_TRIGGERPOSTUN|RPMSENSE_TRIGGERPREIN, 0 },
1629 {
"Conflicts", {
"%{?__find_conflicts}", NULL, NULL, NULL },
1632 {
"Obsoletes", {
"%{?__find_obsoletes}", NULL, NULL, NULL },
1657 for (dm = DepMsgs; dm->
msg != NULL; dm++) {
1658 if ((
int)dm->
ntag != -1) {
1701 int failnonzero = 0;
1713 for (dm = DepMsgs; dm->
msg != NULL; dm++) {
1728 tagflags = RPMSENSE_FIND_PROVIDES;
1734 tagflags = RPMSENSE_FIND_REQUIRES;
1741 xx =
rpmfcExec(dm->
argv, iob_stdin, &iob_stdout, failnonzero);
1750 if (iob_stdout == NULL) {
1778 {
"Requires(pre)", {
"%{?__scriptlet_requires}", NULL, NULL, NULL },
1780 RPMSENSE_SCRIPT_PRE, 0 },
1781 {
"Requires(post)", {
"%{?__scriptlet_requires}", NULL, NULL, NULL },
1783 RPMSENSE_SCRIPT_POST, 0 },
1784 {
"Requires(preun)", {
"%{?__scriptlet_requires}", NULL, NULL, NULL },
1786 RPMSENSE_SCRIPT_PREUN, 0 },
1787 {
"Requires(postun)", {
"%{?__scriptlet_requires}", NULL, NULL, NULL },
1789 RPMSENSE_SCRIPT_POSTUN, 0 },
1805 rpmiob iob_stdout = NULL;
1807 int failnonzero = 0;
1811 for (dm = ScriptMsgs; dm->
msg != NULL; dm++) {
1822 if (!xx || he->
p.
str == NULL)
1824 xx = strcmp(he->
p.
str,
"/bin/sh") && strcmp(he->
p.
str,
"/bin/bash");
1832 if (!xx || he->
p.
str == NULL)
1839 xx =
rpmfcExec(dm->
argv, iob_stdin, &iob_stdout, failnonzero);
1845 if (s != NULL && *s !=
'\0') {
1848 while ((se = strstr(se,
"executable(/")) != NULL) {
1853 se = strchr(se,
')');
1859 rc = spec->
_parseRCPOT(spec, pkg, s, tag, 0, tagflags);
1871 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
1873 unsigned i, rnum, removed = 0;
1874 const char **deps = NULL;
1875 const char **versions = NULL;
1877 int *newpos = NULL, *ddictxPos = NULL;
1886 versions = he->
p.
argv;
1892 if (fc && fc->requires != NULL && fc->ddictx != NULL) {
1893 newpos =
alloca(he->
c*
sizeof(newpos[0]));
1895 ddictxPos =
alloca(fc->ddictx->nvals*
sizeof(ddictxPos[0]));
1897 for (i = 0; i < rnum-removed; i++) {
1899 deps[i] = deps[i+removed];
1900 versions[i] = versions[i+removed];
1901 flags[i] = flags[i+removed];
1903 fc->requires->N[i] = fc->requires->N[i+removed];
1904 fc->requires->EVR[i] = fc->requires->EVR[i+removed];
1905 fc->requires->Flags[i] = fc->requires->Flags[i+removed];
1908 if (fc && fc->requires != NULL && fc->ddictx != NULL)
1909 newpos[i+removed] = i;
1913 if (flags[i] & RPMSENSE_SCRIPT_PRE)
1916 if (fc && fc->requires != NULL && fc->ddictx != NULL)
1917 newpos[i+removed] = -1;
1926 if (fc && fc->requires != NULL && fc->ddictx != NULL && removed) {
1927 fc->requires->Count -= removed;
1929 for (i = 0; i < fc->ddictx->nvals-rx; i++) {
1931 unsigned char deptype;
1933 ix = fc->ddictx->vals[i+rx];
1934 deptype = ((ix >> 24) & 0xff);
1937 if (deptype ==
'P') {
1938 ddictxPos[i+rx] = i;
1939 fc->ddictx->vals[i] = fc->ddictx->vals[i+rx];
1942 if (newpos[ix] == -1) {
1943 ddictxPos[i+rx] = -1;
1948 ddictxPos[i+rx] = i;
1949 fc->ddictx->vals[i] = (deptype << 24) | (newpos[ix] & 0x00ffffff);
1952 fc->ddictx->nvals -= rx;
1954 for (i = 0; i < fc->fddictn->nvals; i++) {
1956 if (fc->fddictn->vals[i]) {
1957 unsigned j, ix = fc->fddictx->vals[i];
1958 for (j = 0, rx = 0; j < fc->fddictn->vals[i]; j++, ix++) {
1959 if (ddictxPos[ix] == -1)
1961 if (j == 0 || fc->fddictx->vals[i] == -1)
1962 fc->fddictx->vals[i] = ddictxPos[ix];
1966 fc->fddictn->vals[i] -= rx;
1967 if (fc->fddictn->vals[i] == 0)
1968 fc->fddictx->vals[i] = 0;
1980 he->
p.
argv = versions;
1985 he->
p.
ui32p = (uint32_t*)flags;
2007 int genConfigDeps, internaldeps;
2022 if (internaldeps == 0) {
2031 if (internaldeps > 1)
2058 {
const char * buildRootURL;
2059 const char * buildRoot;
2061 (void)
urlPath(buildRootURL, &buildRoot);
2062 if (buildRoot && !strcmp(buildRoot,
"/")) buildRoot = NULL;
2063 fc->brlen = (buildRoot ? strlen(buildRoot) : 0);
2064 buildRootURL =
_free(buildRootURL);
2068 if (!fc->skipProv) {
2081 if (genConfigDeps) {
2086 assert(EVR != NULL);
2087 sprintf(buf,
"config(%s)", N);
2108 if (genConfigDeps) {
2113 assert(EVR != NULL);
2114 sprintf(buf,
"config(%s)", N);
2133 assert(ac == (
int)he->
c);
2134 if (he->
p.
ptr != NULL && he->
c > 0) {
2138 for (i = 0; i < (int)he->
c; i++)
2149 if (he->
p.
ptr != NULL && he->
c > 0) {
2158 assert(ac == (
int)he->
c);
2159 if (he->
p.
ptr != NULL && he->
c > 0) {
2164 if (fc->provides != NULL && (he->
c =
rpmdsCount(fc->provides)) > 0
2169 he->
p.
argv = fc->provides->N;
2176 he->
p.
argv = fc->provides->EVR;
2177 assert(he->
p.
ptr != NULL);
2183 assert(he->
p.
ptr != NULL);
2189 if (fc->requires != NULL && (he->
c =
rpmdsCount(fc->requires)) > 0
2194 he->
p.
argv = fc->requires->N;
2195 assert(he->
p.
ptr != NULL);
2202 he->
p.
argv = fc->requires->EVR;
2203 assert(he->
p.
ptr != NULL);
2209 assert(he->
p.
ptr != NULL);
2221 if (he->
p.
ptr != NULL) {
2230 assert(ac == (
int)he->
c);
2231 if (he->
p.
ptr != NULL) {
2239 assert(ac == (
int)he->
c);
2240 if (he->
p.
ptr != NULL) {
2248 sprintf(msg,
"final: files %u cdict[%d] %u%% ddictx[%d]", (
unsigned int)fc->nfiles,
argvCount(fc->cdict), (
unsigned int)((100 * fc->fknown)/fc->nfiles),
argiCount(fc->ddictx));
2253 fmode =
_free(fmode);
2268 fc->fcdictx =
argiFree(fc->fcdictx);
2269 fc->fddictx =
argiFree(fc->fddictx);
2270 fc->fddictn =
argiFree(fc->fddictn);
2276 fc->provides = NULL;
2278 fc->requires = NULL;
2296 if (_rpmfcPool == NULL) {
2302 memset(((
char *)fc)+
sizeof(fc->_item), 0,
sizeof(*fc)-
sizeof(fc->_item));
rpmuint32_t rpmfiFFlags(rpmfi fi)
Return current file flags from file info set.
#define RPM_VENDOR_MANDRIVA
rpmds rpmdsSingle(rpmTag tagN, const char *N, const char *EVR, evrFlags Flags)
Create, load and initialize a dependency set of size 1.
evrFlags rpmdsFlags(const rpmds ds)
Return current dependency flags.
rpmiob rpmiobRTrim(rpmiob iob)
Trim trailing white space.
rpmds rpmdsInit(rpmds ds)
Initialize dependency set iterator.
miRE mireNew(rpmMireMode mode, int tag)
Create pattern container.
const char * rpmmgFile(rpmmg mg, const char *fn)
Return magic string for a file.
static struct rpmfcApplyTbl_s rpmfcApplyTable[]
XXX Having two entries for rpmfcSCRIPT may be unnecessary duplication.
#define RPMELF_FLAG_SKIPREQUIRES
static DepMsg_t ScriptMsgs
#define RPMSENSE_SENSEMASK
ARGI_t argiFree(ARGI_t argi)
Destroy an argi array.
void * mireFreeAll(miRE mire, int nmire)
Destroy compiled patterns.
enum urltype_e urltype
Supported URL types.
static void rpmfcFini(void *_fc)
static int rpmfcMatchRegexps(void *_mire, int nmire, const char *str, char deptype)
struct DepMsg_s * DepMsg_t
static void printDeps(Header h)
Print dependencies in a header.
char * xstrdup(const char *str)
size_t rpmiobLen(rpmiob iob)
Return I/O buffer len.
static int rpmfcExpandAppend(ARGV_t *argvp, const ARGV_t av)
Structure(s) used for file info tag sets.
int mireRegcomp(miRE mire, const char *pattern)
Compile pattern match.
int argvAppend(ARGV_t *argvp, ARGV_t av)
Append one argv array to another.
static int rpmfcELF(rpmfc fc)
Extract Elf dependencies.
rpmTag rpmdsTagN(const rpmds ds)
Return current dependency type.
const char * rpmfiFN(rpmfi fi)
Return current file name from file info set.
unsigned short rpmuint16_t
rpmiob rpmiobFree(rpmiob iob)
Destroy a I/O buffer instance.
int rpmEVRparse(const char *evrstr, EVR_t evr)
Split EVR string into epoch, version, and release components.
static void rpmlog(int code, const char *fmt,...)
rpmRC rpmfcApply(rpmfc fc)
Build file/package dependency dictionary and mappings.
const char * rpmdsDNEVR(const rpmds ds)
Return current formatted dependency string.
rpmiob rpmiobAppend(rpmiob iob, const char *s, size_t nl)
Append string to I/O buffer.
static int rpmfcSaveArg(ARGV_t *argvp, const char *key)
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
static rpmiob getOutputFrom(const char *dir, ARGV_t argv, const char *writePtr, size_t writeBytesLeft, int failNonZero)
Return output from helper script.
int argiCount(ARGI_t argi)
Return no.
rpmds rpmdsFree(rpmds ds)
Destroy a dependency set.
int rpmfiFC(rpmfi fi)
Return file count from file info set.
int rpmEVRcompare(const EVR_t a, const EVR_t b)
Compare EVR containers for equality.
char * argvJoin(ARGV_t argv, char sep)
Concatenate an argv array into a string.
enum evrFlags_e evrFlags
Dependency Attributes.
Yet Another syslog(3) API clone.
static struct rpmfcTokens_s rpmfcTokens[]
static rpmfc rpmfcGetPool(rpmioPool pool)
miRE mireFree(miRE mire)
Free pattern container.
void * xcalloc(size_t nmemb, size_t size)
rpmfc rpmfcLink(rpmfc fc)
Reference a file classifier instance.
rpmioItem rpmioGetPool(rpmioPool pool, size_t size)
Get unused item from pool, or alloc a new item.
rpmfc rpmfcFree(rpmfc fc)
Destroy a file classifier.
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
int rpmdsCompare(const rpmds A, const rpmds B)
Compare two versioned dependency ranges, looking for overlap.
int argvCount(const ARGV_t argv)
Return no.
rpmuint16_t rpmfiFMode(rpmfi fi)
Return current file mode from file info set.
ARGV_t argvData(ARGV_t argv)
Return data from argv array.
int rpmdsFind(rpmds ds, const rpmds ods)
Find a dependency set element using binary search.
enum evrFlags_e rpmsenseFlags
static int rpmfcMergePR(void *context, rpmds ds)
Merge provides/requires dependencies into a rpmfc container.
static unsigned removeSillyDeps(Header h, rpmfc fc)
ARGV_t argvFree(ARGV_t argv)
Destroy an argv array.
int rpmfcExec(ARGV_t av, rpmiob iob_stdin, rpmiob *iob_stdoutp, int failnonzero)
const char * rpmdsEVR(const rpmds ds)
Return current dependency epoch-version-release.
const char * tagName(rpmTag tag)
Return tag name from value.
static int _filter_values
int rpmdsNext(rpmds ds)
Return next dependency set iterator index.
Structure(s) used for dependency tag sets.
static const char * ftype(unsigned type)
const char * rpmGenPath(const char *urlroot, const char *urlmdir, const char *urlfile)
Merge 3 args into path, any or all of which may be a url.
int argvAdd(ARGV_t *argvp, ARGstr_t val)
Add a string to an argv array.
int mireRegexec(miRE mire, const char *val, size_t vallen)
Execute pattern match.
rpmmg rpmmgNew(const char *fn, int flags)
Create and load a magic wrapper.
The structure used to store values parsed from a spec file.
static char * rpmfcFileDep(char *buf, size_t ix, rpmds ds)
struct rpmfcApplyTbl_s * rpmfcApplyTbl
char * rpmExpand(const char *arg,...)
Return (malloc'ed) concatenated macro expansion(s).
static struct DepMsg_s scriptMsgs[]
int Chdir(const char *path)
chdir(2) clone.
int rpmdsCount(const rpmds ds)
Return dependency set count.
void rpmfcPrint(const char *msg, rpmfc fc, FILE *fp)
Print results of file classification.
struct Package_s * Package
void unsetenv(const char *name)
static int rpmfcHelper(rpmfc fc, unsigned char deptype, const char *nsdep)
Run per-interpreter dependency helper.
static struct DepMsg_s depMsgs[]
const char * rpmdsN(const rpmds ds)
Return current dependency name.
static int rpmfcSCRIPT(rpmfc fc)
Extract script dependencies.
rpmiob rpmiobNew(size_t len)
Create an I/O buffer.
enum rpmfileAttrs_e rpmfileAttrs
File Attributes.
int rpmfiNext(rpmfi fi)
Return next file iterator index.
EVR_t rpmEVRnew(uint32_t Flags, int initialize)
Create a new EVR container.
enum rpmRC_e rpmRC
RPM return codes.
char * rpmiobStr(rpmiob iob)
Return I/O buffer (as string).
rpmfi rpmfiInit(rpmfi fi, int fx)
Initialize file iterator index.
EVR_t rpmEVRfree(EVR_t evr)
Destroy an EVR container.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
int rpmfcColoring(const char *fmstr)
Return file color given file(1) string.
static int snprintf(char *buf, int nb, const char *fmt,...)
This is the only module users of librpmbuild should need to include.
rpmioPool rpmioNewPool(const char *name, size_t size, int limit, int flags, char *(*dbg)(void *item), void(*init)(void *item), void(*fini)(void *item))
Create a memory pool.
rpmRC(* _parseRCPOT)(Spec spec, Package pkg, const char *field, rpmTag tagN, rpmuint32_t index, rpmsenseFlags tagflags)
rpmRC rpmfcClassify(rpmfc fc, ARGV_t argv, rpmuint16_t *fmode)
int rpmdsMerge(rpmds *dsp, rpmds ods)
Merge a dependency set maintaining (N,EVR,Flags) sorted order.
char * stpcpy(char *dest, const char *src)
static rpmRC rpmfcGenerateDependsHelper(const Spec spec, Package pkg, rpmfi fi)
static int rpmfcGenerateScriptletDeps(const Spec spec, Package pkg)
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int argiAdd(ARGI_t *argip, int ix, int val)
Add an int to an argi array.
int rpmdsSearch(rpmds ds, rpmds ods)
Search a sorted dependency set for an element that overlaps.
int argvSplit(ARGV_t *argvp, const char *str, const char *seps)
Split a string into an argv array.
ARGV_t argvSearch(ARGV_t argv, ARGstr_t val, int(*compar)(ARGstr_t *, ARGstr_t *))
Find an element in an argv array.
rpmiob rpmiobEmpty(rpmiob iob)
Empty an I/O buffer.
int rpmdsMatch(const rpmds A, rpmds B)
Compare A against every member of B, looking for 1st match.
struct rpmfcTokens_s * rpmfcToken
static void * rpmfcFreeRegexps(void *_mire, int nmire)
int argvSort(ARGV_t argv, int(*compar)(ARGstr_t *, ARGstr_t *))
Sort an argv array.
int rpmdsELF(const char *fn, int flags, int(*add)(void *context, rpmds ds), void *context)
Return a soname dependency constructed from an elf string.
int mireAppend(rpmMireMode mode, int tag, const char *pattern, const unsigned char *table, miRE *mirep, int *nmirep)
Append pattern to array.
The structure used to store values for a package.
#define RPMELF_FLAG_SKIPPROVIDES
rpmRC rpmfcGenerateDepends(void *_spec, void *_pkg)
Generate package dependencies.
rpmds rpmdsNew(Header h, rpmTag tagN, int flags)
Create and load a dependency set.
int rpmdsSetIx(rpmds ds, int ix)
Set dependency set index.
ARGint_t argiData(ARGI_t argi)
Return data from argi array.
int rpmExpandNumeric(const char *arg)
Return macro expansion as a numeric value.
rpmmg rpmmgFree(rpmmg mg)
Destroy a magic wrapper.
rpmfc rpmfcNew(void)
Create a file classifier.
static void * rpmfcExpandRegexps(const char *str, int *nmirep)