Hi,

this diff adds a -J flag to tar that calls xz for compress/decompress.
Requires you to install the xz package on your system.

Attached is the diff, critical positive or negative would be appreciated ;-).

Thanks,

Remi.
Index: cpio.1

===================================================================

RCS file: /cvs/src/bin/pax/cpio.1,v

retrieving revision 1.34

diff -u -p -r1.34 cpio.1

--- cpio.1      3 Sep 2011 22:59:08 -0000       1.34

+++ cpio.1      4 Oct 2011 18:23:46 -0000

@@ -32,7 +32,7 @@

 .Sh SYNOPSIS

 .Nm cpio

 .Fl o

-.Op Fl AaBcjLvZz

+.Op Fl AaBcjJLvZz

 .Op Fl C Ar bytes

 .Op Fl F Ar archive

 .Op Fl H Ar format

@@ -41,7 +41,7 @@

 .Op \*(Gt Ar archive

 .Nm cpio

 .Fl i

-.Op Fl 6BbcdfjmrSstuvZz

+.Op Fl 6BbcdfjJmrSstuvZz

 .Op Fl C Ar bytes

 .Op Fl E Ar file

 .Op Fl F Ar archive

@@ -110,6 +110,9 @@ POSIX ustar format.

 .It Fl j

 Compress archive using the bzip2 format.

 The bzip2 utility must be installed separately.

+.It Fl J

+Compress archive using the xz format.

+The xz utility must be installed separately.

 .It Fl L

 Follow symbolic links.

 .It Fl O Ar archive

@@ -185,6 +188,9 @@ POSIX ustar format.

 .It Fl j

 Uncompress archive using the bzip2 format.

 The bzip2 utility must be installed separately.

+.It Fl J

+Uncompress archive using the xz format.

+The xz utility must be installed separately.

 .It Fl m

 Restore modification times on files.

 .It Fl r

Index: options.c

===================================================================

RCS file: /cvs/src/bin/pax/options.c,v

retrieving revision 1.74

diff -u -p -r1.74 options.c

--- options.c   2 Dec 2010 04:08:27 -0000       1.74

+++ options.c   4 Oct 2011 18:23:47 -0000

@@ -81,6 +81,7 @@ static int getline_error;

 #define GZIP_CMD       "gzip"          /* command to run as gzip */

 #define COMPRESS_CMD   "compress"      /* command to run as compress */

 #define BZIP2_CMD      "bzip2"         /* command to run as bzip2 */

+#define XZ_CMD         "xz"            /* command to run as xz */

 

 /*

  *     Format specific routine table - MUST BE IN SORTED ORDER BY NAME

@@ -192,7 +193,7 @@ pax_options(int argc, char **argv)

        /*

         * process option flags

         */

-       while 
((c=getopt(argc,argv,"ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0"))

+       while 
((c=getopt(argc,argv,"ab:cdf:ijJklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0"))

            != -1) {

                switch (c) {

                case 'a':

@@ -245,6 +246,12 @@ pax_options(int argc, char **argv)

                         */

                        gzip_program = BZIP2_CMD;

                        break;

+               case 'J':

+                       /*

+                        * use xz.  Non standard option.

+                        */

+                       gzip_program = XZ_CMD;

+                       break;

                case 'k':

                        /*

                         * do not clobber files that exist

@@ -620,7 +627,7 @@ tar_options(int argc, char **argv)

         * process option flags

         */

        while ((c = getoldopt(argc, argv,

-           "b:cef:hjmopqruts:vwxzBC:HI:LNOPXZ014578")) != -1) {

+           "b:cef:hjJmopqruts:vwxzBC:HI:LNOPXZ014578")) != -1) {

                switch (c) {

                case 'b':

                        /*

@@ -671,6 +678,12 @@ tar_options(int argc, char **argv)

                         */

                        gzip_program = BZIP2_CMD;

                        break;

+               case 'J':

+                       /*

+                        * use xz.  Non standard option.

+                        */

+                       gzip_program = XZ_CMD;

+                       break;

                case 'm':

                        /*

                         * do not preserve modification time

@@ -1053,7 +1066,7 @@ cpio_options(int argc, char **argv)

        dflag = 1;

        act = -1;

        nodirs = 1;

-       while ((c=getopt(argc,argv,"abcdfijklmoprstuvzABC:E:F:H:I:LO:SZ6")) != 
-1)

+       while ((c=getopt(argc,argv,"abcdfijJklmoprstuvzABC:E:F:H:I:LO:SZ6")) != 
-1)

                switch (c) {

                        case 'a':

                                /*

@@ -1096,6 +1109,12 @@ cpio_options(int argc, char **argv)

                                 */

                                gzip_program = BZIP2_CMD;

                                break;

+                       case 'J':

+                               /*

+                                * use xz.  Non standard option.

+                                */

+                               gzip_program = XZ_CMD;

+                               break;

                        case 'k':

                                break;

                        case 'l':

@@ -1559,11 +1578,11 @@ void

 pax_usage(void)

 {

        (void)fputs(

-           "usage: pax [-0cdjnOvz] [-E limit] [-f archive] [-G group] [-s 
replstr]\n"

+           "usage: pax [-0cdjJnOvz] [-E limit] [-f archive] [-G group] [-s 
replstr]\n"

            "           [-T range] [-U user] [pattern ...]\n"

-           "       pax -r [-0cDdijknOuvYZz] [-E limit] [-f archive] [-G group] 
[-o options]\n"

+           "       pax -r [-0cDdijJknOuvYZz] [-E limit] [-f archive] [-G 
group] [-o options]\n"

            "           [-p string] [-s replstr] [-T range] [-U user] [pattern 
...]\n"

-           "       pax -w [-0adHijLOPtuvXz] [-B bytes] [-b blocksize] [-f 
archive]\n"

+           "       pax -w [-0adHijJLOPtuvXz] [-B bytes] [-b blocksize] [-f 
archive]\n"

            "           [-G group] [-o options] [-s replstr] [-T range] [-U 
