build.c 18 KB

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