build.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * dpkg-deb - construction and deconstruction of *.deb archives
  3. * build.c - building archives
  4. *
  5. * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  6. * Copyright © 2000,2001 Wichert Akkerman <wakkerma@debian.org>
  7. * Copyright © 2007-2015 Guillem Jover <guillem@debian.org>
  8. *
  9. * This is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  21. */
  22. #include <config.h>
  23. #include <compat.h>
  24. #include <sys/types.h>
  25. #include <sys/stat.h>
  26. #include <sys/wait.h>
  27. #include <errno.h>
  28. #include <limits.h>
  29. #include <string.h>
  30. #include <dirent.h>
  31. #include <fcntl.h>
  32. #include <unistd.h>
  33. #include <stdbool.h>
  34. #include <stdint.h>
  35. #include <stdlib.h>
  36. #include <stdio.h>
  37. #include <dpkg/i18n.h>
  38. #include <dpkg/c-ctype.h>
  39. #include <dpkg/dpkg.h>
  40. #include <dpkg/dpkg-db.h>
  41. #include <dpkg/path.h>
  42. #include <dpkg/varbuf.h>
  43. #include <dpkg/fdio.h>
  44. #include <dpkg/buffer.h>
  45. #include <dpkg/subproc.h>
  46. #include <dpkg/compress.h>
  47. #include <dpkg/ar.h>
  48. #include <dpkg/options.h>
  49. #include "dpkg-deb.h"
  50. /**
  51. * Simple structure to store information about a file.
  52. */
  53. struct file_info {
  54. struct file_info *next;
  55. struct stat st;
  56. char *fn;
  57. };
  58. static struct file_info *
  59. file_info_new(const char *filename)
  60. {
  61. struct file_info *fi;
  62. fi = m_malloc(sizeof(*fi));
  63. fi->fn = m_strdup(filename);
  64. fi->next = NULL;
  65. return fi;
  66. }
  67. static void
  68. file_info_free(struct file_info *fi)
  69. {
  70. free(fi->fn);
  71. free(fi);
  72. }
  73. static struct file_info *
  74. file_info_find_name(struct file_info *list, const char *filename)
  75. {
  76. struct file_info *node;
  77. for (node = list; node; node = node->next)
  78. if (strcmp(node->fn, filename) == 0)
  79. return node;
  80. return NULL;
  81. }
  82. /**
  83. * Read a filename from the file descriptor and create a file_info struct.
  84. *
  85. * @return A file_info struct or NULL if there is nothing to read.
  86. */
  87. static struct file_info *
  88. file_info_get(const char *root, int fd)
  89. {
  90. static struct varbuf fn = VARBUF_INIT;
  91. struct file_info *fi;
  92. size_t root_len;
  93. varbuf_reset(&fn);
  94. root_len = varbuf_printf(&fn, "%s/", root);
  95. while (1) {
  96. int res;
  97. varbuf_grow(&fn, 1);
  98. res = fd_read(fd, (fn.buf + fn.used), 1);
  99. if (res < 0)
  100. return NULL;
  101. if (res == 0) /* EOF -> parent died. */
  102. return NULL;
  103. if (fn.buf[fn.used] == '\0')
  104. break;
  105. varbuf_trunc(&fn, fn.used + 1);
  106. }
  107. fi = file_info_new(fn.buf + root_len);
  108. if (lstat(fn.buf, &(fi->st)) != 0)
  109. ohshite(_("unable to stat file name '%.250s'"), fn.buf);
  110. return fi;
  111. }
  112. /**
  113. * Add a new file_info struct to a single linked list of file_info structs.
  114. *
  115. * We perform a slight optimization to work around a ‘feature’ in tar: tar
  116. * always recurses into subdirectories if you list a subdirectory. So if an
  117. * entry is added and the previous entry in the list is its subdirectory we
  118. * remove the subdirectory.
  119. *
  120. * After a file_info struct is added to a list it may no longer be freed, we
  121. * assume full responsibility for its memory.
  122. */
  123. static void
  124. file_info_list_append(struct file_info **head, struct file_info **tail,
  125. struct file_info *fi)
  126. {
  127. if (*head == NULL)
  128. *head = *tail = fi;
  129. else
  130. *tail = (*tail)->next =fi;
  131. }
  132. /**
  133. * Free the memory for all entries in a list of file_info structs.
  134. */
  135. static void
  136. file_info_list_free(struct file_info *fi)
  137. {
  138. while (fi) {
  139. struct file_info *fl;
  140. fl=fi; fi=fi->next;
  141. file_info_free(fl);
  142. }
  143. }
  144. static void
  145. file_treewalk_feed(const char *dir, int fd_out)
  146. {
  147. int pipefd[2];
  148. pid_t pid;
  149. struct file_info *fi;
  150. struct file_info *symlist = NULL;
  151. struct file_info *symlist_end = NULL;
  152. m_pipe(pipefd);
  153. pid = subproc_fork();
  154. if (pid == 0) {
  155. m_dup2(pipefd[1], 1);
  156. close(pipefd[0]);
  157. close(pipefd[1]);
  158. if (chdir(dir))
  159. ohshite(_("failed to chdir to '%.255s'"), dir);
  160. execlp(FIND, "find", ".", "-path", "./" BUILDCONTROLDIR, "-prune", "-o",
  161. "-print0", NULL);
  162. ohshite(_("unable to execute %s (%s)"), "find", FIND);
  163. }
  164. close(pipefd[1]);
  165. /* We need to reorder the files so we can make sure that symlinks
  166. * will not appear before their target. */
  167. while ((fi = file_info_get(dir, pipefd[0])) != NULL) {
  168. if (S_ISLNK(fi->st.st_mode)) {
  169. file_info_list_append(&symlist, &symlist_end, fi);
  170. } else {
  171. if (fd_write(fd_out, fi->fn, strlen(fi->fn) + 1) < 0)
  172. ohshite(_("failed to write filename to tar pipe (%s)"),
  173. _("data member"));
  174. file_info_free(fi);
  175. }
  176. }
  177. close(pipefd[0]);
  178. subproc_reap(pid, "find", 0);
  179. for (fi = symlist; fi; fi = fi->next)
  180. if (fd_write(fd_out, fi->fn, strlen(fi->fn) + 1) < 0)
  181. ohshite(_("failed to write filename to tar pipe (%s)"), _("data member"));
  182. file_info_list_free(symlist);
  183. }
  184. static const char *const maintainerscripts[] = {
  185. PREINSTFILE,
  186. POSTINSTFILE,
  187. PRERMFILE,
  188. POSTRMFILE,
  189. NULL,
  190. };
  191. /**
  192. * Check control directory and file permissions.
  193. */
  194. static void
  195. check_file_perms(const char *dir)
  196. {
  197. struct varbuf path = VARBUF_INIT;
  198. const char *const *mscriptp;
  199. struct stat mscriptstab;
  200. varbuf_printf(&path, "%s/%s/", dir, BUILDCONTROLDIR);
  201. if (lstat(path.buf, &mscriptstab))
  202. ohshite(_("unable to stat control directory"));
  203. if (!S_ISDIR(mscriptstab.st_mode))
  204. ohshit(_("control directory is not a directory"));
  205. if ((mscriptstab.st_mode & 07757) != 0755)
  206. ohshit(_("control directory has bad permissions %03lo "
  207. "(must be >=0755 and <=0775)"),
  208. (unsigned long)(mscriptstab.st_mode & 07777));
  209. for (mscriptp = maintainerscripts; *mscriptp; mscriptp++) {
  210. varbuf_reset(&path);
  211. varbuf_printf(&path, "%s/%s/%s", dir, BUILDCONTROLDIR, *mscriptp);
  212. if (!lstat(path.buf, &mscriptstab)) {
  213. if (S_ISLNK(mscriptstab.st_mode))
  214. continue;
  215. if (!S_ISREG(mscriptstab.st_mode))
  216. ohshit(_("maintainer script '%.50s' is not a plain file or symlink"),
  217. *mscriptp);
  218. if ((mscriptstab.st_mode & 07557) != 0555)
  219. ohshit(_("maintainer script '%.50s' has bad permissions %03lo "
  220. "(must be >=0555 and <=0775)"),
  221. *mscriptp, (unsigned long)(mscriptstab.st_mode & 07777));
  222. } else if (errno != ENOENT) {
  223. ohshite(_("maintainer script '%.50s' is not stattable"), *mscriptp);
  224. }
  225. }
  226. varbuf_destroy(&path);
  227. }
  228. /**
  229. * Check if conffiles contains sane information.
  230. */
  231. static void
  232. check_conffiles(const char *dir)
  233. {
  234. FILE *cf;
  235. struct varbuf controlfile = VARBUF_INIT;
  236. char conffilename[MAXCONFFILENAME + 1];
  237. struct file_info *conffiles_head = NULL;
  238. struct file_info *conffiles_tail = NULL;
  239. varbuf_printf(&controlfile, "%s/%s/%s", dir, BUILDCONTROLDIR, CONFFILESFILE);
  240. cf = fopen(controlfile.buf, "r");
  241. if (cf == NULL) {
  242. if (errno == ENOENT)
  243. return;
  244. ohshite(_("error opening conffiles file"));
  245. }
  246. while (fgets(conffilename, MAXCONFFILENAME + 1, cf)) {
  247. struct stat controlstab;
  248. int n;
  249. n = strlen(conffilename);
  250. if (!n)
  251. ohshite(_("empty string from fgets reading conffiles"));
  252. if (conffilename[n - 1] != '\n')
  253. ohshit(_("conffile name '%s' is too long, or missing final newline"),
  254. conffilename);
  255. conffilename[n - 1] = '\0';
  256. varbuf_reset(&controlfile);
  257. varbuf_printf(&controlfile, "%s/%s", dir, conffilename);
  258. if (lstat(controlfile.buf, &controlstab)) {
  259. if (errno == ENOENT) {
  260. if ((n > 1) && c_isspace(conffilename[n - 2]))
  261. warning(_("conffile filename '%s' contains trailing white spaces"),
  262. conffilename);
  263. ohshit(_("conffile '%.250s' does not appear in package"), conffilename);
  264. } else
  265. ohshite(_("conffile '%.250s' is not stattable"), conffilename);
  266. } else if (!S_ISREG(controlstab.st_mode)) {
  267. warning(_("conffile '%s' is not a plain file"), conffilename);
  268. }
  269. if (file_info_find_name(conffiles_head, conffilename)) {
  270. warning(_("conffile name '%s' is duplicated"), conffilename);
  271. } else {
  272. struct file_info *conffile;
  273. conffile = file_info_new(conffilename);
  274. file_info_list_append(&conffiles_head, &conffiles_tail, conffile);
  275. }
  276. }
  277. file_info_list_free(conffiles_head);
  278. varbuf_destroy(&controlfile);
  279. if (ferror(cf))
  280. ohshite(_("error reading conffiles file"));
  281. fclose(cf);
  282. }
  283. /**
  284. * Check the control file.
  285. *
  286. * @param dir The directory from where to build the binary package.
  287. * @return The pkginfo struct from the parsed control file.
  288. */
  289. static struct pkginfo *
  290. check_control_file(const char *dir)
  291. {
  292. struct pkginfo *pkg;
  293. char *controlfile;
  294. m_asprintf(&controlfile, "%s/%s/%s", dir, BUILDCONTROLDIR, CONTROLFILE);
  295. parsedb(controlfile, pdb_parse_binary, &pkg);
  296. if (strspn(pkg->set->name, "abcdefghijklmnopqrstuvwxyz0123456789+-.") !=
  297. strlen(pkg->set->name))
  298. ohshit(_("package name has characters that aren't lowercase alphanums or '-+.'"));
  299. if (pkg->priority == PKG_PRIO_OTHER)
  300. warning(_("'%s' contains user-defined Priority value '%s'"),
  301. controlfile, pkg->otherpriority);
  302. free(controlfile);
  303. return pkg;
  304. }
  305. /**
  306. * Perform some sanity checks on the to-be-built package control area.
  307. *
  308. * @param dir The directory from where to build the binary package.
  309. * @return The pkginfo struct from the parsed control file.
  310. */
  311. static struct pkginfo *
  312. check_control_area(const char *dir)
  313. {
  314. struct pkginfo *pkg;
  315. int warns;
  316. /* Start by reading in the control file so we can check its contents. */
  317. pkg = check_control_file(dir);
  318. check_file_perms(dir);
  319. check_conffiles(dir);
  320. warns = warning_get_count();
  321. if (warns)
  322. warning(P_("ignoring %d warning about the control file(s)",
  323. "ignoring %d warnings about the control file(s)", warns),
  324. warns);
  325. return pkg;
  326. }
  327. /**
  328. * Generate the pathname for the destination binary package.
  329. *
  330. * If the pathname cannot be computed, because the destination is a directory,
  331. * then NULL will be returned.
  332. *
  333. * @param dir The directory from where to build the binary package.
  334. * @param dest The destination name, either a file or directory name.
  335. * @return The pathname for the package being built.
  336. */
  337. static char *
  338. gen_dest_pathname(const char *dir, const char *dest)
  339. {
  340. if (dest) {
  341. struct stat dest_stab;
  342. if (stat(dest, &dest_stab)) {
  343. if (errno != ENOENT)
  344. ohshite(_("unable to check for existence of archive '%.250s'"), dest);
  345. } else if (S_ISDIR(dest_stab.st_mode)) {
  346. /* Need to compute the destination name from the package control file. */
  347. return NULL;
  348. }
  349. return m_strdup(dest);
  350. } else {
  351. char *pathname;
  352. pathname = m_malloc(strlen(dir) + sizeof(DEBEXT));
  353. strcpy(pathname, dir);
  354. path_trim_slash_slashdot(pathname);
  355. strcat(pathname, DEBEXT);
  356. return pathname;
  357. }
  358. }
  359. /**
  360. * Generate the pathname for the destination binary package from control file.
  361. *
  362. * @return The pathname for the package being built.
  363. */
  364. static char *
  365. gen_dest_pathname_from_pkg(const char *dir, struct pkginfo *pkg)
  366. {
  367. const char *arch_sep;
  368. char *path;
  369. if (pkg->available.arch->type == DPKG_ARCH_NONE ||
  370. pkg->available.arch->type == DPKG_ARCH_EMPTY)
  371. arch_sep = "";
  372. else
  373. arch_sep = "_";
  374. m_asprintf(&path, "%s/%s_%s%s%s%s", dir, pkg->set->name,
  375. versiondescribe(&pkg->available.version, vdew_never),
  376. arch_sep, pkg->available.arch->name, DEBEXT);
  377. return path;
  378. }
  379. /**
  380. * Overly complex function that builds a .deb file.
  381. */
  382. int
  383. do_build(const char *const *argv)
  384. {
  385. struct compress_params control_compress_params;
  386. struct dpkg_error err;
  387. const char *dir, *dest;
  388. char *debar;
  389. char *tfbuf;
  390. int arfd;
  391. int p1[2], p2[2], gzfd;
  392. pid_t c1, c2;
  393. /* Decode our arguments. */
  394. dir = *argv++;
  395. if (!dir)
  396. badusage(_("--%s needs a <directory> argument"), cipaction->olong);
  397. dest = *argv++;
  398. if (dest && *argv)
  399. badusage(_("--%s takes at most two arguments"), cipaction->olong);
  400. debar = gen_dest_pathname(dir, dest);
  401. /* Perform some sanity checks on the to-be-build package. */
  402. if (nocheckflag) {
  403. if (debar == NULL)
  404. ohshit(_("target is directory - cannot skip control file check"));
  405. warning(_("not checking contents of control area"));
  406. printf(_("dpkg-deb: building an unknown package in '%s'.\n"), debar);
  407. } else {
  408. struct pkginfo *pkg;
  409. pkg = check_control_area(dir);
  410. if (debar == NULL)
  411. debar = gen_dest_pathname_from_pkg(dest, pkg);
  412. printf(_("dpkg-deb: building package '%s' in '%s'.\n"),
  413. pkg->set->name, debar);
  414. }
  415. m_output(stdout, _("<standard output>"));
  416. /* Now that we have verified everything its time to actually
  417. * build something. Let's start by making the ar-wrapper. */
  418. arfd = creat(debar, 0644);
  419. if (arfd < 0)
  420. ohshite(_("unable to create '%.255s'"), debar);
  421. /* Fork a tar to package the control-section of the package. */
  422. unsetenv("TAR_OPTIONS");
  423. m_pipe(p1);
  424. c1 = subproc_fork();
  425. if (!c1) {
  426. m_dup2(p1[1],1); close(p1[0]); close(p1[1]);
  427. if (chdir(dir))
  428. ohshite(_("failed to chdir to '%.255s'"), dir);
  429. if (chdir(BUILDCONTROLDIR))
  430. ohshite(_("failed to chdir to '%.255s'"), ".../DEBIAN");
  431. execlp(TAR, "tar", "-cf", "-", "--format=gnu", ".", NULL);
  432. ohshite(_("unable to execute %s (%s)"), "tar -cf", TAR);
  433. }
  434. close(p1[1]);
  435. /* Create a temporary file to store the control data in. Immediately
  436. * unlink our temporary file so others can't mess with it. */
  437. tfbuf = path_make_temp_template("dpkg-deb");
  438. gzfd = mkstemp(tfbuf);
  439. if (gzfd == -1)
  440. ohshite(_("failed to make temporary file (%s)"), _("control member"));
  441. /* Make sure it's gone, the fd will remain until we close it. */
  442. if (unlink(tfbuf))
  443. ohshit(_("failed to unlink temporary file (%s), %s"), _("control member"),
  444. tfbuf);
  445. free(tfbuf);
  446. /* And run the compressor on our control archive. */
  447. if (opt_uniform_compression) {
  448. control_compress_params = compress_params;
  449. } else {
  450. control_compress_params.type = COMPRESSOR_TYPE_GZIP;
  451. control_compress_params.strategy = COMPRESSOR_STRATEGY_NONE;
  452. control_compress_params.level = -1;
  453. }
  454. c2 = subproc_fork();
  455. if (!c2) {
  456. compress_filter(&control_compress_params, p1[0], gzfd, _("compressing control member"));
  457. exit(0);
  458. }
  459. close(p1[0]);
  460. subproc_reap(c2, _("<compress> from tar -cf"), 0);
  461. subproc_reap(c1, "tar -cf", 0);
  462. if (lseek(gzfd, 0, SEEK_SET))
  463. ohshite(_("failed to rewind temporary file (%s)"), _("control member"));
  464. /* We have our first file for the ar-archive. Write a header for it
  465. * to the package and insert it. */
  466. if (deb_format.major == 0) {
  467. struct stat controlstab;
  468. char versionbuf[40];
  469. if (fstat(gzfd, &controlstab))
  470. ohshite(_("failed to stat temporary file (%s)"), _("control member"));
  471. sprintf(versionbuf, "%-8s\n%jd\n", OLDARCHIVEVERSION,
  472. (intmax_t)controlstab.st_size);
  473. if (fd_write(arfd, versionbuf, strlen(versionbuf)) < 0)
  474. ohshite(_("error writing '%s'"), debar);
  475. if (fd_fd_copy(gzfd, arfd, -1, &err) < 0)
  476. ohshit(_("cannot copy '%s' into archive '%s': %s"), _("control member"),
  477. debar, err.str);
  478. } else if (deb_format.major == 2) {
  479. const char deb_magic[] = ARCHIVEVERSION "\n";
  480. char adminmember[16 + 1];
  481. sprintf(adminmember, "%s%s", ADMINMEMBER,
  482. compressor_get_extension(control_compress_params.type));
  483. dpkg_ar_put_magic(debar, arfd);
  484. dpkg_ar_member_put_mem(debar, arfd, DEBMAGIC, deb_magic, strlen(deb_magic));
  485. dpkg_ar_member_put_file(debar, arfd, adminmember, gzfd, -1);
  486. } else {
  487. internerr("unknown deb format version %d.%d", deb_format.major, deb_format.minor);
  488. }
  489. close(gzfd);
  490. /* Control is done, now we need to archive the data. */
  491. if (deb_format.major == 0) {
  492. /* In old format, the data member is just concatenated after the
  493. * control member, so we do not need a temporary file and can use
  494. * the compression file descriptor. */
  495. gzfd = arfd;
  496. } else if (deb_format.major == 2) {
  497. /* Start by creating a new temporary file. Immediately unlink the
  498. * temporary file so others can't mess with it. */
  499. tfbuf = path_make_temp_template("dpkg-deb");
  500. gzfd = mkstemp(tfbuf);
  501. if (gzfd == -1)
  502. ohshite(_("failed to make temporary file (%s)"), _("data member"));
  503. /* Make sure it's gone, the fd will remain until we close it. */
  504. if (unlink(tfbuf))
  505. ohshit(_("failed to unlink temporary file (%s), %s"), _("data member"),
  506. tfbuf);
  507. free(tfbuf);
  508. } else {
  509. internerr("unknown deb format version %d.%d", deb_format.major, deb_format.minor);
  510. }
  511. /* Fork off a tar. We will feed it a list of filenames on stdin later. */
  512. m_pipe(p1);
  513. m_pipe(p2);
  514. c1 = subproc_fork();
  515. if (!c1) {
  516. m_dup2(p1[0],0); close(p1[0]); close(p1[1]);
  517. m_dup2(p2[1],1); close(p2[0]); close(p2[1]);
  518. if (chdir(dir))
  519. ohshite(_("failed to chdir to '%.255s'"), dir);
  520. execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", "--no-unquote",
  521. "-T", "-", "--no-recursion", NULL);
  522. ohshite(_("unable to execute %s (%s)"), "tar -cf", TAR);
  523. }
  524. close(p1[0]);
  525. close(p2[1]);
  526. /* Of course we should not forget to compress the archive as well. */
  527. c2 = subproc_fork();
  528. if (!c2) {
  529. close(p1[1]);
  530. compress_filter(&compress_params, p2[0], gzfd, _("compressing data member"));
  531. exit(0);
  532. }
  533. close(p2[0]);
  534. /* All the pipes are set, now lets walk the tree, and start feeding
  535. * filenames to tar. */
  536. file_treewalk_feed(dir, p1[1]);
  537. /* All done, clean up wait for tar and <compress> to finish their job. */
  538. close(p1[1]);
  539. subproc_reap(c2, _("<compress> from tar -cf"), 0);
  540. subproc_reap(c1, "tar -cf", 0);
  541. /* Okay, we have data.tar as well now, add it to the ar wrapper. */
  542. if (deb_format.major == 2) {
  543. char datamember[16 + 1];
  544. sprintf(datamember, "%s%s", DATAMEMBER,
  545. compressor_get_extension(compress_params.type));
  546. if (lseek(gzfd, 0, SEEK_SET))
  547. ohshite(_("failed to rewind temporary file (%s)"), _("data member"));
  548. dpkg_ar_member_put_file(debar, arfd, datamember, gzfd, -1);
  549. close(gzfd);
  550. }
  551. if (fsync(arfd))
  552. ohshite(_("unable to sync file '%s'"), debar);
  553. if (close(arfd))
  554. ohshite(_("unable to close file '%s'"), debar);
  555. free(debar);
  556. return 0;
  557. }