Ticket #2902: mc-4.7.5.3-alt-extfs-udar.patch

File mc-4.7.5.3-alt-extfs-udar.patch, 3.8 KB (added by asy, 12 years ago)
  • lib/vfs/mc-vfs/extfs/Makefile.am

    diff --git a/lib/vfs/mc-vfs/extfs/Makefile.am b/lib/vfs/mc-vfs/extfs/Makefile.am
    index d955a2c..963b8ea 100644
    a b EXTFSCONFFILES = extfs.ini sfs.ini 
    66EXTFS_MISC  = README 
    77 
    88# Scripts hat don't need adaptation to the local system 
    9 EXTFS_CONST = bpp rpm trpm u7z 
     9EXTFS_CONST = bpp rpm trpm u7z udar 
    1010 
    1111# Scripts that need adaptation to the local system - source files 
    1212EXTFS_IN    =                   \ 
  • new file lib/vfs/mc-vfs/extfs/udar

    diff --git a/lib/vfs/mc-vfs/extfs/udar b/lib/vfs/mc-vfs/extfs/udar
    new file mode 100644
    index 0000000..3103f82
    - +  
     1#!/bin/sh 
     2 
     3# This is a parser for Dar archives in Midnight Commander. You need 
     4# the GPL dar program (version >= 2.3.0) written by Denis Corbin. 
     5 
     6# Author: Guus Jansman 
     7 
     8# Limitations: 
     9# - The archive file can not be changed 
     10# - Symbolic and hard links are not handled properly 
     11# - Block and character special files are not handled 
     12# - Files not stored in (differential) backups are not handled 
     13# - Dar files in archives are not handled (due filename restriction) 
     14 
     15DAR=dar 
     16 
     17# dar expects the basename (without number and extension) 
     18BASENAME="`echo "$2" | sed -e 's/\.[0-9]*\.[Dd][Aa][Rr]$//'`" 
     19 
     20mcdarfs_list () 
     21{ 
     22$DAR -l "$BASENAME" -N -Q -as 2>/dev/null | gawk -v uuid=${UID-0} ' 
     23BEGIN { flag=0 } 
     24/^-------/ { flag++; if (flag > 1) exit 0; next } 
     25/^$/ { next } 
     26{ 
     27    if (flag == 0) next 
     28    line=$0 
     29    split(line, record, " ") 
     30 
     31    # Do not display removed files 
     32    if (record[1] == "[" && record[2] == "REMOVED") 
     33    { 
     34        next 
     35    } 
     36 
     37    # We want "line" to start with permutation 
     38    # TODO: better algorithm 
     39    while (length(record[1]) != 10 || match(substr(record[1], 2, 1), "[r-]") == 0) 
     40    { 
     41        # line without real contents 
     42        if (length(line) == 0) { 
     43            next 
     44        } 
     45        line=substr(line, length(record[1])+1) 
     46        while (length(line) != 0 && substr(line, 1, 1) != " ") 
     47        { 
     48            line=substr(line, 2) 
     49        } 
     50        split(line, record, " ") 
     51    } 
     52 
     53    perm=record[1] 
     54    # Block and character special files not supported 
     55    # Change [bc] to [bcl] if symbolic links should not show up either 
     56    if (match(substr(perm, 1, 1), "[bc]") != 0) 
     57    { 
     58        next 
     59    } 
     60    uid=record[2] 
     61    if (match(uid, "^[0-9]*$") != 0) 
     62    { 
     63        uid=sprintf("%-8d", uid) 
     64    } 
     65    gid=record[3] 
     66    if (match(gid, "^[0-9]*$") != 0) 
     67    { 
     68        gid=sprintf("%-8d", gid) 
     69    } 
     70    size=record[4] 
     71    month=record[6] 
     72    day=record[7] 
     73    tm=substr(record[8], 1, 5) 
     74    year=record[9] 
     75    name=substr(line, index(line, sprintf("%s:", tm))+14) 
     76    # TODO: find symbolic link target (probably the link has to be extracted) 
     77    printf "%s    1 %s %s %8d %3s %02d %04d %s %s\n", perm, uid, gid, size, month, day, year, tm, name 
     78}' 
     79} 
     80 
     81mcdarfs_copyout () 
     82{ 
     83    # Dummy directory necessary since dar cannot output to stdout or named file 
     84    mkdir "$3.dir.tmp" 
     85    chmod 700 "$3.dir.tmp" 
     86    if [ ! -d "$3.dir.tmp" ]; then exit 1; fi 
     87    $DAR -x "$BASENAME" -N -O -Q -wa -g "$2" -R "$3.dir.tmp" >/dev/null 2>&1 
     88    if [ -e "$3.dir.tmp/$2" ]; then 
     89        mv "$3.dir.tmp/$2" "$3" 
     90        rm -rf "$3.dir.tmp" 
     91    else 
     92        rm -rf "$3.dir.tmp" 
     93        exit 1 
     94    fi 
     95} 
     96 
     97umask 077 
     98cmd="$1" 
     99shift 
     100case "$cmd" in 
     101    list)    mcdarfs_list    "$@" ;; 
     102    copyout) mcdarfs_copyout "$@" ;; 
     103    *)       exit 1 ;; 
     104esac 
     105exit 0 
  • misc/mc.ext.in

    diff --git a/misc/mc.ext.in b/misc/mc.ext.in
    index 4860c95..04f9873 100644
    a b regex/\.xz$ 
    654654        View=%view{ascii} xz -dc %f 2>/dev/null 
    655655 
    656656 
     657# dar 
     658regex/\.[0-9]*\.[Dd][Aa][Rr]$ 
     659        Open=%cd %p#udar 
     660        View=%view{ascii} dar -l `echo %f | sed 's/\.[0-9]*\.[Dd][Aa][Rr]$//'` -N 
     661 
    657662### Default ### 
    658663 
    659664# Default target for anything not described above