processarc.c 42 KB

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