build.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  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. *
  8. * This is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2,
  11. * or (at your option) any later version.
  12. *
  13. * This is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <config.h>
  22. #include <compat.h>
  23. #include <sys/types.h>
  24. #include <sys/stat.h>
  25. #include <sys/wait.h>
  26. #include <assert.h>
  27. #include <errno.h>
  28. #include <limits.h>
  29. #include <ctype.h>
  30. #include <string.h>
  31. #include <time.h>
  32. #include <dirent.h>
  33. #include <signal.h>
  34. #include <unistd.h>
  35. #include <stdbool.h>
  36. #include <stdlib.h>
  37. #include <stdio.h>
  38. #ifdef WITH_ZLIB
  39. #include <zlib.h>
  40. #endif
  41. #include <dpkg/i18n.h>
  42. #include <dpkg/dpkg.h>
  43. #include <dpkg/dpkg-db.h>
  44. #include <dpkg/path.h>
  45. #include <dpkg/buffer.h>
  46. #include <dpkg/subproc.h>
  47. #include <dpkg/myopt.h>
  48. #include "dpkg-deb.h"
  49. /* Simple structure to store information about a file.
  50. */
  51. struct file_info {
  52. struct file_info *next;
  53. struct stat st;
  54. char* fn;
  55. };
  56. static const char *arbitrary_fields[] = {
  57. "Package-Type",
  58. "Subarchitecture",
  59. "Kernel-Version",
  60. "Installer-Menu-Item",
  61. "Homepage",
  62. "Tag",
  63. NULL
  64. };
  65. static const char private_prefix[] = "Private-";
  66. static bool
  67. known_arbitrary_field(const struct arbitraryfield *field)
  68. {
  69. const char **known;
  70. /* Always accept fields starting with a private field prefix. */
  71. if (strncasecmp(field->name, private_prefix, strlen(private_prefix)) == 0)
  72. return true;
  73. for (known= arbitrary_fields; *known; known++)
  74. if (strcasecmp(field->name, *known) == 0)
  75. return true;
  76. return false;
  77. }
  78. /* Do a quick check if vstring is a valid versionnumber. Valid in this case
  79. * means it contains at least one digit. If an error is found increment
  80. * *errs.
  81. */
  82. static void checkversion(const char *vstring, const char *valuename, int *errs) {
  83. const char *p;
  84. if (!vstring || !*vstring) return;
  85. for (p=vstring; *p; p++) if (cisdigit(*p)) return;
  86. fprintf(stderr, _("dpkg-deb - error: %s (`%s') doesn't contain any digits\n"),
  87. valuename, vstring);
  88. (*errs)++;
  89. }
  90. static struct file_info *
  91. file_info_new(const char *filename)
  92. {
  93. struct file_info *fi;
  94. fi = m_malloc(sizeof(*fi));
  95. fi->fn = m_strdup(filename);
  96. fi->next = NULL;
  97. return fi;
  98. }
  99. static struct file_info *
  100. file_info_find_name(struct file_info *list, const char *filename)
  101. {
  102. struct file_info *node;
  103. for (node = list; node; node = node->next)
  104. if (strcmp(node->fn, filename) == 0)
  105. return node;
  106. return NULL;
  107. }
  108. /*
  109. * Read the next filename from a filedescriptor and create a file_info struct
  110. * for it. If there is nothing to read return NULL.
  111. */
  112. static struct file_info *
  113. getfi(const char *root, int fd)
  114. {
  115. static char* fn = NULL;
  116. static size_t fnlen = 0;
  117. size_t i= 0;
  118. struct file_info *fi;
  119. size_t rl = strlen(root);
  120. if (fn == NULL) {
  121. fnlen = rl + MAXFILENAME;
  122. fn = m_malloc(fnlen);
  123. } else if (fnlen < (rl + MAXFILENAME)) {
  124. fnlen = rl + MAXFILENAME;
  125. fn = m_realloc(fn, fnlen);
  126. }
  127. i=sprintf(fn,"%s/",root);
  128. while (1) {
  129. int res;
  130. if (i>=fnlen) {
  131. fnlen += MAXFILENAME;
  132. fn = m_realloc(fn, fnlen);
  133. }
  134. if ((res=read(fd, (fn+i), sizeof(*fn)))<0) {
  135. if ((errno==EINTR) || (errno==EAGAIN))
  136. continue;
  137. else
  138. return NULL;
  139. }
  140. if (res == 0) /* EOF -> parent died. */
  141. return NULL;
  142. if (fn[i] == '\0')
  143. break;
  144. i++;
  145. if (i >= MAXFILENAME)
  146. ohshit(_("file name '%.50s...' is too long"), fn + rl + 1);
  147. }
  148. fi = file_info_new(fn + rl + 1);
  149. lstat(fn, &(fi->st));
  150. return fi;
  151. }
  152. /*
  153. * Add a new file_info struct to a single linked list of file_info structs.
  154. * We perform a slight optimization to work around a `feature' in tar: tar
  155. * always recurses into subdirectories if you list a subdirectory. So if an
  156. * entry is added and the previous entry in the list is its subdirectory we
  157. * remove the subdirectory.
  158. *
  159. * After a file_info struct is added to a list it may no longer be freed, we
  160. * assume full responsibility for its memory.
  161. */
  162. static void
  163. add_to_filist(struct file_info **start, struct file_info **end,
  164. struct file_info *fi)
  165. {
  166. if (*start==NULL)
  167. *start=*end=fi;
  168. else
  169. *end=(*end)->next=fi;
  170. }
  171. /*
  172. * Free the memory for all entries in a list of file_info structs.
  173. */
  174. static void
  175. free_filist(struct file_info *fi)
  176. {
  177. while (fi) {
  178. struct file_info *fl;
  179. free(fi->fn);
  180. fl=fi; fi=fi->next;
  181. free(fl);
  182. }
  183. }
  184. /* Overly complex function that builds a .deb file
  185. */
  186. void do_build(const char *const *argv) {
  187. static const char *const maintainerscripts[]= {
  188. PREINSTFILE, POSTINSTFILE, PRERMFILE, POSTRMFILE, NULL
  189. };
  190. char *m;
  191. const char *debar, *directory, *const *mscriptp, *versionstring, *arch;
  192. char *controlfile, *tfbuf;
  193. const char *envbuf;
  194. struct pkginfo *checkedinfo;
  195. struct arbitraryfield *field;
  196. FILE *ar, *cf;
  197. int p1[2],p2[2],p3[2], warns, errs, n, c, subdir, gzfd;
  198. pid_t c1,c2,c3;
  199. struct stat controlstab, datastab, mscriptstab, debarstab;
  200. char conffilename[MAXCONFFILENAME+1];
  201. time_t thetime= 0;
  202. struct file_info *fi;
  203. struct file_info *symlist = NULL;
  204. struct file_info *symlist_end = NULL;
  205. /* Decode our arguments */
  206. directory = *argv++;
  207. if (!directory)
  208. badusage(_("--%s needs a <directory> argument"), cipaction->olong);
  209. /* template for our tempfiles */
  210. if ((envbuf= getenv("TMPDIR")) == NULL)
  211. envbuf= P_tmpdir;
  212. tfbuf = m_malloc(strlen(envbuf) + 13);
  213. strcpy(tfbuf,envbuf);
  214. strcat(tfbuf,"/dpkg.XXXXXX");
  215. subdir= 0;
  216. debar = *argv++;
  217. if (debar != NULL) {
  218. if (*argv) badusage(_("--build takes at most two arguments"));
  219. if (debar) {
  220. if (stat(debar,&debarstab)) {
  221. if (errno != ENOENT)
  222. ohshite(_("unable to check for existence of archive `%.250s'"),debar);
  223. } else if (S_ISDIR(debarstab.st_mode)) {
  224. subdir= 1;
  225. }
  226. }
  227. } else {
  228. m= m_malloc(strlen(directory) + sizeof(DEBEXT));
  229. strcpy(m, directory);
  230. path_rtrim_slash_slashdot(m);
  231. strcat(m, DEBEXT);
  232. debar= m;
  233. }
  234. /* Perform some sanity checks on the to-be-build package.
  235. */
  236. if (nocheckflag) {
  237. if (subdir)
  238. ohshit(_("target is directory - cannot skip control file check"));
  239. warning(_("not checking contents of control area."));
  240. printf(_("dpkg-deb: building an unknown package in '%s'.\n"), debar);
  241. } else {
  242. controlfile= m_malloc(strlen(directory) + sizeof(BUILDCONTROLDIR) +
  243. sizeof(CONTROLFILE) + sizeof(CONFFILESFILE) +
  244. sizeof(POSTINSTFILE) + sizeof(PREINSTFILE) +
  245. sizeof(POSTRMFILE) + sizeof(PRERMFILE) +
  246. MAXCONFFILENAME + 5);
  247. /* Lets start by reading in the control-file so we can check its contents */
  248. strcpy(controlfile, directory);
  249. strcat(controlfile, "/" BUILDCONTROLDIR "/" CONTROLFILE);
  250. warns= 0; errs= 0;
  251. parsedb(controlfile, pdb_recordavailable|pdb_rejectstatus,
  252. &checkedinfo, stderr, &warns);
  253. assert(checkedinfo->available.valid);
  254. if (strspn(checkedinfo->name,
  255. "abcdefghijklmnopqrstuvwxyz0123456789+-.")
  256. != strlen(checkedinfo->name))
  257. ohshit(_("package name has characters that aren't lowercase alphanums or `-+.'"));
  258. if (checkedinfo->priority == pri_other) {
  259. warning(_("'%s' contains user-defined Priority value '%s'"),
  260. controlfile, checkedinfo->otherpriority);
  261. warns++;
  262. }
  263. for (field= checkedinfo->available.arbs; field; field= field->next) {
  264. if (known_arbitrary_field(field))
  265. continue;
  266. warning(_("'%s' contains user-defined field '%s'"),
  267. controlfile, field->name);
  268. warns++;
  269. }
  270. checkversion(checkedinfo->available.version.version,
  271. _("(upstream) version"), &errs);
  272. checkversion(checkedinfo->available.version.revision,
  273. _("Debian revision"), &errs);
  274. if (errs) ohshit(_("%d errors in control file"),errs);
  275. if (subdir) {
  276. versionstring= versiondescribe(&checkedinfo->available.version,vdew_never);
  277. arch= checkedinfo->available.architecture; if (!arch) arch= "";
  278. m= m_malloc(sizeof(DEBEXT)+1+strlen(debar)+1+strlen(checkedinfo->name)+
  279. strlen(versionstring)+1+strlen(arch));
  280. sprintf(m,"%s/%s_%s%s%s" DEBEXT,debar,checkedinfo->name,versionstring,
  281. arch[0] ? "_" : "", arch);
  282. debar= m;
  283. }
  284. printf(_("dpkg-deb: building package `%s' in `%s'.\n"), checkedinfo->name, debar);
  285. /* Check file permissions */
  286. strcpy(controlfile, directory);
  287. strcat(controlfile, "/" BUILDCONTROLDIR "/");
  288. if (lstat(controlfile, &mscriptstab))
  289. ohshite(_("unable to stat control directory"));
  290. if (!S_ISDIR(mscriptstab.st_mode))
  291. ohshit(_("control directory is not a directory"));
  292. if ((mscriptstab.st_mode & 07757) != 0755)
  293. ohshit(_("control directory has bad permissions %03lo (must be >=0755 "
  294. "and <=0775)"), (unsigned long)(mscriptstab.st_mode & 07777));
  295. for (mscriptp= maintainerscripts; *mscriptp; mscriptp++) {
  296. strcpy(controlfile, directory);
  297. strcat(controlfile, "/" BUILDCONTROLDIR "/");
  298. strcat(controlfile, *mscriptp);
  299. if (!lstat(controlfile,&mscriptstab)) {
  300. if (S_ISLNK(mscriptstab.st_mode)) continue;
  301. if (!S_ISREG(mscriptstab.st_mode))
  302. ohshit(_("maintainer script `%.50s' is not a plain file or symlink"),*mscriptp);
  303. if ((mscriptstab.st_mode & 07557) != 0555)
  304. ohshit(_("maintainer script `%.50s' has bad permissions %03lo "
  305. "(must be >=0555 and <=0775)"),
  306. *mscriptp, (unsigned long)(mscriptstab.st_mode & 07777));
  307. } else if (errno != ENOENT) {
  308. ohshite(_("maintainer script `%.50s' is not stattable"),*mscriptp);
  309. }
  310. }
  311. /* Check if conffiles contains sane information */
  312. strcpy(controlfile, directory);
  313. strcat(controlfile, "/" BUILDCONTROLDIR "/" CONFFILESFILE);
  314. if ((cf= fopen(controlfile,"r"))) {
  315. struct file_info *conffiles_head = NULL;
  316. struct file_info *conffiles_tail = NULL;
  317. while (fgets(conffilename,MAXCONFFILENAME+1,cf)) {
  318. n= strlen(conffilename);
  319. if (!n) ohshite(_("empty string from fgets reading conffiles"));
  320. if (conffilename[n-1] != '\n') {
  321. warning(_("conffile name '%.50s...' is too long, or missing final newline"),
  322. conffilename);
  323. warns++;
  324. while ((c= getc(cf)) != EOF && c != '\n');
  325. continue;
  326. }
  327. conffilename[n - 1] = '\0';
  328. strcpy(controlfile, directory);
  329. strcat(controlfile, "/");
  330. strcat(controlfile, conffilename);
  331. if (lstat(controlfile,&controlstab)) {
  332. if (errno == ENOENT) {
  333. if((n > 1) && isspace(conffilename[n-2]))
  334. warning(_("conffile filename '%s' contains trailing white spaces"),
  335. conffilename);
  336. ohshit(_("conffile `%.250s' does not appear in package"), conffilename);
  337. } else
  338. ohshite(_("conffile `%.250s' is not stattable"), conffilename);
  339. } else if (!S_ISREG(controlstab.st_mode)) {
  340. warning(_("conffile '%s' is not a plain file"), conffilename);
  341. warns++;
  342. }
  343. if (file_info_find_name(conffiles_head, conffilename))
  344. warning(_("conffile name '%s' is duplicated"), conffilename);
  345. else {
  346. struct file_info *conffile;
  347. conffile = file_info_new(conffilename);
  348. add_to_filist(&conffiles_head, &conffiles_tail, conffile);
  349. }
  350. }
  351. free_filist(conffiles_head);
  352. if (ferror(cf)) ohshite(_("error reading conffiles file"));
  353. fclose(cf);
  354. } else if (errno != ENOENT) {
  355. ohshite(_("error opening conffiles file"));
  356. }
  357. if (warns)
  358. warning(_("ignoring %d warnings about the control file(s)\n"), warns);
  359. }
  360. m_output(stdout, _("<standard output>"));
  361. /* Now that we have verified everything its time to actually
  362. * build something. Lets start by making the ar-wrapper.
  363. */
  364. if (!(ar=fopen(debar,"wb"))) ohshite(_("unable to create `%.255s'"),debar);
  365. if (setvbuf(ar, NULL, _IONBF, 0))
  366. ohshite(_("unable to unbuffer `%.255s'"), debar);
  367. /* Fork a tar to package the control-section of the package */
  368. unsetenv("TAR_OPTIONS");
  369. m_pipe(p1);
  370. if (!(c1= m_fork())) {
  371. m_dup2(p1[1],1); close(p1[0]); close(p1[1]);
  372. if (chdir(directory)) ohshite(_("failed to chdir to `%.255s'"),directory);
  373. if (chdir(BUILDCONTROLDIR)) ohshite(_("failed to chdir to .../DEBIAN"));
  374. execlp(TAR, "tar", "-cf", "-", "--format=gnu", ".", NULL);
  375. ohshite(_("failed to exec tar -cf"));
  376. }
  377. close(p1[1]);
  378. /* Create a temporary file to store the control data in. Immediately unlink
  379. * our temporary file so others can't mess with it.
  380. */
  381. if ((gzfd= mkstemp(tfbuf)) == -1) ohshite(_("failed to make tmpfile (control)"));
  382. /* make sure it's gone, the fd will remain until we close it */
  383. if (unlink(tfbuf)) ohshit(_("failed to unlink tmpfile (control), %s"),
  384. tfbuf);
  385. /* reset this, so we can use it elsewhere */
  386. strcpy(tfbuf,envbuf);
  387. strcat(tfbuf,"/dpkg.XXXXXX");
  388. /* And run gzip to compress our control archive */
  389. if (!(c2= m_fork())) {
  390. m_dup2(p1[0],0); m_dup2(gzfd,1); close(p1[0]); close(gzfd);
  391. compress_cat(compress_type_gzip, 0, 1, "9", _("control"));
  392. }
  393. close(p1[0]);
  394. subproc_wait_check(c2, "gzip -9c", 0);
  395. subproc_wait_check(c1, "tar -cf", 0);
  396. if (fstat(gzfd,&controlstab)) ohshite(_("failed to fstat tmpfile (control)"));
  397. /* We have our first file for the ar-archive. Write a header for it to the
  398. * package and insert it.
  399. */
  400. if (oldformatflag) {
  401. if (fprintf(ar, "%-8s\n%ld\n", OLDARCHIVEVERSION, (long)controlstab.st_size) == EOF)
  402. werr(debar);
  403. } else {
  404. thetime = time(NULL);
  405. if (fprintf(ar,
  406. "!<arch>\n"
  407. "debian-binary %-12lu0 0 100644 %-10ld`\n"
  408. ARCHIVEVERSION "\n"
  409. "%s"
  410. ADMINMEMBER "%-12lu0 0 100644 %-10ld`\n",
  411. thetime,
  412. (long)sizeof(ARCHIVEVERSION),
  413. (sizeof(ARCHIVEVERSION)&1) ? "\n" : "",
  414. (unsigned long)thetime,
  415. (long)controlstab.st_size) == EOF)
  416. werr(debar);
  417. }
  418. if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (control)"));
  419. fd_fd_copy(gzfd, fileno(ar), -1, _("control"));
  420. /* Control is done, now we need to archive the data. Start by creating
  421. * a new temporary file. Immediately unlink the temporary file so others
  422. * can't mess with it. */
  423. if (!oldformatflag) {
  424. close(gzfd);
  425. if ((gzfd= mkstemp(tfbuf)) == -1) ohshite(_("failed to make tmpfile (data)"));
  426. /* make sure it's gone, the fd will remain until we close it */
  427. if (unlink(tfbuf)) ohshit(_("failed to unlink tmpfile (data), %s"),
  428. tfbuf);
  429. /* reset these, in case we want to use the later */
  430. strcpy(tfbuf,envbuf);
  431. strcat(tfbuf,"/dpkg.XXXXXX");
  432. }
  433. /* Fork off a tar. We will feed it a list of filenames on stdin later.
  434. */
  435. m_pipe(p1);
  436. m_pipe(p2);
  437. if (!(c1= m_fork())) {
  438. m_dup2(p1[0],0); close(p1[0]); close(p1[1]);
  439. m_dup2(p2[1],1); close(p2[0]); close(p2[1]);
  440. if (chdir(directory)) ohshite(_("failed to chdir to `%.255s'"),directory);
  441. execlp(TAR, "tar", "-cf", "-", "--format=gnu", "--null", "-T", "-", "--no-recursion", NULL);
  442. ohshite(_("failed to exec tar -cf"));
  443. }
  444. close(p1[0]);
  445. close(p2[1]);
  446. /* Of course we should not forget to compress the archive as well.. */
  447. if (!(c2= m_fork())) {
  448. close(p1[1]);
  449. m_dup2(p2[0],0); close(p2[0]);
  450. m_dup2(oldformatflag ? fileno(ar) : gzfd,1);
  451. compress_cat(compress_type, 0, 1, compression, _("data"));
  452. }
  453. close(p2[0]);
  454. /* All the pipes are set, now lets run find, and start feeding
  455. * filenames to tar.
  456. */
  457. m_pipe(p3);
  458. if (!(c3= m_fork())) {
  459. m_dup2(p3[1],1); close(p3[0]); close(p3[1]);
  460. if (chdir(directory)) ohshite(_("failed to chdir to `%.255s'"),directory);
  461. execlp(FIND, "find", ".", "-path", "./" BUILDCONTROLDIR, "-prune", "-o",
  462. "-print0", NULL);
  463. ohshite(_("failed to exec find"));
  464. }
  465. close(p3[1]);
  466. /* We need to reorder the files so we can make sure that symlinks
  467. * will not appear before their target.
  468. */
  469. while ((fi=getfi(directory, p3[0]))!=NULL)
  470. if (S_ISLNK(fi->st.st_mode))
  471. add_to_filist(&symlist, &symlist_end, fi);
  472. else {
  473. if (write(p1[1], fi->fn, strlen(fi->fn)+1) ==- 1)
  474. ohshite(_("failed to write filename to tar pipe (data)"));
  475. }
  476. close(p3[0]);
  477. subproc_wait_check(c3, "find", 0);
  478. for (fi= symlist;fi;fi= fi->next)
  479. if (write(p1[1], fi->fn, strlen(fi->fn)+1) == -1)
  480. ohshite(_("failed to write filename to tar pipe (data)"));
  481. /* All done, clean up wait for tar and gzip to finish their job */
  482. close(p1[1]);
  483. free_filist(symlist);
  484. subproc_wait_check(c2, _("<compress> from tar -cf"), 0);
  485. subproc_wait_check(c1, "tar -cf", 0);
  486. /* Okay, we have data.tar.gz as well now, add it to the ar wrapper */
  487. if (!oldformatflag) {
  488. const char *datamember;
  489. switch (compress_type) {
  490. case compress_type_gzip:
  491. datamember = DATAMEMBER_GZ;
  492. break;
  493. case compress_type_bzip2:
  494. datamember = DATAMEMBER_BZ2;
  495. break;
  496. case compress_type_lzma:
  497. datamember = DATAMEMBER_LZMA;
  498. break;
  499. case compress_type_cat:
  500. datamember = DATAMEMBER_CAT;
  501. break;
  502. default:
  503. internerr("unkown compress_type '%i'", compress_type);
  504. }
  505. if (fstat(gzfd, &datastab))
  506. ohshite(_("failed to fstat tmpfile (data)"));
  507. if (fprintf(ar,
  508. "%s"
  509. "%s" "%-12lu0 0 100644 %-10ld`\n",
  510. (controlstab.st_size & 1) ? "\n" : "",
  511. datamember,
  512. (unsigned long)thetime,
  513. (long)datastab.st_size) == EOF)
  514. werr(debar);
  515. if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (data)"));
  516. fd_fd_copy(gzfd, fileno(ar), -1, _("cat (data)"));
  517. if (datastab.st_size & 1)
  518. if (putc('\n',ar) == EOF)
  519. werr(debar);
  520. }
  521. if (fclose(ar)) werr(debar);
  522. exit(0);
  523. }