Ticket #352: 0001-Added-XZ-compression-support.patch

File 0001-Added-XZ-compression-support.patch, 6.1 KB (added by xgizzmo, 16 years ago)
  • edit/edit.c

    From 02807927e47b6efa8cd5e2bb3eeae8d2041ffb63 Mon Sep 17 00:00:00 2001
    From: xgizzmo <xgizzmo@slackbuilds.org>
    Date: Mon, 11 May 2009 22:00:51 -0400
    Subject: [PATCH] Added XZ compression support.
     Signed-off-by: xgizzmo <xgizzmo@slackbuilds.org>
    
    ---
     edit/edit.c          |    1 +
     misc/mc.ext.in       |   14 ++++++++++++++
     src/util.c           |   11 +++++++++++
     src/util.h           |    3 ++-
     vfs/extfs/iso9660.in |    1 +
     vfs/extfs/lslR.in    |    1 +
     vfs/extfs/mailfs.in  |    3 +++
     vfs/extfs/patchfs.in |    5 +++++
     vfs/extfs/sfs.ini    |    2 ++
     9 files changed, 40 insertions(+), 1 deletions(-)
    
    diff --git a/edit/edit.c b/edit/edit.c
    index 77f64ef..1becefb 100644
    a b edit_load_file_fast (WEdit *edit, const char *filename) 
    321321static const struct edit_filters { 
    322322    const char *read, *write, *extension; 
    323323} all_filters[] = { 
     324    { "xz -cd %s 2>&1",     "xz > %s",     ".xz" }, 
    324325    { "lzma -cd %s 2>&1",   "lzma > %s",   ".lzma" }, 
    325326    { "bzip2 -cd %s 2>&1",  "bzip2 > %s",  ".bz2" }, 
    326327    { "gzip -cd %s 2>&1",   "gzip > %s",   ".gz"  }, 
  • misc/mc.ext.in

    diff --git a/misc/mc.ext.in b/misc/mc.ext.in
    index 6cef6bd..86fc7ff 100644
    a b regex/\.t(ar\.lzma|lz)$ 
    124124        Open=%cd %p#utar 
    125125        View=%view{ascii} lzma -dc %f 2>/dev/null | tar tvvf - 
    126126 
     127# .tar.xz, .txz 
     128regex/\.t(ar\.xz|xz)$ 
     129        Open=%cd %p#utar 
     130        View=%view{ascii} xz -dc %f 2>/dev/null | tar tvvf - 
     131 
    127132# .tar.F - used in QNX 
    128133regex/\.tar\.F$ 
    129134        # Open=%cd %p#utar 
    regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.lzma$ 
    320325        Open=case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} 
    321326        View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) lzma -dc %f ;; *) lzma -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac 
    322327 
     328regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$ 
     329        Open=case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac | %var{PAGER:more} 
     330        View=%view{ascii,nroff} case %d/%f in */log/*|*/logs/*) xz -dc %f ;; *) xz -dc %f | nroff @MAN_FLAGS@ @MANDOC@ ;; esac 
     331 
    323332 
    324333### Images ### 
    325334 
    regex/\.lzma$ 
    601610        Open=lzma -dc %f | %var{PAGER:more} 
    602611        View=%view{ascii} lzma -dc %f 2>/dev/null 
    603612 
     613# xz 
     614regex/\.xz$ 
     615        Open=xz -dc %f | %var{PAGER:more} 
     616        View=%view{ascii} xz -dc %f 2>/dev/null 
     617 
    604618 
    605619### Default ### 
    606620 
  • src/util.c

    diff --git a/src/util.c b/src/util.c
    index b4b6e14..2a84a78 100644
    a b get_compression_type (int fd) 
    875875        } 
    876876    } 
    877877 
     878    /* XZ compression magic */ 
     879    if (magic[0] == 0xFD 
     880        && magic[1] == 0x37 && magic[2] == 0x7A && magic[3] == 0x58) { 
     881        if (mc_read (fd, (char *) magic + 4, 2) == 2) { 
     882            if (magic[4] == 0x5A && magic[5] == 0x00) { 
     883                return COMPRESSION_XZ; 
     884            } 
     885        } 
     886    } 
     887 
    878888    return 0; 
    879889} 
    880890 
    decompress_extension (int type) 
    886896        case COMPRESSION_BZIP:   return "#ubz"; 
    887897        case COMPRESSION_BZIP2:  return "#ubz2"; 
    888898        case COMPRESSION_LZMA:  return "#ulzma"; 
     899        case COMPRESSION_XZ:  return "#uxz"; 
    889900        } 
    890901        /* Should never reach this place */ 
    891902        fprintf (stderr, "Fatal: decompress_extension called with an unknown argument\n"); 
  • src/util.h

    diff --git a/src/util.h b/src/util.h
    index 557d70b..76c72e9 100644
    a b enum compression_type { 
    183183        COMPRESSION_GZIP, 
    184184        COMPRESSION_BZIP, 
    185185        COMPRESSION_BZIP2, 
    186         COMPRESSION_LZMA 
     186        COMPRESSION_LZMA, 
     187        COMPRESSION_XZ 
    187188}; 
    188189 
    189190/* Looks for ``magic'' bytes at the start of the VFS file to guess the 
  • vfs/extfs/iso9660.in

    diff --git a/vfs/extfs/iso9660.in b/vfs/extfs/iso9660.in
    index ad58e74..7b2ba70 100644
    a b mcisofs_list () { 
    3030# left as a reminder to implement compressed image support =) 
    3131case "$1" in 
    3232  *.lzma) MYCAT="lzma -dc";; 
     33  *.xz)  MYCAT="xz -dc";; 
    3334  *.bz2) MYCAT="bzip2 -dc";; 
    3435  *.gz)  MYCAT="gzip -dc";; 
    3536  *.z)   MYCAT="gzip -dc";; 
  • vfs/extfs/lslR.in

    diff --git a/vfs/extfs/lslR.in b/vfs/extfs/lslR.in
    index 67f5edb..2bc2bd0 100644
    a b AWK=@AWK@ 
    1313mclslRfs_list () { 
    1414case "$1" in 
    1515  *.lzma) MYCAT="lzma -dc";; 
     16  *.xz)  MYCAT="xz -dc";; 
    1617  *.bz2) MYCAT="bzip2 -dc";; 
    1718  *.gz)  MYCAT="gzip -dc";; 
    1819  *.z)   MYCAT="gzip -dc";; 
  • vfs/extfs/mailfs.in

    diff --git a/vfs/extfs/mailfs.in b/vfs/extfs/mailfs.in
    index 91cf3d7..bb372e3 100644
    a b use bytes; 
    88$zcat="zcat";                 # gunzip to stdout 
    99$bzcat="bzip2 -dc";           # bunzip2 to stdout 
    1010$lzcat="lzma -dc";            # unlzma to stdout 
     11$xzcat="xz -dc";              # unxz to stdout 
    1112$file="file";                 # "file" command 
    1213$TZ='GMT';                    # default timezone (for Date module) 
    1314 
    if (/gzip/) { 
    185186    exit 1 unless (open IN, "$bzcat $mbox_qname|"); 
    186187} elsif (/lzma/) { 
    187188    exit 1 unless (open IN, "$lzcat $mbox_qname|"); 
     189} elsif (/xz/) { 
     190    exit 1 unless (open IN, "$xzcat $mbox_qname|"); 
    188191} else { 
    189192    exit 1 unless (open IN, "<$mbox_name"); 
    190193} 
  • vfs/extfs/patchfs.in

    diff --git a/vfs/extfs/patchfs.in b/vfs/extfs/patchfs.in
    index 62a6d0d..7c6b468 100644
    a b use File::Temp 'tempfile'; 
    1313 
    1414# standard binaries 
    1515my $lzma = 'lzma'; 
     16my $xz   = 'xz'; 
    1617my $bzip = 'bzip2'; 
    1718my $gzip = 'gzip'; 
    1819my $fileutil = 'file'; 
    sub myin 
    7374    $_=`$fileutil $qfname`; 
    7475    if (/lzma/) { 
    7576        return "$lzma -dc $qfname"; 
     77    } elsif (/xz/) { 
     78        return "$xz -dc $qfname"; 
    7679    } elsif (/bzip/) { 
    7780        return "$bzip -dc $qfname"; 
    7881    } elsif (/gzip/) { 
    sub myout 
    9194    $_=`$fileutil $qfname`; 
    9295    if (/lzma/) { 
    9396        return "$lzma -c $sep $qfname"; 
     97    } elsif (/xz/) { 
     98        return "$xz -c $sep $qfname"; 
    9499    } elsif (/bzip/) { 
    95100        return "$bzip -c $sep $qfname"; 
    96101    } elsif (/gzip/) { 
  • vfs/extfs/sfs.ini

    diff --git a/vfs/extfs/sfs.ini b/vfs/extfs/sfs.ini
    index fc77e04..522cca1 100644
    a b bz2/1 bzip2 < %1 > %3 
    1212ubz2/1  bzip2 -d < %1 > %3 
    1313lzma/1  lzma < %1 > %3 
    1414ulzma/1 lzma -d < %1 > %3 
     15xz/1    xz < %1 > %3 
     16uxz/1   xz -d < %1 > %3 
    1517tar/1   tar cf %3 %1 
    1618tgz/1   tar czf %3 %1 
    1719uhtml/1 lynx -force_html -dump %1 > %3