user]\n"

            "           [-x format] [file ...]\n"

            "       pax -rw [-0DdHikLlnOPtuvXYZ] [-G group] [-p string] [-s 
replstr]\n"

@@ -1581,10 +1600,10 @@ void

 tar_usage(void)

 {

        (void)fputs(

-           "usage: tar {crtux}[014578befHhjLmNOoPpqsvwXZz]\n"

+           "usage: tar {crtux}[014578befHhjJLmNOoPpqsvwXZz]\n"

            "           [blocking-factor | archive | replstr] [-C directory] 
[-I file]\n"

            "           [file ...]\n"

-           "       tar {-crtux} [-014578eHhjLmNOoPpqvwXZz] [-b 
blocking-factor]\n"

+           "       tar {-crtux} [-014578ehHhjJLmNOoPpqvwXZz] [-b 
blocking-factor]\n"

            "           [-C directory] [-f archive] [-I file] [-s replstr] 
[file ...]\n",

            stderr);

        exit(1);

@@ -1599,9 +1618,9 @@ void

 cpio_usage(void)

 {

        (void)fputs(

-           "usage: cpio -o [-AaBcjLvZz] [-C bytes] [-F archive] [-H format]\n"

+           "usage: cpio -o [-AaBcjJLvZz] [-C bytes] [-F archive] [-H format]\n"

            "            [-O archive] < name-list [> archive]\n"

-           "       cpio -i [-6BbcdfjmrSstuvZz] [-C bytes] [-E file] [-F 
archive] [-H format]\n"

+           "       cpio -i [-6BbcdfjJmrSstuvZz] [-C bytes] [-E file] [-F 
archive] [-H format]\n"

            "            [-I archive] [pattern ...] [< archive]\n"

            "       cpio -p [-adLlmuv] destination-directory < name-list\n",

            stderr);

