home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / gnu / utils / bug / 2278 < prev    next >
Encoding:
Text File  |  1992-12-29  |  9.2 KB  |  294 lines

  1. Newsgroups: gnu.utils.bug
  2. Path: sparky!uunet!usc!howland.reston.ans.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!thor.atd.ucar.edu!thor
  3. From: thor@thor.atd.ucar.edu (Richard Neitzel)
  4. Subject: Suggested patch to support gzip.
  5. Message-ID: <9212281744.AA29497@thor.atd.ucar.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Mon, 28 Dec 1992 17:44:32 GMT
  10. Approved: bug-gnu-utils@prep.ai.mit.edu
  11. Lines: 281
  12.  
  13. The following is a quick & dirty patch to make tar-1.11.1 support the
  14. new gzip program. It breaks the -z & -Z flags apart, -z becoming the
  15. gzip switch and -Z the compress switch.
  16.  
  17. --
  18. Richard Neitzel thor@thor.atd.ucar.edu          Torren med sitt skjegg
  19. National Center For Atmospheric Research        lokkar borni under sole-vegg
  20. Box 3000 Boulder, CO 80307-3000                    Gjo'i med sitt shinn
  21. 303-497-2057                                    jagar borni inn.
  22. --------------------------------------------------------------------
  23. *** tar.c.orig    Mon Sep 14 15:31:38 1992
  24. --- tar.c    Mon Dec 28 10:33:46 1992
  25. ***************
  26. *** 609,618 ****
  27.               add_exclude_file(optarg);
  28.               break;
  29.   
  30. !         case 'z':        /* Easy to type */
  31. !         case 'Z':        /* Like the filename extension .Z */
  32.               f_compress++;
  33.               break;
  34.   
  35.           case '?':
  36.           badopt:
  37. --- 609,626 ----
  38.               add_exclude_file(optarg);
  39.               break;
  40.   
  41. !         case 'z':        /* Zip mode */
  42. ! #ifdef USE_ZIP
  43.               f_compress++;
  44. +             f_compress_mode = USE_ZIP;
  45.               break;
  46. + #endif
  47. +         case 'Z':        /* Compress mode */
  48. +             f_compress++;
  49. + #ifdef USE_ZIP
  50. +             f_compress_mode = USE_COMPRESS;
  51. + #endif
  52. +             break;
  53.   
  54.           case '?':
  55.           badopt:
  56. ***************
  57. *** 650,655 ****
  58. --- 658,736 ----
  59.   describe()
  60.   {
  61.       puts("choose one of the following:");
  62. + #ifdef USE_ZIP
  63. +     fputs("\
  64. + -A, --catenate,\n\
  65. +     --concatenate    append tar files to an archive\n\
  66. + -c, --create        create a new archive\n\
  67. + -d, --diff,\n\
  68. +     --compare        find differences between archive and file system\n\
  69. + --delete            delete from the archive (not for use on mag tapes!)\n\
  70. + -r, --append        append files to the end of an archive\n\
  71. + -t, --list        list the contents of an archive\n\
  72. + -u, --update        only append files that are newer than copy in archive\n\
  73. + -x, --extract,\n\
  74. +     --get        extract files from an archive\n",stdout);
  75. +     fprintf(stdout, "\
  76. + Other options:\n\
  77. + --atime-preserve    don't change access times on dumped files\n\
  78. + -b, --block-size N    block size of Nx512 bytes (default N=%d)\n", DEFBLOCKING);
  79. +     fputs ("\
  80. + -B, --read-full-blocks    reblock as we read (for reading 4.2BSD pipes)\n\
  81. + -C, --directory DIR    change to directory DIR\n\
  82. + --checkpoint        print directory names while reading the archive\n\
  83. + ", stdout); /* KLUDGE */ fprintf(stdout, "\
  84. + -f, --file [HOSTNAME:]F    use archive file or device F (default %s)\n",
  85. +                  DEF_AR_FILE); fputs("\
  86. + --force-local        archive file is local even if has a colon\n\
  87. + -F, --info-script F    run script at end of each tape (implies -M)\n\
  88. + -G, --incremental    create/list/extract old GNU-format incremental backup\n\
  89. + -g, --listed-incremental F create/list/extract new GNU-format incremental backup\n\
  90. + -h, --dereference    don't dump symlinks; dump the files they point to\n\
  91. + -i, --ignore-zeros    ignore blocks of zeros in archive (normally mean EOF)\n\
  92. + --ignore-failed-read    don't exit with non-zero status on unreadable files\n\
  93. + -k, --keep-old-files    keep existing files; don't overwrite them from archive\n\
  94. + -K, --starting-file FILE    begin at FILE in the archive\n\
  95. + -l, --one-file-system    stay in local file system when creating an archive\n\
  96. + -L, --tape-length LENGTH change tapes after writing LENGTH\n\
  97. + ", stdout); /* KLUDGE */ fputs("\
  98. + -m, --modification-time    don't extract file modified time\n\
  99. + -M, --multi-volume    create/list/extract multi-volume archive\n\
  100. + -N, --after-date DATE,\n\
  101. +     --newer DATE        only store files newer than DATE\n\
  102. + -o, --old-archive,\n\
  103. +     --portability    write a V7 format archive, rather than ANSI format\n\
  104. + -O, --to-stdout        extract files to standard output\n\
  105. + -p, --same-permissions,\n\
  106. +     --preserve-permissions extract all protection information\n\
  107. + -P, --absolute-paths    don't strip leading `/'s from file names\n\
  108. + --preserve        like -p -s\n\
  109. + ", stdout); /* KLUDGE */ fputs("\
  110. + -R, --record-number    show record number within archive with each message\n\
  111. + --remove-files        remove files after adding them to the archive\n\
  112. + -s, --same-order,\n\
  113. +     --preserve-order    list of names to extract is sorted to match archive\n\
  114. + --same-owner        create extracted files with the same ownership \n\
  115. + -S, --sparse        handle sparse files efficiently\n\
  116. + -T, --files-from F    get names to extract or create from file F\n\
  117. + --null            -T reads null-terminated names, disable -C\n\
  118. + --totals            print total bytes written with --create\n\
  119. + -v, --verbose        verbosely list files processed\n\
  120. + -V, --label NAME        create archive with volume name NAME\n\
  121. + --version        print tar program version number\n\
  122. + -w, --interactive,\n\
  123. +     --confirmation    ask for confirmation for every action\n\
  124. + ", stdout); /* KLUDGE */ fputs("\
  125. + -W, --verify        attempt to verify the archive after writing it\n\
  126. + --exclude FILE        exclude file FILE\n\
  127. + -X, --exclude-from FILE    exclude files listed in FILE\n\
  128. + -z filter the archive through gzip\n\
  129. + -Z filter the archive through compress\n\
  130. + -[0-7][lmh]        specify drive and density\n\
  131. + ", stdout);
  132. + }
  133. + #else
  134.       fputs("\
  135.   -A, --catenate,\n\
  136.       --concatenate    append tar files to an archive\n\
  137. ***************
  138. *** 721,727 ****
  139.   -[0-7][lmh]        specify drive and density\n\
  140.   ", stdout);
  141.   }
  142.   void
  143.   name_add(name)
  144.   char *name;
  145. --- 802,808 ----
  146.   -[0-7][lmh]        specify drive and density\n\
  147.   ", stdout);
  148.   }
  149. ! #endif /* USE_ZIP */
  150.   void
  151.   name_add(name)
  152.   char *name;
  153. *** tar.h.orig    Tue Sep  8 13:45:34 1992
  154. --- tar.h    Mon Dec 28 09:35:24 1992
  155. ***************
  156. *** 224,231 ****
  157.   TAR_EXTERN int  f_verify;        /* -W */
  158.               /* CMD_EXTRACT     -x */
  159.   TAR_EXTERN int  f_exclude;        /* -X */
  160. ! TAR_EXTERN int     f_compress;        /* -z */
  161. !                     /* -Z */
  162.   TAR_EXTERN int    f_do_chown;        /* --do-chown */
  163.   TAR_EXTERN int  f_totals;        /* --totals */
  164.   TAR_EXTERN int    f_remove_files;        /* --remove-files */
  165. --- 224,231 ----
  166.   TAR_EXTERN int  f_verify;        /* -W */
  167.               /* CMD_EXTRACT     -x */
  168.   TAR_EXTERN int  f_exclude;        /* -X */
  169. ! TAR_EXTERN int     f_compress;        /* -z/-Z in use */
  170. ! TAR_EXTERN int  f_compress_mode;    /* -z(use gzip) -Z(use compress) */
  171.   TAR_EXTERN int    f_do_chown;        /* --do-chown */
  172.   TAR_EXTERN int  f_totals;        /* --totals */
  173.   TAR_EXTERN int    f_remove_files;        /* --remove-files */
  174. ***************
  175. *** 276,281 ****
  176. --- 276,286 ----
  177.    */
  178.   TAR_EXTERN char        read_error_flag;
  179.   
  180. + /*
  181. +  * Defines for determining which compression program to use.
  182. +  */
  183. + #define USE_ZIP 1
  184. + #define USE_COMPRESS 2
  185.   
  186.   /*
  187.    * Declarations of functions available to the world.
  188. *** buffer.c.orig    Mon Sep 14 14:56:39 1992
  189. --- buffer.c    Mon Dec 28 10:15:56 1992
  190. ***************
  191. *** 262,267 ****
  192. --- 262,268 ----
  193.   
  194.       int kidpipe[2];
  195.       int kidchildpid;
  196. +     char *compress_prog;
  197.   
  198.   #define READ    0
  199.   #define WRITE    1
  200. ***************
  201. *** 451,461 ****
  202.               exit(0);
  203.           }
  204.       }
  205. !         /* So we should exec compress (-d) */
  206.       if(ar_reading)
  207. !         execlp("compress", "compress", "-d", (char *)0);
  208.       else
  209. !         execlp("compress", "compress", (char *)0);
  210.       msg_perror("can't exec compress");
  211.       _exit(EX_SYSTEM);
  212.   }
  213. --- 452,475 ----
  214.               exit(0);
  215.           }
  216.       }
  217. ! #ifndef ZIP_NAME
  218. ! #define ZIP_NAME "gzip"
  219. ! #endif
  220. ! #ifndef COMPRESS_NAME
  221. ! #define COMPRESS_NAME "compress"
  222. ! #endif
  223. !         /* So we should exec compress || zip (-d) */
  224. ! #ifdef USE_ZIP
  225. !     if (f_compress_mode == USE_ZIP)
  226. !       compress_prog = ZIP_NAME;
  227. !     else
  228. ! #endif
  229. !       compress_prog = COMPRESS_NAME;
  230.       if(ar_reading)
  231. !         execlp(compress_prog, compress_prog, "-d", (char *)0);
  232.       else
  233. !         execlp(compress_prog, compress_prog, (char *)0);
  234.       msg_perror("can't exec compress");
  235.       _exit(EX_SYSTEM);
  236.   }
  237. *** Makefile.in.orig    Mon Dec 28 10:01:37 1992
  238. --- Makefile.in    Mon Dec 28 10:01:20 1992
  239. ***************
  240. *** 63,68 ****
  241. --- 63,71 ----
  242.   # -DNO_OPEN3        If you lack the 3-argument open and want to
  243.   #            disable the tar -k option instead of emulating open.
  244.   # -DXENIX        If you have sys/inode.h and need it to be included.
  245. + # -DUSE_ZIP             If you have GNU gzip and what to use it.
  246. + # -DZIPNAME=\"????\"    Your local name for gzip. Defaults to "gzip".
  247. + # -DCOMPRESS_NAME=\"???\" Your local name for compress. Defaults to "compress".
  248.   
  249.   DEF_AR_FILE = @DEF_AR_FILE@
  250.   DEFBLOCKING = 20
  251. *** configure.orig    Tue Sep 15 18:29:09 1992
  252. --- configure    Mon Dec 28 09:56:56 1992
  253. ***************
  254. *** 172,177 ****
  255. --- 172,204 ----
  256.     test -n "$need_trad" && CC="$CC -traditional"
  257.   fi
  258.   
  259. + # Check for gzip.
  260. + if test -z "$USE_ZIP"; then
  261. +   echo checking for gzip
  262. +   saveifs="$IFS"; IFS="${IFS}:"
  263. +   for dir in $PATH; do
  264. +     test -z "$dir" && dir=.
  265. +     if test -f $dir/gzip; then
  266. +       DEFS="$DEFS -DUSE_ZIP"
  267. +       USE_ZIP=1
  268. +       break
  269. +     fi
  270. +   done
  271. +   IFS="$saveifs"
  272. + fi
  273. + if test -z "$USE_ZIP"; then
  274. +   echo checking for zip
  275. +   saveifs="$IFS"; IFS="${IFS}:"
  276. +   for dir in $PATH; do
  277. +     test -z "$dir" && dir=.
  278. +     if test -f $dir/zip; then
  279. +       DEFS="$DEFS -DUSE_ZIP"
  280. +       break
  281. +     fi
  282. +   done
  283. +   IFS="$saveifs"
  284. + fi
  285.   # Make sure to not get the incompatible SysV /etc/install and
  286.   # /usr/sbin/install, which might be in PATH before a BSD-like install,
  287.   # or the SunOS /usr/etc/install directory.
  288.  
  289.  
  290.