processarc.c 42 KB

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