/* * Copyright (c) 2009-2015, SUSE LLC. * * This program is licensed under the BSD license, read LICENSE.BSD * for further information */ /* solv, a little software installer demoing the sat solver library */ /* things it does: * - understands globs for package names / dependencies * - understands .arch suffix * - installation of commandline packages * - repository data caching * - on demand loading of secondary repository data * - gpg and checksum verification * - file conflicts * - deltarpm support * - fastestmirror implementation * * things available in the library but missing from solv: * - vendor policy loading * - multi version handling */ #include #include #include #include #include "pool.h" #include "poolarch.h" #include "evr.h" #include "selection.h" #include "repo.h" #include "solver.h" #include "solverdebug.h" #include "transaction.h" #include "testcase.h" #ifdef SUSE #include "repo_autopattern.h" #endif #include "repoinfo.h" #include "repoinfo_cache.h" #include "repoinfo_download.h" #if defined(ENABLE_RPMDB) #include "fileprovides.h" #include "fileconflicts.h" #include "deltarpm.h" #endif #if defined(SUSE) || defined(FEDORA) || defined(MAGEIA) #include "patchjobs.h" #endif void setarch(Pool *pool) { struct utsname un; if (uname(&un)) { perror("uname"); exit(1); } pool_setarch(pool, un.machine); } int yesno(const char *str, int other) { char inbuf[128], *ip; for (;;) { printf("%s", str); fflush(stdout); *inbuf = 0; if (!(ip = fgets(inbuf, sizeof(inbuf), stdin))) { printf("Abort.\n"); exit(1); } while (*ip == ' ' || *ip == '\t') ip++; if (*ip == 'q') { printf("Abort.\n"); exit(1); } if (*ip == 'y' || *ip == 'n' || *ip == other) return *ip == 'n' ? 0 : *ip; } } #ifdef SUSE static Id nscallback(Pool *pool, void *data, Id name, Id evr) { #if 0 if (name == NAMESPACE_LANGUAGE) { if (!strcmp(pool_id2str(pool, evr), "ja")) return 1; if (!strcmp(pool_id2str(pool, evr), "de")) return 1; if (!strcmp(pool_id2str(pool, evr), "en")) return 1; if (!strcmp(pool_id2str(pool, evr), "en_US")) return 1; } #endif return 0; } #endif #ifdef SUSE static void showdiskusagechanges(Transaction *trans) { DUChanges duc[4]; int i; /* XXX: use mountpoints here */ memset(duc, 0, sizeof(duc)); duc[0].path = "/"; duc[1].path = "/usr/share/man"; duc[2].path = "/sbin"; duc[3].path = "/etc"; transaction_calc_duchanges(trans, duc, 4); for (i = 0; i < 4; i++) printf("duchanges %s: %lld K %lld inodes\n", duc[i].path, duc[i].kbytes, duc[i].files); } #endif static Id find_repo(const char *name, Pool *pool, struct repoinfo *repoinfos, int nrepoinfos) { const char *rp; int i; for (rp = name; *rp; rp++) if (*rp <= '0' || *rp >= '9') break; if (!*rp) { /* repo specified by number */ int rnum = atoi(name); for (i = 0; i < nrepoinfos; i++) { struct repoinfo *cinfo = repoinfos + i; if (!cinfo->enabled || !cinfo->repo) continue; if (--rnum == 0) return cinfo->repo->repoid; } } else { /* repo specified by alias */ Repo *repo; FOR_REPOS(i, repo) { if (!strcasecmp(name, repo->name)) return repo->repoid; } } return 0; } #define MODE_LIST 0 #define MODE_INSTALL 1 #define MODE_ERASE 2 #define MODE_UPDATE 3 #define MODE_DISTUPGRADE 4 #define MODE_VERIFY 5 #define MODE_PATCH 6 #define MODE_INFO 7 #define MODE_REPOLIST 8 #define MODE_SEARCH 9 void usage(int r) { fprintf(stderr, "Usage: solv COMMAND