1 #if defined(ENABLE_DEBIAN) && defined(DEBIAN)
14 #include "transaction.h"
17 #include "repoinfo_cache.h"
18 #include "repoinfo_system_debian.h"
21 rundpkg(const char *arg, const char *name, int dupfd3, const char *rootdir)
26 if ((pid = fork()) == (pid_t)-1)
35 if (dupfd3 != -1 && dupfd3 != 3)
41 fcntl(3, F_SETFD, 0); /* clear CLOEXEC */
42 if (strcmp(arg, "--install") == 0)
43 execlp("dpkg", "dpkg", "--install", "--root", rootdir, "--force", "all", name, (char *)0);
45 execlp("dpkg", "dpkg", "--remove", "--root", rootdir, "--force", "all", name, (char *)0);
49 while (waitpid(pid, &status, 0) != pid)
53 printf("dpkg failed\n");
59 read_installed_debian(struct repoinfo *cinfo)
62 Repo *repo = cinfo->repo;
63 Pool *pool = repo->pool;
65 memset(&stb, 0, sizeof(stb));
66 printf("dpgk database:");
67 if (stat(pool_prepend_rootdir_tmp(pool, "/var/lib/dpkg/status"), &stb))
68 memset(&stb, 0, sizeof(stb));
69 calc_cookie_stat(&stb, REPOKEY_TYPE_SHA256, 0, cinfo->cookie);
71 if (usecachedrepo(cinfo, 0, 0))
76 if (repo_add_debdb(repo, REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE | REPO_USE_ROOTDIR))
78 fprintf(stderr, "installed db: %s\n", pool_errstr(pool));
81 repo_internalize(repo);
82 writecachedrepo(cinfo, 0, 0);
87 commit_transactionelement_debian(Pool *pool, Id type, Id p, FILE *fp)
89 Solvable *s = pool_id2solvable(pool, p);
90 const char *rootdir = pool_get_rootdir(pool);
94 case SOLVER_TRANSACTION_ERASE:
95 rundpkg("--remove", pool_id2str(pool, s->name), 0, rootdir);
97 case SOLVER_TRANSACTION_INSTALL:
98 case SOLVER_TRANSACTION_MULTIINSTALL:
100 lseek(fileno(fp), 0, SEEK_SET);
101 rundpkg("--install", "/dev/fd/3", fileno(fp), rootdir);