Index: pax.1

===================================================================

RCS file: /cvs/src/bin/pax/pax.1,v

retrieving revision 1.61

diff -u -p -r1.61 pax.1

--- pax.1       19 Sep 2010 20:55:25 -0000      1.61

+++ pax.1       4 Oct 2011 18:23:47 -0000

@@ -43,7 +43,7 @@

 .Sh SYNOPSIS

 .Bk -words

 .Nm pax

-.Op Fl 0cdjnOvz

+.Op Fl 0cdjJnOvz

 .Op Fl E Ar limit

 .Op Fl f Ar archive

 .Op Fl G Ar group

@@ -53,7 +53,7 @@

 .Op Ar pattern ...

 .Nm pax

 .Fl r

-.Op Fl 0cDdijknOuvYZz

+.Op Fl 0cDdijJknOuvYZz

 .Op Fl E Ar limit

 .Op Fl f Ar archive

 .Op Fl G Ar group

@@ -65,7 +65,7 @@

 .Op Ar pattern ...

 .Nm pax

 .Fl w

-.Op Fl 0adHijLOPtuvXz

+.Op Fl 0adHijJLOPtuvXz

 .Op Fl B Ar bytes

 .Op Fl b Ar blocksize

 .Op Fl f Ar archive

@@ -78,7 +78,7 @@

 .Op Ar

 .Nm pax

 .Fl rw

-.Op Fl 0DdHijkLlnOPtuvXYZ

+.Op Fl 0DdHijJkLlnOPtuvXYZ

 .Op Fl G Ar group

 .Op Fl p Ar string

 .Op Fl s Ar replstr

@@ -447,6 +447,11 @@ Use bzip2 to compress (decompress) the a

 The bzip2 utility must be installed separately.

 Incompatible with

 .Fl a .

+.It Fl J

+Use xz to compress (decompress) the archive while writing (reading).

+The xz utility must be installed separately.

+Incompatible with

+.Fl a .

 .It Fl k

 Do not overwrite existing files.

 .It Fl L

@@ -951,6 +956,7 @@ The options that operate on the names of

 .Po Fl c ,

 .Fl i ,

 .Fl j ,

+.Fl J ,

 .Fl n ,

 .Fl s ,

 .Fl u ,

Index: tar.1

===================================================================

RCS file: /cvs/src/bin/pax/tar.1,v

retrieving revision 1.55

diff -u -p -r1.55 tar.1

--- tar.1       2 Dec 2010 04:08:27 -0000       1.55

+++ tar.1       4 Oct 2011 18:23:47 -0000

@@ -32,7 +32,7 @@

 .Sh SYNOPSIS

 .Nm tar

 .Sm off

-.No { Cm crtux No } Op Cm 014578befHhjLmNOoPpqsvwXZz

+.No { Cm crtux No } Op Cm 014578befHhjJLmNOoPpqsvwXZz

 .Sm on

 .Bk -words

 .Op Ar blocking-factor | archive | replstr

@@ -43,7 +43,7 @@

 .Nm tar

 .No { Ns Fl crtux Ns }

 .Bk -words

-.Op Fl 014578eHhjLmNOoPpqvwXZz

+.Op Fl 014578eHhjJLmNOoPpqvwXZz

 .Op Fl b Ar blocking-factor

 .Op Fl C Ar directory

 .Op Fl f Ar archive

@@ -160,6 +160,9 @@ archive or extract from the given file, 

 .It Fl j

 Compress archive using bzip2.

 The bzip2 utility must be installed separately.

+.It Fl J

+Compress archive using xz.

+The xz utility must be installed separately.

 .It Fl L

 Synonym for the

 .Fl h

@@ -385,6 +388,8 @@ Keith Muller at the University of Califo

 .Sh CAVEATS

 The

 .Fl j

+,

+.Fl J

 and

 .Fl L

 flags are not portable to other versions of


Reply via email to