2 * Copyright (c) 2009, Novell Inc.
4 * This program is licensed under the BSD license, read LICENSE.BSD
5 * for further information
8 /* solv, a little software installer demoing the sat solver library */
10 /* things available in the library but missing from solv:
11 * - vendor policy loading
12 * - soft locks file handling
13 * - multi version handling
26 #include <sys/utsname.h>
27 #include <sys/types.h>
32 #include <sys/socket.h>
44 #include "solverdebug.h"
46 #include "repo_solv.h"
48 #include "repo_write.h"
49 #include "repo_rpmdb.h"
50 #include "repo_products.h"
51 #include "repo_rpmmd.h"
52 #include "repo_susetags.h"
53 #include "repo_repomdxml.h"
54 #include "repo_updateinfoxml.h"
55 #include "repo_deltainfoxml.h"
56 #include "repo_content.h"
57 #include "pool_fileconflicts.h"
61 # define REPOINFO_PATH "/etc/yum.repos.d"
63 # define REPOINFO_PATH "/etc/zypp/repos.d"
64 # define PRODUCTS_PATH "/etc/products.d"
65 # define SOFTLOCKS_PATH "/var/lib/zypp/SoftLocks"
68 #define SOLVCACHE_PATH "/var/cache/solv"
70 #define METADATA_EXPIRE (60 * 90)
90 unsigned char cookie[32];
91 unsigned char extcookie[32];
96 yum_substitute(Pool *pool, char *line)
99 static char *releaseevr;
100 static char *basearch;
104 sat_free(releaseevr);
111 while ((p2 = strchr(p, '$')) != 0)
113 if (!strncmp(p2, "$releasever", 11))
120 rpm_installedrpmdbids(0, "Providename", "redhat-release", &q);
123 void *handle, *state = 0;
125 handle = rpm_byrpmdbid(q.elements[0], 0, &state);
126 releaseevr = rpm_query(handle, SOLVABLE_EVR);
127 rpm_byrpmdbid(0, 0, &state);
128 if ((p = strchr(releaseevr, '-')) != 0)
133 releaseevr = strdup("?");
136 p = pool_tmpjoin(pool, line, releaseevr, p2 + 11);
137 p2 = p + (p2 - line);
139 p = p2 + strlen(releaseevr);
142 if (!strncmp(p2, "$basearch", 9))
152 basearch = strdup(un.machine);
153 if (basearch[0] == 'i' && basearch[1] && !strcmp(basearch + 2, "86"))
157 p = pool_tmpjoin(pool, line, basearch, p2 + 9);
158 p2 = p + (p2 - line);
160 p = p2 + strlen(basearch);
169 #define TYPE_UNKNOWN 0
170 #define TYPE_SUSETAGS 1
172 #define TYPE_PLAINDIR 3
175 read_repoinfos_sort(const void *ap, const void *bp)
177 const struct repoinfo *a = ap;
178 const struct repoinfo *b = bp;
179 return strcmp(a->alias, b->alias);
183 read_repoinfos(Pool *pool, const char *reposdir, int *nrepoinfosp)
186 char buf2[4096], *kp, *vp, *kpe;
191 struct repoinfo *repoinfos = 0, *cinfo;
194 rdlen = strlen(reposdir);
195 dir = opendir(reposdir);
201 while ((ent = readdir(dir)) != 0)
203 l = strlen(ent->d_name);
204 if (l < 6 || rdlen + 2 + l >= sizeof(buf) || strcmp(ent->d_name + l - 5, ".repo") != 0)
206 snprintf(buf, sizeof(buf), "%s/%s", reposdir, ent->d_name);
207 if ((fp = fopen(buf, "r")) == 0)
213 while(fgets(buf2, sizeof(buf2), fp))
218 while (l && (buf2[l - 1] == '\n' || buf2[l - 1] == ' ' || buf2[l - 1] == '\t'))
221 while (*kp == ' ' || *kp == '\t')
223 if (!*kp || *kp == '#')
227 kp = yum_substitute(pool, kp);
231 vp = strrchr(kp, ']');
235 repoinfos = sat_extend(repoinfos, nrepoinfos, 1, sizeof(*repoinfos), 15);
236 cinfo = repoinfos + nrepoinfos++;
237 memset(cinfo, 0, sizeof(*cinfo));
238 cinfo->alias = strdup(kp + 1);
239 cinfo->type = TYPE_RPMMD;
240 cinfo->autorefresh = 1;
241 cinfo->priority = 99;
243 cinfo->repo_gpgcheck = 1;
245 cinfo->metadata_expire = METADATA_EXPIRE;
250 vp = strchr(kp, '=');
253 for (kpe = vp - 1; kpe >= kp; kpe--)
254 if (*kpe != ' ' && *kpe != '\t')
259 while (*vp == ' ' || *vp == '\t')
262 if (!strcmp(kp, "name"))
263 cinfo->name = strdup(vp);
264 else if (!strcmp(kp, "enabled"))
265 cinfo->enabled = *vp == '0' ? 0 : 1;
266 else if (!strcmp(kp, "autorefresh"))
267 cinfo->autorefresh = *vp == '0' ? 0 : 1;
268 else if (!strcmp(kp, "gpgcheck"))
269 cinfo->pkgs_gpgcheck = *vp == '0' ? 0 : 1;
270 else if (!strcmp(kp, "repo_gpgcheck"))
271 cinfo->repo_gpgcheck = *vp == '0' ? 0 : 1;
272 else if (!strcmp(kp, "baseurl"))
273 cinfo->baseurl = strdup(vp);
274 else if (!strcmp(kp, "mirrorlist"))
276 if (strstr(vp, "metalink"))
277 cinfo->metalink = strdup(vp);
279 cinfo->mirrorlist = strdup(vp);
281 else if (!strcmp(kp, "path"))
283 if (vp && strcmp(vp, "/") != 0)
284 cinfo->path = strdup(vp);
286 else if (!strcmp(kp, "type"))
288 if (!strcmp(vp, "yast2"))
289 cinfo->type = TYPE_SUSETAGS;
290 else if (!strcmp(vp, "rpm-md"))
291 cinfo->type = TYPE_RPMMD;
292 else if (!strcmp(vp, "plaindir"))
293 cinfo->type = TYPE_PLAINDIR;
295 cinfo->type = TYPE_UNKNOWN;
297 else if (!strcmp(kp, "priority"))
298 cinfo->priority = atoi(vp);
299 else if (!strcmp(kp, "keeppackages"))
300 cinfo->keeppackages = *vp == '0' ? 0 : 1;
306 qsort(repoinfos, nrepoinfos, sizeof(*repoinfos), read_repoinfos_sort);
307 *nrepoinfosp = nrepoinfos;
312 free_repoinfos(struct repoinfo *repoinfos, int nrepoinfos)
315 for (i = 0; i < nrepoinfos; i++)
317 struct repoinfo *cinfo = repoinfos + i;
318 sat_free(cinfo->name);
319 sat_free(cinfo->alias);
320 sat_free(cinfo->path);
321 sat_free(cinfo->metalink);
322 sat_free(cinfo->mirrorlist);
323 sat_free(cinfo->baseurl);
334 strcpy(tmpl, "/var/tmp/solvXXXXXX");
346 verify_checksum(int fd, const char *file, const unsigned char *chksum, Id chksumtype)
353 h = sat_chksum_create(chksumtype);
356 printf("%s: unknown checksum type\n", file);
359 while ((l = read(fd, buf, sizeof(buf))) > 0)
360 sat_chksum_add(h, buf, l);
361 lseek(fd, 0, SEEK_SET);
363 sum = sat_chksum_get(h, &l);
364 if (memcmp(sum, chksum, l))
366 printf("%s: checksum mismatch\n", file);
367 sat_chksum_free(h, 0);
370 sat_chksum_free(h, 0);
375 findfastest(char **urls, int nurls)
382 struct addrinfo hints, *result;;
384 fds = sat_calloc(nurls, sizeof(*fds));
385 socks = sat_calloc(nurls, sizeof(*socks));
386 for (i = 0; i < nurls; i++)
389 p = strchr(urls[i], '/');
402 if ((p2 = strchr(p, '@')) != 0)
405 if (!strncmp("https:", urls[i], 6))
407 else if (!strncmp("ftp:", urls[i], 4))
409 if ((p2 = strrchr(p, ':')) != 0)
418 sprintf(portstr, "%d", port);
419 memset(&hints, 0, sizeof(struct addrinfo));
420 hints.ai_family = AF_UNSPEC;
421 hints.ai_socktype = SOCK_STREAM;
422 hints.ai_flags = AI_NUMERICSERV;
424 if (!getaddrinfo(p, portstr, &hints, &result))
426 socks[i] = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
429 fcntl(socks[i], F_SETFL, O_NONBLOCK);
430 if (connect(socks[i], result->ai_addr, result->ai_addrlen) == -1)
432 if (errno != EINPROGRESS)
439 freeaddrinfo(result);
446 for (i = j = 0; i < nurls; i++)
450 fds[j].fd = socks[i];
451 fds[j].events = POLLOUT;
459 if (poll(fds, j, 10000) <= 0)
461 i = -1; /* something is wrong */
464 for (i = 0; i < j; i++)
465 if ((fds[i].revents & POLLOUT) != 0)
468 socklen_t soel = sizeof(int);
469 if (getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, &soe, &soel) == -1 || soe != 0)
471 /* connect failed, kill socket */
472 for (j = 0; j < nurls; j++)
473 if (socks[j] == fds[i].fd)
486 i = -1; /* something is wrong, no bit was set */
489 /* now i contains the fastest fd index */
492 for (j = 0; j < nurls; j++)
493 if (socks[j] == fds[i].fd)
497 char *url0 = urls[0];
502 for (i = j = 0; i < nurls; i++)
510 findmetalinkurl(FILE *fp, unsigned char *chksump, Id *chksumtypep)
512 char buf[4096], *bp, *ep;
519 while((bp = fgets(buf, sizeof(buf), fp)) != 0)
521 while (*bp == ' ' || *bp == '\t')
523 if (chksumtypep && !*chksumtypep && !strncmp(bp, "<hash type=\"sha256\">", 20))
528 memset(chksump, 0, 32);
529 for (i = 0; i < 64; i++)
532 if (c >= '0' && c <= '9')
533 chksump[i / 2] = chksump[i / 2] * 16 + (c - '0');
534 else if (c >= 'a' && c <= 'f')
535 chksump[i / 2] = chksump[i / 2] * 16 + (c - ('a' - 10));
536 else if (c >= 'A' && c <= 'F')
537 chksump[i / 2] = chksump[i / 2] * 16 + (c - ('A' - 10));
542 *chksumtypep = REPOKEY_TYPE_SHA256;
545 if (strncmp(bp, "<url", 4))
547 bp = strchr(bp, '>');
551 ep = strstr(bp, "repodata/repomd.xml</url>");
555 if (strncmp(bp, "http", 4))
557 urls = sat_extend(urls, nurls, 1, sizeof(*urls), 15);
558 urls[nurls++] = strdup(bp);
563 findfastest(urls, nurls > 5 ? 5 : nurls);
566 for (i = 0; i < nurls; i++)
569 ep = strchr(bp, '/');
570 if ((ep = strchr(ep + 2, '/')) != 0)
573 printf("[using mirror %s]\n", bp);
582 findmirrorlisturl(FILE *fp)
584 char buf[4096], *bp, *ep;
589 while((bp = fgets(buf, sizeof(buf), fp)) != 0)
591 while (*bp == ' ' || *bp == '\t')
593 if (!*bp || *bp == '#')
596 while (l > 0 && (bp[l - 1] == ' ' || bp[l - 1] == '\t' || bp[l - 1] == '\n'))
598 urls = sat_extend(urls, nurls, 1, sizeof(*urls), 15);
599 urls[nurls++] = strdup(bp);
604 findfastest(urls, nurls > 5 ? 5 : nurls);
607 for (i = 0; i < nurls; i++)
610 ep = strchr(bp, '/');
611 if ((ep = strchr(ep + 2, '/')) != 0)
614 printf("[using mirror %s]\n", bp);
623 cookie_gzread(void *cookie, char *buf, size_t nbytes)
625 return gzread((gzFile *)cookie, buf, nbytes);
629 cookie_gzclose(void *cookie)
631 return gzclose((gzFile *)cookie);
635 curlfopen(struct repoinfo *cinfo, const char *file, int uncompress, const unsigned char *chksum, Id chksumtype, int *badchecksump)
641 const char *baseurl = cinfo->baseurl;
645 if (!cinfo->metalink && !cinfo->mirrorlist)
647 if (file != cinfo->metalink && file != cinfo->mirrorlist)
649 FILE *fp = curlfopen(cinfo, cinfo->metalink ? cinfo->metalink : cinfo->mirrorlist, 0, 0, 0, 0);
650 unsigned char mlchksum[32];
655 cinfo->baseurl = findmetalinkurl(fp, mlchksum, &mlchksumtype);
657 cinfo->baseurl = findmirrorlisturl(fp);
662 if (strchr(cinfo->baseurl, '$'))
664 char *b = yum_substitute(cinfo->repo->pool, cinfo->baseurl);
665 free(cinfo->baseurl);
666 cinfo->baseurl = strdup(b);
669 if (!chksumtype && mlchksumtype && !strcmp(file, "repodata/repomd.xml"))
671 chksumtype = mlchksumtype;
674 return curlfopen(cinfo, file, uncompress, chksum, chksumtype, badchecksump);
676 snprintf(url, sizeof(url), "%s", file);
681 if (l && baseurl[l - 1] == '/')
682 snprintf(url, sizeof(url), "%s%s", baseurl, file);
684 snprintf(url, sizeof(url), "%s/%s", baseurl, file);
687 // printf("url: %s\n", url);
688 if ((pid = fork()) == (pid_t)-1)
700 execlp("curl", "curl", "-f", "-s", "-L", url, (char *)0);
705 while (waitpid(pid, &status, 0) != pid)
707 if (lseek(fd, 0, SEEK_END) == 0 && (!status || !chksumtype))
713 lseek(fd, 0, SEEK_SET);
716 printf("%s: download error %d\n", file, status >> 8 ? status >> 8 : status);
722 if (chksumtype && !verify_checksum(fd, file, chksum, chksumtype))
732 cookie_io_functions_t cio;
735 sprintf(tmpl, "/dev/fd/%d", fd);
736 gzf = gzopen(tmpl, "r");
740 fprintf(stderr, "could not open /dev/fd/%d, /proc not mounted?\n", fd);
743 memset(&cio, 0, sizeof(cio));
744 cio.read = cookie_gzread;
745 cio.close = cookie_gzclose;
746 return fopencookie(gzf, "r", cio);
748 fcntl(fd, F_SETFD, FD_CLOEXEC);
749 return fdopen(fd, "r");
753 cleanupgpg(char *gpgdir)
756 snprintf(cmd, sizeof(cmd), "%s/pubring.gpg", gpgdir);
758 snprintf(cmd, sizeof(cmd), "%s/pubring.gpg~", gpgdir);
760 snprintf(cmd, sizeof(cmd), "%s/secring.gpg", gpgdir);
762 snprintf(cmd, sizeof(cmd), "%s/trustdb.gpg", gpgdir);
764 snprintf(cmd, sizeof(cmd), "%s/keys", gpgdir);
770 checksig(Pool *sigpool, FILE *fp, FILE *sigfp)
779 off_t posfp, possigfp;
782 gpgdir = mkdtemp(pool_tmpjoin(sigpool, "/var/tmp/solvgpg.XXXXXX", 0, 0));
785 keysfile = pool_tmpjoin(sigpool, gpgdir, "/keys", 0);
786 if (!(kfp = fopen(keysfile, "w")) )
792 for (p = 1, s = sigpool->solvables + p; p < sigpool->nsolvables; p++, s++)
796 pubkey = solvable_lookup_str(s, SOLVABLE_DESCRIPTION);
797 if (!pubkey || !*pubkey)
799 if (fwrite(pubkey, strlen(pubkey), 1, kfp) != 1)
801 if (fputc('\n', kfp) == EOF) /* Just in case... */
805 if (fclose(kfp) || !nkeys)
810 snprintf(cmd, sizeof(cmd), "gpg2 -q --homedir %s --import %s", gpgdir, keysfile);
813 fprintf(stderr, "key import error\n");
818 posfp = lseek(fileno(fp), 0, SEEK_CUR);
819 lseek(fileno(fp), 0, SEEK_SET);
820 possigfp = lseek(fileno(sigfp), 0, SEEK_CUR);
821 lseek(fileno(sigfp), 0, SEEK_SET);
822 snprintf(cmd, sizeof(cmd), "gpg -q --homedir %s --verify /dev/fd/%d /dev/fd/%d >/dev/null 2>&1", gpgdir, fileno(sigfp), fileno(fp));
823 fcntl(fileno(fp), F_SETFD, 0); /* clear CLOEXEC */
824 fcntl(fileno(sigfp), F_SETFD, 0); /* clear CLOEXEC */
826 lseek(fileno(sigfp), possigfp, SEEK_SET);
827 lseek(fileno(fp), posfp, SEEK_SET);
828 fcntl(fileno(fp), F_SETFD, FD_CLOEXEC);
829 fcntl(fileno(sigfp), F_SETFD, FD_CLOEXEC);
831 return r == 0 ? 1 : 0;
834 #define CHKSUM_IDENT "1.1"
837 calc_checksum_fp(FILE *fp, Id chktype, unsigned char *out)
840 void *h = sat_chksum_create(chktype);
843 sat_chksum_add(h, CHKSUM_IDENT, strlen(CHKSUM_IDENT));
844 while ((l = fread(buf, 1, sizeof(buf), fp)) > 0)
845 sat_chksum_add(h, buf, l);
847 sat_chksum_free(h, out);
851 calc_checksum_stat(struct stat *stb, Id chktype, unsigned char *out)
853 void *h = sat_chksum_create(chktype);
854 sat_chksum_add(h, CHKSUM_IDENT, strlen(CHKSUM_IDENT));
855 sat_chksum_add(h, &stb->st_dev, sizeof(stb->st_dev));
856 sat_chksum_add(h, &stb->st_ino, sizeof(stb->st_ino));
857 sat_chksum_add(h, &stb->st_size, sizeof(stb->st_size));
858 sat_chksum_add(h, &stb->st_mtime, sizeof(stb->st_mtime));
859 sat_chksum_free(h, out);
871 pool_setarch(pool, un.machine);
874 char *calccachepath(Repo *repo, const char *repoext)
876 char *q, *p = pool_tmpjoin(repo->pool, SOLVCACHE_PATH, "/", repo->name);
879 p = pool_tmpjoin(repo->pool, p, "_", repoext);
880 p = pool_tmpjoin(repo->pool, p, ".solvx", 0);
883 p = pool_tmpjoin(repo->pool, p, ".solv", 0);
884 q = p + strlen(SOLVCACHE_PATH) + 1;
894 usecachedrepo(Repo *repo, const char *repoext, unsigned char *cookie, int mark)
897 unsigned char mycookie[32];
898 unsigned char myextcookie[32];
899 struct repoinfo *cinfo;
902 cinfo = repo->appdata;
903 if (!(fp = fopen(calccachepath(repo, repoext), "r")))
905 if (fseek(fp, -sizeof(mycookie), SEEK_END) || fread(mycookie, sizeof(mycookie), 1, fp) != 1)
910 if (cookie && memcmp(cookie, mycookie, sizeof(mycookie)))
915 if (cinfo && !repoext)
917 if (fseek(fp, -sizeof(mycookie) * 2, SEEK_END) || fread(myextcookie, sizeof(myextcookie), 1, fp) != 1)
928 flags = REPO_USE_LOADING|REPO_EXTEND_SOLVABLES;
929 if (strcmp(repoext, "DL") != 0)
930 flags |= REPO_LOCALPOOL; /* no local pool for DL so that we can compare IDs */
933 if (repo_add_solv_flags(repo, fp, flags))
938 if (cinfo && !repoext)
940 memcpy(cinfo->cookie, mycookie, sizeof(mycookie));
941 memcpy(cinfo->extcookie, myextcookie, sizeof(myextcookie));
944 futimes(fileno(fp), 0); /* try to set modification time */
950 writecachedrepo(Repo *repo, Repodata *info, const char *repoext, unsigned char *cookie)
955 struct repoinfo *cinfo;
958 cinfo = repo->appdata;
959 mkdir(SOLVCACHE_PATH, 0755);
960 tmpl = sat_dupjoin(SOLVCACHE_PATH, "/", ".newsolv-XXXXXX");
968 if (!(fp = fdopen(fd, "w")))
977 for (i = repo->start; i < repo->end; i++)
978 if (repo->pool->solvables[i].repo != repo)
984 repo_write(repo, fp, repo_write_stdkeyfilter, 0, 0);
986 repodata_write(info, fp, repo_write_stdkeyfilter, 0);
989 int oldnrepodata = repo->nrepodata;
990 repo->nrepodata = 1; /* XXX: do this right */
991 repo_write(repo, fp, repo_write_stdkeyfilter, 0, 0);
992 repo->nrepodata = oldnrepodata;
996 if (!repoext && cinfo)
998 if (!cinfo->extcookie[0])
1000 /* create the ext cookie and append it */
1001 /* we just need some unique ID */
1003 if (!fstat(fileno(fp), &stb))
1007 calc_checksum_stat(&stb, REPOKEY_TYPE_SHA256, cinfo->extcookie);
1008 for (i = 0; i < 32; i++)
1009 cinfo->extcookie[i] ^= cookie[i];
1011 if (cinfo->extcookie[0] == 0)
1012 cinfo->extcookie[0] = 1;
1014 if (fwrite(cinfo->extcookie, 32, 1, fp) != 1)
1022 /* append our cookie describing the metadata state */
1023 if (fwrite(cookie, 32, 1, fp) != 1)
1038 /* switch to just saved repo to activate paging and save memory */
1039 FILE *fp = fopen(tmpl, "r");
1045 repo_empty(repo, 1);
1046 if (repo_add_solv_flags(repo, fp, SOLV_ADD_NO_STUBS))
1048 /* oops, no way to recover from here */
1049 fprintf(stderr, "internal error\n");
1055 /* make sure repodata contains complete repo */
1056 /* (this is how repodata_write saves it) */
1057 repodata_extend_block(info, repo->start, repo->end - repo->start);
1058 info->state = REPODATA_LOADING;
1059 /* no need for LOCALPOOL as pool already contains ids */
1060 repo_add_solv_flags(repo, fp, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES);
1061 info->state = REPODATA_AVAILABLE; /* in case the load failed */
1066 if (!rename(tmpl, calccachepath(repo, repoext)))
1075 Pool *sigpool = pool_create();
1076 Repo *repo = repo_create(sigpool, "rpmdbkeys");
1077 repo_add_rpmdb_pubkeys(repo, 0, 0);
1082 /* repomd helpers */
1084 static inline const char *
1085 repomd_find(Repo *repo, const char *what, const unsigned char **chksump, Id *chksumtypep)
1087 Pool *pool = repo->pool;
1089 const char *filename;
1094 dataiterator_init(&di, pool, repo, SOLVID_META, REPOSITORY_REPOMD_TYPE, what, SEARCH_STRING);
1095 dataiterator_prepend_keyname(&di, REPOSITORY_REPOMD);
1096 if (dataiterator_step(&di))
1098 dataiterator_setpos_parent(&di);
1099 filename = pool_lookup_str(pool, SOLVID_POS, REPOSITORY_REPOMD_LOCATION);
1100 *chksump = pool_lookup_bin_checksum(pool, SOLVID_POS, REPOSITORY_REPOMD_CHECKSUM, chksumtypep);
1102 dataiterator_free(&di);
1103 if (filename && !*chksumtypep)
1105 printf("no %s file checksum!\n", what);
1112 repomd_add_ext(Repo *repo, Repodata *data, const char *what)
1114 Pool *pool = repo->pool;
1116 Id chksumtype, handle;
1117 const unsigned char *chksum;
1118 const char *filename;
1120 dataiterator_init(&di, pool, repo, SOLVID_META, REPOSITORY_REPOMD_TYPE, what, SEARCH_STRING);
1121 dataiterator_prepend_keyname(&di, REPOSITORY_REPOMD);
1122 if (!dataiterator_step(&di))
1124 dataiterator_free(&di);
1127 if (!strcmp(what, "prestodelta"))
1129 dataiterator_setpos_parent(&di);
1130 filename = pool_lookup_str(pool, SOLVID_POS, REPOSITORY_REPOMD_LOCATION);
1131 chksum = pool_lookup_bin_checksum(pool, SOLVID_POS, REPOSITORY_REPOMD_CHECKSUM, &chksumtype);
1132 if (!filename || !chksum)
1134 dataiterator_free(&di);
1137 handle = repodata_new_handle(data);
1138 repodata_set_poolstr(data, handle, REPOSITORY_REPOMD_TYPE, what);
1139 repodata_set_str(data, handle, REPOSITORY_REPOMD_LOCATION, filename);
1141 repodata_set_bin_checksum(data, handle, REPOSITORY_REPOMD_CHECKSUM, chksumtype, chksum);
1142 if (!strcmp(what, "deltainfo"))
1144 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOSITORY_DELTAINFO);
1145 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_FLEXARRAY);
1147 if (!strcmp(what, "filelists"))
1149 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_FILELIST);
1150 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRSTRARRAY);
1152 dataiterator_free(&di);
1153 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_EXTERNAL, handle);
1158 /* susetags helpers */
1160 static inline const char *
1161 susetags_find(Repo *repo, const char *what, const unsigned char **chksump, Id *chksumtypep)
1163 Pool *pool = repo->pool;
1165 const char *filename;
1170 dataiterator_init(&di, pool, repo, SOLVID_META, SUSETAGS_FILE_NAME, what, SEARCH_STRING);
1171 dataiterator_prepend_keyname(&di, SUSETAGS_FILE);
1172 if (dataiterator_step(&di))
1174 dataiterator_setpos_parent(&di);
1175 *chksump = pool_lookup_bin_checksum(pool, SOLVID_POS, SUSETAGS_FILE_CHECKSUM, chksumtypep);
1178 dataiterator_free(&di);
1179 if (filename && !*chksumtypep)
1181 printf("no %s file checksum!\n", what);
1187 static Id susetags_langtags[] = {
1188 SOLVABLE_SUMMARY, REPOKEY_TYPE_STR,
1189 SOLVABLE_DESCRIPTION, REPOKEY_TYPE_STR,
1190 SOLVABLE_EULA, REPOKEY_TYPE_STR,
1191 SOLVABLE_MESSAGEINS, REPOKEY_TYPE_STR,
1192 SOLVABLE_MESSAGEDEL, REPOKEY_TYPE_STR,
1193 SOLVABLE_CATEGORY, REPOKEY_TYPE_ID,
1198 susetags_add_ext(Repo *repo, Repodata *data)
1200 Pool *pool = repo->pool;
1203 Id handle, filechksumtype;
1204 const unsigned char *filechksum;
1207 dataiterator_init(&di, pool, repo, SOLVID_META, SUSETAGS_FILE_NAME, 0, 0);
1208 dataiterator_prepend_keyname(&di, SUSETAGS_FILE);
1209 while (dataiterator_step(&di))
1211 if (strncmp(di.kv.str, "packages.", 9) != 0)
1213 if (!strcmp(di.kv.str + 9, "gz"))
1215 if (!di.kv.str[9] || !di.kv.str[10] || (di.kv.str[11] && di.kv.str[11] != '.'))
1217 ext[0] = di.kv.str[9];
1218 ext[1] = di.kv.str[10];
1220 if (!strcmp(ext, "en"))
1222 if (!susetags_find(repo, di.kv.str, &filechksum, &filechksumtype))
1224 handle = repodata_new_handle(data);
1225 repodata_set_str(data, handle, SUSETAGS_FILE_NAME, di.kv.str);
1227 repodata_set_bin_checksum(data, handle, SUSETAGS_FILE_CHECKSUM, filechksumtype, filechksum);
1228 if (!strcmp(ext, "DU"))
1230 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_DISKUSAGE);
1231 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRNUMNUMARRAY);
1233 else if (!strcmp(ext, "FL"))
1235 repodata_add_idarray(data, handle, REPOSITORY_KEYS, SOLVABLE_FILELIST);
1236 repodata_add_idarray(data, handle, REPOSITORY_KEYS, REPOKEY_TYPE_DIRSTRARRAY);
1240 for (i = 0; susetags_langtags[i]; i += 2)
1242 repodata_add_idarray(data, handle, REPOSITORY_KEYS, pool_id2langid(pool, susetags_langtags[i], ext, 1));
1243 repodata_add_idarray(data, handle, REPOSITORY_KEYS, susetags_langtags[i + 1]);
1246 repodata_add_flexarray(data, SOLVID_META, REPOSITORY_EXTERNAL, handle);
1248 dataiterator_free(&di);
1253 iscompressed(const char *name)
1255 int l = strlen(name);
1256 return l > 3 && !strcmp(name + l - 3, ".gz") ? 1 : 0;
1263 load_stub(Pool *pool, Repodata *data, void *dp)
1265 const char *filename, *descrdir, *repomdtype;
1266 const unsigned char *filechksum;
1268 struct repoinfo *cinfo;
1273 cinfo = data->repo->appdata;
1275 filename = repodata_lookup_str(data, SOLVID_META, SUSETAGS_FILE_NAME);
1279 ext[0] = filename[9];
1280 ext[1] = filename[10];
1283 printf("[%s:%s", data->repo->name, ext);
1285 if (usecachedrepo(data->repo, ext, cinfo->extcookie, 0))
1287 printf(" cached]\n"); fflush(stdout);
1291 printf(" fetching]\n"); fflush(stdout);
1293 defvendor = repo_lookup_id(data->repo, SOLVID_META, SUSETAGS_DEFAULTVENDOR);
1294 descrdir = repo_lookup_str(data->repo, SOLVID_META, SUSETAGS_DESCRDIR);
1296 descrdir = "suse/setup/descr";
1298 filechksum = repodata_lookup_bin_checksum(data, SOLVID_META, SUSETAGS_FILE_CHECKSUM, &filechksumtype);
1299 if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, 0)) == 0)
1301 repo_add_susetags(data->repo, fp, defvendor, ext, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES);
1303 writecachedrepo(data->repo, data, ext, cinfo->extcookie);
1307 repomdtype = repodata_lookup_str(data, SOLVID_META, REPOSITORY_REPOMD_TYPE);
1310 if (!strcmp(repomdtype, "filelists"))
1312 else if (!strcmp(repomdtype, "deltainfo"))
1317 printf("[%s:%s", data->repo->name, ext);
1319 if (usecachedrepo(data->repo, ext, cinfo->extcookie, 0))
1321 printf(" cached]\n");fflush(stdout);
1324 printf(" fetching]\n"); fflush(stdout);
1325 filename = repodata_lookup_str(data, SOLVID_META, REPOSITORY_REPOMD_LOCATION);
1327 filechksum = repodata_lookup_bin_checksum(data, SOLVID_META, REPOSITORY_REPOMD_CHECKSUM, &filechksumtype);
1328 if ((fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, 0)) == 0)
1330 if (!strcmp(ext, "FL"))
1331 repo_add_rpmmd(data->repo, fp, ext, REPO_USE_LOADING|REPO_EXTEND_SOLVABLES);
1332 else if (!strcmp(ext, "DL"))
1333 repo_add_deltainfoxml(data->repo, fp, REPO_USE_LOADING);
1335 writecachedrepo(data->repo, data, ext, cinfo->extcookie);
1342 static unsigned char installedcookie[32];
1345 read_repos(Pool *pool, struct repoinfo *repoinfos, int nrepoinfos)
1348 struct repoinfo *cinfo;
1352 const char *filename;
1353 const unsigned char *filechksum;
1355 const char *descrdir;
1363 repo = repo_create(pool, "@System");
1364 printf("rpm database:");
1365 if (stat("/var/lib/rpm/Packages", &stb))
1366 memset(&stb, 0, sizeof(&stb));
1367 calc_checksum_stat(&stb, REPOKEY_TYPE_SHA256, installedcookie);
1368 if (usecachedrepo(repo, 0, installedcookie, 0))
1369 printf(" cached\n");
1373 printf(" reading\n");
1376 #ifdef PRODUCTS_PATH
1377 repo_add_products(repo, PRODUCTS_PATH, 0, REPO_NO_INTERNALIZE);
1379 if ((ofp = fopen(calccachepath(repo, 0), "r")) != 0)
1381 Repo *ref = repo_create(pool, "@System.old");
1382 if (!repo_add_solv(ref, ofp))
1384 repo_add_rpmdb(repo, ref, 0, REPO_REUSE_REPODATA);
1391 repo_add_rpmdb(repo, 0, 0, REPO_REUSE_REPODATA);
1392 writecachedrepo(repo, 0, 0, installedcookie);
1394 pool_set_installed(pool, repo);
1396 for (i = 0; i < nrepoinfos; i++)
1398 cinfo = repoinfos + i;
1399 if (!cinfo->enabled)
1402 repo = repo_create(pool, cinfo->alias);
1404 repo->appdata = cinfo;
1405 repo->priority = 99 - cinfo->priority;
1407 dorefresh = cinfo->autorefresh;
1408 if (dorefresh && cinfo->metadata_expire && stat(calccachepath(repo, 0), &stb) == 0)
1410 if (cinfo->metadata_expire == -1 || time(0) - stb.st_mtime < cinfo->metadata_expire)
1413 if (!dorefresh && usecachedrepo(repo, 0, 0, 0))
1415 printf("repo '%s':", cinfo->alias);
1416 printf(" cached\n");
1420 switch (cinfo->type)
1423 printf("rpmmd repo '%s':", cinfo->alias);
1425 if ((fp = curlfopen(cinfo, "repodata/repomd.xml", 0, 0, 0, 0)) == 0)
1427 printf(" no repomd.xml file, skipped\n");
1432 calc_checksum_fp(fp, REPOKEY_TYPE_SHA256, cinfo->cookie);
1433 if (usecachedrepo(repo, 0, cinfo->cookie, 1))
1435 printf(" cached\n");
1439 if (cinfo->repo_gpgcheck)
1441 sigfp = curlfopen(cinfo, "repodata/repomd.xml.asc", 0, 0, 0, 0);
1444 printf(" unsigned, skipped\n");
1449 sigpool = read_sigs();
1450 if (!checksig(sigpool, fp, sigfp))
1452 printf(" checksig failed, skipped\n");
1459 repo_add_repomdxml(repo, fp, 0);
1461 printf(" fetching\n");
1462 filename = repomd_find(repo, "primary", &filechksum, &filechksumtype);
1463 if (filename && (fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
1465 repo_add_rpmmd(repo, fp, 0, 0);
1469 break; /* hopeless */
1471 filename = repomd_find(repo, "updateinfo", &filechksum, &filechksumtype);
1472 if (filename && (fp = curlfopen(cinfo, filename, iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
1474 repo_add_updateinfoxml(repo, fp, 0);
1478 data = repo_add_repodata(repo, 0);
1479 if (!repomd_add_ext(repo, data, "deltainfo"))
1480 repomd_add_ext(repo, data, "prestodelta");
1481 repomd_add_ext(repo, data, "filelists");
1482 repodata_internalize(data);
1484 writecachedrepo(repo, 0, 0, cinfo->cookie);
1485 repodata_create_stubs(repo_last_repodata(repo));
1489 printf("susetags repo '%s':", cinfo->alias);
1493 if ((fp = curlfopen(cinfo, "content", 0, 0, 0, 0)) == 0)
1495 printf(" no content file, skipped\n");
1500 calc_checksum_fp(fp, REPOKEY_TYPE_SHA256, cinfo->cookie);
1501 if (usecachedrepo(repo, 0, cinfo->cookie, 1))
1503 printf(" cached\n");
1507 if (cinfo->repo_gpgcheck)
1509 sigfp = curlfopen(cinfo, "content.asc", 0, 0, 0, 0);
1512 printf(" unsigned, skipped\n");
1519 sigpool = read_sigs();
1520 if (!checksig(sigpool, fp, sigfp))
1522 printf(" checksig failed, skipped\n");
1530 repo_add_content(repo, fp, 0);
1532 defvendor = repo_lookup_id(repo, SOLVID_META, SUSETAGS_DEFAULTVENDOR);
1533 descrdir = repo_lookup_str(repo, SOLVID_META, SUSETAGS_DESCRDIR);
1535 descrdir = "suse/setup/descr";
1536 filename = susetags_find(repo, "packages.gz", &filechksum, &filechksumtype);
1538 filename = susetags_find(repo, "packages", &filechksum, &filechksumtype);
1541 printf(" no packages file entry, skipped\n");
1544 printf(" fetching\n");
1545 if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, &badchecksum)) == 0)
1546 break; /* hopeless */
1547 repo_add_susetags(repo, fp, defvendor, 0, REPO_NO_INTERNALIZE);
1549 /* add default language */
1550 filename = susetags_find(repo, "packages.en.gz", &filechksum, &filechksumtype);
1552 filename = susetags_find(repo, "packages.en", &filechksum, &filechksumtype);
1555 if ((fp = curlfopen(cinfo, pool_tmpjoin(pool, descrdir, "/", filename), iscompressed(filename), filechksum, filechksumtype, &badchecksum)) != 0)
1557 repo_add_susetags(repo, fp, defvendor, 0, REPO_NO_INTERNALIZE|REPO_REUSE_REPODATA|REPO_EXTEND_SOLVABLES);
1561 repo_internalize(repo);
1562 data = repo_add_repodata(repo, 0);
1563 susetags_add_ext(repo, data);
1564 repodata_internalize(data);
1566 writecachedrepo(repo, 0, 0, cinfo->cookie);
1567 repodata_create_stubs(repo_last_repodata(repo));
1570 printf("unsupported repo '%s': skipped\n", cinfo->alias);
1582 str2archid(Pool *pool, char *arch)
1587 id = str2id(pool, arch, 0);
1588 if (id == ARCH_SRC || id == ARCH_NOSRC || id == ARCH_NOARCH)
1590 if (pool->id2arch && (id > pool->lastarch || !pool->id2arch[id]))
1596 #define DEPGLOB_NAME 1
1597 #define DEPGLOB_DEP 2
1598 #define DEPGLOB_NAMEDEP 3
1601 depglob(Pool *pool, char *name, Queue *job, int what)
1604 Id id = str2id(pool, name, 0);
1609 FOR_PROVIDES(p, pp, id)
1611 Solvable *s = pool->solvables + p;
1613 if (s->name == id && (what & DEPGLOB_NAME) != 0)
1615 queue_push2(job, SOLVER_SOLVABLE_NAME, id);
1621 if (what == DEPGLOB_NAMEDEP)
1622 printf("[using capability match for '%s']\n", name);
1623 queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
1628 if (strpbrk(name, "[*?") == 0)
1631 if ((what & DEPGLOB_NAME) != 0)
1633 /* looks like a name glob. hard work. */
1634 for (p = 1; p < pool->nsolvables; p++)
1636 Solvable *s = pool->solvables + p;
1637 if (!s->repo || !pool_installable(pool, s))
1640 if (fnmatch(name, id2str(pool, id), 0) == 0)
1642 for (i = 0; i < job->count; i += 2)
1643 if (job->elements[i] == SOLVER_SOLVABLE_NAME && job->elements[i + 1] == id)
1645 if (i == job->count)
1646 queue_push2(job, SOLVER_SOLVABLE_NAME, id);
1653 if ((what & DEPGLOB_DEP))
1655 /* looks like a dep glob. really hard work. */
1656 for (id = 1; id < pool->ss.nstrings; id++)
1658 if (!pool->whatprovides[id])
1660 if (fnmatch(name, id2str(pool, id), 0) == 0)
1662 if (!match && what == DEPGLOB_NAMEDEP)
1663 printf("[using capability match for '%s']\n", name);
1664 for (i = 0; i < job->count; i += 2)
1665 if (job->elements[i] == SOLVER_SOLVABLE_PROVIDES && job->elements[i + 1] == id)
1667 if (i == job->count)
1668 queue_push2(job, SOLVER_SOLVABLE_PROVIDES, id);
1679 limitrelation(Pool *pool, Queue *job, int flags, Id evr)
1683 for (i = j = 0; i < job->count; i += 2)
1685 Id select = job->elements[i] & SOLVER_SELECTMASK;
1686 if (select != SOLVER_SOLVABLE_NAME && select != SOLVER_SOLVABLE_PROVIDES)
1688 fprintf(stderr, "limitrelation only works on name/provides jobs\n");
1691 job->elements[i + 1] = rel2id(pool, job->elements[i + 1], evr, flags, 1);
1692 if (flags == REL_ARCH)
1693 job->elements[i] |= SOLVER_SETARCH;
1694 if (flags == REL_EQ && select == SOLVER_SOLVABLE_NAME && job->elements[i])
1696 const char *evrstr = id2str(pool, evr);
1697 if (strchr(evrstr, '-'))
1698 job->elements[i] |= SOLVER_SETEVR;
1700 job->elements[i] |= SOLVER_SETEV;
1702 /* make sure we still have matches */
1703 FOR_JOB_SELECT(p, pp, job->elements[i], job->elements[i + 1])
1707 job->elements[j] = job->elements[i];
1708 job->elements[j + 1] = job->elements[i + 1];
1712 queue_truncate(job, j);
1717 limitrelation_arch(Pool *pool, Queue *job, int flags, char *evr)
1721 if ((r = strrchr(evr, '.')) != 0 && r[1] && (archid = str2archid(pool, r + 1)) != 0)
1724 limitrelation(pool, job, REL_ARCH, archid);
1725 limitrelation(pool, job, flags, str2id(pool, evr, 1));
1729 limitrelation(pool, job, flags, str2id(pool, evr, 1));
1730 return job->count / 2;
1734 limitrepo(Pool *pool, Id repofilter, Queue *job)
1742 for (i = j = 0; i < job->count; i += 2)
1745 FOR_JOB_SELECT(p, pp, job->elements[i], job->elements[i + 1])
1747 s = pool_id2solvable(pool, p);
1748 if (s->repo && s->repo->repoid == repofilter)
1753 /* here we assume that repo == vendor, so we also set SOLVER_SETVENDOR */
1756 job->elements[j] = SOLVER_SOLVABLE | (job->elements[i] & SOLVER_SETMASK) | SOLVER_SETVENDOR | SOLVER_SETREPO | SOLVER_NOAUTOSET;
1757 job->elements[j + 1] = mq.elements[0];
1761 job->elements[j] = SOLVER_SOLVABLE_ONE_OF | (job->elements[i] & SOLVER_SETMASK) | SOLVER_SETVENDOR | SOLVER_SETREPO;
1762 job->elements[j + 1] = pool_queuetowhatprovides(pool, &mq);
1767 queue_truncate(job, j);
1773 mkselect(Pool *pool, int mode, char *name, Queue *job)
1784 dataiterator_init(&di, pool, mode == SOLVER_ERASE ? pool->installed : 0, 0, SOLVABLE_FILELIST, name, SEARCH_STRING|SEARCH_FILES|SEARCH_COMPLETE_FILELIST);
1785 while (dataiterator_step(&di))
1787 Solvable *s = pool->solvables + di.solvid;
1788 if (!s->repo || !pool_installable(pool, s))
1790 queue_push(&q, di.solvid);
1791 dataiterator_skip_solvable(&di);
1793 dataiterator_free(&di);
1796 printf("[using file list match for '%s']\n", name);
1798 queue_push2(job, SOLVER_SOLVABLE_ONE_OF, pool_queuetowhatprovides(pool, &q));
1800 queue_push2(job, SOLVER_SOLVABLE | SOLVER_NOAUTOSET, q.elements[0]);
1802 return job->count / 2;
1805 if ((r = strpbrk(name, "<=>")) != 0)
1807 /* relation case, support:
1812 int nend = r - name;
1825 while (*r && *r == ' ' && *r == '\t')
1827 while (nend && (name[nend - 1] == ' ' || name[nend -1 ] == '\t'))
1831 fprintf(stderr, "bad relation\n");
1834 oldnend = name[nend];
1836 if (depglob(pool, name, job, DEPGLOB_NAMEDEP))
1838 name[nend] = oldnend;
1839 limitrelation(pool, job, rflags, str2id(pool, r, 1));
1840 return job->count / 2;
1842 if ((r2 = strrchr(name, '.')) != 0 && r2[1] && (archid = str2archid(pool, r2 + 1)) != 0)
1845 if (depglob(pool, name, job, DEPGLOB_NAMEDEP))
1847 name[nend] = oldnend;
1849 limitrelation(pool, job, REL_ARCH, archid);
1850 limitrelation(pool, job, rflags, str2id(pool, r, 1));
1851 return job->count / 2;
1855 name[nend] = oldnend;
1859 /* no relation case, support:
1863 * nameglob-version.arch
1864 * nameglob-version-release
1865 * nameglob-version-release.arch
1867 if (depglob(pool, name, job, DEPGLOB_NAMEDEP))
1868 return job->count / 2;
1869 if ((r = strrchr(name, '.')) != 0 && r[1] && (archid = str2archid(pool, r + 1)) != 0)
1872 if (depglob(pool, name, job, DEPGLOB_NAMEDEP))
1875 limitrelation(pool, job, REL_ARCH, archid);
1876 return job->count / 2;
1880 if ((r = strrchr(name, '-')) != 0)
1883 if (depglob(pool, name, job, DEPGLOB_NAME))
1885 /* have just the version */
1886 limitrelation_arch(pool, job, REL_EQ, r + 1);
1888 return job->count / 2;
1890 if ((r2 = strrchr(name, '-')) != 0)
1895 if (depglob(pool, name, job, DEPGLOB_NAME))
1897 /* have version-release */
1898 limitrelation_arch(pool, job, REL_EQ, r + 1);
1900 return job->count / 2;
1911 yesno(const char *str)
1913 char inbuf[128], *ip;
1920 if (!(ip = fgets(inbuf, sizeof(inbuf), stdin)))
1925 while (*ip == ' ' || *ip == '\t')
1932 if (*ip == 'y' || *ip == 'n')
1933 return *ip == 'y' ? 1 : 0;
1945 fileconflict_cb(Pool *pool, Id p, void *cbdata)
1947 struct fcstate *fcstate = cbdata;
1955 rpm_byrpmdbid(0, 0, &fcstate->rpmdbstate);
1958 s = pool_id2solvable(pool, p);
1959 if (pool->installed && s->repo == pool->installed)
1961 if (!s->repo->rpmdbid)
1963 rpmdbid = s->repo->rpmdbid[p - s->repo->start];
1966 return rpm_byrpmdbid(rpmdbid, 0, &fcstate->rpmdbstate);
1968 for (i = 0; i < fcstate->newpkgscnt; i++)
1969 if (fcstate->checkq->elements[i] == p)
1971 if (i == fcstate->newpkgscnt)
1973 fp = fcstate->newpkgsfps[i];
1977 return rpm_byfp(fp, solvable2str(pool, s), &fcstate->rpmdbstate);
1981 runrpm(const char *arg, const char *name, int dupfd3)
1986 if ((pid = fork()) == (pid_t)-1)
1993 if (dupfd3 != -1 && dupfd3 != 3)
1999 fcntl(3, F_SETFD, 0); /* clear CLOEXEC */
2000 if (strcmp(arg, "-e") == 0)
2001 execlp("rpm", "rpm", arg, "--nodeps", "--nodigest", "--nosignature", name, (char *)0);
2003 execlp("rpm", "rpm", arg, "--force", "--nodeps", "--nodigest", "--nosignature", name, (char *)0);
2007 while (waitpid(pid, &status, 0) != pid)
2011 printf("rpm failed\n");
2017 nscallback(Pool *pool, void *data, Id name, Id evr)
2019 if (name == NAMESPACE_PRODUCTBUDDY)
2021 /* SUSE specific hack: each product has an associated rpm */
2022 Solvable *s = pool->solvables + evr;
2025 cap = str2id(pool, pool_tmpjoin(pool, "product(", id2str(pool, s->name) + 8, ")"), 0);
2028 cap = rel2id(pool, cap, s->evr, REL_EQ, 0);
2031 FOR_PROVIDES(p, pp, cap)
2033 Solvable *ps = pool->solvables + p;
2034 if (ps->repo == s->repo && ps->arch == s->arch)
2042 #ifdef SOFTLOCKS_PATH
2045 addsoftlocks(Pool *pool, Queue *job)
2049 char *bp, *ep, buf[4096];
2051 if ((fp = fopen(SOFTLOCKS_PATH, "r")) == 0)
2053 while((bp = fgets(buf, sizeof(buf), fp)) != 0)
2055 while (*bp == ' ' || *bp == '\t')
2057 if (!*bp || *bp == '#')
2059 for (ep = bp; *ep; ep++)
2060 if (*ep == ' ' || *ep == '\t' || *ep == '\n')
2063 type = SOLVER_SOLVABLE_NAME;
2064 if (!strncmp(bp, "provides:", 9) && bp[9])
2066 type = SOLVER_SOLVABLE_PROVIDES;
2069 id = str2id(pool, bp, 1);
2070 if (pool->installed)
2072 FOR_JOB_SELECT(p, pp, type, id)
2073 if (pool->solvables[p].repo == pool->installed)
2076 continue; /* ignore, as it is already installed */
2078 queue_push2(job, SOLVER_LOCK|SOLVER_WEAK|type, id);
2087 rewrite_repos(Pool *pool, Id *addedfileprovides)
2092 Queue fileprovidesq;
2094 int i, j, n, nprovidedids;
2095 struct repoinfo *cinfo;
2097 map_init(&providedids, pool->ss.nstrings);
2098 queue_init(&fileprovidesq);
2099 for (nprovidedids = 0; (id = addedfileprovides[nprovidedids]) != 0; nprovidedids++)
2100 MAPSET(&providedids, id);
2103 /* make sure this repo has just one main repodata */
2104 if (!repo->nrepodata)
2106 cinfo = repo->appdata;
2107 data = repo->repodata + 0;
2108 if (data->store.pagefd == -1)
2110 if (repodata_lookup_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, &fileprovidesq))
2113 for (j = 0; j < fileprovidesq.count; j++)
2114 if (MAPTST(&providedids, fileprovidesq.elements[j]))
2116 if (n == nprovidedids)
2117 continue; /* nothing new added */
2120 for (j = 0; addedfileprovides[j]; j++)
2121 repodata_add_idarray(data, SOLVID_META, REPOSITORY_ADDEDFILEPROVIDES, addedfileprovides[j]);
2122 repodata_internalize(data);
2123 writecachedrepo(repo, data, 0, cinfo ? cinfo->cookie : installedcookie);
2125 queue_free(&fileprovidesq);
2126 map_free(&providedids);
2130 #define MODE_INSTALL 1
2131 #define MODE_ERASE 2
2132 #define MODE_UPDATE 3
2133 #define MODE_DISTUPGRADE 4
2134 #define MODE_VERIFY 5
2135 #define MODE_PATCH 6
2137 #define MODE_REPOLIST 8
2138 #define MODE_SEARCH 9
2139 #define MODE_ERASECLEAN 10
2144 fprintf(stderr, "Usage: solv COMMAND <select>\n");
2145 fprintf(stderr, "\n");
2146 fprintf(stderr, " dist-upgrade: replace installed packages with\n");
2147 fprintf(stderr, " versions from the repositories\n");
2148 fprintf(stderr, " erase: erase installed packages\n");
2149 fprintf(stderr, " info: display package information\n");
2150 fprintf(stderr, " install: install packages\n");
2151 fprintf(stderr, " list: list packages\n");
2152 fprintf(stderr, " repos: list enabled repositories\n");
2153 fprintf(stderr, " search: search name/summary/description\n");
2154 fprintf(stderr, " update: update installed packages\n");
2155 fprintf(stderr, " verify: check dependencies of installed packages\n");
2156 fprintf(stderr, "\n");
2161 main(int argc, char **argv)
2164 Repo *commandlinerepo = 0;
2165 Id *commandlinepkgs = 0;
2167 struct repoinfo *repoinfos;
2169 int mainmode = 0, mode = 0;
2174 char inbuf[128], *ip;
2177 struct fcstate fcstate;
2178 Id *addedfileprovides = 0;
2185 if (!strcmp(argv[0], "install") || !strcmp(argv[0], "in"))
2187 mainmode = MODE_INSTALL;
2188 mode = SOLVER_INSTALL;
2190 else if (!strcmp(argv[0], "patch"))
2192 mainmode = MODE_PATCH;
2193 mode = SOLVER_INSTALL;
2195 else if (!strcmp(argv[0], "erase") || !strcmp(argv[0], "rm"))
2197 mainmode = MODE_ERASE;
2198 mode = SOLVER_ERASE;
2200 else if (!strcmp(argv[0], "eraseclean") || !strcmp(argv[0], "rmclean"))
2202 mainmode = MODE_ERASECLEAN;
2203 mode = SOLVER_ERASE;
2205 else if (!strcmp(argv[0], "list"))
2207 mainmode = MODE_LIST;
2210 else if (!strcmp(argv[0], "info"))
2212 mainmode = MODE_INFO;
2215 else if (!strcmp(argv[0], "search"))
2217 mainmode = MODE_SEARCH;
2220 else if (!strcmp(argv[0], "verify"))
2222 mainmode = MODE_VERIFY;
2223 mode = SOLVER_VERIFY;
2225 else if (!strcmp(argv[0], "update") || !strcmp(argv[0], "up"))
2227 mainmode = MODE_UPDATE;
2228 mode = SOLVER_UPDATE;
2230 else if (!strcmp(argv[0], "dist-upgrade") || !strcmp(argv[0], "dup"))
2232 mainmode = MODE_DISTUPGRADE;
2233 mode = SOLVER_UPDATE;
2235 else if (!strcmp(argv[0], "repos") || !strcmp(argv[0], "repolist") || !strcmp(argv[0], "lr"))
2237 mainmode = MODE_REPOLIST;
2243 pool = pool_create();
2247 const char *langs[] = {"de_DE", "de", "en"};
2248 pool_set_languages(pool, langs, sizeof(langs)/sizeof(*langs));
2253 pool->obsoleteusescolors = 1;
2255 pool_setloadcallback(pool, load_stub, 0);
2256 pool->nscallback = nscallback;
2257 // pool_setdebuglevel(pool, 2);
2259 repoinfos = read_repoinfos(pool, REPOINFO_PATH, &nrepoinfos);
2261 if (mainmode == MODE_REPOLIST)
2264 for (i = 0; i < nrepoinfos; i++)
2266 struct repoinfo *cinfo = repoinfos + i;
2267 if (!cinfo->enabled)
2269 printf("%d: %-20s %s (prio %d)\n", j++, cinfo->alias, cinfo->name, cinfo->priority);
2274 read_repos(pool, repoinfos, nrepoinfos);
2276 if (argc > 2 && !strcmp(argv[1], "-r"))
2278 const char *rname = argv[2], *rp;
2279 for (rp = rname; *rp; rp++)
2280 if (*rp <= '0' || *rp >= '9')
2284 /* repo specified by number */
2285 int rnum = atoi(rname);
2286 for (i = 0; i < nrepoinfos; i++)
2288 struct repoinfo *cinfo = repoinfos + i;
2289 if (!cinfo->enabled)
2292 repofilter = cinfo->repo->repoid;
2297 /* repo specified by alias */
2301 if (!strcasecmp(rname, repo->name))
2302 repofilter = repo->repoid;
2307 fprintf(stderr, "%s: no such repo\n", rname);
2313 if (mainmode == MODE_SEARCH)
2319 map_init(&m, pool->nsolvables);
2320 dataiterator_init(&di, pool, 0, 0, 0, argv[1], SEARCH_SUBSTRING|SEARCH_NOCASE);
2321 dataiterator_set_keyname(&di, SOLVABLE_NAME);
2322 dataiterator_set_search(&di, 0, 0);
2323 while (dataiterator_step(&di))
2324 MAPSET(&m, di.solvid);
2325 dataiterator_set_keyname(&di, SOLVABLE_SUMMARY);
2326 dataiterator_set_search(&di, 0, 0);
2327 while (dataiterator_step(&di))
2328 MAPSET(&m, di.solvid);
2329 dataiterator_set_keyname(&di, SOLVABLE_DESCRIPTION);
2330 dataiterator_set_search(&di, 0, 0);
2331 while (dataiterator_step(&di))
2332 MAPSET(&m, di.solvid);
2333 dataiterator_free(&di);
2335 for (p = 1; p < pool->nsolvables; p++)
2337 Solvable *s = pool_id2solvable(pool, p);
2340 printf(" - %s: %s\n", solvable2str(pool, s), solvable_lookup_str(s, SOLVABLE_SUMMARY));
2347 if (mainmode == MODE_LIST || mainmode == MODE_INSTALL)
2349 for (i = 1; i < argc; i++)
2352 l = strlen(argv[i]);
2353 if (l <= 4 || strcmp(argv[i] + l - 4, ".rpm"))
2355 if (access(argv[i], R_OK))
2360 if (!commandlinepkgs)
2361 commandlinepkgs = sat_calloc(argc, sizeof(Id));
2362 if (!commandlinerepo)
2363 commandlinerepo = repo_create(pool, "@commandline");
2364 repo_add_rpms(commandlinerepo, (const char **)argv + i, 1, REPO_REUSE_REPODATA|REPO_NO_INTERNALIZE);
2365 commandlinepkgs[i] = commandlinerepo->end - 1;
2367 if (commandlinerepo)
2368 repo_internalize(commandlinerepo);
2371 // FOR_REPOS(i, repo)
2372 // printf("%s: %d solvables\n", repo->name, repo->nsolvables);
2373 addedfileprovides = 0;
2374 pool_addfileprovides_ids(pool, 0, &addedfileprovides);
2375 if (addedfileprovides && *addedfileprovides)
2376 rewrite_repos(pool, addedfileprovides);
2377 sat_free(addedfileprovides);
2378 pool_createwhatprovides(pool);
2381 for (i = 1; i < argc; i++)
2386 if (commandlinepkgs && commandlinepkgs[i])
2388 queue_push2(&job, SOLVER_SOLVABLE, commandlinepkgs[i]);
2392 if (!mkselect(pool, mode, argv[i], &job2))
2394 fprintf(stderr, "nothing matches '%s'\n", argv[i]);
2397 if (repofilter && !limitrepo(pool, repofilter, &job2))
2399 fprintf(stderr, "nothing in repo matches '%s'\n", argv[i]);
2402 for (j = 0; j < job2.count; j++)
2403 queue_push(&job, job2.elements[j]);
2407 if (!job.count && mainmode != MODE_UPDATE && mainmode != MODE_DISTUPGRADE && mainmode != MODE_VERIFY && mainmode != MODE_PATCH)
2409 printf("no package matched\n");
2416 if (mainmode == MODE_LIST || mainmode == MODE_INFO)
2418 /* list mode, no solver needed */
2419 for (i = 0; i < job.count; i += 2)
2421 FOR_JOB_SELECT(p, pp, job.elements[i], job.elements[i + 1])
2423 Solvable *s = pool_id2solvable(pool, p);
2424 if (mainmode == MODE_INFO)
2426 printf("Name: %s\n", solvable2str(pool, s));
2427 printf("Repo: %s\n", s->repo->name);
2428 printf("Summary: %s\n", solvable_lookup_str(s, SOLVABLE_SUMMARY));
2429 printf("Url: %s\n", solvable_lookup_str(s, SOLVABLE_URL));
2430 printf("License: %s\n", solvable_lookup_str(s, SOLVABLE_LICENSE));
2431 printf("Description:\n%s\n", solvable_lookup_str(s, SOLVABLE_DESCRIPTION));
2437 const char *sum = solvable_lookup_str_lang(s, SOLVABLE_SUMMARY, "de", 1);
2439 const char *sum = solvable_lookup_str_poollang(s, SOLVABLE_SUMMARY);
2441 printf(" - %s [%s]\n", solvable2str(pool, s), s->repo->name);
2443 printf(" %s\n", sum);
2449 free_repoinfos(repoinfos, nrepoinfos);
2450 sat_free(commandlinepkgs);
2452 yum_substitute(pool, 0);
2457 if (mainmode == MODE_PATCH)
2463 map_init(&installedmap, pool->nsolvables);
2464 if (pool->installed)
2465 FOR_REPO_SOLVABLES(pool->installed, p, s)
2466 MAPSET(&installedmap, p);
2468 /* install all patches */
2469 for (p = 1; p < pool->nsolvables; p++)
2475 s = pool->solvables + p;
2476 if (strncmp(id2str(pool, s->name), "patch:", 6) != 0)
2478 FOR_PROVIDES(p2, pp, s->name)
2480 Solvable *s2 = pool->solvables + p2;
2481 if (s2->name != s->name)
2483 r = evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE);
2484 if (r < 0 || (r == 0 && p > p2))
2489 type = solvable_lookup_str(s, SOLVABLE_PATCHCATEGORY);
2490 if (type && !strcmp(type, "optional"))
2492 r = solvable_trivial_installable_map(s, &installedmap, 0);
2495 if (solvable_lookup_bool(s, UPDATE_RESTART) && r == 0)
2502 queue_push2(&job, SOLVER_SOLVABLE, p);
2504 map_free(&installedmap);
2508 for (i = 0; i < job.count; i += 2)
2510 if (mode == SOLVER_UPDATE)
2512 /* make update of not installed packages an install */
2513 FOR_JOB_SELECT(p, pp, job.elements[i], job.elements[i + 1])
2514 if (pool->installed && pool->solvables[p].repo == pool->installed)
2518 job.elements[i] |= SOLVER_INSTALL;
2522 job.elements[i] |= mode;
2523 if (mainmode == MODE_ERASECLEAN)
2524 job.elements[i] |= SOLVER_CLEANDEPS;
2527 if (mainmode == MODE_DISTUPGRADE && allpkgs && repofilter)
2528 queue_push2(&job, SOLVER_DISTUPGRADE|SOLVER_SOLVABLE_REPO, repofilter);
2530 // multiversion test
2531 // queue_push2(&job, SOLVER_NOOBSOLETES|SOLVER_SOLVABLE_NAME, str2id(pool, "kernel-pae", 1));
2532 // queue_push2(&job, SOLVER_NOOBSOLETES|SOLVER_SOLVABLE_NAME, str2id(pool, "kernel-pae-base", 1));
2533 // queue_push2(&job, SOLVER_NOOBSOLETES|SOLVER_SOLVABLE_NAME, str2id(pool, "kernel-pae-extra", 1));
2535 #ifdef SOFTLOCKS_PATH
2536 addsoftlocks(pool, &job);
2542 Id problem, solution;
2545 solv = solver_create(pool);
2546 solv->ignorealreadyrecommended = 1;
2547 solv->updatesystem = allpkgs && !repofilter && (mainmode == MODE_UPDATE || mainmode == MODE_DISTUPGRADE);
2548 solv->dosplitprovides = solv->updatesystem;
2549 solv->fixsystem = allpkgs && !repofilter && mainmode == MODE_VERIFY;
2550 if (mainmode == MODE_DISTUPGRADE && allpkgs && !repofilter)
2552 solv->distupgrade = 1;
2553 solv->allowdowngrade = 1;
2554 solv->allowarchchange = 1;
2555 solv->allowvendorchange = 1;
2557 if (mainmode == MODE_ERASE || mainmode == MODE_ERASECLEAN)
2558 solv->allowuninstall = 1; /* don't nag */
2560 solver_solve(solv, &job);
2561 if (!solv->problems.count)
2563 pcnt = solver_problem_count(solv);
2564 printf("Found %d problems:\n", pcnt);
2565 for (problem = 1; problem <= pcnt; problem++)
2568 printf("Problem %d:\n", problem);
2569 solver_printprobleminfo(solv, problem);
2571 scnt = solver_solution_count(solv, problem);
2572 for (solution = 1; solution <= scnt; solution++)
2574 printf("Solution %d:\n", solution);
2575 solver_printsolution(solv, problem, solution);
2580 printf("Please choose a solution: ");
2583 if (!(ip = fgets(inbuf, sizeof(inbuf), stdin)))
2588 while (*ip == ' ' || *ip == '\t')
2590 if (*ip >= '0' && *ip <= '9')
2593 if (take >= 1 && take <= scnt)
2609 solver_take_solution(solv, problem, take, &job);
2615 trans = &solv->trans;
2616 if (!trans->steps.count)
2618 printf("Nothing to do.\n");
2622 printf("Transaction summary:\n\n");
2623 solver_printtransaction(solv);
2632 duc[1].path = "/usr/share/man";
2633 duc[2].path = "/sbin";
2634 duc[3].path = "/etc";
2635 transaction_calc_duchanges(trans, duc, 4);
2636 for (i = 0; i < 4; i++)
2637 printf("duchanges %s: %d K %d inodes\n", duc[i].path, duc[i].kbytes, duc[i].files);
2640 printf("install size change: %d K\n", transaction_calc_installsizechange(trans));
2643 if (!yesno("OK to continue (y/n)? "))
2649 free_repoinfos(repoinfos, nrepoinfos);
2650 sat_free(commandlinepkgs);
2652 yum_substitute(pool, 0);
2657 queue_init(&checkq);
2658 newpkgs = transaction_installedresult(trans, &checkq);
2663 int downloadsize = 0;
2664 for (i = 0; i < newpkgs; i++)
2668 p = checkq.elements[i];
2669 s = pool_id2solvable(pool, p);
2670 downloadsize += solvable_lookup_num(s, SOLVABLE_DOWNLOADSIZE, 0);
2672 printf("Downloading %d packages, %d K\n", newpkgs, downloadsize);
2673 newpkgsfps = sat_calloc(newpkgs, sizeof(*newpkgsfps));
2674 for (i = 0; i < newpkgs; i++)
2676 unsigned int medianr;
2679 struct repoinfo *cinfo;
2680 const unsigned char *chksum;
2684 p = checkq.elements[i];
2685 s = pool_id2solvable(pool, p);
2686 if (s->repo == commandlinerepo)
2688 loc = solvable_get_location(s, &medianr);
2689 if (!(newpkgsfps[i] = fopen(loc, "r")))
2697 cinfo = s->repo->appdata;
2700 printf("%s: no repository information\n", s->repo->name);
2703 loc = solvable_get_location(s, &medianr);
2707 if (pool->installed && pool->installed->nsolvables)
2709 /* try a delta first */
2710 char *matchname = strdup(id2str(pool, s->name));
2711 dataiterator_init(&di, pool, s->repo, SOLVID_META, DELTA_PACKAGE_NAME, matchname, SEARCH_STRING);
2712 dataiterator_prepend_keyname(&di, REPOSITORY_DELTAINFO);
2713 while (dataiterator_step(&di))
2717 dataiterator_setpos_parent(&di);
2718 if (pool_lookup_id(pool, SOLVID_POS, DELTA_PACKAGE_EVR) != s->evr ||
2719 pool_lookup_id(pool, SOLVID_POS, DELTA_PACKAGE_ARCH) != s->arch)
2721 baseevr = pool_lookup_id(pool, SOLVID_POS, DELTA_BASE_EVR);
2722 FOR_PROVIDES(op, pp, s->name)
2724 Solvable *os = pool->solvables + op;
2725 if (os->repo == pool->installed && os->name == s->name && os->arch == s->arch && os->evr == baseevr)
2728 if (op && access("/usr/bin/applydeltarpm", X_OK) == 0)
2730 /* base is installed, run sequence check */
2731 const char *seqname;
2740 seqname = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NAME);
2741 seqevr = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_EVR);
2742 seqnum = pool_lookup_str(pool, SOLVID_POS, DELTA_SEQ_NUM);
2743 seq = pool_tmpjoin(pool, seqname, "-", seqevr);
2744 seq = pool_tmpjoin(pool, seq, "-", seqnum);
2746 sprintf(cmd, "/usr/bin/applydeltarpm -a %s -c -s ", id2str(pool, s->arch));
2748 sprintf(cmd, "/usr/bin/applydeltarpm -c -s ");
2750 if (system(pool_tmpjoin(pool, cmd, seq, 0)) != 0)
2751 continue; /* didn't match */
2752 /* looks good, download delta */
2754 chksum = pool_lookup_bin_checksum(pool, SOLVID_POS, DELTA_CHECKSUM, &chksumtype);
2756 continue; /* no way! */
2757 dloc = pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_DIR);
2758 dloc = pool_tmpjoin(pool, dloc, "/", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_NAME));
2759 dloc = pool_tmpjoin(pool, dloc, "-", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_EVR));
2760 dloc = pool_tmpjoin(pool, dloc, ".", pool_lookup_str(pool, SOLVID_POS, DELTA_LOCATION_SUFFIX));
2761 if ((fp = curlfopen(cinfo, dloc, 0, chksum, chksumtype, 0)) == 0)
2763 /* got it, now reconstruct */
2764 newfd = opentmpfile();
2766 sprintf(cmd, "applydeltarpm -a %s /dev/fd/%d /dev/fd/%d", id2str(pool, s->arch), fileno(fp), newfd);
2768 sprintf(cmd, "applydeltarpm /dev/fd/%d /dev/fd/%d", fileno(fp), newfd);
2770 fcntl(fileno(fp), F_SETFD, 0);
2777 lseek(newfd, 0, SEEK_SET);
2779 chksum = solvable_lookup_bin_checksum(s, SOLVABLE_CHECKSUM, &chksumtype);
2780 if (chksumtype && !verify_checksum(newfd, loc, chksum, chksumtype))
2786 newpkgsfps[i] = fdopen(newfd, "r");
2791 dataiterator_free(&di);
2792 sat_free(matchname);
2799 continue; /* delta worked! */
2801 if (cinfo->type == TYPE_SUSETAGS)
2803 const char *datadir = repo_lookup_str(cinfo->repo, SOLVID_META, SUSETAGS_DATADIR);
2804 loc = pool_tmpjoin(pool, datadir ? datadir : "suse", "/", loc);
2807 chksum = solvable_lookup_bin_checksum(s, SOLVABLE_CHECKSUM, &chksumtype);
2808 if ((newpkgsfps[i] = curlfopen(cinfo, loc, 0, chksum, chksumtype, 0)) == 0)
2810 printf("\n%s: %s not found in repository\n", s->repo->name, loc);
2823 printf("Searching for file conflicts\n");
2824 queue_init(&conflicts);
2825 fcstate.rpmdbstate = 0;
2826 fcstate.newpkgscnt = newpkgs;
2827 fcstate.checkq = &checkq;
2828 fcstate.newpkgsfps = newpkgsfps;
2829 pool_findfileconflicts(pool, &checkq, newpkgs, &conflicts, &fileconflict_cb, &fcstate);
2830 if (conflicts.count)
2833 for (i = 0; i < conflicts.count; i += 5)
2834 printf("file %s of package %s conflicts with package %s\n", id2str(pool, conflicts.elements[i]), solvid2str(pool, conflicts.elements[i + 1]), solvid2str(pool, conflicts.elements[i + 3]));
2836 if (yesno("Re-run solver (y/n/q)? "))
2838 for (i = 0; i < newpkgs; i++)
2840 fclose(newpkgsfps[i]);
2841 newpkgsfps = sat_free(newpkgsfps);
2843 pool_add_fileconflicts_deps(pool, &conflicts);
2844 pool_createwhatprovides(pool); /* Hmm... */
2848 queue_free(&conflicts);
2851 printf("Committing transaction:\n\n");
2852 transaction_order(trans, 0);
2853 for (i = 0; i < trans->steps.count; i++)
2855 const char *evr, *evrp, *nvra;
2860 p = trans->steps.elements[i];
2861 s = pool_id2solvable(pool, p);
2862 Id type = transaction_type(trans, p, SOLVER_TRANSACTION_RPM_ONLY);
2865 case SOLVER_TRANSACTION_ERASE:
2866 printf("erase %s\n", solvid2str(pool, p));
2867 if (!s->repo->rpmdbid || !s->repo->rpmdbid[p - s->repo->start])
2869 /* strip epoch from evr */
2870 evr = evrp = id2str(pool, s->evr);
2871 while (*evrp >= '0' && *evrp <= '9')
2873 if (evrp > evr && evrp[0] == ':' && evrp[1])
2875 nvra = pool_tmpjoin(pool, id2str(pool, s->name), "-", evr);
2876 nvra = pool_tmpjoin(pool, nvra, ".", id2str(pool, s->arch));
2877 runrpm("-e", nvra, -1); /* to bad that --querybynumber doesn't work */
2879 case SOLVER_TRANSACTION_INSTALL:
2880 case SOLVER_TRANSACTION_MULTIINSTALL:
2881 printf("install %s\n", solvid2str(pool, p));
2882 for (j = 0; j < newpkgs; j++)
2883 if (checkq.elements[j] == p)
2885 fp = j < newpkgs ? newpkgsfps[j] : 0;
2889 lseek(fileno(fp), 0, SEEK_SET);
2890 runrpm(type == SOLVER_TRANSACTION_MULTIINSTALL ? "-i" : "-U", "/dev/fd/3", fileno(fp));
2899 for (i = 0; i < newpkgs; i++)
2901 fclose(newpkgsfps[i]);
2902 sat_free(newpkgsfps);
2903 queue_free(&checkq);
2907 free_repoinfos(repoinfos, nrepoinfos);
2908 sat_free(commandlinepkgs);
2910 yum_substitute(pool, 0);