2 const char *__progname;
11 #define _RPMTS_INTERNAL /* ts->goal, ts->dbmode, ts->suggests */
15 #include "misc.h" /* rpmGlob */
19 static int noDeps = 1;
21 static rpmVSFlags vsflags = 0;
23 static inline const char * identifyDepend(int_32 f)
25 if (isLegacyPreReq(f))
28 if (f & RPMSENSE_SCRIPT_PRE)
29 return "Requires(pre):";
30 if (f & RPMSENSE_SCRIPT_POST)
31 return "Requires(post):";
32 if (f & RPMSENSE_SCRIPT_PREUN)
33 return "Requires(preun):";
34 if (f & RPMSENSE_SCRIPT_POSTUN)
35 return "Requires(postun):";
36 if (f & RPMSENSE_SCRIPT_VERIFY)
37 return "Requires(verify):";
38 if (f & RPMSENSE_FIND_REQUIRES)
39 return "Requires(auto):";
44 rpmGraph(rpmts ts, struct rpmInstallArguments_s * ia, const char ** fileArgv)
47 const char ** pkgURL = NULL;
48 char * pkgState = NULL;
50 const char * fileURL = NULL;
55 const char ** argv = NULL;
57 const char ** av = NULL;
68 if (ia->qva_flags & VERIFY_DIGEST)
69 vsflags |= _RPMVSF_NODIGESTS;
70 if (ia->qva_flags & VERIFY_SIGNATURE)
71 vsflags |= _RPMVSF_NOSIGNATURES;
72 ovsflags = rpmtsSetVSFlags(ts, vsflags);
74 /* Build fully globbed list of arguments in argv[argc]. */
75 for (fnp = fileArgv; *fnp; fnp++) {
78 rc = rpmGlob(*fnp, &ac, &av);
79 if (rc || ac == 0) continue;
81 argv = xrealloc(argv, (argc+2) * sizeof(*argv));
82 memcpy(argv+argc, av, ac * sizeof(*av));
86 av = _free(av); ac = 0;
89 /* Allocate sufficient storage for next set of args. */
90 if (pkgx >= numPkgs) {
91 numPkgs = pkgx + argc;
92 pkgURL = xrealloc(pkgURL, (numPkgs + 1) * sizeof(*pkgURL));
93 memset(pkgURL + pkgx, 0, ((argc + 1) * sizeof(*pkgURL)));
94 pkgState = xrealloc(pkgState, (numPkgs + 1) * sizeof(*pkgState));
95 memset(pkgState + pkgx, 0, ((argc + 1) * sizeof(*pkgState)));
98 /* Copy next set of args. */
99 for (i = 0; i < argc; i++) {
100 fileURL = _free(fileURL);
104 pkgURL[pkgx] = fileURL;
108 fileURL = _free(fileURL);
110 /* Continue processing file arguments, building transaction set. */
111 for (fnp = pkgURL+prevx; *fnp != NULL; fnp++, prevx++) {
112 const char * fileName;
115 (void) urlPath(*fnp, &fileName);
117 /* Try to read the header from a package file. */
118 fd = Fopen(*fnp, "r.ufdio");
119 if (fd == NULL || Ferror(fd)) {
120 rpmlog(RPMERR_OPEN, _("open of %s failed: %s\n"), *fnp,
126 numFailed++; *fnp = NULL;
130 /* Read the header, verifying signatures (if present). */
131 ovsflags = rpmtsSetVSFlags(ts, vsflags);
132 rpmrc = rpmReadPackageFile(ts, fd, *fnp, &h);
133 ovsflags = rpmtsSetVSFlags(ts, ovsflags);
140 rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), *fnp);
141 numFailed++; *fnp = NULL;
144 rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName, 0, NULL);
154 /* Try to read a package manifest. */
155 fd = Fopen(*fnp, "r.fpio");
156 if (fd == NULL || Ferror(fd)) {
157 rpmlog(RPMERR_OPEN, _("open of %s failed: %s\n"), *fnp,
163 numFailed++; *fnp = NULL;
167 /* Read list of packages from manifest. */
168 rc = rpmReadPackageManifest(fd, &argc, &argv);
170 rpmlog(RPMERR_MANIFEST, _("%s: read manifest failed: %s\n"),
171 fileURL, Fstrerror(fd));
175 /* If successful, restart the query loop. */
181 numFailed++; *fnp = NULL;
185 if (numFailed > 0) goto exit;
190 numFailed += numPkgs;
193 ps = rpmtsProblems(ts);
194 if (rpmpsNumProblems(ps) > 0) {
195 rpmlog(RPMLOG_ERR, _("Failed dependencies:\n"));
196 rpmpsPrint(NULL, ps);
197 numFailed += numPkgs;
199 if (ts->suggests != NULL && ts->nsuggests > 0) {
200 rpmlog(RPMLOG_NOTICE, _(" Suggested resolutions:\n"));
201 for (i = 0; i < ts->nsuggests; i++) {
202 const char * str = ts->suggests[i];
207 rpmlog(RPMLOG_NOTICE, "\t%s\n", str);
208 ts->suggests[i] = NULL;
211 ts->suggests = _free(ts->suggests);
224 unsigned char * selected =
225 alloca(sizeof(*selected) * (rpmtsNElements(ts) + 1));
226 int oType = TR_ADDED;
228 fprintf(stdout, "digraph XXX {\n");
230 fprintf(stdout, " rankdir=LR\n");
232 fprintf(stdout, "//===== Packages:\n");
234 while ((p = rpmtsiNext(pi, oType)) != NULL) {
235 fprintf(stdout, "//%5d%5d %s\n", rpmteTree(p), rpmteDepth(p), rpmteN(p));
238 fprintf(stdout, " \"%s\" -> \"%s\"\n", rpmteN(p), rpmteN(q));
240 fprintf(stdout, " \"%s\"\n", rpmteN(p));
241 fprintf(stdout, " { rank=max ; \"%s\" }\n", rpmteN(p));
246 fprintf(stdout, "}\n");
252 for (i = 0; i < numPkgs; i++)
253 pkgURL[i] = _free(pkgURL[i]);
254 pkgState = _free(pkgState);
255 pkgURL = _free(pkgURL);
261 static struct poptOption optionsTable[] = {
262 { "check", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noDeps, 0,
263 N_("don't verify package dependencies"), NULL },
264 { "nolegacy", '\0', POPT_BIT_SET, &vsflags, RPMVSF_NEEDPAYLOAD,
265 N_("don't verify header+payload signature"), NULL },
266 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
267 N_("Common options for all rpm modes and executables:"),
276 main(int argc, char *argv[])
279 struct rpmInstallArguments_s * ia = &rpmIArgs;
283 optCon = rpmcliInit(argc, argv, optionsTable);
288 if (rpmcliQueryFlags & VERIFY_DIGEST)
289 vsflags |= _RPMVSF_NODIGESTS;
290 if (rpmcliQueryFlags & VERIFY_SIGNATURE)
291 vsflags |= _RPMVSF_NOSIGNATURES;
292 if (rpmcliQueryFlags & VERIFY_HDRCHK)
293 vsflags |= RPMVSF_NOHDRCHK;
294 (void) rpmtsSetVSFlags(ts, vsflags);
296 ec = rpmGraph(ts, ia, poptGetArgs(optCon));
300 optCon = rpmcliFini(optCon);