processarc.c 42 KB

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