processarc.c 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. /*
  2. * dpkg - main program for package management
  3. * processarc.c - the huge function process_archive
  4. *
  5. * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
  6. *
  7. * This is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2,
  10. * or (at your option) any later version.
  11. *
  12. * This is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public
  18. * License along with dpkg; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21. #include <errno.h>
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <stdlib.h>
  25. #include <unistd.h>
  26. #include <utime.h>
  27. #include <assert.h>
  28. #include <time.h>
  29. #include <ctype.h>
  30. #include <dirent.h>
  31. #include <fcntl.h>
  32. #include <sys/stat.h>
  33. #include <sys/types.h>
  34. #include <sys/wait.h>
  35. #include <config.h>
  36. #include <dpkg.h>
  37. #include <dpkg-db.h>
  38. #include <tarfn.h>
  39. #include <myopt.h>
  40. #include "filesdb.h"
  41. #include "main.h"
  42. #include "archives.h"
  43. void process_archive(const char *filename) {
  44. static const struct TarFunctions tf = {
  45. tarfileread,
  46. tarobject, tarobject, tarobject, tarobject, tarobject
  47. };
  48. /* These need to be static so that we can pass their addresses to
  49. * push_cleanup as arguments to the cu_xxx routines; if an error occurs
  50. * we unwind the stack before processing the cleanup list, and these
  51. * variables had better still exist ...
  52. */
  53. static int p1[2];
  54. static char cidirtmpnambuf[L_tmpnam+100];
  55. static char *cidirbuf=0, *reasmbuf=0;
  56. static struct fileinlist *newconffiles, *newfileslist;
  57. static enum pkgstatus oldversionstatus;
  58. static struct varbuf infofnvb, fnvb, depprobwhy;
  59. static struct tarcontext tc;
  60. int c1, r, admindirlen, i, infodirlen, infodirbaseused, status;
  61. struct pkgiterator *it;
  62. struct pkginfo *pkg, *otherpkg, *divpkg;
  63. struct conflict *conflictor, *cflict;
  64. char *cidir, *cidirrest, *p;
  65. char pfilenamebuf[35], conffilenamebuf[MAXCONFFILENAME];
  66. const char *pfilename, *newinfofilename;
  67. struct fileinlist *newconff, **newconffileslastp;
  68. struct fileinlist *cfile;
  69. struct reversefilelistiter rlistit;
  70. struct conffile *searchconff, **iconffileslastp, *newiconff;
  71. struct filepackages *packageslump;
  72. struct dependency *dsearch, *newdeplist, **newdeplistlastp;
  73. struct dependency *newdep, *dep, *providecheck;
  74. struct deppossi *psearch, **newpossilastp, *possi, *newpossi, *pdep;
  75. FILE *conff, *tmpf;
  76. DIR *dsd;
  77. struct filenamenode *namenode;
  78. struct dirent *de;
  79. struct stat stab;
  80. struct packageinlist *deconpil, *deconpiltemp;
  81. cleanup_pkg_failed= cleanup_conflictor_failed= 0;
  82. admindirlen= strlen(admindir);
  83. pfilename= filename;
  84. while (strlen(pfilename) > sizeof(pfilenamebuf)-5) {
  85. pfilename= strchr(pfilename,'/');
  86. if (!pfilename) break;
  87. pfilename++;
  88. }
  89. if (pfilename && pfilename != filename) {
  90. strcpy(pfilenamebuf,".../");
  91. strcat(pfilenamebuf,pfilename);
  92. pfilename= pfilenamebuf;
  93. } else {
  94. pfilename= filename;
  95. }
  96. if (stat(filename,&stab)) ohshite(_("cannot access archive"));
  97. if (!f_noact) {
  98. /* We can't `tentatively-reassemble' packages. */
  99. if (!reasmbuf) {
  100. reasmbuf= m_malloc(admindirlen+sizeof(REASSEMBLETMP)+5);
  101. strcpy(reasmbuf,admindir);
  102. strcat(reasmbuf,"/" REASSEMBLETMP);
  103. }
  104. if (unlink(reasmbuf) && errno != ENOENT)
  105. ohshite(_("error ensuring `%.250s' doesn't exist"),reasmbuf);
  106. push_cleanup(cu_pathname,~0, 0,0, 1,(void*)reasmbuf);
  107. c1= m_fork();
  108. if (!c1) {
  109. execlp(SPLITTER, SPLITTER,"-Qao",reasmbuf,filename,(char*)0);
  110. ohshite(_("failed to exec dpkg-split to see if it's part of a multiparter"));
  111. }
  112. while ((r= waitpid(c1,&status,0)) == -1 && errno == EINTR);
  113. if (r != c1) { onerr_abort++; ohshite(_("wait for dpkg-split failed")); }
  114. switch (WIFEXITED(status) ? WEXITSTATUS(status) : -1) {
  115. case 0:
  116. /* It was a part - is it complete ? */
  117. if (!stat(reasmbuf,&stab)) { /* Yes. */
  118. filename= reasmbuf;
  119. pfilename= "reassembled package file";
  120. break;
  121. } else if (errno == ENOENT) { /* No. That's it, we skip it. */
  122. return;
  123. }
  124. case 1:
  125. /* No, it wasn't a part. */
  126. break;
  127. default:
  128. checksubprocerr(status,SPLITTER,0);
  129. }
  130. }
  131. if (f_noact) {
  132. cidir= cidirtmpnambuf;
  133. if (!tmpnam(cidir)) ohshite(_("unable to get unique filename for control info"));
  134. strcat(cidir,"/");
  135. } else {
  136. /* We want it to be on the same filesystem so that we can
  137. * use rename(2) to install the postinst &c.
  138. */
  139. if (!cidirbuf)
  140. cidirbuf= m_malloc(admindirlen+sizeof(CONTROLDIRTMP)+MAXCONTROLFILENAME+10);
  141. cidir= cidirbuf;
  142. strcpy(cidir,admindir);
  143. strcat(cidir, "/" CONTROLDIRTMP);
  144. }
  145. cidirrest= cidir + strlen(cidir);
  146. assert(*cidir && cidirrest[-1] == '/'); cidirrest[-1]= 0;
  147. ensure_pathname_nonexisting(cidir); cidirrest[-1]= '/';
  148. push_cleanup(cu_cidir,~0, 0,0, 2,(void*)cidir,(void*)cidirrest);
  149. c1= m_fork();
  150. if (!c1) {
  151. cidirrest[-1]= 0;
  152. execlp(BACKEND, BACKEND,"--control",filename,cidir,(char*)0);
  153. ohshite(_("failed to exec dpkg-deb to extract control information"));
  154. }
  155. waitsubproc(c1,BACKEND " --control",0);
  156. strcpy(cidirrest,CONTROLFILE);
  157. parsedb(cidir, pdb_recordavailable|pdb_rejectstatus|pdb_ignorefiles|pdb_weakclassification,
  158. &pkg,0,0);
  159. if (!pkg->files) {
  160. pkg->files= nfmalloc(sizeof(struct filedetails));
  161. pkg->files->next= 0;
  162. pkg->files->name= pkg->files->msdosname= pkg->files->md5sum= 0;
  163. pkg->files->size= nfmalloc(30);
  164. }
  165. sprintf(pkg->files->size,"%lu",(unsigned long)stab.st_size);
  166. if (cipaction->arg == act_avail) {
  167. printf(_("Recorded info about %s from %s.\n"),pkg->name,pfilename);
  168. pop_cleanup(ehflag_normaltidy);
  169. return;
  170. }
  171. if (pkg->available.architecture && *pkg->available.architecture &&
  172. strcmp(pkg->available.architecture,"all") &&
  173. strcmp(pkg->available.architecture,architecture))
  174. forcibleerr(fc_architecture,
  175. _("package architecture (%s) does not match system (%s)"),
  176. pkg->available.architecture,architecture);
  177. if (!pkg->installed.valid) blankpackageperfile(&pkg->installed);
  178. assert(pkg->available.valid);
  179. for (deconpil= deconfigure;
  180. deconpil;
  181. deconpil= deconpiltemp) {
  182. deconpiltemp= deconpil->next;
  183. free(deconpil);
  184. }
  185. deconfigure= 0;
  186. clear_istobes();
  187. if (!wanttoinstall(pkg,&pkg->available.version,1)) {
  188. pop_cleanup(ehflag_normaltidy);
  189. return;
  190. }
  191. /* Check if anything is installed that we conflict with, or not installed
  192. * that we need */
  193. pkg->clientdata->istobe= itb_installnew;
  194. conflictor= 0;
  195. for (dsearch= pkg->available.depends; dsearch; dsearch= dsearch->next) {
  196. switch (dsearch->type) {
  197. case dep_conflicts:
  198. /* Look for things we conflict with. */
  199. check_conflict(dsearch, pkg, pfilename, &conflictor);
  200. break;
  201. case dep_provides:
  202. /* Look for things that conflict with what we provide. */
  203. if (dsearch->list->ed->installed.valid) {
  204. for (psearch= dsearch->list->ed->installed.depended;
  205. psearch;
  206. psearch= psearch->nextrev) {
  207. if (psearch->up->type != dep_conflicts) continue;
  208. check_conflict(psearch->up, pkg, pfilename, &conflictor);
  209. }
  210. }
  211. break;
  212. case dep_suggests: case dep_recommends: case dep_depends: case dep_replaces:
  213. /* Ignore these here. */
  214. break;
  215. case dep_predepends:
  216. if (!depisok(dsearch,&depprobwhy,0,1)) {
  217. varbufaddc(&depprobwhy,0);
  218. fprintf(stderr, _("dpkg: regarding %s containing %s, pre-dependency problem:\n%s"),
  219. pfilename, pkg->name, depprobwhy.buf);
  220. if (!force_depends(dsearch->list))
  221. ohshit(_("pre-dependency problem - not installing %.250s"),pkg->name);
  222. fprintf(stderr, _("dpkg: warning - ignoring pre-dependency problem !\n"));
  223. }
  224. }
  225. }
  226. /* Look for things that conflict with us. */
  227. for (psearch= pkg->installed.depended; psearch; psearch= psearch->nextrev) {
  228. if (psearch->up->type != dep_conflicts) continue;
  229. check_conflict(psearch->up, pkg, pfilename, &conflictor);
  230. }
  231. ensure_allinstfiles_available();
  232. filesdbinit();
  233. if (pkg->status != stat_notinstalled && pkg->status != stat_configfiles)
  234. printf(_("Preparing to replace %s %s (using %s) ...\n"),
  235. pkg->name,
  236. versiondescribe(&pkg->installed.version,vdew_nonambig),
  237. pfilename);
  238. else
  239. printf(_("Unpacking %s (from %s) ...\n"),pkg->name,pfilename);
  240. if (f_noact) {
  241. pop_cleanup(ehflag_normaltidy);
  242. return;
  243. }
  244. /* OK, we're going ahead. First we read the conffiles, and copy the
  245. * hashes across.
  246. */
  247. newconffiles= 0; newconffileslastp= &newconffiles;
  248. push_cleanup(cu_fileslist,~0, 0,0, 1,(void*)&newconffiles);
  249. strcpy(cidirrest,CONFFILESFILE);
  250. conff= fopen(cidir,"r");
  251. if (conff) {
  252. push_cleanup(cu_closefile,ehflag_bombout, 0,0, 1,(void*)conff);
  253. while (fgets(conffilenamebuf,MAXCONFFILENAME-2,conff)) {
  254. p= conffilenamebuf + strlen(conffilenamebuf);
  255. assert(p != conffilenamebuf);
  256. if (p[-1] != '\n')
  257. ohshit(_("name of conffile (starting `%.250s') is too long (>%d characters)"),
  258. conffilenamebuf, MAXCONFFILENAME);
  259. while (p > conffilenamebuf && isspace(p[-1])) --p;
  260. if (p == conffilenamebuf) continue;
  261. *p= 0;
  262. newconff= m_malloc(sizeof(struct fileinlist));
  263. newconff->next= 0;
  264. newconff->namenode= findnamenode(conffilenamebuf);
  265. *newconffileslastp= newconff;
  266. newconffileslastp= &newconff->next;
  267. newconff->namenode->oldhash= NEWCONFFILEFLAG;
  268. /* Let's see if any packages have this file. If they do we
  269. * check to see if they listed it as a conffile, and if they did
  270. * we copy the hash across. Since (for plain file conffiles,
  271. * which is the only kind we are supposed to have) there will
  272. * only be one package which `has' the file, this will usually
  273. * mean we only look in the package which we're installing now.
  274. * The `conffiles' data in the status file is ignored when a
  275. * package isn't also listed in the file ownership database as
  276. * having that file. If several packages are listed as owning
  277. * the file we pick one at random.
  278. */
  279. searchconff= 0;
  280. for (packageslump= newconff->namenode->packages;
  281. packageslump;
  282. packageslump= packageslump->more) {
  283. for (i=0; i < PERFILEPACKAGESLUMP && packageslump->pkgs[i]; i++) {
  284. otherpkg= packageslump->pkgs[i];
  285. debug(dbg_conffdetail,"process_archive conffile `%s' in package %s - conff ?",
  286. newconff->namenode->name,otherpkg->name);
  287. for (searchconff= otherpkg->installed.conffiles;
  288. searchconff && strcmp(newconff->namenode->name,searchconff->name);
  289. searchconff= searchconff->next)
  290. debug(dbg_conffdetail,
  291. "process_archive conffile `%s' in package %s - conff ? not `%s'",
  292. newconff->namenode->name,otherpkg->name,searchconff->name);
  293. if (searchconff) {
  294. debug(dbg_conff,"process_archive conffile `%s' package=%s %s hash=%s",
  295. newconff->namenode->name,otherpkg->name,
  296. otherpkg == pkg ? "same" : "different!",
  297. searchconff->hash);
  298. if (otherpkg == pkg) goto xit_conff_hashcopy_srch;
  299. }
  300. }
  301. }
  302. xit_conff_hashcopy_srch:
  303. if (searchconff) {
  304. newconff->namenode->oldhash= searchconff->hash;
  305. } else {
  306. debug(dbg_conff,"process_archive conffile `%s' no package, no hash",
  307. newconff->namenode->name);
  308. }
  309. newconff->namenode->flags |= fnnf_new_conff;
  310. }
  311. if (ferror(conff)) ohshite(_("read error in %.250s"),cidir);
  312. pop_cleanup(ehflag_normaltidy); /* conff= fopen() */
  313. if (fclose(conff)) ohshite(_("error closing %.250s"),cidir);
  314. } else {
  315. if (errno != ENOENT) ohshite(_("error trying to open %.250s"),cidir);
  316. }
  317. /* All the old conffiles are marked with a flag, so that we don't delete
  318. * them if they seem to disappear completely.
  319. */
  320. oldconffsetflags(pkg->installed.conffiles);
  321. for (cflict= conflictor ; cflict ; cflict= cflict->next) {
  322. oldconffsetflags(cflict->cflict->installed.conffiles);
  323. }
  324. oldversionstatus= pkg->status;
  325. assert(oldversionstatus <= stat_configfiles);
  326. debug(dbg_general,"process_archive oldversionstatus=%s",
  327. statusstrings[oldversionstatus]);
  328. if (oldversionstatus == stat_halfconfigured || oldversionstatus == stat_installed) {
  329. pkg->eflag |= eflagf_reinstreq;
  330. pkg->status= stat_halfconfigured;
  331. modstatdb_note(pkg);
  332. push_cleanup(cu_prermupgrade,~ehflag_normaltidy, 0,0, 1,(void*)pkg);
  333. maintainer_script_alternative(pkg, PRERMFILE, "pre-removal", cidir, cidirrest,
  334. "upgrade", "failed-upgrade");
  335. pkg->status= stat_unpacked;
  336. oldversionstatus= stat_unpacked;
  337. modstatdb_note(pkg);
  338. }
  339. for (cflict= conflictor ; cflict ; cflict= cflict->next) {
  340. if (!(cflict->cflict->status == stat_halfconfigured ||
  341. cflict->cflict->status == stat_installed)) continue;
  342. for (deconpil= deconfigure; deconpil; deconpil= deconpil->next) {
  343. printf(_("De-configuring %s, so that we can remove %s ...\n"),
  344. deconpil->pkg->name, cflict->cflict->name);
  345. deconpil->pkg->status= stat_halfconfigured;
  346. modstatdb_note(deconpil->pkg);
  347. /* This means that we *either* go and run postinst abort-deconfigure,
  348. * *or* queue the package for later configure processing, depending
  349. * on which error cleanup route gets taken.
  350. */
  351. push_cleanup(cu_prermdeconfigure,~ehflag_normaltidy,
  352. ok_prermdeconfigure,ehflag_normaltidy,
  353. 3,(void*)deconpil->pkg,(void*)cflict->cflict,(void*)pkg);
  354. maintainer_script_installed(deconpil->pkg, PRERMFILE, "pre-removal",
  355. "deconfigure", "in-favour", pkg->name,
  356. versiondescribe(&pkg->available.version,
  357. vdew_nonambig),
  358. "removing", cflict->cflict->name,
  359. versiondescribe(&cflict->cflict->installed.version,
  360. vdew_nonambig),
  361. (char*)0);
  362. }
  363. cflict->cflict->status= stat_halfconfigured;
  364. modstatdb_note(cflict->cflict);
  365. push_cleanup(cu_prerminfavour,~ehflag_normaltidy, 0,0,
  366. 2,(void*)cflict->cflict,(void*)pkg);
  367. maintainer_script_installed(cflict->cflict, PRERMFILE, "pre-removal",
  368. "remove", "in-favour", pkg->name,
  369. versiondescribe(&pkg->available.version,
  370. vdew_nonambig),
  371. (char*)0);
  372. cflict->cflict->status= stat_halfinstalled;
  373. modstatdb_note(cflict->cflict);
  374. }
  375. pkg->eflag |= eflagf_reinstreq;
  376. if (pkg->status == stat_notinstalled)
  377. pkg->installed.version= pkg->available.version;
  378. pkg->status= stat_halfinstalled;
  379. modstatdb_note(pkg);
  380. if (oldversionstatus == stat_notinstalled) {
  381. push_cleanup(cu_preinstverynew,~ehflag_normaltidy, 0,0,
  382. 3,(void*)pkg,(void*)cidir,(void*)cidirrest);
  383. maintainer_script_new(PREINSTFILE, "pre-installation", cidir, cidirrest,
  384. "install", (char*)0);
  385. } else if (oldversionstatus == stat_configfiles) {
  386. push_cleanup(cu_preinstnew,~ehflag_normaltidy, 0,0,
  387. 3,(void*)pkg,(void*)cidir,(void*)cidirrest);
  388. maintainer_script_new(PREINSTFILE, "pre-installation", cidir, cidirrest,
  389. "install", versiondescribe(&pkg->installed.version,
  390. vdew_nonambig),
  391. (char*)0);
  392. } else {
  393. push_cleanup(cu_preinstupgrade,~ehflag_normaltidy, 0,0,
  394. 4,(void*)pkg,(void*)cidir,(void*)cidirrest,(void*)&oldversionstatus);
  395. maintainer_script_new(PREINSTFILE, "pre-installation", cidir, cidirrest,
  396. "upgrade", versiondescribe(&pkg->installed.version,
  397. vdew_nonambig),
  398. (char*)0);
  399. printf(_("Unpacking replacement %.250s ...\n"),pkg->name);
  400. }
  401. /*
  402. * Now we unpack the archive, backing things up as we go.
  403. * For each file, we check to see if it already exists.
  404. * There are several possibilities:
  405. * + We are trying to install a non-directory ...
  406. * - It doesn't exist. In this case we simply extract it.
  407. * - It is a plain file, device, symlink, &c. We do an `atomic
  408. * overwrite' using link() and rename(), but leave a backup copy.
  409. * Later, when we delete the backup, we remove it from any other
  410. * packages' lists.
  411. * - It is a directory. In this case it depends on whether we're
  412. * trying to install a symlink or something else.
  413. * = If we're not trying to install a symlink we move the directory
  414. * aside and extract the node. Later, when we recursively remove
  415. * the backed-up directory, we remove it from any other packages'
  416. * lists.
  417. * = If we are trying to install a symlink we do nothing - ie,
  418. * dpkg will never replace a directory tree with a symlink. This
  419. * is to avoid embarrassing effects such as replacing a directory
  420. * tree with a link to a link to the original directory tree.
  421. * + We are trying to install a directory ...
  422. * - It doesn't exist. We create it with the appropriate modes.
  423. * - It exists as a directory or a symlink to one. We do nothing.
  424. * - It is a plain file or a symlink (other than to a directory).
  425. * We move it aside and create the directory. Later, when we
  426. * delete the backup, we remove it from any other packages' lists.
  427. *
  428. * Install non-dir Install symlink Install dir
  429. * Exists not X X X
  430. * File/node/symlink LXR LXR BXR
  431. * Directory BXR - -
  432. *
  433. * X: extract file/node/link/directory
  434. * LX: atomic overwrite leaving backup
  435. * B: ordinary backup
  436. * R: later remove from other packages' lists
  437. * -: do nothing
  438. *
  439. * After we've done this we go through the remaining things in the
  440. * lists of packages we're trying to remove (including the old
  441. * version of the current package). This happens in reverse order,
  442. * so that we process files before the directories (or symlinks-to-
  443. * directories) containing them.
  444. * + If the thing is a conffile then we leave it alone for the purge
  445. * operation.
  446. * + Otherwise, there are several possibilities too:
  447. * - The listed thing does not exist. We ignore it.
  448. * - The listed thing is a directory or a symlink to a directory.
  449. * We delete it only if it isn't listed in any other package.
  450. * - The listed thing is not a directory, but was part of the package
  451. * that was upgraded, we check to make sure the files aren't the
  452. * same ones from the old package by checking dev/inode
  453. * - The listed thing is not a directory or a symlink to one (ie,
  454. * it's a plain file, device, pipe, &c, or a symlink to one, or a
  455. * dangling symlink). We delete it.
  456. * The removed packages' list becomes empty (of course, the new
  457. * version of the package we're installing will have a new list,
  458. * which replaces the old version's list).
  459. *
  460. * If at any stage we remove a file from a package's list, and the
  461. * package isn't one we're already processing, and the package's
  462. * list becomes empty as a result, we `vanish' the package. This
  463. * means that we run its postrm with the `disappear' argument, and
  464. * put the package in the `not-installed' state. Its conffiles are
  465. * ignored and forgotten about.
  466. *
  467. * NOTE THAT THE OLD POSTRM IS RUN AFTER THE NEW PREINST, since the
  468. * files get replaced `as we go'.
  469. */
  470. m_pipe(p1);
  471. push_cleanup(cu_closepipe,ehflag_bombout, 0,0, 1,(void*)&p1[0]);
  472. c1= m_fork();
  473. if (!c1) {
  474. m_dup2(p1[1],1); close(p1[0]); close(p1[1]);
  475. execlp(BACKEND, BACKEND, "--fsys-tarfile", filename, (char*)0);
  476. ohshite(_("unable to exec dpkg-deb to get filesystem archive"));
  477. }
  478. close(p1[1]);
  479. newfileslist= 0; tc.newfilesp= &newfileslist;
  480. push_cleanup(cu_fileslist,~0, 0,0, 1,(void*)&newfileslist);
  481. tc.pkg= pkg;
  482. tc.backendpipe= fdopen(p1[0],"r");
  483. if (!tc.backendpipe) ohshite(_("unable to fdopen dpkg-deb extract pipe"));
  484. push_cleanup(cu_backendpipe,~ehflag_bombout, 0,0, 1,(void*)&tc.backendpipe);
  485. r= TarExtractor((void*)&tc, &tf);
  486. if (r) {
  487. if (errno) {
  488. ohshite(_("error reading dpkg-deb tar output"));
  489. } else if (feof(tc.backendpipe)) {
  490. waitsubproc(c1,BACKEND " --fsys-tarfile (EOF)",1);
  491. ohshite(_("unexpected EOF in filesystem tarfile - corrupted package archive"));
  492. } else {
  493. ohshite(_("corrupted filesystem tarfile - corrupted package archive"));
  494. }
  495. }
  496. tmpf= tc.backendpipe;
  497. tc.backendpipe= 0;
  498. fclose(tmpf);
  499. waitsubproc(c1,BACKEND " --fsys-tarfile",1);
  500. if (oldversionstatus == stat_halfinstalled || oldversionstatus == stat_unpacked) {
  501. /* Packages that were in `installed' and `postinstfailed' have been reduced
  502. * to `unpacked' by now, by the running of the prerm script.
  503. */
  504. pkg->status= stat_halfinstalled;
  505. modstatdb_note(pkg);
  506. push_cleanup(cu_postrmupgrade,~ehflag_normaltidy, 0,0, 1,(void*)pkg);
  507. maintainer_script_alternative(pkg, POSTRMFILE, "post-removal", cidir, cidirrest,
  508. "upgrade", "failed-upgrade");
  509. }
  510. /* If anything goes wrong while tidying up it's a bit late to do
  511. * anything about it. However, we don't install the new status
  512. * info yet, so that a future dpkg installation will put everything
  513. * right (we hope).
  514. *
  515. * If something does go wrong later the `conflictor' package will be
  516. * left in the `removal_failed' state. Removing or installing it
  517. * will be impossible if it was required because of the conflict with
  518. * the package we're installing now and (presumably) the dependency
  519. * by other packages. This means that the files it contains in
  520. * common with this package will hang around until we successfully
  521. * get this package installed, after which point we can trust the
  522. * conflicting package's file list, which will have been updated to
  523. * remove any files in this package.
  524. */
  525. push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
  526. /* Now we delete all the files that were in the old version of
  527. * the package only, except (old or new) conffiles, which we leave
  528. * alone.
  529. */
  530. reversefilelist_init(&rlistit,pkg->clientdata->files);
  531. while ((namenode= reversefilelist_next(&rlistit))) {
  532. if ((namenode->flags & fnnf_old_conff) ||
  533. (namenode->flags & fnnf_new_conff) ||
  534. (namenode->flags & fnnf_new_inarchive))
  535. continue;
  536. if (isdirectoryinuse(namenode,pkg)) continue;
  537. fnamevb.used= fnameidlu;
  538. varbufaddstr(&fnamevb, namenodetouse(namenode,pkg)->name);
  539. varbufaddc(&fnamevb,0);
  540. if (!rmdir(fnamevb.buf)) continue;
  541. if (errno == ENOENT || errno == ELOOP) continue;
  542. if (errno == ENOTDIR) {
  543. /* Ok, it's an old file, but is it really not in the new package?
  544. * We need to check to make sure, so we stat the file, then compare
  545. * it to the new list. If we find a dev/inode match, we assume they
  546. * are the same file, and leave it alone. NOTE: we don't check in
  547. * other packages for sanity reasons (we don't want to stat _all_
  548. * the files on the system).
  549. *
  550. * We run down the list of _new_ files in this package. This keeps
  551. * the process a little leaner. We are only worried about new ones
  552. * since ones that stayed the same don't really apply here.
  553. */
  554. struct stat oldfs;
  555. int donotrm = 0;
  556. /* If we can't stat the old or new file, or it's a directory,
  557. * we leave it up to the normal code
  558. */
  559. debug(dbg_eachfile, "process_archive: checking %s for same files on "
  560. "upgrade/downgrade", fnamevb.buf);
  561. if (!lstat(fnamevb.buf, &oldfs) && !S_ISDIR(oldfs.st_mode)) {
  562. for (cfile = newfileslist; cfile; cfile = cfile->next) {
  563. if (!cfile->namenode->filestat) {
  564. cfile->namenode->filestat = (struct stat *) nfmalloc(sizeof(struct stat));
  565. if (lstat(cfile->namenode->name, cfile->namenode->filestat)) {
  566. cfile->namenode->filestat= 0;
  567. continue;
  568. }
  569. }
  570. if (S_ISDIR(cfile->namenode->filestat->st_mode))
  571. continue;
  572. if (oldfs.st_dev == cfile->namenode->filestat->st_dev &&
  573. oldfs.st_ino == cfile->namenode->filestat->st_ino) {
  574. donotrm = 1;
  575. debug(dbg_eachfile, "process_archive: not removing %s, since it matches %s",
  576. fnamevb.buf, cfile->namenode->name);
  577. }
  578. }
  579. } else
  580. debug(dbg_eachfile, "process_archive: could not stat %s, skipping", fnamevb.buf);
  581. if (donotrm) continue;
  582. if (!unlink(fnamevb.buf)) continue;
  583. if (errno == ENOTDIR) continue;
  584. }
  585. fprintf(stderr,
  586. _("dpkg: warning - unable to delete old file `%.250s': %s\n"),
  587. namenode->name, strerror(errno));
  588. }
  589. /* OK, now we can write the updated files-in-this package list,
  590. * since we've done away (hopefully) with all the old junk.
  591. */
  592. write_filelist_except(pkg,newfileslist,0);
  593. /* We also install the new maintainer scripts, and any other
  594. * cruft that may have come along with the package. First
  595. * we go through the existing scripts replacing or removing
  596. * them as appropriate; then we go through the new scripts
  597. * (any that are left) and install them.
  598. */
  599. debug(dbg_general, "process_archive updating info directory");
  600. varbufreset(&infofnvb);
  601. varbufaddstr(&infofnvb,admindir);
  602. varbufaddstr(&infofnvb,"/" INFODIR "/");
  603. infodirlen= infofnvb.used;
  604. varbufaddc(&infofnvb,0);
  605. dsd= opendir(infofnvb.buf);
  606. if (!dsd) ohshite(_("cannot read info directory"));
  607. push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
  608. while ((de= readdir(dsd)) != 0) {
  609. debug(dbg_veryverbose, "process_archive info file `%s'", de->d_name);
  610. if (de->d_name[0] == '.') continue; /* ignore dotfiles, including `.' and `..' */
  611. p= strrchr(de->d_name,'.'); if (!p) continue; /* ignore anything odd */
  612. if (strlen(pkg->name) != p-de->d_name ||
  613. strncmp(de->d_name,pkg->name,p-de->d_name)) continue;
  614. debug(dbg_stupidlyverbose, "process_archive info this pkg");
  615. /* Right do we have one ? */
  616. p++; /* skip past the full stop */
  617. if (!strcmp(p,LISTFILE)) continue; /* We do the list separately */
  618. if (strlen(p) > MAXCONTROLFILENAME)
  619. ohshit(_("old version of package has overly-long info file name starting `%.250s'"),
  620. de->d_name);
  621. infofnvb.used= infodirlen;
  622. varbufaddstr(&infofnvb,de->d_name);
  623. varbufaddc(&infofnvb,0);
  624. strcpy(cidirrest,p);
  625. if (!rename(cidir,infofnvb.buf)) {
  626. debug(dbg_scripts, "process_archive info installed %s as %s",
  627. cidir, infofnvb.buf);
  628. } else if (errno == ENOENT) {
  629. /* Right, no new version. */
  630. if (unlink(infofnvb.buf))
  631. ohshite(_("unable to remove obsolete info file `%.250s'"),infofnvb.buf);
  632. debug(dbg_scripts, "process_archive info unlinked %s",infofnvb.buf);
  633. } else {
  634. ohshite(_("unable to install (supposed) new info file `%.250s'"),cidir);
  635. }
  636. }
  637. pop_cleanup(ehflag_normaltidy); /* closedir */
  638. *cidirrest= 0; /* the directory itself */
  639. dsd= opendir(cidir);
  640. if (!dsd) ohshite(_("unable to open temp control directory"));
  641. push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
  642. while ((de= readdir(dsd))) {
  643. if (strchr(de->d_name,'.')) {
  644. debug(dbg_scripts,"process_archive tmp.ci script/file `%s' contains dot",
  645. de->d_name);
  646. continue;
  647. }
  648. if (strlen(de->d_name) > MAXCONTROLFILENAME)
  649. ohshit(_("package contains overly-long control info file name (starting `%.50s')"),
  650. de->d_name);
  651. strcpy(cidirrest,de->d_name);
  652. /* First we check it's not a directory. */
  653. if (!rmdir(cidir))
  654. ohshit(_("package control info contained directory `%.250s'"),cidir);
  655. else if (errno != ENOTDIR)
  656. ohshite(_("package control info rmdir of `%.250s' didn't say not a dir"),de->d_name);
  657. if (!strcmp(de->d_name,CONTROLFILE)) {
  658. debug(dbg_scripts,"process_archive tmp.ci script/file `%s' is control",cidir);
  659. continue; /* ignore the control file */
  660. }
  661. if (!strcmp(de->d_name,LISTFILE)) {
  662. fprintf(stderr, _("dpkg: warning - package %s"
  663. " contained list as info file"), pkg->name);
  664. continue;
  665. }
  666. /* Right, install it */
  667. newinfofilename= pkgadminfile(pkg,de->d_name);
  668. if (rename(cidir,newinfofilename))
  669. ohshite(_("unable to install new info file `%.250s' as `%.250s'"),
  670. cidir,newinfofilename);
  671. debug(dbg_scripts,"process_archive tmp.ci script/file `%s' installed as `%s'",
  672. cidir, newinfofilename);
  673. }
  674. pop_cleanup(ehflag_normaltidy); /* closedir */
  675. /* Update the status database.
  676. * This involves copying each field across from the `available'
  677. * to the `installed' half of the pkg structure.
  678. * For some of the fields we have to do a complicated construction
  679. * operation; for others we can just copy the value.
  680. * We tackle the fields in the order they appear, so that
  681. * we don't miss any out :-).
  682. * At least we don't have to copy any strings that are referred
  683. * to, because these are never modified and never freed.
  684. */
  685. /* The dependencies are the most difficult. We have to build
  686. * a whole new forward dependency tree. At least the reverse
  687. * links (linking our deppossi's into the reverse chains)
  688. * can be done by copy_dependency_links.
  689. */
  690. newdeplist= 0; newdeplistlastp= &newdeplist;
  691. for (dep= pkg->available.depends; dep; dep= dep->next) {
  692. newdep= nfmalloc(sizeof(struct dependency));
  693. newdep->up= pkg;
  694. newdep->next= 0;
  695. newdep->list= 0; newpossilastp= &newdep->list;
  696. for (possi= dep->list; possi; possi= possi->next) {
  697. newpossi= nfmalloc(sizeof(struct deppossi));
  698. newpossi->up= newdep;
  699. newpossi->ed= possi->ed;
  700. newpossi->next= 0; newpossi->nextrev= newpossi->backrev= 0;
  701. newpossi->verrel= possi->verrel;
  702. if (possi->verrel != dvr_none) newpossi->version= possi->version;
  703. newpossi->cyclebreak= 0;
  704. *newpossilastp= newpossi;
  705. newpossilastp= &newpossi->next;
  706. }
  707. newdep->type= dep->type;
  708. *newdeplistlastp= newdep;
  709. newdeplistlastp= &newdep->next;
  710. }
  711. /* Right, now we've replicated the forward tree, we
  712. * get copy_dependency_links to remove all the old dependency
  713. * structures from the reverse links and add the new dependency
  714. * structures in instead. It also copies the new dependency
  715. * structure pointer for this package into the right field.
  716. */
  717. copy_dependency_links(pkg,&pkg->installed.depends,newdeplist,0);
  718. /* The `depended' pointer in the structure doesn't represent anything
  719. * that is actually specified by this package - it's there so we
  720. * can find out what other packages refer to this one. So,
  721. * we don't copy it. We go straight on to copy the text fields.
  722. */
  723. pkg->installed.essential= pkg->available.essential;
  724. pkg->installed.description= pkg->available.description;
  725. pkg->installed.maintainer= pkg->available.maintainer;
  726. pkg->installed.source= pkg->available.source;
  727. pkg->installed.architecture= 0; /* This is irrelevant in the status file. */
  728. pkg->installed.installedsize= pkg->available.installedsize;
  729. pkg->installed.version= pkg->available.version;
  730. /* We have to generate our own conffiles structure. */
  731. pkg->installed.conffiles= 0; iconffileslastp= &pkg->installed.conffiles;
  732. for (cfile= newconffiles; cfile; cfile= cfile->next) {
  733. newiconff= nfmalloc(sizeof(struct conffile));
  734. newiconff->next= 0;
  735. newiconff->name= nfstrsave(cfile->namenode->name);
  736. newiconff->hash= nfstrsave(cfile->namenode->oldhash);
  737. *iconffileslastp= newiconff;
  738. iconffileslastp= &newiconff->next;
  739. }
  740. /* We can just copy the arbitrary fields list, because it is
  741. * never even rearragned. Phew !
  742. */
  743. pkg->installed.arbs= pkg->available.arbs;
  744. /* Check for disappearing packages:
  745. * We go through all the packages on the system looking for ones
  746. * whose files are entirely part of the one we've just unpacked
  747. * (and which actually *have* some files!).
  748. *
  749. * Any that we find are removed - we run the postrm with `disappear'
  750. * as an argument, and remove their info/... files and status info.
  751. * Conffiles are ignored (the new package had better do something
  752. * with them !).
  753. */
  754. it= iterpkgstart();
  755. while ((otherpkg= iterpkgnext(it)) != 0) {
  756. ensure_package_clientdata(otherpkg);
  757. if (otherpkg == pkg ||
  758. otherpkg->status == stat_notinstalled ||
  759. otherpkg->status == stat_configfiles ||
  760. !otherpkg->clientdata->files) continue;
  761. for (cflict= conflictor ; cflict && cflict->cflict != otherpkg ;
  762. cflict= cflict->next);
  763. if (cflict) continue;
  764. debug(dbg_veryverbose, "process_archive checking disappearance %s",otherpkg->name);
  765. assert(otherpkg->clientdata->istobe == itb_normal ||
  766. otherpkg->clientdata->istobe == itb_deconfigure);
  767. for (cfile= otherpkg->clientdata->files;
  768. cfile && !strcmp(cfile->namenode->name,"/.");
  769. cfile= cfile->next);
  770. if (!cfile) {
  771. debug(dbg_stupidlyverbose, "process_archive no non-root, no disappear");
  772. continue;
  773. }
  774. for (cfile= otherpkg->clientdata->files;
  775. cfile && !filesavespackage(cfile,otherpkg,pkg);
  776. cfile= cfile->next);
  777. if (cfile) continue;
  778. /* So dependency things will give right answers ... */
  779. otherpkg->clientdata->istobe= itb_remove;
  780. debug(dbg_veryverbose, "process_archive disappear checking dependencies");
  781. for (pdep= otherpkg->installed.depended;
  782. pdep;
  783. pdep= pdep->nextrev) {
  784. if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
  785. pdep->up->type != dep_recommends) continue;
  786. if (depisok(pdep->up, &depprobwhy, 0,0)) continue;
  787. varbufaddc(&depprobwhy,0);
  788. debug(dbg_veryverbose,"process_archive cannot disappear: %s",depprobwhy.buf);
  789. break;
  790. }
  791. if (!pdep) {
  792. /* If we haven't found a reason not to yet, let's look some more. */
  793. for (providecheck= otherpkg->installed.depends;
  794. providecheck;
  795. providecheck= providecheck->next) {
  796. if (providecheck->type != dep_provides) continue;
  797. for (pdep= providecheck->list->ed->installed.depended;
  798. pdep;
  799. pdep= pdep->nextrev) {
  800. if (pdep->up->type != dep_depends && pdep->up->type != dep_predepends &&
  801. pdep->up->type != dep_recommends)
  802. continue;
  803. if (depisok(pdep->up, &depprobwhy, 0,0)) continue;
  804. varbufaddc(&depprobwhy,0);
  805. debug(dbg_veryverbose,"process_archive cannot disappear (provides %s): %s",
  806. providecheck->list->ed->name, depprobwhy.buf);
  807. goto break_from_both_loops_at_once;
  808. }
  809. }
  810. break_from_both_loops_at_once:;
  811. }
  812. otherpkg->clientdata->istobe= itb_normal;
  813. if (pdep) continue;
  814. printf(_("(Noting disappearance of %s, which has been completely replaced.)\n"),
  815. otherpkg->name);
  816. debug(dbg_general, "process_archive disappearing %s",otherpkg->name);
  817. /* No, we're disappearing it. This is the wrong time to go and
  818. * run maintainer scripts and things, as we can't back out. But
  819. * what can we do ? It has to be run this late.
  820. */
  821. maintainer_script_installed(otherpkg, POSTRMFILE,
  822. "post-removal script (for disappearance)",
  823. "disappear", pkg->name,
  824. versiondescribe(&pkg->available.version,
  825. vdew_nonambig),
  826. (char*)0);
  827. /* OK, now we delete all the stuff in the `info' directory .. */
  828. varbufreset(&fnvb);
  829. varbufaddstr(&fnvb,admindir);
  830. varbufaddstr(&fnvb,"/" INFODIR);
  831. infodirbaseused= fnvb.used;
  832. varbufaddc(&fnvb,0);
  833. dsd= opendir(fnvb.buf); if (!dsd) ohshite(_("cannot read info directory"));
  834. push_cleanup(cu_closedir,~0, 0,0, 1,(void*)dsd);
  835. debug(dbg_general, "process_archive disappear cleaning info directory");
  836. while ((de= readdir(dsd)) != 0) {
  837. debug(dbg_veryverbose, "process_archive info file `%s'", de->d_name);
  838. if (de->d_name[0] == '.') continue;
  839. p= strrchr(de->d_name,'.'); if (!p) continue;
  840. if (strlen(otherpkg->name) != p-de->d_name ||
  841. strncmp(de->d_name,otherpkg->name,p-de->d_name)) continue;
  842. debug(dbg_stupidlyverbose, "process_archive info this pkg");
  843. fnvb.used= infodirbaseused;
  844. varbufaddstr(&fnvb,de->d_name);
  845. varbufaddc(&fnvb,0);
  846. if (unlink(fnvb.buf))
  847. ohshite(_("unable to delete disappearing control info file `%.250s'"),fnvb.buf);
  848. debug(dbg_scripts, "process_archive info unlinked %s",fnvb.buf);
  849. }
  850. pop_cleanup(ehflag_normaltidy); /* closedir */
  851. otherpkg->status= stat_notinstalled;
  852. otherpkg->want= want_purge;
  853. otherpkg->eflag= eflagv_ok;
  854. otherpkg->installed.depends= 0;
  855. otherpkg->installed.essential= 0;
  856. otherpkg->installed.description= otherpkg->installed.maintainer= 0;
  857. otherpkg->installed.installedsize= otherpkg->installed.source= 0;
  858. otherpkg->installed.conffiles= 0;
  859. blankversion(&otherpkg->installed.version);
  860. otherpkg->installed.arbs= 0;
  861. otherpkg->clientdata->fileslistvalid= 0;
  862. modstatdb_note(otherpkg);
  863. } /* while (otherpkg= ... */
  864. iterpkgend(it);
  865. /* Delete files from any other packages' lists.
  866. * We have to do this before we claim this package is in any
  867. * sane kind of state, as otherwise we might delete by mistake
  868. * a file that we overwrote, when we remove the package which
  869. * had the version we overwrote. To prevent this we make
  870. * sure that we don't claim this package is OK until we
  871. * have claimed `ownership' of all its files.
  872. */
  873. for (cfile= newfileslist; cfile; cfile= cfile->next) {
  874. if (!(cfile->namenode->flags & fnnf_elide_other_lists)) continue;
  875. if (cfile->namenode->divert && cfile->namenode->divert->useinstead) {
  876. divpkg= cfile->namenode->divert->pkg;
  877. if (divpkg == pkg) {
  878. debug(dbg_eachfile,
  879. "process_archive not overwriting any `%s' (overriding, `%s')",
  880. cfile->namenode->name, cfile->namenode->divert->useinstead->name);
  881. continue;
  882. } else {
  883. debug(dbg_eachfile,
  884. "process_archive looking for overwriting `%s' (overridden by %s)",
  885. cfile->namenode->name, divpkg ? divpkg->name : "<local>");
  886. }
  887. } else {
  888. divpkg= 0;
  889. debug(dbg_eachfile, "process_archive looking for overwriting `%s'",
  890. cfile->namenode->name);
  891. }
  892. for (packageslump= cfile->namenode->packages;
  893. packageslump;
  894. packageslump= packageslump->more) {
  895. for (i=0; i < PERFILEPACKAGESLUMP && packageslump->pkgs[i]; i++) {
  896. otherpkg= packageslump->pkgs[i];
  897. debug(dbg_eachfiledetail, "process_archive ... found in %s\n",otherpkg->name);
  898. /* If !fileslistvalid then it's one of the disappeared packages above
  899. * and we don't bother with it here, clearly.
  900. */
  901. if (otherpkg == pkg || !otherpkg->clientdata->fileslistvalid) continue;
  902. if (otherpkg == divpkg) {
  903. debug(dbg_eachfiledetail, "process_archive ... diverted, skipping\n");
  904. continue;
  905. }
  906. /* Found one. We delete remove the list entry for this file,
  907. * (and any others in the same package) and then mark the package
  908. * as requiring a reread.
  909. */
  910. write_filelist_except(otherpkg, otherpkg->clientdata->files, 1);
  911. ensure_package_clientdata(otherpkg);
  912. debug(dbg_veryverbose, "process_archive overwrote from %s",otherpkg->name);
  913. }
  914. }
  915. }
  916. /* Right, the package we've unpacked is now in a reasonable state.
  917. * The only thing that we have left to do with it is remove
  918. * backup files, and we can leave the user to fix that if and when
  919. * it happens (we leave the reinstall required flag, of course).
  920. */
  921. pkg->status= stat_unpacked;
  922. modstatdb_note(pkg);
  923. /* Now we delete all the backup files that we made when
  924. * extracting the archive - except for files listed as conffiles
  925. * in the new package.
  926. * This time we count it as an error if something goes wrong.
  927. *
  928. * Note that we don't ever delete things that were in the old
  929. * package as a conffile and don't appear at all in the new.
  930. */
  931. for (cfile= newfileslist; cfile; cfile= cfile->next) {
  932. if (cfile->namenode->flags & fnnf_new_conff) continue;
  933. fnametmpvb.used= fnameidlu;
  934. varbufaddstr(&fnametmpvb,namenodetouse(cfile->namenode,pkg)->name);
  935. varbufaddstr(&fnametmpvb,DPKGTEMPEXT);
  936. varbufaddc(&fnametmpvb,0);
  937. ensure_pathname_nonexisting(fnametmpvb.buf);
  938. }
  939. /* OK, we're now fully done with the main package.
  940. * This is quite a nice state, so we don't unwind past here.
  941. */
  942. pkg->eflag= eflagv_ok;
  943. modstatdb_note(pkg);
  944. push_checkpoint(~ehflag_bombout, ehflag_normaltidy);
  945. /* Only the removal of the conflictor left to do.
  946. * The files list for the conflictor is still a little inconsistent in-core,
  947. * as we have not yet updated the filename->packages mappings; however,
  948. * the package->filenames mapping is
  949. */
  950. for (cflict= conflictor ; cflict ; cflict= cflict->next) {
  951. /* We need to have the most up-to-date info about which files are what ... */
  952. ensure_allinstfiles_available();
  953. removal_bulk(cflict->cflict);
  954. }
  955. if (cipaction->arg == act_install) add_to_queue(pkg);
  956. }