2 const char *__progname;
4 #include <rpm/rpmcli.h>
5 #include <rpm/rpmlib.h> /* rpmReadPackageFile */
10 #include <rpm/rpmds.h>
12 #include <rpm/rpmlog.h>
13 #include <rpm/rpmfileutil.h>
15 #include "lib/manifest.h"
18 static int noDeps = 1;
20 static rpmVSFlags vsflags = 0;
23 rpmGraph(rpmts ts, struct rpmInstallArguments_s * ia, const char ** fileArgv)
25 char ** pkgURL = NULL;
26 char * pkgState = NULL;
28 char * fileURL = NULL;
46 /* Build fully globbed list of arguments in argv[argc]. */
47 for (fnp = fileArgv; *fnp; fnp++) {
50 rc = rpmGlob(*fnp, &ac, &av);
51 if (rc || ac == 0) continue;
53 argv = xrealloc(argv, (argc+2) * sizeof(*argv));
54 memcpy(argv+argc, av, ac * sizeof(*av));
58 av = _free(av); ac = 0;
61 /* Allocate sufficient storage for next set of args. */
62 if (pkgx >= numPkgs) {
63 numPkgs = pkgx + argc;
64 pkgURL = xrealloc(pkgURL, (numPkgs + 1) * sizeof(*pkgURL));
65 memset(pkgURL + pkgx, 0, ((argc + 1) * sizeof(*pkgURL)));
66 pkgState = xrealloc(pkgState, (numPkgs + 1) * sizeof(*pkgState));
67 memset(pkgState + pkgx, 0, ((argc + 1) * sizeof(*pkgState)));
70 /* Copy next set of args. */
71 for (i = 0; i < argc; i++) {
72 fileURL = _free(fileURL);
76 pkgURL[pkgx] = fileURL;
80 fileURL = _free(fileURL);
82 /* Continue processing file arguments, building transaction set. */
83 for (fnp = (const char **) pkgURL+prevx; *fnp != NULL; fnp++, prevx++) {
84 const char * fileName;
87 (void) urlPath(*fnp, &fileName);
89 /* Try to read the header from a package file. */
90 fd = Fopen(*fnp, "r.ufdio");
91 if (fd == NULL || Ferror(fd)) {
92 rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *fnp,
98 numFailed++; *fnp = NULL;
102 /* Read the header, verifying signatures (if present). */
103 ovsflags = rpmtsSetVSFlags(ts, vsflags);
104 rpmrc = rpmReadPackageFile(ts, fd, *fnp, &h);
105 rpmtsSetVSFlags(ts, ovsflags);
112 rpmlog(RPMLOG_ERR, _("%s cannot be installed\n"), *fnp);
113 numFailed++; *fnp = NULL;
116 rc = rpmtsAddInstallElement(ts, h, (fnpyKey)fileName, 0, NULL);
126 /* Try to read a package manifest. */
127 fd = Fopen(*fnp, "r.ufdio");
128 if (fd == NULL || Ferror(fd)) {
129 rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), *fnp,
135 numFailed++; *fnp = NULL;
139 /* Read list of packages from manifest. */
140 rc = rpmReadPackageManifest(fd, &argc, &argv);
142 rpmlog(RPMLOG_NOTICE, _("%s: read manifest failed: %s\n"),
143 fileURL, Fstrerror(fd));
147 /* If successful, restart the query loop. */
153 numFailed++; *fnp = NULL;
157 if (numFailed > 0) goto exit;
163 numFailed += numPkgs;
166 ps = rpmtsProblems(ts);
167 if (rpmpsNumProblems(ps) > 0) {
168 rpmlog(RPMLOG_ERR, _("Failed dependencies:\n"));
169 rpmpsPrint(NULL, ps);
170 numFailed += numPkgs;
182 int oType = TR_ADDED;
184 fprintf(stdout, "digraph XXX {\n");
186 fprintf(stdout, " rankdir=LR\n");
188 fprintf(stdout, "//===== Packages:\n");
190 while ((p = rpmtsiNext(pi, oType)) != NULL) {
193 fprintf(stdout, " \"%s\" -> \"%s\"\n", rpmteN(p), rpmteN(q));
195 fprintf(stdout, " \"%s\"\n", rpmteN(p));
196 fprintf(stdout, " { rank=max ; \"%s\" }\n", rpmteN(p));
201 fprintf(stdout, "}\n");
207 for (i = 0; i < numPkgs; i++)
208 pkgURL[i] = _free(pkgURL[i]);
209 pkgState = _free(pkgState);
210 pkgURL = _free(pkgURL);
216 static struct poptOption optionsTable[] = {
217 { "check", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN, &noDeps, 0,
218 N_("don't verify package dependencies"), NULL },
219 { "nolegacy", '\0', POPT_BIT_SET, &vsflags, RPMVSF_NEEDPAYLOAD,
220 N_("don't verify header+payload signature"), NULL },
221 { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmcliAllPoptTable, 0,
222 N_("Common options for all rpm modes and executables:"),
231 main(int argc, char *argv[])
234 struct rpmInstallArguments_s * ia = &rpmIArgs;
238 optCon = rpmcliInit(argc, argv, optionsTable);
243 if (rpmcliQueryFlags & VERIFY_DIGEST)
244 vsflags |= _RPMVSF_NODIGESTS;
245 if (rpmcliQueryFlags & VERIFY_SIGNATURE)
246 vsflags |= _RPMVSF_NOSIGNATURES;
247 if (rpmcliQueryFlags & VERIFY_HDRCHK)
248 vsflags |= RPMVSF_NOHDRCHK;
249 (void) rpmtsSetVSFlags(ts, vsflags);
251 ec = rpmGraph(ts, ia, poptGetArgs(optCon));