�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PKD1]:MMhp48+nuȯ#!/bin/sh # # Written by Christofer Edvardsen , Feb 1998 # # This script makes it possible to view and copy files to/from a hp48 # (tested with a HP48G and the emulator x48) # # To use the hp48 external filesystem: # - read the relevant parts of your HP48 manual # - install kermit # - connect the HP48 to your computer or start x48 # - below change the line which reflects the serial device you use # - configure your HP48 ( - i/o - iopar): # port: wire # baud: 9600 # transfer format: binary (fast transfers) or # ascii (editable on the pc) # - start the server on the HP48: - i/o - srvr - serve # or the shortcut - # - on MC's commandline enter "cd hp48://" # # Make sure you have kermit installed and that it's using the right serial # device by changing /dev/ttyXX on the next line AWK=gawk KERMIT=${MC_TEST_EXTFS_LIST_CMD:-"kermit -l /dev/ttyS1 -b 9600"} NOW=`date +"%m-%d-%Y %H:%M"` hp48_cmd() { $KERMIT -C "SET EXIT WARNING OFF,REMOTE $1,QUIT" } hp48_cd() { (echo SET EXIT WARNING OFF;echo REMOTE HOST HOME for HP48_DIR in `echo "$1" | tr '/' ' '`;do if [ "x$HP48_DIR" != "x." ];then echo REMOTE HOST "$HP48_DIR"; fi done echo QUIT)| $KERMIT -B >/dev/null } # # Parses the reply to the DIRECTORY command. # # Here's an example reply (taken from [1][2]): # # { HOME } 105617 # STRAY 185.5 Directory 29225 # YEN 30.5 Program 53391 # JYTLIGHT 21848.5 String 62692 # IOPAR 37.5 List 61074 # # The meaning of the fields (according to [3][4]): # # { Current_directory } Free_space # Object_name Object_size_bytes Object_type Object_CRC # ... # # [1] http://newarea48.tripod.com/kermit.html # [2] http://www.hpmuseum.org/forum/thread-4684.html # [3] https://groups.google.com/d/msg/comp.sys.hp48/bYTCu9K3k20/YWQfF--W3EEJ # [4] http://www.columbia.edu/kermit/hp48.html (also has a link to the HP's user manual). # hp48_parser() { HP48_DIRS= read -r INPUT while [ "x$INPUT" != "xEOF" ] do set -- $INPUT obj_name=$1 obj_size=$2 obj_type=$3 obj_size=`echo $obj_size | $AWK '{ print int($0) }'` # Truncates floats to ints; anything else to "0". if [ "$obj_size" != "0" ]; then # Skips the 1st reply line (purportedly there aren't zero-size files b/c, according to resource [4], the size is "including name"). case "$obj_type" in Directory) HP48_DIRS="$HP48_DIRS $obj_name" printf "%crwxr-xr-x 1 %-8d %-8d %8d %s %s\n" 'd' \ 0 0 $obj_size "$NOW" "$HP48_CDIR/$obj_name" ;; *) printf "%crw-r--r-- 1 %-8d %-8d %8d %s %s\n" '-' \ 0 0 $obj_size "$NOW" "$HP48_CDIR/$obj_name" ;; esac fi read -r INPUT done for HP48_DIR in $HP48_DIRS; do HP48_PDIR="$HP48_CDIR" HP48_CDIR="$HP48_CDIR/$HP48_DIR"; hp48_cmd "HOST $HP48_DIR" >/dev/null hp48_list HP48_CDIR="$HP48_PDIR"; hp48_cmd "HOST UPDIR" >/dev/null done } hp48_list() { # It's hard to see why this "EOF" thing is needed. The loop above can be changed to "while read -r obj_name ...". @TODO. { hp48_cmd "DIRECTORY"; echo; echo EOF; } | hp48_parser } # override any locale for dates LC_ALL=C export LC_ALL case "$1" in list) HP48_CDIR= hp48_cmd "HOST HOME" >/dev/null hp48_list exit 0;; copyout) cd "`dirname "$4"`" hp48_cd "`dirname "$3"`" $KERMIT -B -g "`basename "$3"`" -a "$4" >/dev/null exit 0;; copyin) cd "`dirname "$4"`" hp48_cd "`dirname "$3"`" $KERMIT -B -s "$4" -a "`basename "$3"`" >/dev/null exit 0;; esac exit 1 PKD1]XXdebnuȯ#! /usr/bin/perl # # Written by Fernando Alegre 1996 # # Applied patch by Dimitri Maziuk 1997 # (to handle new tar format) # # Modified by Fernando Alegre 1997 # (to handle both new and old tar formats) # # Modified by Patrik Rak 1998 # (add by Michael Bramer Debian-mc-maintainer ) # (to allow access to package control files) # # Modified by Martin Bialasinski 1999 # (deal with change in tar format) # # # Copyright (C) 1997 Free Software Foundation # sub quote { $_ = shift(@_); s/([^\w\/.+-])/\\$1/g; return($_); } sub mcdebfs_list { # # CAVEAT: Hard links are listed as if they were symlinks # Empty directories do not appear at all # local($archivename)=@_; local $qarchivename = quote($archivename); chop($date=`LC_ALL=C date "+%b %d %H:%M"`); chop($info_size=`dpkg -I $qarchivename | wc -c`); $install_size=length($pressinstall); print "dr-xr-xr-x 1 root root 0 $date CONTENTS\n"; print "dr-xr-xr-x 1 root root 0 $date DEBIAN\n"; print "-r--r--r-- 1 root root $info_size $date INFO\n"; print "-r-xr--r-- 1 root root $install_size $date INSTALL\n"; if ( open(PIPEIN, "LC_ALL=C dpkg-deb -c $qarchivename |") ) { while() { @_ = split; $perm=$_[0]; $owgr=$_[1]; $size=$_[2]; if($_[3] =~ /^\d\d\d\d\-/) { # New tar format ($year,$mon,$day) = split(/-/,$_[3]); $month = ("Gee","Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec")[$mon] || "Gee"; $time=$_[4]; $pathindex=5; } else { $mstring='GeeJanFebMarAprMayJunJulAugSepOctNovDec'; $month=$_[3]; $mon=index($mstring,$month) / 3; $day=$_[4]; $time=$_[5]; $year=$_[6]; $pathindex=7; } $path=$_[$pathindex++]; $arrow=$_[$pathindex++]; $link=$_[$pathindex++]; $link2=$_[$pathindex++]; $owgr=~s!/! !; if($arrow eq 'link') { # report hard links as soft links $arrow='->'; $link="/$link2"; substr($perm, 0, 1) = "l"; } if($arrow ne '') { $arrow=' ' . $arrow; $link= ' ' . $link; } $now=`date "+%Y %m"`; ($thisyear, $thismon) = split(/ /, $now); # show time for files younger than 6 months # but not for files with dates in the future if ($year * 12 + $mon > $thisyear * 12 + $thismon - 6 && $year * 12 + $mon <= $thisyear * 12 + $thismon) { print "$perm 1 $owgr $size $month $day $time CONTENTS/$path$arrow$link\n"; } else { print "$perm 1 $owgr $size $month $day $year CONTENTS/$path$arrow$link\n"; } } } if ( open(PIPEIN, "LC_ALL=C dpkg-deb -I $qarchivename |") ) { while() { @_ = split; $size=$_[0]; last if $size =~ /:/; next if $size !~ /\d+/; if($_[4] eq '*') { $perm='-r-xr-xr-x'; $name=$_[5]; } else { $perm='-r--r--r--'; $name=$_[4]; } print "$perm 1 root root $size $date DEBIAN/$name\n"; } } } sub mcdebfs_copyout { local($archive,$filename,$destfile)=@_; local $qarchive = quote($archive); local $qfilename = quote($filename); local $qdestfile = quote($destfile); if($filename eq "INFO") { system("dpkg-deb -I $qarchive > $qdestfile"); } elsif($filename =~ /^DEBIAN/) { $qfilename=~s!^DEBIAN/!!; system("dpkg-deb -I $qarchive $qfilename > $qdestfile"); } elsif($filename eq "INSTALL") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressinstall; close FILEOUT; system("chmod a+x $qdestfile"); } } else { # files can be prepended with ./ or not, depending on the version of tar $qfilename=~s!^CONTENTS/!!; system("dpkg-deb --fsys-tarfile $qarchive | tar xOf - $qfilename ./$qfilename > $qdestfile 2>/dev/null"); } } sub mcdebfs_run { local($archive,$filename)=@_; local $qarchive = quote($archive); if($filename eq "INSTALL") { print "Installing $archive\n"; system("dpkg -i $qarchive"); } else { use File::Temp qw(mkdtemp); my $template = "/tmp/mcdebfs.run.XXXXXX"; $template="$ENV{MC_TMPDIR}/mcdebfs.XXXXXX" if ($ENV{MC_TMPDIR}); $tmpdir = mkdtemp($template); $tmpcmd="$tmpdir/run"; &mcdebfs_copyout($archive, $filename, $tmpcmd); system("chmod u+x $tmpcmd"); system($tmpcmd); unlink($tmpcmd); rmdir($tmpdir); } } $pressinstall=< "$output_fname" } # --- COMMON -------------------------------------------------------------------- changesetfs_list() { VCS_type=$1; shift WORK_DIR=$1; shift fname=$1; shift DATE=`date +"%b %d %H:%M"` USER=`whoami` case "$VCS_type" in git) changesetfs_list_git "$WORK_DIR" "$fname" "$USER" "$DATE" ;; esac } changesetfs_copyout() { VCS_type=$1; shift WORK_DIR=$1; shift fname=$1; shift case "$VCS_type" in git) changesetfs_copyout_git "$WORK_DIR" "$fname" "$@" ;; esac } # --- MAIN ---------------------------------------------------------------------- command=$1; shift tmp_file=$1; shift WORK_DIR=`head -n1 $tmp_file` fname=`tail -n2 $tmp_file | head -n1` VCS_type=`tail -n1 $tmp_file` case "$command" in list) changesetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;; copyout) changesetfs_copyout "$VCS_type" "$WORK_DIR" "$fname" "$@" ;; *) exit 1 ;; esac exit 0 PKD1]rlslRnuȯ#! /bin/sh # Based on previous version of lslR # Modified by Tomas Novak April 2000 # (to allow spaces in filenames) # # It's assumed that lslR was generated in C locale. LC_ALL=C export LC_ALL=C AWK=gawk mclslRfs_list () { case "$1" in *.lz) MYCAT="lzip -dc";; *.lz4) MYCAT="lz4 -dc";; *.lzma) MYCAT="lzma -dc";; *.xz) MYCAT="xz -dc";; *.bz2) MYCAT="bzip2 -dc";; *.gz) MYCAT="gzip -dc";; *.z) MYCAT="gzip -dc";; *.Z) MYCAT="gzip -dc";; *) MYCAT="cat";; esac MYCAT=${MC_TEST_EXTFS_LIST_CMD:-$MYCAT} # Let the test framework hook in. $MYCAT "$1" | $AWK ' BEGIN { dir=""; empty=1; rx = "[^ ]+[ ]+"; # Pattern to match 7 first fields. rx7 = "^" rx rx rx rx rx rx "[^ ]+[ ]"; # Pattern to match 8 first fields. rx8 = "^" rx rx rx rx rx rx rx "[^ ]+[ ]"; } /^total\ [0-9]*$/ { next } /^$/ { empty=1; next } empty==1 && /:$/ { empty=0 if ($0 ~ /^\//) dir=substr($0, 2); else dir=$0; if (dir ~ /\/:$/) sub(/:$/, "", dir); else sub(/:$/, "/", dir); if (dir ~ /^[ ]/) dir="./"dir; next; } ( NF > 7 ) { empty=0 # gensub() is not portable. name=$0 i=index($6, "-") if (i) { sub(rx7, "", name) NF = 7 $6=substr($6,i+1)"-"substr($6,1,i-1) } else { sub(rx8, "", name) NF = 8 } printf "%s %s%s\n", $0, dir, name } { empty=0 }' } case "$1" in list) mclslRfs_list "$2"; exit 0;; esac exit 1 PKD1]y<;;uzipnuȯ#! /usr/bin/perl -w # # zip file archive Virtual File System for Midnight Commander # Version 1.4.0 (2001-08-07). # # (C) 2000-2001 Oskar Liljeblad . # use POSIX; use File::Basename; use strict; # # Configuration options # # Location of the zip program my $app_zip = "/usr/bin/zip"; # Location of the unzip program my $app_unzip = $ENV{MC_TEST_EXTFS_LIST_CMD} || "/usr/bin/unzip"; # Set this to 1 if zipinfo (unzip -Z) is to be used (recommended), otherwise 0. my $op_has_zipinfo = exists($ENV{MC_TEST_EXTFS_HAVE_ZIPINFO}) ? $ENV{MC_TEST_EXTFS_HAVE_ZIPINFO} : 0; # Command used to list archives (zipinfo mode) my $cmd_list_zi = "$app_unzip -Z -l -T"; # Command used to list archives (non-zipinfo mode) my $cmd_list_nzi = "$app_unzip -qq -v"; # Command used to add a file to the archive my $cmd_add = "$app_zip -g"; # Command used to add a link file to the archive (unused) my $cmd_addlink = "$app_zip -g -y"; # Command used to delete a file from the archive my $cmd_delete = "$app_zip -d"; # Command used to extract a file to standard out my $cmd_extract = "$app_unzip -p"; # -rw-r--r-- 2.2 unx 2891 tx 1435 defN 20000330.211927 ./edit.html # (perm) (?) (?) (size) (?) (zippedsize) (method) (yyyy)(mm)(dd).(HH)(MM)(SS) (fname) my $regex_zipinfo_line = qr"^(\S{7,10})\s+(\d+\.\d+)\s+(\S+)\s+(\d+)\s+(\S\S)\s+(\d+)\s+(\S{4})\s+(\d{4})(\d\d)(\d\d)\.(\d\d)(\d\d)(\d\d)\s(.*)$"; # 2891 Defl:N 1435 50% 03-30-00 21:19 50cbaaf8 ./edit.html # (size) (method) (zippedsize) (zipratio) (mm)-(dd)-(yy|yyyy) (HH):(MM) (cksum) (fname) # or: (yyyy)-(mm)-(dd) my $regex_nonzipinfo_line = qr"^\s*(\d+)\s+(\S+)\s+(\d+)\s+(-?\d+\%)\s+(\d+)-(\d?\d)-(\d+)\s+(\d?\d):(\d\d)\s+([0-9a-f]+)\s\s(.*)$"; # # Main code # die "uzip: missing command and/or archive arguments\n" if ($#ARGV < 1); # Initialization of some global variables my $cmd = shift; my %known = ( './' => 1 ); my %pending = (); my $oldpwd = POSIX::getcwd(); my $archive = shift; my $aarchive = absolutize($archive, $oldpwd); my $cmd_list = ($op_has_zipinfo ? $cmd_list_zi : $cmd_list_nzi); my ($qarchive, $aqarchive) = map (quotemeta, $archive, $aarchive); # Strip all "." and ".." path components from a pathname. sub zipfs_canonicalize_pathname($) { my ($fname) = @_; $fname =~ s,/+,/,g; $fname =~ s,(^|/)(?:\.?\./)+,$1,; return $fname; } # The Midnight Commander never calls this script with archive pathnames # starting with either "./" or "../". Some ZIP files contain such names, # so we need to build a translation table for them. my $zipfs_realpathname_table = undef; sub zipfs_realpathname($) { my ($fname) = @_; if (!defined($zipfs_realpathname_table)) { $zipfs_realpathname_table = {}; if (!open(ZIP, "$cmd_list $qarchive |")) { return $fname; } foreach my $line () { $line =~ s/\r*\n*$//; if ($op_has_zipinfo) { if ($line =~ $regex_zipinfo_line) { my ($fname) = ($14); $zipfs_realpathname_table->{zipfs_canonicalize_pathname($fname)} = $fname; } } else { if ($line =~ $regex_nonzipinfo_line) { my ($fname) = ($11); $zipfs_realpathname_table->{zipfs_canonicalize_pathname($fname)} = $fname; } } } if (!close(ZIP)) { return $fname; } } if (exists($zipfs_realpathname_table->{$fname})) { return $zipfs_realpathname_table->{$fname}; } return $fname; } if ($cmd eq 'list') { &mczipfs_list(@ARGV); } if ($cmd eq 'rm') { &mczipfs_rm(@ARGV); } if ($cmd eq 'rmdir') { &mczipfs_rmdir(@ARGV); } if ($cmd eq 'mkdir') { &mczipfs_mkdir(@ARGV); } if ($cmd eq 'copyin') { &mczipfs_copyin(@ARGV); } if ($cmd eq 'copyout') { &mczipfs_copyout(@ARGV); } if ($cmd eq 'run') { &mczipfs_run(@ARGV); } #if ($cmd eq 'mklink') { &mczipfs_mklink(@ARGV); } # Not supported by MC extfs #if ($cmd eq 'linkout') { &mczipfs_linkout(@ARGV); } # Not supported by MC extfs exit 1; # Remove a file from the archive. sub mczipfs_rm { my ($qfile) = map { &zipquotemeta(zipfs_realpathname($_)) } @_; # "./" at the beginning of pathnames is stripped by Info-ZIP, # so convert it to "[.]/" to prevent stripping. $qfile =~ s/^\\\./[.]/; &checkargs(1, 'archive file', @_); &safesystem("$cmd_delete $qarchive $qfile >/dev/null"); exit; } # Remove an empty directory from the archive. # The only difference from mczipfs_rm is that we append an # additional slash to the directory name to remove. I am not # sure this is absolutely necessary, but it doesn't hurt. sub mczipfs_rmdir { my ($qfile) = map { &zipquotemeta(zipfs_realpathname($_)) } @_; &checkargs(1, 'archive directory', @_); &safesystem("$cmd_delete $qarchive $qfile/ >/dev/null", 12); exit; } # Extract a file from the archive. # Note that we don't need to check if the file is a link, # because mc apparently doesn't call copyout for symbolic links. sub mczipfs_copyout { my ($qafile, $qfsfile) = map { &zipquotemeta(zipfs_realpathname($_)) } @_; &checkargs(1, 'archive file', @_); &checkargs(2, 'local file', @_); &safesystem("$cmd_extract $qarchive $qafile > $qfsfile", 11); exit; } # Add a file to the archive. # This is done by making a temporary directory, in which # we create a symlink the original file (with a new name). # Zip is then run to include the real file in the archive, # with the name of the symbolic link. # Here we also doesn't need to check for symbolic links, # because the mc extfs doesn't allow adding of symbolic # links. sub mczipfs_copyin { my ($afile, $fsfile) = @_; &checkargs(1, 'archive file', @_); &checkargs(2, 'local file', @_); my ($qafile) = quotemeta $afile; $fsfile = &absolutize($fsfile, $oldpwd); my $adir = File::Basename::dirname($afile); my $tmpdir = &mktmpdir(); chdir $tmpdir || &croak("chdir $tmpdir failed"); &mkdirs($adir, 0700); symlink ($fsfile, $afile) || &croak("link $afile failed"); &safesystem("$cmd_add $aqarchive $qafile >/dev/null"); unlink $afile || &croak("unlink $afile failed"); &rmdirs($adir); chdir $oldpwd || &croak("chdir $oldpwd failed"); rmdir $tmpdir || &croak("rmdir $tmpdir failed"); exit; } # Add an empty directory the the archive. # This is similar to mczipfs_copyin, except that we don't need # to use symlinks. sub mczipfs_mkdir { my ($dir) = @_; &checkargs(1, 'directory', @_); my ($qdir) = quotemeta $dir; my $tmpdir = &mktmpdir(); chdir $tmpdir || &croak("chdir $tmpdir failed"); &mkdirs($dir, 0700); &safesystem("$cmd_add $aqarchive $qdir >/dev/null"); &rmdirs($dir); chdir $oldpwd || &croak("chdir $oldpwd failed"); rmdir $tmpdir || &croak("rmdir $tmpdir failed"); exit; } # Add a link to the archive. This operation is not used yet, # because it is not supported by the MC extfs. sub mczipfs_mklink { my ($linkdest, $afile) = @_; &checkargs(1, 'link destination', @_); &checkargs(2, 'archive file', @_); my ($qafile) = quotemeta $afile; my $adir = File::Basename::dirname($afile); my $tmpdir = &mktmpdir(); chdir $tmpdir || &croak("chdir $tmpdir failed"); &mkdirs($adir, 0700); symlink ($linkdest, $afile) || &croak("link $afile failed"); &safesystem("$cmd_addlink $aqarchive $qafile >/dev/null"); unlink $afile || &croak("unlink $afile failed"); &rmdirs($adir); chdir $oldpwd || &croak("chdir $oldpwd failed"); rmdir $tmpdir || &croak("rmdir $tmpdir failed"); exit; } # This operation is not used yet, because it is not # supported by the MC extfs. sub mczipfs_linkout { my ($afile, $fsfile) = @_; &checkargs(1, 'archive file', @_); &checkargs(2, 'local file', @_); my ($qafile) = map { &zipquotemeta($_) } $afile; my $linkdest = &get_link_destination($afile); symlink ($linkdest, $fsfile) || &croak("link $fsfile failed"); exit; } # Use unzip to find the link destination of a certain file in the # archive. sub get_link_destination { my ($afile) = @_; my ($qafile) = map { &zipquotemeta($_) } $afile; my $linkdest = safeticks("$cmd_extract $qarchive $qafile"); &croak ("extract failed", "link destination of $afile not found") if (!defined $linkdest || $linkdest eq ''); return $linkdest; } # List files in the archive. # Because mc currently doesn't allow a file's parent directory # to be listed after the file itself, we need to do some # rearranging of the output. Most of this is done in # checked_print_file. sub mczipfs_list { open (PIPE, "$cmd_list $qarchive |") || &croak("$app_unzip failed"); if ($op_has_zipinfo) { while () { chomp; next if /^Archive:/; next if /^\d+ file/; next if /^Empty zipfile\.$/; my @match = /$regex_zipinfo_line/; next if ($#match != 13); &checked_print_file(@match); } } else { while () { chomp; my @match = /$regex_nonzipinfo_line/; next if ($#match != 10); # Massage the date. my ($year, $month, $day) = $match[4] > 12 ? ($match[4], $match[5], $match[6]) # 4,5,6 = Y,M,D : ($match[6], $match[4], $match[5]); # 4,5,6 = M,D,Y $year += ($year < 70 ? 2000 : 1900) if $year < 100; # Fix 2-digit year. my @rmatch = ('', '', 'unknown', $match[0], '', $match[2], $match[1], $year, $month, $day, $match[7], $match[8], "00", $match[10]); &checked_print_file(@rmatch); } } if (!close (PIPE)) { &croak("$app_unzip failed") if ($! != 0); &croak("$app_unzip failed", 'non-zero exit status ('.($? >> 8).')') } foreach my $key (sort keys %pending) { foreach my $file (@{ $pending{$key} }) { &print_file(@{ $file }); } } exit; } # Execute a file in the archive, by first extracting it to a # temporary directory. The name of the extracted file will be # the same as the name of it in the archive. sub mczipfs_run { my ($afile) = @_; &checkargs(1, 'archive file', @_); my $qafile = &zipquotemeta(zipfs_realpathname($afile)); my $tmpdir = &mktmpdir(); my $tmpfile = File::Basename::basename($afile); chdir $tmpdir || &croak("chdir $tmpdir failed"); &safesystem("$cmd_extract $aqarchive $qafile > $tmpfile"); chmod 0700, $tmpfile; &safesystem("./$tmpfile"); unlink $tmpfile || &croak("rm $tmpfile failed"); chdir $oldpwd || &croak("chdir $oldpwd failed"); rmdir $tmpdir || &croak("rmdir $tmpdir failed"); exit; } # This is called prior to printing the listing of a file. # A check is done to see if the parent directory of the file has already # been printed or not. If it hasn't, we must cache it (in %pending) and # print it later once the parent directory has been listed. When all # files have been processed, there may still be some that haven't been # printed because their parent directories weren't listed at all. These # files are dealt with in mczipfs_list. sub checked_print_file { my @waiting = ([ @_ ]); while ($#waiting != -1) { my $item = shift @waiting; my $filename = ${$item}[13]; my $dirname = File::Basename::dirname($filename) . '/'; if (exists $known{$dirname}) { &print_file(@{$item}); if ($filename =~ /\/$/) { $known{$filename} = 1; if (exists $pending{$filename}) { push @waiting, @{ $pending{$filename} }; delete $pending{$filename}; } } } else { push @{$pending{$dirname}}, $item; } } } # Print the mc extfs listing of a file from a set of parsed fields. # If the file is a link, we extract it from the zip archive and # include the output as the link destination. Because this output # is not newline terminated, we must execute unzip once for each # link file encountered. sub print_file { my ($perms,$zipver,$platform,$realsize,$format,$cmpsize,$comp,$year,$mon,$day,$hours,$mins,$secs,$filename) = @_; if ($platform ne 'unx') { $perms = ($filename =~ /\/$/ ? 'drwxr-xr-x' : '-rw-r--r--'); } # adjust abnormal perms on directory if ($platform eq 'unx' && $filename =~ /\/$/ && $perms =~ /^\?(.*)$/) { $perms = 'd'.$1; } printf "%-10s 1 %-8d %-8d %8s %s/%s/%s %s:%s:%s %s", $perms, $<, $(, $realsize, $mon, $day, $year, $hours, $mins, $secs, $filename; if ($platform eq 'unx' && $perms =~ /^l/) { my $linkdest = &get_link_destination($filename); print " -> $linkdest"; } print "\n"; } # Die with a reasonable error message. sub croak { my ($command, $desc) = @_; die "uzip ($cmd): $command - $desc\n" if (defined $desc); die "uzip ($cmd): $command - $!\n"; } # Make a set of directories, like the command `mkdir -p'. # This subroutine has been tailored for this script, and # because of that, it ignored the directory name '.'. sub mkdirs { my ($dirs, $mode) = @_; $dirs = &cleandirs($dirs); return if ($dirs eq '.'); my $newpos = -1; while (($newpos = index($dirs, '/', $newpos+1)) != -1) { my $dir = substr($dirs, 0, $newpos); mkdir ($dir, $mode) || &croak("mkdir $dir failed"); } mkdir ($dirs, $mode) || &croak("mkdir $dirs failed"); } # Remove a set of directories, failing if the directories # contain other files. # This subroutine has been tailored for this script, and # because of that, it ignored the directory name '.'. sub rmdirs { my ($dirs) = @_; $dirs = &cleandirs($dirs); return if ($dirs eq '.'); rmdir $dirs || &croak("rmdir $dirs failed"); my $newpos = length($dirs); while (($newpos = rindex($dirs, '/', $newpos-1)) != -1) { my $dir = substr($dirs, 0, $newpos); rmdir $dir || &croak("rmdir $dir failed"); } } # Return a semi-canonical directory name. sub cleandirs { my ($dir) = @_; $dir =~ s:/+:/:g; $dir =~ s:/*$::; return $dir; } # Make a temporary directory with mode 0700. sub mktmpdir { use File::Temp qw(mkdtemp); my $template = "/tmp/mcuzipfs.XXXXXX"; $template="$ENV{MC_TMPDIR}/mcuzipfs.XXXXXX" if ($ENV{MC_TMPDIR}); return mkdtemp($template); } # Make a filename absolute and return it. sub absolutize { my ($file, $pwd) = @_; return "$pwd/$file" if ($file !~ /^\//); return $file; } # Like the system built-in function, but with error checking. # The other argument is an exit status to allow. sub safesystem { my ($command, @allowrc) = @_; my ($desc) = ($command =~ /^([^ ]*) */); $desc = File::Basename::basename($desc); system $command; my $rc = $?; &croak("`$desc' failed") if (($rc & 0xFF) != 0); if ($rc != 0) { $rc = $rc >> 8; foreach my $arc (@allowrc) { return if ($rc == $arc); } &croak("`$desc' failed", "non-zero exit status ($rc)"); } } # Like backticks built-in, but with error checking. sub safeticks { my ($command, @allowrc) = @_; my ($desc) = ($command =~ /^([^ ]*) /); $desc = File::Basename::basename($desc); my $out = `$command`; my $rc = $?; &croak("`$desc' failed") if (($rc & 0xFF) != 0); if ($rc != 0) { $rc = $rc >> 8; foreach my $arc (@allowrc) { return if ($rc == $arc); } &croak("`$desc' failed", "non-zero exit status ($rc)"); } return $out; } # Make sure enough arguments are supplied, or die. sub checkargs { my $count = shift; my $desc = shift; &croak('missing argument', $desc) if ($count-1 > $#_); } # Quote zip wildcard metacharacters. Unfortunately Info-ZIP zip and unzip # on unix interpret some wildcards in filenames, despite the fact that # the shell already does this. Thus this function. sub zipquotemeta { my ($name) = @_; my $out = ''; for (my $c = 0; $c < length $name; $c++) { my $ch = substr($name, $c, 1); $out .= '\\' if (index('*?[]\\', $ch) != -1); $out .= $ch; } return quotemeta($out); } PKD1]auacenuȯ#! /bin/sh # # ACE Virtual filesystem executive v0.1 # Works with unace v2.5 # Note: There are two packages for Debian: 'unace' (v1.2b) and # 'unace-nonfree' (v2.x). This script supports 'unace-nonfree' only. # 'unace', which supports only old versions of ACE archives (and is # therefore of little use), uses the pipe character to separate columns # in its listing format. # Copyright (C) 2008 Jacques Pelletier # May be distributed under the terms of the GNU Public License # # # Define which archiver you are using with appropriate options ACE_LIST=${MC_TEST_EXTFS_LIST_CMD:-"unace l"} ACE_GET="unace x" # ACE_PUT="unace ?" not available # The 'list' command executive # Unace: DD.MM.YY HH:MM packed size ratio file # ls: mc_ace_fs_list() { if [ "x$UID" = "x" ]; then UID=`id -ru 2>/dev/null` if [ "x$UID" = "x" ]; then UID=0 fi fi $ACE_LIST "$1" | gawk -v uid=$UID ' /%/ { split($1,date,".") if (date[3] > 50) date[3]=date[3] + 1900 else date[3]=date[3] + 2000 printf "-rw-r--r-- 1 %-8d %-8d %8d %02d-%02d-%04d %s %s\n", uid, 0, $4, date[2], date[1], date[3], $2, $6 }' 2>/dev/null exit 0 } # Command: copyout archivename storedfilename extractto mc_ace_fs_copyout() { $ACE_GET "$1" "$2" > /dev/null 2>&1 mv "$2" "$3" } # The main routine umask 077 cmd="$1" shift case "$cmd" in list) mc_ace_fs_list "$@" ;; copyout) mc_ace_fs_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]<+ ulibnuȯ#! /usr/bin/perl -w # # VFS to manage the gputils archives. # Written by Molnár Károly (proton7@freemail.hu) 2012 # my %month = ('jan' => '01', 'feb' => '02', 'mar' => '03', 'apr' => '04', 'may' => '05', 'jun' => '06', 'jul' => '07', 'aug' => '08', 'sep' => '09', 'oct' => '10', 'nov' => '11', 'dec' => '12'); my @PATHS = ('/usr/bin/gplib', '/usr/local/bin/gplib'); my $gplib = ''; foreach my $i (@PATHS) { if (-x $i) { $gplib = $i; last; } } if ($gplib eq '') { print STDERR "\a\t$0 : Gplib not found!\n"; exit(1); } my $cmd = shift; my $archive = shift; #------------------------------------------------------------------------------- sub mc_ulib_fs_list { open(PIPE, "$gplib -tq $archive |") || die("Error in $gplib -tq"); my($dev, $inode, $mode, $nlink, $uid, $gid) = stat($archive); while () { chomp; my @w = split(/\s+/o); my $fname = $w[0]; $fname =~ s|\\|/|g; printf("-rw-r--r-- 1 %s %s %d %s-%02u-%s %s %s\n", $uid, $gid, int($w[1]), $month{lc($w[4])}, $w[5], $w[7], substr($w[6], 0, 5), $fname); } close (PIPE); } #------------------------------------------------------------------------------- sub mc_ulib_fs_copyin { system("$gplib -r $archive $_[0]"); my $ret = $?; if ($ret) { die("Error in: $gplib -r"); } } #------------------------------------------------------------------------------- sub mc_ulib_fs_copyout { my($module, $fname) = @_; my $tmpdir = $ENV{'TMPDIR'}; $tmpdir = '/tmp' if (! defined $tmpdir or $tmpdir eq ''); open(PIPE, "$gplib -tq $archive |") || die("Error in: $gplib -tq"); while () { chomp; my @w = split(/\s+/o); my $module_orig = $w[0]; my $count = () = ($module_orig =~ /(\\)/g); my $md = $module_orig; $md =~ s|\\|/|g; if ($module eq $md) { return if ($count); } } close (PIPE); chdir($tmpdir); system("$gplib -x $archive $module"); my $ret = $?; if ($ret) { die("Error in: $gplib -x"); } rename($module, $fname) || die("Error in: rename($module, $fname)"); } #------------------------------------------------------------------------------- sub mc_ulib_fs_rm { system("$gplib -d $archive $_[0]"); my $ret = $?; if ($ret) { die("Error in: $gplib -d"); } } ################################################################################ if ($cmd eq 'list') { mc_ulib_fs_list(@ARGV); } elsif ($cmd eq 'copyin') { mc_ulib_fs_copyin(@ARGV); } elsif ($cmd eq 'copyout') { mc_ulib_fs_copyout(@ARGV); } elsif ($cmd eq 'rm') { mc_ulib_fs_rm(@ARGV); } else { exit(1); } PKD1]$ANiso9660nuȯ#! /bin/sh # Midnight Commander - ISO9660 VFS for MC # based on lslR by Tomas Novak April 2000 # # Copyright (C) 2000, 2003 # The Free Software Foundation, Inc. # # Written by: # Michael Shigorin , # Grigory Milev , # Kachalov Anton , 2003 # Victor Ananjevsky , 2013 # slava zanko , 2013 # # This file is part of the Midnight Commander. # # The Midnight Commander is free software: you can redistribute it # and/or modify it under the terms of the GNU General Public License as # published by the Free Software Foundation, either version 3 of the License, # or (at your option) any later version. # # The Midnight Commander is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . #*** include section (source functions, for example) ******************* #*** file scope functions ********************************************** XORRISO=$(which xorriso 2>/dev/null) xorriso_list() { if test -z "$XORRISO"; then return 1 fi local dir attr ln usr gr sz dt1 dt2 dt3 nm len name lsl r dir="${2:-/}" lsl=$( $XORRISO -abort_on FATAL -dev stdio:"$1" -cd "$dir" -lsl 2> /dev/null ) r=$? test $r -gt 0 && return $r echo "$lsl" | /usr/bin/grep "^[-d]" | \ while read attr ln usr gr sz dt1 dt2 dt3 nm ; do len=$((${#nm} - 1)) name=$(printf -- "$nm" | cut -c2-$len) # remove quotes if test $(printf -- "$attr" | cut -c1-1) != "d"; then printf -- "%s %s %s %s %s %s %s %s %s/%s\n" "$attr" "$ln" "$usr" "$gr" "$sz" "$dt1" "$dt2" "$dt3" "$dir" "$name" else xorriso_list "$1" "$dir/$name" fi done } xorriso_copyout() { if test -z "$XORRISO"; then return 1 fi $XORRISO -dev stdio:"$1" -osirrox on -extract "$2" "$3" >/dev/null 2>&1 } xorriso_copyin() { if test -z "$XORRISO"; then return 1 fi $XORRISO -dev stdio:"$1" -cpr "$3" "$2" >/dev/null 2>&1 } xorriso_mkdir() { if test -z "$XORRISO"; then return 1 fi $XORRISO -dev stdio:"$1" -mkdir "$2" >/dev/null 2>&1 } xorriso_rmdir() { if test -z "$XORRISO"; then return 1 fi $XORRISO -dev stdio:"$1" -rmdir "$2" >/dev/null 2>&1 } xorriso_rm() { if test -z "$XORRISO"; then return 1 fi $XORRISO -dev stdio:"$1" -rm "$2" >/dev/null 2>&1 } # tested to comply with isoinfo 2.0's output test_iso () { CHARSET=$(locale charmap 2>/dev/null) if test -z "$CHARSET"; then CHARSET=$(locale 2>/dev/null | /usr/bin/grep LC_CTYPE | sed -n -e 's/.*\.\(.*\)"$/\1/p') fi if test -n "$CHARSET"; then CHARSET=$(echo "$CHARSET" | tr '[A-Z]' '[a-z]' | sed -e 's/^iso-/iso/') isoinfo -j $CHARSET -i /dev/null 2>&1 | /usr/bin/grep "Iconv not yet supported\|Unknown charset" >/dev/null && CHARSET= fi if test -n "$CHARSET"; then JOLIET_OPT="-j $CHARSET -J" else JOLIET_OPT="-J" fi ISOINFO="isoinfo -R" ISOINFO_D_I="$(isoinfo -d -i "$1" 2>/dev/null)" echo "$ISOINFO_D_I" | /usr/bin/grep "UCS level 1\|NO Joliet" > /dev/null || ISOINFO="$ISOINFO $JOLIET_OPT" if [ $(echo "$ISOINFO_D_I" | /usr/bin/grep "Joliet with UCS level 3 found" | wc -l) = 1 \ -a $(echo "$ISOINFO_D_I" | /usr/bin/grep "NO Rock Ridge" | wc -l) = 1 ] ; then SEMICOLON="YES" fi } mcisofs_list () { # left as a reminder to implement compressed image support =) case "$1" in *.lz) MYCAT="lzip -dc";; *.lz4) MYCAT="lz4 -dc";; *.lzma) MYCAT="lzma -dc";; *.xz) MYCAT="xz -dc";; *.bz2) MYCAT="bzip2 -dc";; *.gz) MYCAT="gzip -dc";; *.z) MYCAT="gzip -dc";; *.Z) MYCAT="gzip -dc";; *) MYCAT="cat";; esac $ISOINFO -l -i "$1" 2>/dev/null | gawk -v SEMICOLON=$SEMICOLON ' BEGIN { dir=""; # Pattern to match 8 first fields. rx = "[^ ]+[ ]+"; rx = "^" rx rx rx rx rx rx rx rx; irx = "^\\[ *-?[0-9]* *[0-9]+\\] +"; } /^$/ { next } /^d---------/ { next } /^Directory listing of [^ ].*$/ { dir=substr($0, 23); next; } { $11 != "" } { name=$0 sub(rx, "", name) attr=substr($0, 1, length($0)-length(name)) # strip inodes and extra dir entries; fix perms sub(irx, "", name) sub("^---------- 0 0 0", "-r--r--r-- 1 root root", attr) sub(" $", "", name) # for Joliet UCS level 3 if (SEMICOLON == "YES") sub(";1$", "", name); ## sub(";[0-9]+$", "", name) ## would break copyout # skip . and .. if (name == ".") next; if (name == "..") next; printf "%s%s%s\n", attr, dir, name }' } mcisofs_copyout () { if [ "x$SEMICOLON" = "xYES" ]; then $ISOINFO -i "$1" -x "/$2;1" 2>/dev/null > "$3" else $ISOINFO -i "$1" -x "/$2" 2>/dev/null > "$3" fi } #*** main code ********************************************************* LC_ALL=C cmd="$1" shift case "$cmd" in list) xorriso_list "$@" || { test_iso "$@"; mcisofs_list "$@"; } exit 0 ;; rm) xorriso_rm "$@" || { exit 1 } exit 0 ;; rmdir) xorriso_rmdir "$@" || { exit 1 } exit 0 ;; mkdir) xorriso_mkdir "$@" || { exit 1 } exit 0 ;; copyin) xorriso_copyin "$@" || { exit 1 } exit 0 ;; copyout) xorriso_copyout "$@" || { test_iso "$@"; mcisofs_copyout "$@"; } exit 0 ;; esac exit 1 PKD1] :nn README.extfsnu[# Each external VFS type must be registered in extfs.d directory if you want to use it. # Trailing plus means that the filesystem is not tied to a certain file. # Popular PC archivers uzip uzoo ulha urar uha u7z ualz # FIXME: for arj usage you need a special patch to unarj (see unarj.diff) uarj uarc uace # For cab files ucab # ar is used for static libraries uar # Packages from popular Linux distributions rpm deb # a+ - mtools filesystem a+ # For browsing lslR listings (found on many ftp sites) lslR # Hewlett Packard calculator hp48+ # Commodore 64/128 d64/D64 files uc1541 # Break patches into chunks patchfs # Represents a mailbox as a directory mailfs # List all installed RPM packages on the system rpms+ trpm # dpkg frontend dpkg+ debd # apt frontend apt+ deba # Simple filesystem for audio cdroms. Use /dev/cdrom#audio (or /#audio) audio # Package of Bad Penguin (an Italian GNU/Linux distribution) bpp # ISO image iso9660 # Amazon S3 s3+ # git frontend gitfs - browse the git repo changesetfs - list of versions of current file patchsetfs - list of patches of current file # Gputils lib archives. ulib PKD1]3;rpms+nuȯ#! /usr/bin/perl # # Written by Balazs Nagy (julian7@kva.hu) 1998 # locale bugfix by Michal Svec (rebel@penguin.cz) 2000 # (C) 1998 The Free Software Foundation. # # # override any locale for dates delete $ENV{"LC_ALL"}; $ENV{"LC_TIME"}="C"; #print $ENV{"LC_ALL"}; #exit 0; sub gd { my ($dt) = @_; $dt =~ tr/ //s; $dt =~ s/^\w+ (\w+) (\d+) (\d+:\d+):\d+ .+\n?$/$1 $2 $3/; return $dt; } $DATE=gd(`date`); sub list { my (@rpms, %files, $i, $fn, $dn, $sz, $bt); # @rpms = `rpm -qa --qf "\%{NAME}-\%{VERSION}-\%{RELEASE}:\%{GROUP}:\%{SIZE}:\%{BUILDTIME:date}\n"`; @rpms = `rpm -qa --qf "\%{NAME}-\%{VERSION}:\%{GROUP}:\%{SIZE}:\%{BUILDTIME:date}\n"`; print @trpms; %files = (); %sizes = (); %dates = (); for $i (@rpms) { if ($i =~ /^([^:]+):([^:]+):([^:]+):(.+)$/) { ($fn, $dn, $sz, $bt) = ($1, $2, $3, $4); $dn =~ s/ /_/g; if (defined $files{$dn}) { push(@{$files{$dn}}, $fn); } else { @{$files{$dn}} = ($fn); } $sizes{$fn} = $sz; $dates{$fn} = gd($bt); } } for $i (sort keys %files) { print "dr-xr-xr-x 1 root root 0 $DATE $i/\n"; for $fn (sort @{$files{$i}}) { print "-r--r--r-- 1 root root $sizes{$fn} $dates{$fn} $i/$fn.trpm\n"; } } } #open O, ">>/tmp/tt"; #print O "RPMS: "; #for $i (@ARGV) { # print O "$i "; #} #print O "\n"; #close O; if ($ARGV[0] eq "list") { list(); exit(0); } elsif ($ARGV[0] eq "copyout") { open O, ">$ARGV[3]"; print O $ARGV[2], "\n"; close O; exit(0); } exit(1); PKD1]$$uarcnuȯ#! /bin/sh # # ARC Virtual filesystem executive # Copyright (C) 2008 Jacques Pelletier # May be distributed under the terms of the GNU Public License # # # Define which archiver you are using with appropriate options ARC_LIST=${MC_TEST_EXTFS_LIST_CMD:-"arc v"} ARC_GET="arc x" ARC_PUT="arc a" ARC_DEL="arc d" # The 'list' command executive mc_arc_fs_list() { if [ "x$UID" = "x" ]; then UID=`id -ru 2>/dev/null` if [ "x$UID" = "x" ]; then UID=0 fi fi $ARC_LIST "$1" | gawk -v uid=$UID ' BEGIN { # Copied from uzoo.in. split("Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec", month_list, ":") for (i=1; i<=12; i++) { month[month_list[i]] = i } } /^Name/ { next } /===/ { next } /^Total/ { next } { if ($8 > 50) $8=$8 + 1900 else $8=$8 + 2000 split($9, a, ":") # convert AM/PM to 00-23 if (a[2] ~ /a$|p$/) { if (a[2] ~ /p$/) a[1] = a[1]+12 a[2]=substr(a[2],1,2) } printf "-rw-r--r-- 1 %-8d %-8d %8d %02d-%02d-%04d %02d:%02d %s\n", uid, 0, $2, month[$7], $6, $8, a[1], a[2], $1 }' 2>/dev/null exit 0 } # Command: copyout archivename storedfilename extractto mc_arc_fs_copyout() { $ARC_GET "$1" "$2" 2> /dev/null mv "$2" "$3" } # Command: copyin archivename storedfilename sourcefile mc_arc_fs_copyin() { mv "$3" "$2" $ARC_PUT "$1" "$2" 2> /dev/null } # Command: rm archivename storedfilename mc_arc_fs_rm() { $ARC_DEL "$1" "$2" 2> /dev/null } # The main routine umask 077 cmd="$1" shift case "$cmd" in list) mc_arc_fs_list "$@" ;; copyout) mc_arc_fs_copyout "$@" ;; copyin) mc_arc_fs_copyin "$@" ;; rm) mc_arc_fs_rm "$@" ;; *) exit 1 ;; esac exit 0 PKD1]ualznuȯ#!/bin/sh # # Written by Pavel Roskin # (C) 2005 The Free Software Foundation. # # UNALZ=unalz mcualz_list () { $UNALZ -l "$1" | gawk -v uid=`id -nu` -v gid=`id -ng` ' { if ($1 ~ /[0-9][0-9][:/][0-9][0-9][:/][0-9][0-9]$/) { # Kludge for non-POSIX date format in unalz 0.50 split($1, date, "[/:]") if (length(date[1]) == 4) { pdate = date[2] "/" date[3] "/" date[1] } else { pdate = date[1] "/" date[2] "/" date[3] } time=$2 perm=$3 size=$4 sub(/^ *[^ ]* *[^ ]* *[^ ]* *[^ ]* *[^ ]* */, "") file=$0 gsub(/\\/, "/", file) if (perm ~ /.D../) perm = "drwxr-xr-x" else perm = "-rw-r--r--" printf "%s 1 %s %s %d %s %s %s\n", perm, uid, gid, size, pdate, time, file } } ' } mcualz_copyout () { TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-ualz.XXXXXX` || exit 1 # This is a workaround for a bug in unalz 0.50 - it crashes if the # output directory is an absolute path. dir=`dirname "$TMPDIR/$2"` mkdir -p "$dir" $UNALZ -d "$TMPDIR" "$1" "$2" >/dev/null cat "$TMPDIR/$2" > "$3" rm -rf "$TMPDIR" } # override any locale for dates LC_ALL=C export LC_ALL umask 077 cmd="$1" shift case "$cmd" in list) mcualz_list "$@" ;; copyout) mcualz_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]8AAuzoonuȯ#! /bin/sh # # Zoo file system # # Source of zoo can be found at # ftp://ftp.ibiblio.org/pub/Linux/utils/compress/ ZOO=${MC_TEST_EXTFS_LIST_CMD:-zoo} # Stupid zoo won't work if the archive name has no .zoo extension, so we # have to make a symlink with a "better" name. Also, zoo can create # directories even if printing files to stdout, so it's safer to confine # it to a temporary directory. mklink () { TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uzoo.XXXXXX` || exit 1 trap 'cd /; rm -rf "$TMPDIR"' 0 1 2 3 5 13 15 ARCHIVE="$TMPDIR/tmp.zoo" ln -sf "$1" "$ARCHIVE" cd "$TMPDIR" || exit 1 } mczoofs_list () { mklink "$1" $ZOO lq "$ARCHIVE" | gawk -v uid=$(id -ru) ' /^[^\ ]/ { next } { if (NF < 8) next if ($8 ~ /^\^/) $8=substr($8, 2) if ($6 > 50) $6=$6 + 1900 else $6=$6 + 2000 split($7, a, ":") split("Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec", month_list, ":") for (i=1; i<=12; i++) { month[month_list[i]] = i } if ($8 ~ /\/$/) printf "drwxr-xr-x 1 %-8d %-8d %8d %02d-%02d-%4d %02d:%02d %s\n", uid, 0, $1, month[$5], $4, $6, a[1], a[2], $8 else printf "-rw-r--r-- 1 %-8d %-8d %8d %02d-%02d-%4d %02d:%02d %s\n", uid, 0, $1, month[$5], $4, $6, a[1], a[2], $8 }' 2>/dev/null exit 0 } mczoofs_copyout () { mklink "$1" # zoo only accepts name without directory as file to extract base=`echo "$2" | sed 's,.*/,,'` $ZOO xpq: "$ARCHIVE" "$base" > "$3" cd / exit 0 } umask 077 cmd="$1" shift case "$cmd" in list) mczoofs_list "$@" ;; copyout) mczoofs_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]iU0XXmailfsnuȯ#! /usr/bin/perl -w use bytes; # MC extfs for (possibly compressed) Berkeley style mailbox files # Peter Daum (Jan 1998, mc-4.1.24) $zcat="zcat"; # gunzip to stdout $bzcat="bzip2 -dc"; # bunzip2 to stdout $lzipcat="lzip -dc"; # unlzip to stdout $lz4cat="lz4 -dc"; # unlz4 to stdout $lzcat="lzma -dc"; # unlzma to stdout $xzcat="xz -dc"; # unxz to stdout $file="file"; # "file" command $TZ='GMT'; # default timezone (for Date module) if (eval "require Date::Parse") { import Date::Parse; $parse_date= sub { local $ftime = str2time($_[0],$TZ); $_ = localtime($ftime); /^(...) (...) ([ \d]\d) (\d\d:\d\d):\d\d (\d\d\d\d)$/; if ($ftime + 6 * 30 * 24 * 60 * 60 < $now || $ftime + 60 * 60 > $now) { return "$2 $3 $5"; } else { return "$2 $3 $4"; } } } elsif (eval "require Date::Manip") { import Date::Manip; $parse_date= sub { return UnixDate($_[0], "%l"); # "ls -l" format } } else { # use "light" version $parse_date= sub { local $mstring='GeeJanFebMarAprMayJunJulAugSepOctNovDec'; # assumes something like: Mon, 5 Jan 1998 16:08:19 +0200 (GMT+0200) # if you have mails with another date format, add it here if (/(\d\d?) ([A-Z][a-z][a-z]) (\d\d\d\d) (\d\d?):(\d\d)/) { $day = $1; $month = $2; $mon = index($mstring,$month) / 3; $year = $3; $hour = $4; $min = $5; # pass time not year for files younger than roughly 6 months # but not for files with dates more than 1-2 hours in the future if ($year * 12 + $mon > $thisyear * 12 + $thismon - 7 && $year * 12 + $mon <= $thisyear * 12 + $thismon && ! (($year * 12 + $mon) * 31 + $day == ($thisyear * 12 + $thismon) * 31 + $thisday && $hour > $thishour + 2)) { return "$month $day $hour:$min"; } else { return "$month $day $year"; } } # Y2K bug. # Date: Mon, 27 Mar 100 16:30:47 +0000 (GMT) if (/(\d\d?) ([A-Z][a-z][a-z]) (1?\d\d) (\d\d?):(\d\d)/) { $day = $1; $month = $2; $mon = index($mstring,$month) / 3; $year = 1900 + $3; $hour = $4; $min = $5; if ($year < 1970) { $year += 100; } if ($year * 12 + $mon > $thisyear * 12 + $thismon - 7 && $year * 12 + $mon <= $thisyear * 12 + $thismon && ! (($year * 12 + $mon) * 31 + $day == ($thisyear * 12 + $thismon) * 31 + $thisday && $hour > $thishour + 2)) { return "$month $day $hour:$min"; } else { return "$month $day $year"; } } # AOLMail(SM). # Date: Sat Jul 01 10:06:06 2000 if (/([A-Z][a-z][a-z]) (\d\d?) (\d\d?):(\d\d)(:\d\d)? (\d\d\d\d)/) { $month = $1; $mon = index($mstring,$month) / 3; $day = $2; $hour = $3; $min = $4; $year = $6; if ($year * 12 + $mon > $thisyear * 12 + $thismon - 7 && $year * 12 + $mon <= $thisyear * 12 + $thismon && ! (($year * 12 + $mon) * 31 + $day == ($thisyear * 12 + $thismon) * 31 + $thisday && $hour > $thishour + 2)) { return "$month $day $hour:$min"; } else { return "$month $day $year"; } } # Fallback return $fallback; } } sub process_header { while () { $size+=length; s/\r$//; last if /^$/; die "unexpected EOF\n" if eof; if (/^date:\s(.*)$/i) { $date=&$parse_date($1); } elsif (/^subject:\s(.*)$/i) { $subj=lc($1); $subj=~ s/^(re:\s?)+//gi; # no leading Re: $subj=~ tr/a-zA-Z0-9//cd; # strip all "special" characters } elsif (/^from:\s.*?(\w+)\@/i) { $from=$1; } elsif (/^to:\s.*?(\w+)\@/i) { $to=lc($1); } } } sub print_dir_line { $from=$to if ($from eq $user); # otherwise, it would look pretty boring $date=localtime(time) if (!defined $date); printf "-r-------- 1 $< $< %d %s %3.3d_%.25s\n", $size, $date, $msg_nr, "${from}_${subj}"; } sub mailfs_list { my $blank = 1; $user=$ENV{USER}||getlogin||getpwuid($<) || "nobody"; while() { s/\r$//; if($blank && /^from\s+\w+(\.\w+)*@/i) { # Start of header print_dir_line unless (!$msg_nr); $size=length; $msg_nr++; ($from,$to,$subj,$date)=("none","none","none", "01-01-80"); process_header; $line=$blank=0; } else { $size+=length; $line++; $blank= /^$/; } } print_dir_line unless (!$msg_nr); exit 0; } sub mailfs_copyout { my($source,$dest)=@_; exit 1 unless (open STDOUT, ">$dest"); ($nr)= ($source =~ /^(\d+)/); # extract message number from "filename" my $blank = 1; while() { s/\r$//; if($blank && /^from\s+\w+(\.\w+)*@/i) { $msg_nr++; exit(0) if ($msg_nr > $nr); $blank= 0; } else { $blank= /^$/; } print if ($msg_nr == $nr); } } # main { exit 1 unless ($#ARGV >= 1); $msg_nr=0; $cmd=shift; $mbox_name=shift; my $mbox_qname = quotemeta ($mbox_name); $_=`$file $mbox_qname`; if (/gzip/) { exit 1 unless (open IN, "$zcat $mbox_qname|"); } elsif (/bzip/) { exit 1 unless (open IN, "$bzcat $mbox_qname|"); } elsif (/lzip/) { exit 1 unless (open IN, "$lzipcat $mbox_qname|"); } elsif (/lz4/) { exit 1 unless (open IN, "$lz4cat $mbox_qname|"); } elsif (/lzma/) { exit 1 unless (open IN, "$lzcat $mbox_qname|"); } elsif (/xz/) { exit 1 unless (open IN, "$xzcat $mbox_qname|"); } else { exit 1 unless (open IN, "<$mbox_name"); } umask 077; if($cmd eq "list") { $now = time; $_ = localtime($now); /^... (... [ \d]\d \d\d:\d\d):\d\d \d\d\d\d$/; $fallback = $1; $nowstring=`date "+%Y %m %d %H"`; ($thisyear, $thismon, $thisday, $thishour) = split(/ /, $nowstring); &mailfs_list; exit 0; } elsif($cmd eq "copyout") { &mailfs_copyout(@ARGV); exit 0; } exit 1; PKD1]A?0  patchsetfsnuȯ#!/bin/sh LANG=C export LANG LC_TIME=C export LC_TIME # --- GIT ----------------------------------------------------------------------- found_git_dir() { work_dir=$1 while [ -n "$work_dir" -a "$work_dir" != "/" ]; do [ -d "${work_dir}/.git" ] && { echo "${work_dir}/.git/" return } work_dir=`dirname "$work_dir"` done echo '' } patchsetfs_list_git() { WORK_DIR=$1; shift fname=$1; shift USER=$1; shift DATE=$1; shift GIT_DIR=`found_git_dir "$WORK_DIR"` [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR curr_year=`date +"%Y"` git --git-dir="$GIT_DIR" log --abbrev=7 --pretty="format:%at %h %an" -- "$fname" | while read TIMESTAMP chset author do year=`date -d @"$TIMESTAMP" +"%Y"` [ "$year" = "$curr_year" ] && { DATE=`date -d @"$TIMESTAMP" +"%b %d %H:%M"` } || { DATE=`date -d @"$TIMESTAMP" +"%b %d %Y"` } NAME="$chset $author" echo "-rw-rw-rw- 1 $USER 0 0 $DATE $NAME.diff" done } patchsetfs_copyout_git() { WORK_DIR=$1; shift fname=$1; shift orig_fname=$1;shift output_fname=$1;shift chset=`echo "$orig_fname"| cut -f 1 -d " "` GIT_DIR=`found_git_dir "$WORK_DIR"` [ -z "$GIT_DIR" ] && GIT_DIR=$WORK_DIR git --git-dir="$GIT_DIR" show "$chset" -- "$fname" > "$output_fname" } # --- COMMON -------------------------------------------------------------------- patchsetfs_list() { VCS_type=$1; shift WORK_DIR=$1; shift fname=$1; shift DATE=`date +"%b %d %H:%M"` USER=`whoami` case "$VCS_type" in git) patchsetfs_list_git "$WORK_DIR" "$fname" "$USER" "$DATE" ;; esac } patchsetfs_copyout() { VCS_type=$1; shift WORK_DIR=$1; shift fname=$1; shift case "$VCS_type" in git) patchsetfs_copyout_git "$WORK_DIR" "$fname" "$@" ;; esac } # --- MAIN ---------------------------------------------------------------------- command=$1; shift tmp_file=$1; shift WORK_DIR=`head -n1 $tmp_file` fname=`tail -n2 $tmp_file | head -n1` VCS_type=`tail -n1 $tmp_file` case "$command" in list) patchsetfs_list "$VCS_type" "$WORK_DIR" "$fname" ;; copyout) patchsetfs_copyout "$VCS_type" "$WORK_DIR" "$fname" "$@" ;; *) exit 1 ;; esac exit 0 PKD1]&&READMEnu[ Writing scripts for Midnight Commander's external vfs IMPORTANT NOTE: There may be some bugs left in extfs. Enjoy. Starting with version 3.1, the Midnight Commander comes with so called extfs, which is one of the virtual filesystems. This system makes it possible to create new virtual filesystems for the GNU MC very easily. To handle requests, create a shell/perl/python/etc script/program (with executable permissions) in $(libexecdir)/mc/extfs.d or in ~/.mc/extfs.d. (Note: $(libexecdir) should be substituted for actual libexecdir path stored when configured or compiled, like /usr/local/libexec or /usr/libexec). Assign a vfs suffix. For example, if you have .zip file, and would like to see what's inside it, path will be /anypath/my.zip/uzip://some_path/... In this example, .zip is suffix, but I call vfs 'uzip'. Why? Well, what this vfs essentially does is UNzip. UN is too long, so I choosed U. Note that sometime in future filesystem like zip may exist: It will take whole tree and create .zip file from it. So /usr/zip:// will be zipfile containing whole /usr tree. If your vfs does not require file to work on, add '+' to the end of name. Note, that trailing '+' in file name is not a part of vfs name, it is just an vfs attribue. So you have not use it in vfs commands: cd rpms:// is correct command, and cd rpms+:// is incorrect command. * Commands that should be implemented by your shell script ---------------------------------------------------------- Return zero from your script upon completion of the command, otherwise nonzero for failure or in case of an unsupported command. $libdir/extfs/prefix command [arguments] * Command: list archivename This command should list the complete archive content in the following format (a little modified ls -l listing): AAAAAAA NNN OOOOOOOO GGGGGGGG SSSSSSSS DATETIME [PATH/]FILENAME [-> [PATH/]FILENAME[/]]] where (things in [] are optional): AAAAAAA is the permission string like in ls -l NNN is the number of links OOOOOOOO is the owner (either UID or name) GGGGGGGG is the group (either GID or name) SSSSSSSS is the file size FILENAME is the filename PATH is the path from the archive's root without the leading slash (/) DATETIME has one of the following formats: Mon DD hh:mm[:ss], Mon DD YYYY, MM-DD-YYYY hh:mm[:ss] where Mon is a three letter English month name, DD is day 01-31 (can be 1-31, if following Mon), MM is month 01-12, YYYY is four digit year, hh is hours, mm is minutes, and ss is optional seconds. If the -> [PATH/]FILENAME part is present, it means: If permissions start with an l (ell), then it is the name that symlink points to. (If this PATH starts with a MC vfs prefix, then it is a symlink somewhere to the other virtual filesystem (if you want to specify path from the local root, use local:/path_name instead of /path_name, since /path_name means from root of the archive listed). If permissions do not start with l, but number of links is greater than one, then it says that this file should be a hardlinked with the other file. * Command: copyout archivename storedfilename extractto This should extract from archive archivename the file called storedfilename (possibly with path if not located in archive's root [this is wrong. current extfs strips paths! -- pavel@ucw.cz]) to file extractto. * Command: copyin archivename storedfilename sourcefile This should add to the archivename the sourcefile with the name storedfilename inside the archive. Important note: archivename in the above examples may not have the extension you are expecting to have, like it may happen that archivename will be something like /tmp/f43513254 or just anything. Some archivers do not like it, so you'll have to find some workaround. * Command: rm archivename storedfilename This should remove storedfilename from archivename. * Command: mkdir archivename dirname This should create a new directory called dirname inside archivename. * Command: rmdir archivename dirname This should remove an existing directory dirname. If the directory is not empty, mc will recursively delete it (possibly prompting). * Command: run Undocumented :-) --------------------------------------------------------- Don't forget to mark this file executable (chmod 755 ThisFile, for example) For skeleton structure of executable, look at some of filesystems similar to yours. --------------------------------------------------------- In constructing these routines, errors will be made, and mc will not display a malformed printing line. That can lead the programmer down many false trails in search of the bug. Since this routine is an executable shell script it can be run from the command line independently of mc, and its output will show on the console or can be redirected to a file. * Putting it to use ---------------------------------------------------------- The file .mc.ext in a home directory, and in mc's user directory (commonly /etc/mc), contains instructions for operations on files depending on filename extensions. It is well documented in other files in this distribution, so here are just a few notes specifically on use of the Virtual File System you just built. There are entries in .mc.ext defining a few operations that can be done on a file from an mc panel. Typically they are annotated with a hash mark and a file extension like this: # zip There must be a way to find the file by extension, so the next line does that. In essence it says "identify the string ".zip" or (|) ".ZIP" at the end ($) of a filename": regex/\.(zip|ZIP)$ The operations themselves follow that. They must be indented by at least a space, and a tab works as well. In particular, the Open operation will now use your new virtual file system by cd'ing to it like this: Open=%cd zip:%d/%p This is the line used when a file is highlighted in a panel and the user presses or . The contents of the archive should show just as if they were in a real directory, and can be manipulated as such. The rest of the entry pertains to use of the F3 View key: View=%view{ascii} unzip -v %f And perhaps an optional icon for X: Icon=zip.xpm And perhaps an operation to extract the contents of the file, called from a menu selection: Extract=unzip %f '*' This is just an example. The current entry for .zip files has a menu selection of 'Unzip' which could be used in place of 'Extract'. What goes here depends on what items you have in, or add to, the menu system, and that's another subject. The sum of this is the .mc.ext entry: # zip regex/\.(zip|ZIP)$ Open=%cd %p/uzip:// View=%view{ascii} unzip -v %f Icon=zip.xpm Extract=unzip %f '*' Add an entry like this to the .mc.ext file in a user's home directory, If you want others to have it, add it to the mc.ext file in the mc system directory, often /etc/mc/mc.ext. Notice this file is not prepended with a dot. Once all this is done, and things are in their proper places, exit mc if you were using it, and restart it so it picks up the new information. That's all there is to it. The hardest part is making a listing function that sorts the output of a system listing command and turns it into a form that mc can use. Currently awk (or gawk) is used because nearly all systems have it. If another scripting language is available, like perl, that could also be used. PKD1]8u7znuȯ#! /bin/sh # # extfs support for p7zip # Written by Pavel Roskin # Some Bugfixes/workarounds by Sergiy Niskorodov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . P7ZIP=`which 7z 2>/dev/null` || P7ZIP=`which 7za 2>/dev/null` || P7ZIP=`which 7zr 2>/dev/null` || P7ZIP="" # Let the test framework hook in: P7ZIP=${MC_TEST_EXTFS_LIST_CMD:-$P7ZIP} STAT=${MC_TEST_EXTFS_U7Z_STAT:-stat} mcu7zip_list () { # Symlinks are not shown - no idea how to distinguish them # Read-only files are not shown as such - it's rarely useful ugid="`id -nu` `id -ng`" date_re='^\(....\)-\(..\)-\(..\) \(..:..:..\)' # 19 chars. date_mc='\2-\3-\1 \4' empty_date_re='^ \{19\}' size_re='............' # 12 chars. empty_size_re=' \{12\}' zero_size=' 0' # archive entries can have no datetime info, 7z will use archive file datetime date_archive=`$STAT -c %y "$1" 2>/dev/null | sed -n "s/${date_re}.*/${date_mc}/p" 2>/dev/null` [ "${date_archive}"x = x ] && date_archive=`ls -lan "$1" 2>/dev/null | awk '{print $6, $7, $8}' 2>/dev/null` [ "${date_archive}"x = x ] && date_archive="01-01-1970 00:00:00" $P7ZIP l "$1" | sed -n " # If the uncompressed size is missing, we copy the compressed size onto it. # # But first, if the compressed size is missing too, set it to zero: s/^\(.\{19\} [D.]....\) $empty_size_re $empty_size_re/\1 $zero_size $zero_size/ # Next, do the copy: s/^\(.\{19\} [D.]....\) $empty_size_re \($size_re\)/\1 \2 \2/ # # (We use '.\{19\}' as the date may be missing. It may give false positives # but we don't mind: the printing commands that follow use strict patterns.). # Handle directories. s/$date_re D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_mc \5/p s/$empty_date_re D.... $size_re $size_re\(.*\)/drwxr-xr-x 1 $ugid 0 $date_archive \1/p # Handle normal files. s/$date_re \..... \($size_re\) $size_re\(.*\)/-rw-r--r-- 1 $ugid \5 $date_mc \6/p s/$empty_date_re \..... \($size_re\) $size_re\(.*\)/-rw-r--r-- 1 $ugid \1 $date_archive \2/p " } mcu7zip_copyout () { #first we check if we have old p7zip archive with prefix ./ in filename $P7ZIP l "$1" "$2" | grep -q "0 files, 0 folders" && \ EXFNAME='*./'"$2" || EXFNAME="$2" $P7ZIP e -so "$1" "$EXFNAME" > "$3" 2>/dev/null } mcu7zip_copyin () { $P7ZIP a -si"$2" "$1" <"$3" >/dev/null 2>&1 } mcu7zip_mkdir () { dir=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-u7z.XXXXXX"` || exit 1 mkdir -p "$dir"/"$2" $P7ZIP a -w"$dir" "$1" "$dir"/"$2" >/dev/null 2>&1 rm -rf "$dir" } mcu7zip_rm () { # NOTE: Version 4.20 fails to delete files in subdirectories #first we check if we have old p7zip archive with prefix ./ in filename $P7ZIP l "$1" "$2" | grep -q "0 files, 0 folders" && \ EXFNAME='*./'"$2" || EXFNAME="$2" $P7ZIP d "$1" "$EXFNAME" 2>&1 | grep -q E_NOTIMPL > /dev/null 2>&1 && \ { printf "Function not implemented...\n7z cannot delete from solid archive." >&2 ; exit 1 ; } } mcu7zip_rmdir () { #first we check if we have old p7zip archive with prefix ./ in filename $P7ZIP l "$1" "$2" | grep -q "0 files, 0 folders" && \ EXFNAME='*./'"$2" || EXFNAME="$2" $P7ZIP d "$1" "$EXFNAME"/ 2>&1 | grep -q E_NOTIMPL > /dev/null 2>&1 && \ { printf "Function not implemented...\n7z cannot delete from solid archive." >&2 ; exit 1 ; } } # override any locale for dates LC_DATE=C export LC_DATE umask 077 if [ -z "$P7ZIP" ]; then echo "Error: could not find p7zip (looked for 7z, 7za and 7zr)" >&2 exit 1 fi cmd="$1" shift case "$cmd" in list) mcu7zip_list "$@" | sort -k 8 ;; copyout) mcu7zip_copyout "$@" ;; copyin) mcu7zip_copyin "$@" ;; mkdir) mcu7zip_mkdir "$@" ;; rm) mcu7zip_rm "$@" ;; rmdir) mcu7zip_rmdir "$@" ;; *) exit 1 ;; esac exit 0 PKD1]Wp a+nuȯ#! /usr/bin/perl -w # # External filesystem for mc, using mtools # Written Ludek Brukner , 1997 # Much improved by Tom Perkins <968794022@noid.net>, 2000 # # WARNING - This software is ALPHA - Absolutely NO WARRANTY # # These mtools components must be in PATH for this to work sub quote { $_ = shift(@_); s/([^\w\/.+-])/\\$1/g; return($_); } $mmd = "mmd"; $mrd = "mrd"; $mdel = "mdel"; $mdir = "mdir -a"; $mcopy = "mcopy -noQ"; $0 =~ s|.*/||; $qdisk = quote($0); $ENV{MTOOLS_DATE_STRING} = "mm-dd-yyyy"; $ENV{MTOOLS_TWENTY_FOUR_HOUR_CLOCK} = "1"; SWITCH: for ( $ARGV[0] ) { /list/ && do { @dirs = get_dirs(""); while ($dir = shift(@dirs)) { push @dirs, get_dirs("$dir/"); } exit 0; }; /mkdir/ && do { shift; shift; exit 1 if scalar(@ARGV) != 1; $qname = quote($ARGV[0]); system("$mmd $qdisk:/$qname >/dev/null"); exit 0; }; /rmdir/ && do { shift; shift; exit 1 if scalar(@ARGV) != 1; $qname = quote($ARGV[0]); system("$mrd $qdisk:/$qname >/dev/null"); exit 0; }; /rm/ && do { shift; shift; exit 1 if scalar(@ARGV) != 1; $qname = quote($ARGV[0]); system("$mdel $qdisk:/$qname >/dev/null"); exit 0; }; /copyout/ && do { shift; shift; exit 1 if scalar(@ARGV) != 2; ( $qsrc, $qdest ) = @ARGV; $qsrc = quote($qsrc); $qdest = quote($qdest); system("$mcopy $qdisk:/$qsrc $qdest >/dev/null"); exit 0; }; /copyin/ && do { shift; shift; exit 1 if scalar(@ARGV) != 2; ( $qdest, $qsrc ) = @ARGV; $qsrc = quote($qsrc); $qdest = quote($qdest); system("$mcopy $qsrc $qdisk:/$qdest >/dev/null"); exit 0; }; /.*/ && do { # an unfamiliar command exit 1; }; } sub get_dirs { my ($path, $name, $size, $date, $time, $longname, @lst, @rv); $path = shift(@_); my $qpath = quote($path); @rv = (); open(FILE,"$mdir $qdisk:/$qpath |"); while ( ) { chomp(); /^ / && next; # ignore `non-file' lines m{^Directory for $0:/}i && next; # ignore `non-file' lines /^$/ && next; # ignore empty lines /^\.\.?/ && next; # ignore `.' and `..' $name = substr($_,0,12); $name =~ s/^([^ ]*) +([^ ]+)[ \t]*$/$1.$2/; $name =~ s/[ .]+$//; $_ = substr($_,12); s/^[ ]+//; ($size,$date,$time,$longname) = split(/[ \t]+/, $_, 4); defined $time || next; # process "am" and "pm". Should not be needed if # MTOOLS_TWENTY_FOUR_HOUR_CLOCK is respected. @lst = split(/([:ap])/, $time); $lst[0] += 12 if (defined $lst[3] && $lst[3] eq "p"); $time = sprintf("%02d:%02d", $lst[0], $lst[2]); @lst = split(/-/, $date); $lst[2] %= 100 if ($lst[2] > 100); $date = sprintf ("%02d-%02d-%02d", @lst); $name = $path . lc(($longname) ? $longname : $name); if ($size =~ /DIR/) { printf("drwxr-xr-x 1 %-8d %-8d %8d %s %s %s\n", 0, 0, 0, $date, $time, $name); push @rv, $name; } else { printf("-rw-r--r-- 1 %-8d %-8d %8d %s %s %s\n", 0, 0, $size, $date, $time, $name); } } close(FILE); return @rv; } 1; PKD1]>Strpmnuȯ#! /bin/sh # # Browse contents of an installed RPM package. # This filesystem works on the entries of the "rpms" filesystem. # # Written by Erik Troan (ewt@redhat.com) 1996 # Jakub Jelinek (jj@sunsite.mff.cuni.cz) 1996 # Tomasz Koczko (kloczek@rudy.mif.pg.gda.pl) 1997 # minor changes by Wojtek Pilorz (wpilorz@bdk.lublin.pl) 1997 # minor changes by Michele Marziani (marziani@fe.infn.it) 1997 # slight changes to put rpm to Trpm by Balazs Nagy (julian7@kva.hu) 1998 # locale bugfix by Michal Svec (rebel@penguin.cz) 2000 # (C) 1996 The Free Software Foundation. # # # override any locale for dates unset LC_ALL LC_TIME=C export LC_TIME if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" else RPM="rpm" fi mcrpmfs_list () { # set MCFASTRPM_DFLT to 1 for faster rpm files handling by default, to 0 for # slower handling MCFASTRPM_DFLT=0 if test -z "$MCFASTRPM"; then MCFASTRPM=$MCFASTRPM_DFLT fi FILEPREF="-r--r--r-- 1 root root " DESC=`$RPM -qi -- "$1"` DATE=`$RPM -q --qf "%{BUILDTIME:date}" -- "$1" | cut -c 5-11,21-24` HEADERSIZE=`echo "$DESC" | wc -c` echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER" echo "-r-xr-xr-x 1 root root 40 $DATE UNINSTALL" echo "dr-xr-xr-x 3 root root 0 $DATE INFO" echo "$FILEPREF 0 $DATE INFO/NAME-VERSION-RELEASE" echo "$FILEPREF 0 $DATE INFO/GROUP" echo "$FILEPREF 0 $DATE INFO/BUILDHOST" echo "$FILEPREF 0 $DATE INFO/SOURCERPM" if test "$MCFASTRPM" = 0 ; then test "`$RPM -q --qf \"%{DISTRIBUTION}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" test "`$RPM -q --qf \"%{VENDOR}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/VENDOR" test "`$RPM -q --qf \"%{DESCRIPTION}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" test "`$RPM -q --qf \"%{SUMMARY}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/SUMMARY" if test "`$RPM -q --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" -- "$1"`" != "(none)(none)(none)(none)(none)"; then echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" test "`$RPM -q --qf \"%{RPMTAG_PREIN}\" -- "$1"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" test "`$RPM -q --qf \"%{RPMTAG_POSTIN}\" -- "$1"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" test "`$RPM -q --qf \"%{RPMTAG_PREUN}\" -- "$1"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" test "`$RPM -q --qf \"%{RPMTAG_POSTUN}\" -- "$1"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" test "`$RPM -q --qf \"%{VERIFYSCRIPT}\" -- "$1"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" fi else echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" echo "$FILEPREF 0 $DATE INFO/VENDOR" echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" echo "$FILEPREF 0 $DATE INFO/SUMMARY" echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" fi if test "$MCFASTRPM" = 0 ; then test "`$RPM -q --qf \"%{PACKAGER}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/PACKAGER" test "`$RPM -q --qf \"%{URL}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/URL" test "`$RPM -q --qf \"%{EPOCH}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/EPOCH" test "`$RPM -q --qf \"%{LICENSE}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/LICENSE" else echo "$FILEPREF 0 $DATE INFO/PACKAGER" echo "$FILEPREF 0 $DATE INFO/URL" echo "$FILEPREF 0 $DATE INFO/EPOCH" echo "$FILEPREF 0 $DATE INFO/LICENSE" fi echo "$FILEPREF 0 $DATE INFO/BUILDTIME" echo "$FILEPREF 0 $DATE INFO/RPMVERSION" echo "$FILEPREF 0 $DATE INFO/OS" echo "$FILEPREF 0 $DATE INFO/SIZE" if test "$MCFASTRPM" != 0 ; then $RPM -q --qf "[%{REQUIRENAME}\n]" -- "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" $RPM -q --qf "[%{OBSOLETES}\n]" -- "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/OBSOLETES" $RPM -q --qf "[%{PROVIDES}\n]" -- "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/PROVIDES" $RPM -q --qf "[%{CONFLICTS}\n]" -- "$1" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/CONFLICTS" test "`$RPM -q --qf \"%{CHANGELOGTEXT}\" -- "$1"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/CHANGELOG" else echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" echo "$FILEPREF 0 $DATE INFO/OBSOLETES" echo "$FILEPREF 0 $DATE INFO/PROVIDES" echo "$FILEPREF 0 $DATE INFO/CONFLICTS" echo "$FILEPREF 0 $DATE INFO/CHANGELOG" fi $RPM -qlv -- "$1" | grep '^[A-Za-z0-9-]' } mcrpmfs_copyout () { case "$2" in HEADER) $RPM -qi -- "$1" > "$3"; exit 0;; UNINSTALL) echo "# Run this to uninstall this RPM package" > "$3"; exit 0;; INFO/NAME-VERSION-RELEASE) $RPM -q --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" -- "$1" > "$3"; exit 0;; INFO/RELEASE) $RPM -q --qf "%{RELEASE}\n" -- "$1" > "$3"; exit 0;; INFO/GROUP) $RPM -q --qf "%{GROUP}\n" -- "$1" > "$3"; exit 0;; INFO/DISTRIBUTION) $RPM -q --qf "%{DISTRIBUTION}\n" -- "$1" > "$3"; exit 0;; INFO/VENDOR) $RPM -q --qf "%{VENDOR}\n" -- "$1" > "$3"; exit 0;; INFO/BUILDHOST) $RPM -q --qf "%{BUILDHOST}\n" -- "$1" > "$3"; exit 0;; INFO/SOURCERPM) $RPM -q --qf "%{SOURCERPM}\n" -- "$1" > "$3"; exit 0;; INFO/DESCRIPTION) $RPM -q --qf "%{DESCRIPTION}\n" -- "$1" > "$3"; exit 0;; INFO/PACKAGER) $RPM -q --qf "%{PACKAGER}\n" -- "$1" > "$3"; exit 0;; INFO/URL) $RPM -q --qf "%{URL}\n" -- "$1" > "$3"; exit 0;; INFO/BUILDTIME) $RPM -q --qf "%{BUILDTIME:date}\n" -- "$1" > "$3"; exit 0;; INFO/EPOCH) $RPM -q --qf "%{EPOCH}\n" -- "$1" > "$3"; exit 0;; INFO/LICENSE) $RPM -q --qf "%{LICENSE}\n" -- "$1" > "$3"; exit 0;; INFO/RPMVERSION) $RPM -q --qf "%{RPMVERSION}\n" -- "$1" > "$3"; exit 0;; INFO/REQUIRENAME) $RPM -q --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" -- "$1" > "$3"; exit 0;; INFO/OBSOLETES) $RPM -q --qf "[%{OBSOLETENAME} %|OBSOLETEFLAGS?{%{OBSOLETEFLAGS:depflags} %{OBSOLETEVERSION}}:{}|\n]" -- "$1" > "$3"; exit 0;; INFO/PROVIDES) $RPM -q --qf "[%{PROVIDES}\n]" -- "$1" > "$3"; exit 0;; INFO/CONFLICTS) $RPM -q --qf "[%{CONFLICTS}\n]" -- "$1" > "$3"; exit 0;; INFO/SCRIPTS/PREIN) $RPM -q --qf "%{RPMTAG_PREIN}\n" -- "$1" > "$3"; exit 0;; INFO/SCRIPTS/POSTIN) $RPM -q --qf "%{RPMTAG_POSTIN}\n" -- "$1" > "$3"; exit 0;; INFO/SCRIPTS/PREUN) $RPM -q --qf "%{RPMTAG_PREUN}\n" -- "$1" > "$3"; exit 0;; INFO/SCRIPTS/POSTUN) $RPM -q --qf "%{RPMTAG_POSTUN}\n" -- "$1" > "$3"; exit 0;; INFO/SCRIPTS/VERIFYSCRIPT) $RPM -q --qf "%{VERIFYSCRIPT}\n" -- "$1" > "$3"; exit 0;; INFO/SCRIPTS/ALL) $RPM -q --scripts -- "$1" > "$3"; exit 0;; INFO/SUMMARY) $RPM -q --qf "%{SUMMARY}\n" -- "$1" > "$3"; exit 0;; INFO/OS) $RPM -q --qf "%{OS}\n" -- "$1" > "$3"; exit 0;; INFO/CHANGELOG) $RPM -q --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" -- "$1" > "$3"; exit 0;; INFO/SIZE) $RPM -q --qf "%{SIZE} bytes\n" -- "$1" > "$3"; exit 0;; *) cp "/$2" "$3" esac } mcrpmfs_run () { case "$2" in UNINSTALL) echo "Uninstalling $1"; rpm -e -- "$1"; exit 0;; esac } name=`sed 's/.*\///;s/\.trpm$//' "$2"` case "$1" in list) mcrpmfs_list "$name"; exit 0;; copyout) mcrpmfs_copyout "$name" "$3" "$4"; exit 0;; run) mcrpmfs_run "$name" "$3"; exit 1;; esac exit 1 PKD1] ʬW++patchfsnuȯ#! /usr/bin/perl -w # # Written by Adam Byrtek , 2002 # Rewritten by David Sterba , 2009 # # Extfs to handle patches in context and unified diff format. # Known issues: When name of file to patch is modified during editing, # hunk is duplicated on copyin. It is unavoidable. use bytes; use strict; use POSIX; use File::Temp 'tempfile'; # standard binaries my $lzip = 'lzip'; my $lz4 = 'lz4'; my $lzma = 'lzma'; my $xz = 'xz'; my $bzip = 'bzip2'; my $gzip = 'gzip'; my $fileutil = 'file -b'; # date parsing requires Date::Parse from TimeDate module my $parsedates = eval 'require Date::Parse'; # regular expressions my $unified_header=qr/^--- .*\t.*\n\+\+\+ .*\t.*\n$/; my $unified_extract=qr/^--- ([^\t]+).*\n\+\+\+ ([^\t]+)\s*(.*)\n/; my $unified_header2=qr/^--- .*\n\+\+\+ .*\n$/; my $unified_extract2=qr/^--- ([^\s]+).*\n\+\+\+ ([^\s]+)\s*(.*)\n/; my $unified_contents=qr/^([+\-\\ \n]|@@ .* @@)/; my $unified_hunk=qr/@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@.*\n/; my $context_header=qr/^\*\*\* .*\t.*\n--- .*\t.*\n$/; my $context_extract=qr/^\*\*\* ([^\t]+).*\n--- ([^\t]+)\s*(.*)\n/; my $context_header2=qr/^\*\*\* .*\n--- .*\n$/; my $context_extract2=qr/^\*\*\* ([^\s]+).*\n--- ([^\s]+)\s*(.*)\n/; my $context_contents=qr/^([!+\-\\ \n]|-{3} .* -{4}|\*{3} .* \*{4}|\*{15})/; my $ls_extract_id=qr/^[^\s]+\s+[^\s]+\s+([^\s]+)\s+([^\s]+)/; my $basename=qr|^(.*/)*([^/]+)$|; sub patchfs_canonicalize_path ($) { my ($fname) = @_; $fname =~ s,/+,/,g; $fname =~ s,(^|/)(?:\.?\./)+,$1,; return $fname; } # output unix date in a mc-readable format sub timef { my @time=localtime($_[0]); return sprintf '%02d-%02d-%02d %02d:%02d', $time[4]+1, $time[3], $time[5]+1900, $time[2], $time[1]; } # parse given string as a date and return unix time sub datetime { # in case of problems fall back to 0 in unix time # note: str2time interprets some wrong values (eg. " ") as 'today' if ($parsedates && defined (my $t=str2time($_[0]))) { return timef($t); } return timef(time); } # print message on stderr and exit sub error { print STDERR $_[0], "\n"; exit 1; } # (compressed) input sub myin { my ($qfname)=(quotemeta $_[0]); $_=`$fileutil $qfname`; if (/^'*lz4/) { return "$lz4 -dc $qfname"; } elsif (/^'*lzip/) { return "$lzip -dc $qfname"; } elsif (/^'*lzma/) { return "$lzma -dc $qfname"; } elsif (/^'*xz/) { return "$xz -dc $qfname"; } elsif (/^'*bzip/) { return "$bzip -dc $qfname"; } elsif (/^'*gzip/) { return "$gzip -dc $qfname"; } else { return "cat $qfname"; } } # (compressed) output sub myout { my ($qfname,$append)=(quotemeta $_[0],$_[1]); my ($sep) = $append ? '>>' : '>'; $_=`$fileutil $qfname`; if (/^'*lz4/) { return "$lz4 -c $sep $qfname"; } elsif (/^'*lzip/) { return "$lzip -c $sep $qfname"; } elsif (/^'*lzma/) { return "$lzma -c $sep $qfname"; } elsif (/^'*xz/) { return "$xz -c $sep $qfname"; } elsif (/^'*bzip/) { return "$bzip -c $sep $qfname"; } elsif (/^'*gzip/) { return "$gzip -c $sep $qfname"; } else { return "cat $sep $qfname"; } } # select diff filename conforming with rules found in diff.info sub diff_filename { my ($fsrc,$fdst)= @_; # TODO: can remove these two calls later $fsrc = patchfs_canonicalize_path ($fsrc); $fdst = patchfs_canonicalize_path ($fdst); if (!$fdst && !$fsrc) { error 'Index: not yet implemented'; } elsif (!$fsrc || $fsrc eq '/dev/null') { return ($fdst,'PATCH-CREATE/'); } elsif (!$fdst || $fdst eq '/dev/null') { return ($fsrc,'PATCH-REMOVE/'); } elsif (($fdst eq '/dev/null') && ($fsrc eq '/dev/null')) { error 'Malformed diff, missing a sane filename'; } else { # fewest path name components if ($fdst=~s|/|/|g < $fsrc=~s|/|/|g) { return ($fdst,''); } elsif ($fdst=~s|/|/|g > $fsrc=~s|/|/|g) { return ($fsrc,''); } else { # shorter base name if (($fdst=~/$basename/o,length $2) < ($fsrc=~/$basename/o,length $2)) { return ($fdst,''); } elsif (($fdst=~/$basename/o,length $2) > ($fsrc=~/$basename/o,length $2)) { return ($fsrc,''); } else { # shortest names if (length $fdst < length $fsrc) { return ($fdst,''); } else { return ($fsrc,''); } } } } } # IN: diff "archive" name # IN: file handle for output; STDIN for list, tempfile else # IN: filename to watch (for: copyout, rm), '' for: list # IN: remove the file? # true - ... and print out the rest # false - ie. copyout mode, print just the file sub parse($$$$) { my $archive=quotemeta shift; my $fh=shift; my $file=shift; my $rmmod=shift; my ($state,$fsize,$time); my ($f,$fsrc,$fdst,$prefix); my ($unified,$context); my ($skipread, $filetoprint, $filefound); my ($h_add,$h_del,$h_ctx); # hunk line counts my ($h_r1,$h_r2); # hunk ranges my @outsrc; # if desired ... my @outdst; my $line; my %fmap_size=(); my %fmap_time=(); import Date::Parse if ($parsedates && $file eq ''); $line=1; $state=0; $fsize=0; $f=''; $filefound=0; while ($skipread || ($line++,$_=)) { $skipread=0; if($state == 0) { # expecting comments $unified=$context=0; $unified=1 if (/^--- /); $context=1 if (/^\*\*\* /); if (!$unified && !$context) { $filefound=0 if($file ne '' && $filetoprint); # shortcut for rmmod xor filefound # - in rmmod we print if not found # - in copyout (!rmmod) we print if found print $fh $_ if($rmmod != $filefound); next; } if($file eq '' && $filetoprint) { $fmap_size{"$prefix$f"}+=$fsize; $fmap_time{"$prefix$f"}=$time; } # start of new file $_ .=; # steal next line, both formats $line++; if($unified) { if(/$unified_header/o) { ($fsrc,$fdst,$time) = /$unified_extract/o; } elsif(/$unified_header2/o) { ($fsrc,$fdst,$time) = /$unified_extract2/o; } else { error "Can't parse unified diff header"; } } elsif($context) { if(/$context_header/o) { ($fsrc,$fdst,$time) = /$context_extract/o; } elsif(/$context_header2/o) { ($fsrc,$fdst,$time) = /$context_extract2/o; } else { error "Can't parse context diff header"; } } else { error "Unrecognized diff header"; } $fsrc=patchfs_canonicalize_path($fsrc); $fdst=patchfs_canonicalize_path($fdst); if(wantarray) { push @outsrc,$fsrc; push @outdst,$fdst; } ($f,$prefix)=diff_filename($fsrc,$fdst); $filefound=($f eq $file); $f="$f.diff"; $filetoprint=1; $fsize=length; print $fh $_ if($rmmod != $filefound); $state=1; } elsif($state == 1) { # expecting diff hunk headers, end of file or comments if($unified) { my ($a,$b,$c,$d); ($a,$b,$h_r1,$c,$d,$h_r2)=/$unified_hunk/o; if(!defined($a) || !defined($c)) { # hunk header does not come, a comment inside # or maybe a new file, state 0 will decide $skipread=1; $state=0; next; } $fsize+=length; print $fh $_ if($rmmod != $filefound); $h_r1=1 if(!defined($b)); $h_r2=1 if(!defined($d)); $h_add=$h_del=$h_ctx=0; $state=2; } elsif($context) { if(!/$context_contents/o) { $skipread=1; $state=0; next; } print $fh $_ if($rmmod != $filefound); $fsize+=length; } } elsif($state == 2) { # expecting hunk contents if($h_del + $h_ctx == $h_r1 && $h_add + $h_ctx == $h_r2) { # hooray, end of hunk # we optimistically ended with a hunk before but # the line has been read already $skipread=1; $state=1; next; } print $fh $_ if($rmmod != $filefound); $fsize+=length; my ($first)= /^(.)/; if(ord($first) == ord('+')) { $h_add++; } elsif(ord($first) == ord('-')) { $h_del++; } elsif(ord($first) == ord(' ')) { $h_ctx++; } elsif(ord($first) == ord('\\')) { 0; } elsif(ord($first) == ord('@')) { error "Malformed hunk, header came too early"; } else { error "Unrecognized character in hunk"; } } } if($file eq '' && $filetoprint) { $fmap_size{"$prefix$f"}+=$fsize; $fmap_time{"$prefix$f"}=$time; } # use uid and gid from file my ($uid,$gid)=(`ls -l $archive`=~/$ls_extract_id/o); # flush all file names with cumulative file size while(my ($fn, $fs) = each %fmap_size) { printf $fh "-rw-r--r-- 1 %s %s %d %s %s\n", $uid, $gid, $fs, datetime($fmap_time{$fn}), $fn; } close($fh) if($file ne ''); return \(@outsrc, @outdst) if wantarray; } # list files affected by patch sub list($) { parse($_[0], *STDOUT, '', 0); close(I); } # extract diff from patch # IN: diff file to find # IN: output file name sub copyout($$) { my ($file,$out)=@_; $file=~s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/; $file = patchfs_canonicalize_path ($file); open(FH, ">$out") or error("Cannot open output file"); parse('', *FH, $file, 0); } # remove diff(s) from patch # IN: archive # IN: file to delete sub rm($$) { my $archive=shift; my ($tmp,$tmpname)=tempfile(); @_=map {scalar(s/^(PATCH-(CREATE|REMOVE)\/)?(.*)\.diff$/$3/,$_)} @_; # just the first file for now parse($archive, $tmp, $_[0], 1); close I; # replace archive system("cat \Q$tmpname\E | " . myout($archive,0))==0 or error "Can't write to archive"; system("rm -f -- \Q$tmpname\E"); } # append diff to archive # IN: diff archive name # IN: newly created file name in archive # IN: the real source file sub copyin($$$) { # TODO: seems to be tricky. what to do? # copyin of file which is already there may: # * delete the original and copy only the new # * just append the new hunks to the same file # problems: may not be a valid diff, unmerged hunks # * try to merge the two together # ... but we do not want write patchutils again, right? error "Copying files into diff not supported"; return; my ($archive,$name,$src)=@_; # in case we are appending another diff, we have # to delete/merge all the files open(DEVNULL, ">/dev/null"); open I, myin($src).'|'; my ($srclist,$dstlist)=parse($archive, *DEVNULL, '', 0); close(I); close(DEVNULL); foreach(@$srclist) { print("SRC: del $_\n"); } foreach(@$dstlist) { print("DST: del $_\n"); } return; # remove overwritten file open I, myin($archive).'|'; rm ($archive, $name); close I; my $cmd1=myin("$src.diff"); my $cmd2=myout($archive,1); system("$cmd1 | $cmd2")==0 or error "Can't write to archive"; } my $fin = $ARGV[1]; # resolve symlink while (-l $fin) { $fin = readlink $fin; } if ($ARGV[0] eq 'list') { open I, myin($fin).'|'; list ($fin); exit 0; } elsif ($ARGV[0] eq 'copyout') { open I, myin($fin)."|"; copyout ($ARGV[2], $ARGV[3]); exit 0; } elsif ($ARGV[0] eq 'rm') { open I, myin($fin)."|"; rm ($fin, $ARGV[2]); exit 0; } elsif ($ARGV[0] eq 'rmdir') { exit 0; } elsif ($ARGV[0] eq 'mkdir') { exit 0; } elsif ($ARGV[0] eq 'copyin') { copyin ($fin, $ARGV[2], $ARGV[3]); exit 0; } exit 1; PKD1]Yzzurarnuȯ#! /bin/sh # # Written by andrey joukov # (C) 1996 2:5020/337.13@fidonet.org # Updated by christian.gennerat@alcatel.fr 1999 # Andrew V. Samoilov 2000 # # Andrew Borodin # David Haller # 2013: support unrar5 # # beta version 2.0 # # rar and unrar can be found on http://www.rarlabs.com/ RAR=rar # Prefer unrar (freeware). UNRAR=`which unrar 2>/dev/null` [ -z $UNRAR ] && UNRAR=$RAR [ ! -x $UNRAR -a -x $RAR ] && UNRAR=$RAR # Let the test framework hook in: UNRAR=${MC_TEST_EXTFS_LIST_CMD:-$UNRAR} # Determine the $UNRAR version if [ -n "$MC_TEST_EXTFS_UNRAR_VERSION" ]; then # Let the test framework fool us: UNRAR_VERSION=$MC_TEST_EXTFS_UNRAR_VERSION else # Figure it out from rar itself: UNRAR_VERSION=`$UNRAR -cfg- -? | grep "Copyright" | sed -e 's/.*\([0-9]\)\..*/\1/'` fi mcrar4fs_list () { $UNRAR v -c- -cfg- "$1" | gawk -v uid=`id -u` -v gid=`id -g` ' BEGIN { flag=0 } /^-------/ { flag++; if (flag > 1) exit 0; next } flag==1 { str = substr($0, 2) getline split($4, a, "-") if (index($6, "D") != 0) $6="drwxr-xr-x" else if (index($6, ".") != 0) $6="-rw-r--r--" printf "%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", $6, uid, gid, $1, a[2], a[1], a[3], $5, str }' } mcrar5fs_list () { $UNRAR vt -c- -cfg- "$1" | gawk -F ':' -v uid=`id -u` -v gid=`id -g` ' { ### remove space after the ":" of the field name sub ("^ ", "", $2); } $1 ~ /^ *Name$/ { ### next file name = mtime = size = attrs = ""; delete date; name = $2; ### if the name contains ":", append the rest of the fields if (NF > 2) { for (i = 3; i <= NF; i++) { name = name ":" $i; } } } $1 ~ /^ *mtime$/ { mtime = $2 ":" $3; } $1 ~ /^ *Size$/ { size = $2; } $1 ~ /^ *Attributes$/ { attrs = $2; } $1 ~ /^ *Compression$/ { ### file done, using /^$/ is not so good you ### would have to skip the version stuff first ### get date and time split (mtime, date, " "); time = date[2]; ### cut off seconds from the time sub (",[0-9]*$", "", time); ### split for reordering of the date in the printf below split (date[1], date, "-"); ### mc seems to be able to parse 4 digit years too, so remove if tested # sub ("^..", "", date[1]); ### cut year to 2 digits only ### check/adjust rights if (index (attrs, "D") != 0) { attrs = "drwxr-xr-x"; } else { if (index (attrs, ".") != 0) { attrs = "-rw-r--r--"; } } ### and finally printf ("%s 1 %s %s %d %02d/%02d/%02d %s ./%s\n", attrs, uid, gid, size, date[2], date[3], date[1], time, name); } ' } mcrarfs_list () { [ x$UNRAR_VERSION = x5 ] && mcrar5fs_list "$@" || mcrar4fs_list "$@" } mcrarfs_copyin () { # copyin by christian.gennerat@alcatel.fr # preserve pwd. It is clean, but is it necessary? pwd=`pwd` # Create a directory and copy in it the tmp file with the good name mkdir "$3.dir" cd "$3.dir" di="${2%/*}" # if file is to be written upper in the archive tree, make fake dir if test x"$di" != x"${2##*/}" ; then mkdir -p "$di" fi cp -fp "$3" "$3.dir/$2" $RAR a "$1" "$2" >/dev/null cd "$pwd" rm -rf "$3.dir" } mcrarfs_copyout () { $UNRAR p -p- -c- -cfg- -inul "$1" "$2" > "$3" } mcrarfs_mkdir () { # preserve pwd. It is clean, but is it necessary? pwd=`pwd` # Create a directory and create in it a tmp directory with the good name dir=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-urar.XXXXXX"` || exit 1 cd "$dir" mkdir -p "$2" # rar cannot create an empty directory touch "$2"/.rarfs $RAR a -r "$1" "$2" >/dev/null $RAR d "$1" "$2/.rarfs" >/dev/null cd "$pwd" rm -rf "$dir" } mcrarfs_rm () { $RAR d "$1" "$2" >/dev/null } umask 077 cmd="$1" shift case "$cmd" in # Workaround for a bug in mc - directories must precede files to # avoid duplicate entries, so we sort output by filenames list) mcrarfs_list "$@" | sort -k 8 ;; rm) mcrarfs_rm "$@" ;; rmdir) mcrarfs_rm "$@" ;; mkdir) mcrarfs_mkdir "$@" ;; copyin) mcrarfs_copyin "$@" ;; copyout) mcrarfs_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]rgitfs+nuȯ#!/bin/sh LANG=C export LANG LC_TIME=C export LC_TIME umask 077 prefix='[git]' gitfs_list() { DATE=`date +"%b %d %H:%M"` GIT_DIR="$2/.git" user=`whoami` git ls-files -v -c -m -d | sort -k 2 | uniq -f 1 | while read status fname do [ "$status" = "H" ] && status=" " [ "$status" = "C" ] && status="*" echo "-r--r--r-- 1 $user 0 0 $DATE `dirname $fname`/$prefix$status`basename $fname`" done } gitfs_copyout() { printf "%s\n" "$2" > "$4" b=`echo "$prefix"| wc -c` b=`expr "$b" + 1` # remove prefix from file name echo "`dirname "$3"`/`basename "$3" | tail -c+"$b"`" >> "$4" echo "git" >> "$4" } case "$1" in list) gitfs_list "$@" ;; copyout) gitfs_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]E;r@55rpmnuȯ#! /bin/sh # VFS-wrapper for RPM (and src.rpm) files # # Copyright (C) 1996-2004,2009 # Free Software Foundation, Inc. # # Written by # Erik Troan 1996 # Jakub Jelinek 1996, 2004 # Tomasz Kłoczko 1997 # Wojtek Pilorz # 1997: minor changes # Michele Marziani # 1997: minor changes # Marc Merlin 1998 # 1998: bug files # Michal Svec 2000 # 2000: locale bugfix # Andrew V. Samoilov # 2004: Whitespace(s) & single quote(s) in filename workaround # https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=64007 # Slava Zanko # 2009: Totally rewritten. # Alexander Chumachenko # 2013: add dependency version output # Denis Silakov # 2013: tar payload support. # Arkadiusz Miśkiewicz # 2013: improve support for EPOCH # add support for PREINPROG/POSTINPROG/PREUNPROG/POSTUNPROG # add support for VERIFYSCRIPTPROG # add support for TRIGGERSCRIPTS/TRIGGERSCRIPTPROG # Jiri Tyr # 2016: add support for PRETRANS/PRETRANSPROG/POSTTRANS/POSTTRANSPROG # # This file is part of the Midnight Commander. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # override any locale for dates unset LC_ALL LC_TIME=C export LC_TIME if rpmbuild --version >/dev/null 2>&1; then RPMBUILD="rpmbuild" else RPMBUILD="rpm" fi if rpm --nosignature --version >/dev/null 2>&1; then RPM="rpm --nosignature" RPMBUILD="$RPMBUILD --nosignature" else RPM="rpm" fi RPM_QUERY_FMT="$RPM -qp --qf" RPM2CPIO="rpm2cpio" SED="sed" param=$1; shift rpm_filename=$1; shift FILEPREF="-r--r--r-- 1 root root " mcrpmfs_getSupportedTags() { rpm --querytags } mcrpmfs_getDesription() { $RPM -qip "${rpm_filename}" } mcrpmfs_getAllNeededTags() { supportedTags=`mcrpmfs_getSupportedTags` if test "`echo supportedTags | grep -c CONFLICTS`" -eq 1; then tag_CONFLICTS="|CONFLICTS=%{CONFLICTS}" else tag_CONFLICTS="" fi $RPM_QUERY_FMT \ "|NAME=%{NAME}"\ "|VERSION=%{VERSION}"\ "|RELEASE=%{RELEASE}"\ "|DISTRIBUTION=%{DISTRIBUTION}"\ "|VENDOR=%{VENDOR}"\ "|DESCRIPTION=%{DESCRIPTION}"\ "|SUMMARY=%{SUMMARY}"\ "|URL=%{URL}"\ "|EPOCH=%{EPOCH}"\ "|LICENSE=%{LICENSE}"\ "|REQUIRES=%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}"\ "|OBSOLETES=%{OBSOLETES}"\ "|PROVIDES=%{PROVIDES} %{PROVIDEFLAGS:depflags} %{PROVIDEVERSION}"\ ${tag_CONFLICTS}\ "|PACKAGER=%{PACKAGER}" \ "${rpm_filename}" } mcrpmfs_getRawOneTag() { $RPM_QUERY_FMT "$1" "${rpm_filename}" } mcrpmfs_getOneTag() { echo $AllTAGS | $SED "s/.*|${1}=//" | cut -d '|' -f 1 } mcrpmfs_printOneMetaInfo() { if test "$3" = "raw"; then metaInfo=`mcrpmfs_getRawOneTag "%{$2}"` else metaInfo=`mcrpmfs_getOneTag "$2"` fi if test -n "${metaInfo}" -a "${metaInfo}" != "(none)"; then echo "${FILEPREF} 0 ${DATE} ${1}" return 0 fi return 1 } mcrpmfs_list_fastRPM () { echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" echo "$FILEPREF 0 $DATE INFO/VENDOR" echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" echo "$FILEPREF 0 $DATE INFO/SUMMARY" echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PRETRANS" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTTRANS" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/TRIGGERSCRIPTS" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" echo "$FILEPREF 0 $DATE INFO/PACKAGER" echo "$FILEPREF 0 $DATE INFO/URL" echo "$FILEPREF 0 $DATE INFO/EPOCH" echo "$FILEPREF 0 $DATE INFO/LICENSE" echo "$FILEPREF 0 $DATE INFO/REQUIRES" echo "$FILEPREF 0 $DATE INFO/OBSOLETES" echo "$FILEPREF 0 $DATE INFO/PROVIDES" echo "$FILEPREF 0 $DATE INFO/CONFLICTS" echo "$FILEPREF 0 $DATE INFO/CHANGELOG" } mcrpmfs_list_fullRPM () { mcrpmfs_printOneMetaInfo "INFO/DISTRIBUTION" "DISTRIBUTION" mcrpmfs_printOneMetaInfo "INFO/VENDOR" "VENDOR" mcrpmfs_printOneMetaInfo "INFO/DESCRIPTION" "DESCRIPTION" mcrpmfs_printOneMetaInfo "INFO/SUMMARY" "SUMMARY" if test "`mcrpmfs_getRawOneTag \"%{RPMTAG_PRETRANS}%{RPMTAG_POSTTRANS}%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}%{TRIGGERSCRIPTS}\"`" != "(none)(none)(none)(none)(none)(none)(none)(none)"; then mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/PRETRANS" "RPMTAG_PRETRANS" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/POSTTRANS" "RPMTAG_POSTTRANS" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/PREIN" "RPMTAG_PREIN" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/POSTIN" "RPMTAG_POSTIN" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/PREUN" "RPMTAG_PREUN" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/POSTUN" "RPMTAG_POSTUN" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/VERIFYSCRIPT" "VERIFYSCRIPT" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/TRIGGERSCRIPTS" "TRIGGERSCRIPTS" "raw" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" fi if test "`mcrpmfs_getRawOneTag \"%{RPMTAG_PRETRANSPROG}%{RPMTAG_POSTTRANSPROG}%{RPMTAG_PREINPROG}%{RPMTAG_POSTINPROG}%{RPMTAG_PREUNPROG}%{RPMTAG_POSTUNPROG}%{VERIFYSCRIPTPROG}%{TRIGGERSCRIPTPROG}\"`" != "(none)(none)(none)(none)(none)(none)(none)(none)"; then mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/PRETRANSPROG" "RPMTAG_PRETRANSPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/POSTTRANSPROG" "RPMTAG_POSTTRANSPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/PREINPROG" "RPMTAG_PREINPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/POSTINPROG" "RPMTAG_POSTINPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/PREUNPROG" "RPMTAG_PREUNPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/POSTUNPROG" "RPMTAG_POSTUNPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/VERIFYSCRIPTPROG" "VERIFYSCRIPTPROG" "raw" mcrpmfs_printOneMetaInfo "INFO/SCRIPTS/TRIGGERSCRIPTPROG" "TRIGGERSCRIPTPROG" "raw" fi mcrpmfs_printOneMetaInfo "INFO/PACKAGER" "PACKAGER" mcrpmfs_printOneMetaInfo "INFO/URL" "URL" mcrpmfs_printOneMetaInfo "INFO/EPOCH" "EPOCH" mcrpmfs_printOneMetaInfo "INFO/LICENSE" "LICENSE" mcrpmfs_printOneMetaInfo "INFO/REQUIRES" "REQUIRES" mcrpmfs_printOneMetaInfo "INFO/OBSOLETES" "OBSOLETES" mcrpmfs_printOneMetaInfo "INFO/PROVIDES" "PROVIDES" mcrpmfs_printOneMetaInfo "INFO/CONFLICTS" "CONFLICTS" mcrpmfs_printOneMetaInfo "INFO/CHANGELOG" "CHANGELOGTEXT" "raw" } mcrpmfs_list () { # set MCFASTRPM_DFLT to 1 for faster rpm files handling by default, to 0 for # slower handling MCFASTRPM_DFLT=0 if test -z "$MCFASTRPM"; then MCFASTRPM=$MCFASTRPM_DFLT fi DESC=`mcrpmfs_getDesription 2>/dev/null` || { echo "$FILEPREF 0 "`date +"%b %d %H:%M"`" ERROR" exit 1 } DATE=`mcrpmfs_getRawOneTag "%{BUILDTIME:date}\n" | cut -c 5-11,21-24` PAYLOAD=`mcrpmfs_getRawOneTag "%{PAYLOADFORMAT}\n" | sed s/ustar/tar/` HEADERSIZE=`echo "$DESC" | wc -c` printf '%s %s %s HEADER\n' "${FILEPREF}" "${HEADERSIZE}" "${DATE}" echo "-r-xr-xr-x 1 root root 39 $DATE INSTALL" case "${rpm_filename}" in *.src.rpm) echo "-r-xr-xr-x 1 root root 39 $DATE REBUILD" ;; *) echo "-r-xr-xr-x 1 root root 39 $DATE UPGRADE" ;; esac echo "dr-xr-xr-x 3 root root 0 $DATE INFO" if [ `mcrpmfs_getRawOneTag "%{EPOCH}"` = "(none)" ]; then echo "$FILEPREF 0 $DATE INFO/NAME-VERSION-RELEASE" else echo "$FILEPREF 0 $DATE INFO/NAME-EPOCH:VERSION-RELEASE" fi echo "$FILEPREF 0 $DATE INFO/GROUP" echo "$FILEPREF 0 $DATE INFO/BUILDHOST" echo "$FILEPREF 0 $DATE INFO/SOURCERPM" echo "$FILEPREF 0 $DATE INFO/BUILDTIME" echo "$FILEPREF 0 $DATE INFO/RPMVERSION" echo "$FILEPREF 0 $DATE INFO/OS" echo "$FILEPREF 0 $DATE INFO/SIZE" if test "$MCFASTRPM" = 0 ; then mcrpmfs_list_fullRPM else mcrpmfs_list_fastRPM fi echo "$FILEPREF 0 $DATE CONTENTS.$PAYLOAD" } mcrpmfs_copyout () { case "$1" in HEADER) mcrpmfs_getDesription > "$2"; exit 0;; INSTALL) echo "# Run this script to install this RPM package" > "$2" echo $RPM -ivh "${rpm_filename}" >> "$2" exit 0 ;; UPGRADE) echo "# Run this to upgrade this RPM package" > "$2" echo $RPM -Uvh "${rpm_filename}" >> "$2" exit 0 ;; REBUILD) echo "# Run this to rebuild this RPM package" > "$2" echo $RPMBUILD --rebuild "${rpm_filename}" >> "$2" exit 0 ;; ERROR) mcrpmfs_getDesription > /dev/null 2> "$2"; exit 0;; INFO/NAME-VERSION-RELEASE) echo `mcrpmfs_getOneTag "NAME"`-`mcrpmfs_getOneTag "VERSION"`-`mcrpmfs_getOneTag "RELEASE"` > "$2" exit 0 ;; INFO/NAME-EPOCH:VERSION-RELEASE) echo `mcrpmfs_getOneTag "NAME"`-`mcrpmfs_getOneTag "EPOCH"`:`mcrpmfs_getOneTag "VERSION"`-`mcrpmfs_getOneTag "RELEASE"` > "$2" exit 0 ;; INFO/RELEASE) mcrpmfs_getOneTag "RELEASE" > "$2"; exit 0;; INFO/GROUP) mcrpmfs_getRawOneTag "%{GROUP}\n" > "$2"; exit 0;; INFO/DISTRIBUTION) mcrpmfs_getOneTag "DISTRIBUTION" > "$2"; exit 0;; INFO/VENDOR) mcrpmfs_getOneTag "VENDOR" > "$2"; exit 0;; INFO/BUILDHOST) mcrpmfs_getRawOneTag "%{BUILDHOST}\n" > "$2"; exit 0;; INFO/SOURCERPM) mcrpmfs_getRawOneTag "%{SOURCERPM}\n" > "$2"; exit 0;; INFO/DESCRIPTION) mcrpmfs_getRawOneTag "%{DESCRIPTION}\n" > "$2"; exit 0;; INFO/PACKAGER) mcrpmfs_getOneTag "PACKAGER" > "$2"; exit 0;; INFO/URL) mcrpmfs_getOneTag "URL" >"$2"; exit 0;; INFO/BUILDTIME) mcrpmfs_getRawOneTag "%{BUILDTIME:date}\n" >"$2"; exit 0;; INFO/EPOCH) mcrpmfs_getOneTag "EPOCH" >"$2"; exit 0;; INFO/LICENSE) mcrpmfs_getOneTag "LICENSE" >"$2"; exit 0;; INFO/RPMVERSION) mcrpmfs_getRawOneTag "%{RPMVERSION}\n" >"$2"; exit 0;; INFO/REQUIRES) mcrpmfs_getRawOneTag "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" >"$2"; exit 0;; INFO/PROVIDES) mcrpmfs_getRawOneTag "[%{PROVIDES} %{PROVIDEFLAGS:depflags} %{PROVIDEVERSION}\n]" >"$2"; exit 0;; INFO/SCRIPTS/PRETRANS) mcrpmfs_getRawOneTag "%{RPMTAG_PRETRANS}\n" >"$2"; exit 0;; INFO/SCRIPTS/PRETRANSPROG) mcrpmfs_getRawOneTag "%{RPMTAG_PRETRANSPROG}\n" >"$2"; exit 0;; INFO/SCRIPTS/POSTTRANS) mcrpmfs_getRawOneTag "%{RPMTAG_POSTTRANS}\n" >"$2"; exit 0;; INFO/SCRIPTS/POSTTRANSPROG) mcrpmfs_getRawOneTag "%{RPMTAG_POSTTRANSPROG}\n" >"$2"; exit 0;; INFO/SCRIPTS/PREIN) mcrpmfs_getRawOneTag "%{RPMTAG_PREIN}\n" >"$2"; exit 0;; INFO/SCRIPTS/PREINPROG) mcrpmfs_getRawOneTag "%{RPMTAG_PREINPROG}\n" >"$2"; exit 0;; INFO/SCRIPTS/POSTIN) mcrpmfs_getRawOneTag "%{RPMTAG_POSTIN}\n" >"$2"; exit 0;; INFO/SCRIPTS/POSTINPROG) mcrpmfs_getRawOneTag "%{RPMTAG_POSTINPROG}\n" >"$2"; exit 0;; INFO/SCRIPTS/PREUN) mcrpmfs_getRawOneTag "%{RPMTAG_PREUN}\n" >"$2"; exit 0;; INFO/SCRIPTS/PREUNPROG) mcrpmfs_getRawOneTag "%{RPMTAG_PREUNPROG}\n" >"$2"; exit 0;; INFO/SCRIPTS/POSTUN) mcrpmfs_getRawOneTag "%{RPMTAG_POSTUN}\n" >"$2"; exit 0;; INFO/SCRIPTS/POSTUNPROG) mcrpmfs_getRawOneTag "%{RPMTAG_POSTUNPROG}\n" >"$2"; exit 0;; INFO/SCRIPTS/VERIFYSCRIPT) mcrpmfs_getRawOneTag "%{VERIFYSCRIPT}\n" > "$2"; exit 0;; INFO/SCRIPTS/VERIFYSCRIPTPROG) mcrpmfs_getRawOneTag "%{VERIFYSCRIPTPROG}\n" > "$2"; exit 0;; INFO/SCRIPTS/TRIGGERSCRIPTS) $RPM -qp --triggers "${rpm_filename}" > "$2"; exit 0;; INFO/SCRIPTS/TRIGGERSCRIPTPROG) mcrpmfs_getRawOneTag "%{TRIGGERSCRIPTPROG}\n" > "$2"; exit 0;; INFO/SCRIPTS/ALL) $RPM -qp --scripts "${rpm_filename}" > "$2"; exit 0;; INFO/SUMMARY) mcrpmfs_getRawOneTag "%{SUMMARY}\n" > "$2"; exit 0;; INFO/OS) mcrpmfs_getRawOneTag "%{OS}\n" > "$2"; exit 0;; INFO/CHANGELOG) mcrpmfs_getRawOneTag "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" > "$2"; exit 0;; INFO/SIZE) mcrpmfs_getRawOneTag "%{SIZE} bytes\n" > "$2"; exit 0;; INFO/OBSOLETES) mcrpmfs_getRawOneTag "[%{OBSOLETENAME} %|OBSOLETEFLAGS?{%{OBSOLETEFLAGS:depflags} %{OBSOLETEVERSION}}:{}|\n]" > "$2"; exit 0;; INFO/CONFLICTS) mcrpmfs_getRawOneTag "[%{CONFLICTNAME} %{CONFLICTFLAGS:depflags} %{CONFLICTVERSION}\n]" >"$2"; exit 0;; CONTENTS.*) $RPM2CPIO "${rpm_filename}" > "$2"; exit 0;; *) ;; esac } mcrpmfs_run () { case "$1" in INSTALL) echo "Installing \"${rpm_filename}\""; $RPM -ivh "${rpm_filename}"; exit 0;; UPGRADE) echo "Upgrading \"${rpm_filename}\""; $RPM -Uvh "${rpm_filename}"; exit 0;; REBUILD) echo "Rebuilding \"${rpm_filename}\""; $RPMBUILD --rebuild "${rpm_filename}"; exit 0;; esac } # Let the test framework override functions and variables. [ -n "$MC_TEST_RPM_REWRITE" ] && . "$MC_TEST_RPM_REWRITE" AllTAGS=`mcrpmfs_getAllNeededTags "$1"` umask 077 case "${param}" in list) mcrpmfs_list; exit 0;; copyout) mcrpmfs_copyout "$1" "$2"; exit 0;; run) mcrpmfs_run "$1"; exit 1;; esac exit 1 PKD1]wucabnuȯ#! /bin/sh CAB=cabextract mccabfs_list () { $CAB -l "$1" | gawk -v uid=`id -un` -v gid=`id -gn` ' BEGIN { flag=0 } /^-------/ { flag++; if (flag > 1) exit 0; next } { if (flag == 0) next if (length($6) == 0) next pr="-rw-r--r--" split($3, a, ".") split($4, b, ":") printf "%s 1 %s %s %d %02d/%02d/%02d %02d:%02d %s\n", pr, uid, gid, $1, a[2], a[1], a[3], b[1], b[2], $6 }' } mccabfs_copyout () { $CAB -F "$2" -p "$1" > "$3" } LC_ALL=C export LC_ALL umask 077 cmd="$1" case "$cmd" in # Workaround for a bug in mc - directories must precede files to # avoid duplicate entries, so we sort output by filenames list) mccabfs_list "$2" ;; copyout) mccabfs_copyout "$2" "$3" "$4" ;; *) exit 1 ;; esac exit 0 PKD1]++uarnuȯ#!/bin/sh # # Written by Alex Kuchma # Alex Tkachenko # Updated by Vitezslav Samel # # (C) 1997, 1998 The Free Software Foundation. # # XAR=ar mcarfs_list () { # If $temp_replace string is part of the filename that part might get lost temp_replace='Unique Separator String' thisyear="`date +%Y`" $XAR tv "$1" | sed 's,^,-,;s, , 1 ,;s,/, ,' | sed -e "s/\( [0-2][0-9]\:[0-5][0-9]\)\( $thisyear \)\(.*\)/\1$temp_replace\3/" | sed -e "s/\( [0-2][0-9]\:[0-5][0-9] \)\([12][0-9][0-9][0-9] \)\(.*\)/ \2\3/" | sed -e "s/$temp_replace/ /" } mcarfs_copyout () { $XAR p "$1" "$2" > "$3" } mcarfs_copyin () { TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-uar.XXXXXX"` || exit 1 name=`basename "$2"` (cd "$TMPDIR" && cp -fp "$3" "$name" && $XAR r "$1" "$name") rm -rf "$TMPDIR" } mcarfs_rm () { $XAR d "$1" "$2" } # override any locale for dates LC_ALL=C export LC_ALL umask 077 case "$1" in list) mcarfs_list "$2" ;; copyout) shift; mcarfs_copyout "$@" ;; copyin) shift; mcarfs_copyin "$@" ;; rm) shift; mcarfs_rm "$@" ;; mkdir|rmdir) echo "mcarfs: ar archives cannot contain directories." 1>&2 exit 1;; *) echo "mcarfs: unknown command: \"$1\"." 1>&2 exit 1;; esac exit 0 PKD1]uhanuȯ#!/bin/sh # # It is the uhafs Valery Kornienkov vlk@st.simbirsk.su 2:5051/30@fidonet # ver 0.1 Thu Apr 6 12:05:08 2000 # # Tested with HA 0.999. Source of ha can be found at # ftp://ftp.ibiblio.org/pub/Linux/utils/compress/ HA=ha mchafs_list () { $HA lf "$1" 2>/dev/null | gawk -v uid=$(id -ru) ' /^===========/ {next} { if ($5="%" && $8~/DIR|ASC|HSC|CPY/) { split($6, a, "-") split($7, t, ":") filename=$1 filesize=$2 getline if ($2=="(none)") $2="" path=$2 getline if ($1~/^d.*/) next printf "%s %s %-8d %-8d %8d %s-%s-%s %s:%s %s%s\n",\ $1,1,0,0,filesize,a[3],a[2],a[1],t[1],t[2],path,filename } }' } mchafs_copyout () { TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-uha.XXXXXX"` || exit 1 cd "$TMPDIR" $HA xyq "$1" "$2" >/dev/null cat "$2" > "$3" cd / rm -rf "$TMPDIR" } cmd="$1" shift case "$cmd" in list) mchafs_list "$@" ;; copyout) mchafs_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]~&#&#dpkg+nuȯ#! /usr/bin/perl # # 1999 (c) Piotr Roszatycki # This software is under GNU license # last modification: 1999-12-08 # # dpkg sub quote { $_ = shift(@_); s/([^\w\/.+-])/\\$1/g; return($_); } sub bt { my ($dt) = @_; my (@time); @time = localtime($dt); $bt = sprintf "%02d-%02d-%d %02d:%02d", $time[4] + 1, $time[3], $time[5] + 1900, $time[2], $time[1]; return $bt; } sub ft { my ($f) = @_; return "d" if -d $f; return "l" if -l $f; return "p" if -p $f; return "S" if -S $f; return "b" if -b $f; return "c" if -c $f; return "-"; } sub fm { my ($n) = @_; my ($m); if( $n & 0400 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0200 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 04000 ) { $m .= "s"; } elsif( $n & 0100 ) { $m .= "x"; } else { $m .= "-"; } if( $n & 0040 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0020 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 02000 ) { $m .= "s"; } elsif( $n & 0010 ) { $m .= "x"; } else { $m .= "-"; } if( $n & 0004 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0002 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 01000 ) { $m .= "t"; } elsif( $n & 0001 ) { $m .= "x"; } else { $m .= "-"; } return $m; } sub ls { my ($file,$path,$mode) = @_; if (-f $file) { my @stat = stat(_); # mode, nlink, uid, gid, size, mtime, filename printf "%s %d %d %d %d %s %s\n", $mode || ft($file).fm($stat[2] & 07777), $stat[3], $stat[4], $stat[5], $stat[7], bt($stat[9]), $path; } } $DATE=bt(time()); sub list { my ($pkg, $fn, $dn, $sz, $bt); my %debs = (); my %sects = (); my($diversions,$architecture); chop($diversions = `dpkg-divert --list 2>/dev/null`); chop($architecture = `dpkg-architecture 2>/dev/null`); chop($list = `dpkg -l '*' 2>/dev/null`); chop($getselections = `dpkg --get-selections 2>/dev/null`); chop($audit = `dpkg --audit 2>/dev/null`); $sz = length($diversions); print "-r--r--r-- 1 root root $sz $DATE DIVERSIONS\n"; $sz = length($architecture); print "-r--r--r-- 1 root root $sz $DATE ARCHITECTURE\n"; $sz = length($list); print "-r--r--r-- 1 root root $sz $DATE LIST\n"; $sz = length($getselections); print "-r--r--r-- 1 root root $sz $DATE GET-SELECTIONS\n"; $sz = length($audit); print "-r--r--r-- 1 root root $sz $DATE AUDIT\n"; $sz = length($pressconfigure); print "-r-xr--r-- 1 root root $sz $DATE CONFIGURE\n"; $sz = length($pressremove); print "-r-xr--r-- 1 root root $sz $DATE REMOVE\n"; $sz = length($pressclearavail); print "-r-xr--r-- 1 root root $sz $DATE CLEAR-AVAIL\n"; $sz = length($pressforgetoldunavail); print "-r-xr--r-- 1 root root $sz $DATE FORGET-OLD-UNAVAIL\n"; ls("/var/lib/dpkg/status","STATUS","-r--r--r--"); # ls("/var/lib/dpkg/available","AVAILABLE","-r--r--r--"); print "drwxr-xr-x 1 root root 0 $DATE all\n"; open STAT, "/var/lib/dpkg/status" or exit 1; while( ) { chop; if( /^([\w-]*): (.*)/ ) { $pkg = $2 if( lc($1) eq 'package' ); $debs{$pkg}{lc($1)} = $2; } } close STAT; foreach $pkg (sort keys %debs) { next if $debs{$pkg}{status} =~ /not-installed/; $fn = $debs{$pkg}{package}. "_". $debs{$pkg}{version}; $dn = $debs{$pkg}{section}; if( ! $dn ) { $dn = "unknown"; } elsif( $dn =~ /^(non-us)$/i ) { $dn .= "/main"; } elsif( $dn !~ /\// ) { $dn = "main/". $dn; } unless( $sects{$dn} ) { my $sub = $dn; while( $sub =~ s!^(.*)/[^/]*$!$1! ) { unless( $sects{$sub} ) { print "drwxr-xr-x 1 root root 0 $DATE $sub/\n"; $sects{$sub} = 1; } } print "drwxr-xr-x 1 root root 0 $DATE $dn/\n"; $sects{$dn} = 1; } $sz = $debs{$pkg}{'status'} =~ /config-files/ ? 0 : $debs{$pkg}{'installed-size'} * 1024; @stat = stat("/var/lib/dpkg/info/".$debs{$pkg}{package}.".list"); $bt = bt($stat[9]); print "-rw-r--r-- 1 root root $sz $bt $dn/$fn.debd\n"; print "lrwxrwxrwx 1 root root $sz $bt all/$fn.debd -> ../$dn/$fn.debd\n"; } } sub copyout { my($archive,$filename) = @_; my $qfilename = quote($filename); if( $archive eq 'DIVERSIONS' ) { system("dpkg-divert --list > $qfilename 2>/dev/null"); } elsif( $archive eq 'ARCHITECTURE' ) { system("dpkg-architecture > $qfilename 2>/dev/null"); } elsif( $archive eq 'LIST' ) { system("dpkg -l '*' > $qfilename 2>/dev/null"); } elsif( $archive eq 'AUDIT' ) { system("dpkg --audit > $qfilename 2>/dev/null"); } elsif( $archive eq 'GET-SELECTIONS' ) { system("dpkg --get-selections > $qfilename 2>/dev/null"); } elsif( $archive eq 'STATUS' ) { system("cp /var/lib/dpkg/status $qfilename"); } elsif( $archive eq 'AVAILABLE' ) { system("cp /var/lib/dpkg/available $qfilename"); } elsif( $archive eq 'CONFIGURE' ) { open O, ">$filename"; print O $pressconfigure; close O; } elsif( $archive eq 'REMOVE' ) { open O, ">$filename"; print O $pressremove; close O; } elsif( $archive eq 'CLEAR-AVAIL' ) { open O, ">$filename"; print O $pressclearavail; close O; } elsif( $archive eq 'FORGET-OLD-UNAVAIL' ) { open O, ">$filename"; print O $pressforgetoldunavail; close O; } else { open O, ">$filename"; print O $archive, "\n"; close O; } } # too noisy but less dangerouse sub copyin { my($archive,$filename) = @_; my $qfilename = quote($filename); if( $archive =~ /\.deb$/ ) { system("dpkg -i $qfilename>/dev/null"); } else { die "extfs: cannot create regular file \`$archive\': Permission denied\n"; } } sub run { my($archive,$filename) = @_; if( $archive eq 'CONFIGURE' ) { system("dpkg --pending --configure"); } elsif( $archive eq 'REMOVE' ) { system("dpkg --pending --remove"); } elsif( $archive eq 'CLEAR-AVAIL' ) { system("dpkg --clear-avail"); } elsif( $archive eq 'FORGET-OLD-UNAVAIL' ) { system("dpkg --forget-old-unavail"); } else { die "extfs: $filename: command not found\n"; } } # Disabled - too dangerous and too noisy sub rm_disabled { my($archive) = @_; if( $archive =~ /\.debd?$/ ) { my $qname = quote($archive); $qname =~ s%.*/%%g; $qname =~ s%_.*%%g; system("if dpkg -s $qname | grep ^Status | grep -qs config-files; \ then dpkg --purge $qname>/dev/null; \ else dpkg --remove $qname>/dev/null; fi"); die("extfs: $archive: Operation not permitted\n") if $? != 0; } else { die "extfs: $archive: Operation not permitted\n"; } } $pressconfigure=< # This software is under GNU license # last modification: 1999-12-08 # # deba sub quote { $_ = shift(@_); s/([^\w\/.+-])/\\$1/g; return($_); } sub list { my($qarchive)=@_; $qarchive = quote($qarchive); chop($date=`LC_ALL=C date "+%m-%d-%Y %H:%M"`); chop($info_size=`apt-cache show $qarchive | wc -c`); $install_size=length($pressinstall); $upgrade_size=length($pressupgrade); print "-r--r--r-- 1 root root $info_size $date INFO\n"; chop($debd = `dpkg -s $qarchive | grep -i ^Version | sed 's/^version: //i'`); chop($deba = `apt-cache show $qarchive | grep -i ^Version | sed 's/^version: //i'`); if( ! $debd ) { print "-r-xr--r-- 1 root root $install_size $date INSTALL\n"; } elsif( $debd ne $deba ) { print "-r-xr--r-- 1 root root $upgrade_size $date UPGRADE\n"; } } sub copyout { my($archive,$filename,$destfile)=@_; my $qarchive = quote($archive); my $qdestfile = quote($destfile); if($filename eq "INFO") { system("apt-cache show $qarchive > $qdestfile"); } elsif($filename eq "INSTALL") { if ( open(FILEOUT, "> $destfile") ) { print FILEOUT $pressinstall; close FILEOUT; system("chmod a+x $qdestfile"); } } elsif($filename eq "UPGRADE") { if ( open(FILEOUT, ">, $destfile") ) { print FILEOUT $pressupgrade; close FILEOUT; system("chmod a+x $qdestfile"); } } else { die "extfs: $filename: No such file or directory\n"; } } sub run { my($archive,$filename)=@_; my $qarchive = quote($archive); if($filename eq "INSTALL") { system("apt-get install $qarchive"); } elsif($filename eq "UPGRADE") { system("apt-get install $qarchive"); } else { die "extfs: $filename: Permission denied\n"; } } $pressinstall=<&1 | grep '^[ 0-9][ 0-9][ 0-9]\.' | while read A B C do A=`echo "$A" | sed -e 's/\.//' -e 's/^\(.\)$/0\1/'` SIZE=`expr 44 + $B \* 2352` echo "-r--r--r-- 1 0 0 $SIZE $DATE track-${A}.wav" done } audiofs_copyout() { if [ x"$2" = x"CDDB" ]; then DISCID=`cd-discid "$1" | tr " " "+"` if [ -z "$DISCID" ]; then exit 1 fi RESPONSE=`wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+query+$DISCID&$CDDB_HANDSHAKE" | tee "$3" | gawk '/^200/ { print $2,$3; }'` wget -q -T $CDDB_TIMEOUT -O - "$CDDB_SERVER/~cddb/cddb.cgi?cmd=cddb+read+$RESPONSE&$CDDB_HANDSHAKE" | grep -v "^#" >> "$3" else TRACK=`echo "$2" | sed 's/track-0*//' | sed 's/\.wav//'` cdparanoia -q -d "$1" "$TRACK" "$3" >/dev/null fi } if [ ! -b "$2" ] then BASE="/dev/cdrom" else BASE="$2" fi case "$1" in list) audiofs_list "$BASE"; exit 0;; copyout) audiofs_copyout "$BASE" "$3" "$4"; exit 0;; esac exit 1 PKD1]砜))debdnuȯ#! /usr/bin/perl # # 1999 (c) Piotr Roszatycki # This software is under GNU license # last modification: 1999-12-08 # # debd sub quote { $_ = shift(@_); s/([^\w\/.+-])/\\$1/g; return($_); } sub bt { my ($dt) = @_; my (@time); @time = localtime($dt); $bt = sprintf "%02d-%02d-%d %02d:%02d", $time[4] + 1, $time[3], $time[5] + 1900, $time[2], $time[1]; return $bt; } sub ft { my ($f) = @_; return "d" if -d $f; return "l" if -l $f; return "p" if -p $f; return "S" if -S $f; return "b" if -b $f; return "c" if -c $f; return "-"; } sub fm { my ($n) = @_; my ($m); if( $n & 0400 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0200 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 04000 ) { $m .= "s"; } elsif( $n & 0100 ) { $m .= "x"; } else { $m .= "-"; } if( $n & 0040 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0020 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 02000 ) { $m .= "s"; } elsif( $n & 0010 ) { $m .= "x"; } else { $m .= "-"; } if( $n & 0004 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0002 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 01000 ) { $m .= "t"; } elsif( $n & 0001 ) { $m .= "x"; } else { $m .= "-"; } return $m; } sub ls { my ($file) = @_; my @stat = stat($file); # mode, nlink, uid, gid, size, mtime, filename printf "%s%s %d %d %d %d %s CONTENTS%s\n", ft($file), fm($stat[2] & 07777), $stat[3], $stat[4], $stat[5], $stat[7], bt($stat[9]), $file; } sub list { my($archive)=@_; my $qarchive = quote($archive); chop($date=`LC_ALL=C date "+%m-%d-%Y %H:%M"`); chop($info_size=`dpkg -s $qarchive | wc -c`); $repack_size=length($pressrepack); $reinstall_size=length($pressreinstall); $remove_size=length($pressremove); $purge_size=length($presspurge); $reconfigure_size=length($pressreconfigure); $reinstall_size=length($pressreinstall); $select_size=length($pressselect); $unselect_size=length($pressunselect); print "dr-xr-xr-x 1 root root 0 $date CONTENTS\n"; print "dr-xr-xr-x 1 root root 0 $date DEBIAN\n"; print "-r--r--r-- 1 root root $info_size $date INFO\n"; print "-r-xr--r-- 1 root root $purge_size $date DPKG-PURGE\n"; chop($status = `dpkg -s $qarchive | grep ^Status`); if( $status =~ /deinstall/ ) { print "-r-xr--r-- 1 root root $select_size $date DPKG-SELECT\n"; } elsif( $status =~ /install/ ) { print "-r-xr--r-- 1 root root $unselect_size $date DPKG-UNSELECT\n"; } if( $status !~ /config-files/ ) { if ( -x "/usr/bin/dpkg-repack" ) { print "-r-xr--r-- 1 root root $repack_size $date DPKG-REPACK\n"; } print "-r-xr--r-- 1 root root $remove_size $date DPKG-REMOVE\n"; if ( -x "/usr/bin/apt-get" ) { print "-r-xr--r-- 1 root root $remove_size $date APT-REMOVE\n"; print "-r-xr--r-- 1 root root $reinstall_size $date APT-REINSTALL\n"; print "-r-xr--r-- 1 root root $purge_size $date APT-PURGE\n"; } } if( -x "/usr/bin/dpkg-reconfigure" && -x "/var/lib/dpkg/info/$archive.config" ) { print "-r-xr--r-- 1 root root $reconfigure_size $date DPKG-RECONFIGURE\n"; } if ( open(PIPEIN, "LC_TIME=C LANG=C ls -l /var/lib/dpkg/info/$qarchive.* |") ) { while() { chop; next if /\.list$/; s%/var/lib/dpkg/info/$archive.%DEBIAN/%; print $_, "\n"; } close PIPEIN; } if ( open(LIST, "/var/lib/dpkg/info/$archive.list") ) { while() { chop; ls($_); } close LIST; } } sub copyout { my($archive,$filename,$destfile)=@_; my $qarchive = quote($archive); my $qfilename = quote($filename); my $qdestfile = quote($destfile); if($filename eq "INFO") { system("dpkg -s $qarchive > $qdestfile"); } elsif($filename eq "DPKG-REPACK") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressrepack; close FILEOUT; system("chmod a+x $qdestfile"); } } elsif($filename =~ /^DEBIAN/) { $qfilename=~s!^DEBIAN/!!; system("cat /var/lib/dpkg/info/$qarchive.$qfilename > $qdestfile"); } elsif($filename eq "DPKG-REMOVE" || $filename eq "APT-REMOVE") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressremove; close FILEOUT; system("chmod a+x $qdestfile"); } } elsif($filename eq "DPKG-PURGE" || $filename eq "APT-PURGE") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $presspurge; close FILEOUT; system("chmod a+x $qdestfile"); } } elsif($filename eq "DPKG-RECONFIGURE") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressreconfigure; close FILEOUT; system("chmod a+x $qdestfile"); } } elsif($filename eq "APT-REINSTALL") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressreinstall; close FILEOUT; system("chmod a+x $destfile"); } } elsif($filename eq "DPKG-SELECT") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressselect; close FILEOUT; system("chmod a+x $destfile"); } } elsif($filename eq "DPKG-UNSELECT") { if ( open(FILEOUT,">$destfile") ) { print FILEOUT $pressunselect; close FILEOUT; system("chmod a+x $qdestfile"); } } else { $qfilename=~s!^CONTENTS!!; system("cat $qfilename > $qdestfile"); } } sub run { my($archive,$filename)=@_; my $qarchive = quote($archive); my $qfilename = quote($filename); if($filename eq "DPKG-REMOVE") { system("dpkg --remove $qarchive"); } elsif($filename eq "APT-REMOVE") { system("apt-get remove $qarchive"); } elsif($filename eq "DPKG-PURGE") { system("dpkg --purge $qarchive"); } elsif($filename eq "APT-PURGE") { system("apt-get --purge remove $qarchive"); } elsif($filename eq "DPKG-REPACK") { system("dpkg-repack $qarchive"); } elsif($filename eq "DPKG-SELECT") { system("echo $aqrchive install | dpkg --set-selections"); } elsif($filename eq "DPKG-UNSELECT") { system("echo $qarchive deinstall | dpkg --set-selections"); } elsif($filename eq "APT-REINSTALL") { system("apt-get -u --reinstall install $qarchive"); } elsif($filename eq "DPKG-RECONFIGURE") { system("dpkg-reconfigure $qarchive"); } elsif($filename=~/^DEBIAN/) { $qfilename=~s!^DEBIAN!!; system("/var/lib/dpkg/info/$qarchive.$qfilename"); } else { $qfilename=~s!^CONTENTS!!; system($qfilename); } } $pressrepack=< .*/) { symfile = " -> "$3 perm="l"substr(perm, 2) } if ($0 ~ /^[\t ]+Owner: UID [0-9]+\, GID [0-9]+/) { uid=$3 gid=$5 owner=1 } }' } mcarjfs_copyout () { $ARJ e -y "$1" "$2" -jw"$3" >/dev/null 2>/dev/null } umask 077 cmd="$1" shift case "$cmd" in list) mcarjfs_list "$@" ;; copyout) mcarjfs_copyout "$@" ;; *) exit 1 ;; esac exit 0 PKD1]6[%%apt+nuȯ#! /usr/bin/perl # # 1999 (c) Piotr Roszatycki # This software is under GNU license # last modification: 1999-12-08 # # apt sub quote { $_ = shift(@_); s/([^\w\/.+-])/\\$1/g; return($_); } sub bt { my ($dt) = @_; my (@time); @time = localtime($dt); $bt = sprintf "%02d-%02d-%d %02d:%02d", $time[4] + 1, $time[3], $time[5] + 1900, $time[2], $time[1]; return $bt; } sub ft { my ($f) = @_; return "d" if -d $f; return "l" if -l $f; return "p" if -p $f; return "S" if -S $f; return "b" if -b $f; return "c" if -c $f; return "-"; } sub fm { my ($n) = @_; my ($m); if( $n & 0400 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0200 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 04000 ) { $m .= "s"; } elsif( $n & 0100 ) { $m .= "x"; } else { $m .= "-"; } if( $n & 0040 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0020 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 02000 ) { $m .= "s"; } elsif( $n & 0010 ) { $m .= "x"; } else { $m .= "-"; } if( $n & 0004 ) { $m .= "r"; } else { $m .= "-"; } if( $n & 0002 ) { $m .= "w"; } else { $m .= "-"; } if( $n & 01000 ) { $m .= "t"; } elsif( $n & 0001 ) { $m .= "x"; } else { $m .= "-"; } return $m; } sub ls { my ($file,$path,$mode) = @_; if (-f $file) { my @stat = stat(_); # mode, nlink, uid, gid, size, mtime, filename printf "%s %d %d %d %d %s %s\n", $mode || ft($file).fm($stat[2] & 07777), $stat[3], $stat[4], $stat[5], $stat[7], bt($stat[9]), $path; } } $DATE=bt(time()); sub list { my ($pkg, $fn, $dn, $sz, $bt); my($check,$stats,$config); chop($check = `apt-get -q check 2>/dev/null`); chop($available = `apt-cache dumpavail 2>/dev/null`); chop($stats = `apt-cache stats 2>/dev/null`); chop($config = `apt-config dump 2>&1`); $sz = length($check); print "-r--r--r-- 1 root root $sz $DATE CHECK\n"; $sz = length($available); print "-r--r--r-- 1 root root $sz $DATE AVAILABLE\n"; $sz = length($stats); print "-r--r--r-- 1 root root $sz $DATE STATS\n"; $sz = length($config); print "-r--r--r-- 1 root root $sz $DATE CONFIG\n"; $sz = length($pressupdate); print "-r-xr--r-- 1 root root $sz $DATE UPDATE\n"; $sz = length($pressupgrade); print "-r-xr--r-- 1 root root $sz $DATE UPGRADE\n"; print "-r-xr--r-- 1 root root $sz $DATE DIST-UPGRADE\n"; ls("/etc/apt/sources.list","sources.list"); ls('/etc/apt/apt.conf','apt.conf') if (-f '/etc/apt/apt.conf'); print "drwxr-xr-x 1 root root 0 $DATE all\n"; if ( open(PIPEIN, "find /var/cache/apt/archives -type f |") ) { while() { chop; next if /\/lock$/; my $file = $_; s%/var/cache/apt/archives/%CACHE/%; ls($file, $_); } close PIPEIN; } my %sects = (); my %debd = (); my %deba = (); open STAT, "/var/lib/dpkg/status" or exit 1; while( ) { chop; if( /^([\w-]*): (.*)/ ) { $pkg = $2 if( lc($1) eq 'package' ); $debd{$pkg}{lc($1)} = $2; } } close STAT; foreach $pkg (sort keys %debd) { next if $debd{$pkg}{status} =~ /not-installed/; $fn = $debd{$pkg}{package}. "_". $debd{$pkg}{version}; $dn = $debd{$pkg}{section}; if( ! $dn ) { $dn = "unknown"; } elsif( $dn =~ /^(non-us)$/i ) { $dn .= "/main"; } elsif( $dn !~ /\// ) { $dn = "main/". $dn; } unless( $sects{$dn} ) { my $sub = $dn; while( $sub =~ s!^(.*)/[^/]*$!$1! ) { unless( $sects{$sub} ) { print "drwxr-xr-x 1 root root 0 $DATE $sub/\n"; $sects{$sub} = 1; } } print "drwxr-xr-x 1 root root 0 $DATE $dn/\n"; $sects{$dn} = 1; } $sz = $debd{$pkg}{'status'} =~ /config-files/ ? 0 : $debd{$pkg}{'installed-size'} * 1024; @stat = stat("/var/lib/dpkg/info/".$debd{$pkg}{package}.".list"); $bt = bt($stat[9]); print "-rw-r--r-- 1 root root $sz $bt $dn/$fn.debd\n"; print "lrwxrwxrwx 1 root root $sz $bt all/$fn.debd -> ../$dn/$fn.debd\n"; } open STAT, "apt-cache dumpavail |" or exit 1; while( ) { chop; if( /^([\w-]*): (.*)/ ) { $pkg = $2 if( lc($1) eq 'package' ); $deba{$pkg}{lc($1)} = $2; } } close STAT; foreach $pkg (sort keys %deba) { next if $deba{$pkg}{version} eq $debd{$pkg}{version}; $fn = $deba{$pkg}{package}. "_". $deba{$pkg}{version}; $dn = $deba{$pkg}{section}; if( ! $dn ) { $dn = "unknown"; } elsif( $dn =~ /^(non-us)$/i ) { $dn .= "/main"; } elsif( $dn !~ /\// ) { $dn = "main/". $dn; } unless( $sects{$dn} ) { my $sub = $dn; while( $sub =~ s!^(.*)/[^/]*$!$1! ) { unless( $sects{$sub} ) { print "drwxr-xr-x 1 root root 0 $DATE $sub/\n"; $sects{$sub} = 1; } } print "drwxr-xr-x 1 root root 0 $DATE $dn/\n"; $sects{$dn} = 1; } $sz = $deba{$pkg}{'status'} =~ /config-files/ ? 0 : $deba{$pkg}{'installed-size'} * 1024; print "-rw-r--r-- 1 root root $sz $DATE $dn/$fn.deba\n"; print "lrwxrwxrwx 1 root root $sz $DATE all/$fn.deba -> ../$dn/$fn.deba\n"; } } sub copyout { my($archive,$filename) = @_; my $qarchive = quote($archive); my $qfilename = quote($filename); if( $archive eq 'CHECK' ) { system("apt-get -q check > $qfilename"); } elsif( $archive eq 'AVAILABLE' ) { system("apt-cache dumpavail > $qfilename"); } elsif( $archive eq 'STATS' ) { system("apt-cache stats > $qfilename"); } elsif( $archive eq 'CONFIG' ) { system("(apt-config dump 2>&1) > $qfilename"); } elsif( $archive eq 'UPDATE' ) { open O, ">$filename"; print O $pressupdate; close O; } elsif( $archive eq 'UPGRADE' || $archive eq 'DIST-UPGRADE' ) { open O, ">$filename"; print O $pressupgrade; close O; } elsif( $archive eq 'apt.conf' ) { system("cp /etc/apt/apt.conf $qfilename"); } elsif( $archive eq 'sources.list' ) { system("cp /etc/apt/sources.list $qfilename"); } elsif( $archive =~ /^CACHE\// ) { $archive =~ s%^CACHE/%/var/cache/apt/archives/%; system("cp $qarchive $qfilename"); } else { open O, ">$filename"; print O $archive, "\n"; close O; } } sub copyin { my($archive,$filename) = @_; my $qarchive = quote($archive); my $qfilename = quote($filename); if( $archive =~ /\.deb$/ ) { system("dpkg -i $qfilename>/dev/null"); } elsif( $archive eq 'apt.conf' ) { system("cp $qfilename /etc/apt/apt.conf"); } elsif( $archive eq 'sources.list' ) { system("cp $qfilename /etc/apt/sources.list"); } elsif( $archive =~ /^CACHE\// ) { $qarchive =~ s%^CACHE/%/var/cache/apt/archives/%; system("cp $qfilename $qarchive"); } else { die "extfs: cannot create regular file \`$archive\': Permission denied\n"; } } sub run { my($archive,$filename) = @_; if( $archive eq 'UPDATE' ) { system("apt-get update"); } elsif( $archive eq 'UPGRADE' ) { system("apt-get upgrade -u"); } elsif( $archive eq 'DIST-UPGRADE' ) { system("apt-get dist-upgrade -u"); } else { die "extfs: $archive: command not found\n"; } } sub rm { my($archive) = @_; my $qarchive = quote($archive); if( $archive =~ /^CACHE\// ) { $qarchive =~ s%^CACHE/%/var/cache/apt/archives/%; system("rm -f $qarchive"); } elsif( $archive eq 'apt.conf' ) { system("rm -f /etc/apt/apt.conf"); } elsif( $archive eq 'sources.list' ) { system("rm -f /etc/apt/sources.list"); } elsif( $archive =~ /\.debd?$/ ) { # uncommented and changed to use dpkg - alpha my $qname = $qarchive; $qname =~ s%.*/%%g; $qname =~ s%_.*%%g; system("dpkg --remove $qname >/dev/null"); die("extfs: $archive: Operation not permitted\n") if $? != 0; } else { die "extfs: $archive: Operation not permitted\n"; } } $pressupdate=< # # Code for mc_lha_fs_run() suggested by: # Jan 97 Zdenek Kabelac # Tested with mc 3.5.18 and gawk 3.0.0 on Linux 2.0.0 # Tested with lha v1.01 and lharc v1.02 # Information and sources for other forms of lha/lzh appreciated # Nota bene: # There are several compression utilities which produce *.lha files. # LHArc and LHa in exist several versions, and their listing output varies. # Another variable is the architecture on which the compressed file was made. # This program attempts to sort out the variables known to me, but it is likely # to display an empty panel if it encounters a mystery. # In that case it will be useful to execute this file from the command line: # ./lha list Mystery.lha # to examine the output directly on the console. The output string must be # precisely in the format described in the README in this directory. # Caveat emptor. # Learn Latin. # Define your awk AWK=gawk # Define which archiver you are using with appropriate options LHA_LIST="lha lq" LHA_GET="lha pq" LHA_PUT="lha aq" # The 'list' command executive mc_lha_fs_list() { # List the contents of the archive and sort it out $LHA_LIST "$1" | $AWK -v uid=`id -nu` -v gid=`id -ng` ' # Strip a leading '/' if present in a filepath $(NF) ~ /^\// { $(NF) = substr($NF,2) } # Print the line this way if there is no permission string $1 ~ /^\[.*\]/ { # Invent a generic permission $1 = ($NF ~ /\/$/) ? "drwxr-xr-x":"-rwxr--r--"; # Print it printf "%s 1 %-8s %-8s %-8d %s %s %s %s\n", $1, uid, gid, $2, $4, $5, $6, $7; # Get the next line of the list next; } # Do it this way for a defined permission $1 !~ /^\[.*\]/ { # If the permissions and UID run together if ($1 ~ /\//) { $8 = $7; $7 = $6; $6 = $5; $5 = $4; $3 = $2; $2 = substr($1,10); $1 = substr($1,1,9); } # If the permission string is missing a type if (length($1) == 9) { if ($NF ~ /\/$/) $1 = ("d" $1); else $1 = ("-" $1); } # UID:GID might not be the same as on your system so print numbers # Well, that is the intent. At the moment mc is translating them. split($2, id, "/"); printf "%s 1 %-8d %-8d %-8d %s %s %s %s\n", $1, id[1], id[2], $3, $5, $6, $7, $8; # Get the next line of the list next; } ' } # The 'copyout' command executive to copy displayed files to a destination mc_lha_fs_copyout() { $LHA_GET "$1" "$2" > "$3" } # The 'copyin' command executive to add something to the archive mc_lha_fs_copyin () { NAME2=`basename "$2"`; DIR2=${2%$NAME2} NAME3=`basename "$3"`; DIR3=${3%$NAME3} cd "${DIR3}" ONE2=${2%%/*} [ -n "${ONE2}" ] || exit 1 [ -e "${ONE2}" ] && exit 1 [ -e "${DIR2}" ] || mkdir -p "${DIR2}" ln "$3" "$2" || exit 1 $LHA_PUT "$1" "$2" rm -r "${ONE2}" } # The 'run' command executive to run a command from within an archive mc_lha_fs_run() { TMPDIR=`mktemp -d "${MC_TMPDIR:-/tmp}/mctmpdir-ulha.XXXXXX"` || exit 1 trap "rm -rf \"$TMPDIR\"; exit 0" 1 2 3 4 15 TMPCMD=$TMPDIR/run $LHA_GET "$1" "$2" > $TMPCMD chmod a+x "$TMPCMD" "$TMPCMD" rm -rf "$TMPDIR" } # The main routine umask 077 cmd="$1" shift case "$cmd" in list) mc_lha_fs_list "$@" ;; copyout) mc_lha_fs_copyout "$@" ;; copyin) mc_lha_fs_copyin "$@" ;; run) mc_lha_fs_run "$@" ;; *) exit 1 ;; esac exit 0 PKD1]A˷bppnuȯ#! /bin/sh # # Written by Marco Ciampa 2000 # (a simple cut & paste from rpm vfs) # (C) 1996 The Free Software Foundation. # # Package of a new italian distribution: Bad Penguin # http://www.badpenguin.org/ # override any locale for dates unset LC_ALL LC_TIME=C export LC_TIME mcbppfs_list () { FILEPREF="-r--r--r-- 1 root root " FIEXPREF="-r-xr-xr-x 1 root root " DATE=`date +"%b %d %H:%M"` set x `ls -l "$1"` size=$6 echo "$FILEPREF $size $DATE CONTENTS.tar.gz" echo "$FIEXPREF 35 $DATE INSTALL" echo "$FIEXPREF 35 $DATE UPGRADE" } mcbppfs_copyout () { case "$2" in CONTENTS.tar.gz) cat "$1" > "$3"; exit 0;; INSTALL) echo "# Run this to install this package" > "$3"; exit 0;; UPGRADE) echo "# Run this to upgrade this package" > "$3"; exit 0;; esac } mcbppfs_run () { case "$2" in INSTALL) echo "Installing \"$1\""; package-setup --install "$1"; exit 0;; UPGRADE) echo "Upgrading \"$1\""; package-setup --update "$1"; exit 0;; esac } umask 077 case "$1" in list) mcbppfs_list "$2"; exit 0;; copyout) mcbppfs_copyout "$2" "$3" "$4"; exit 0;; run) mcbppfs_run "$2" "$3"; exit 1;; esac exit 1 PKD1]:MMhp48+nuȯPKD1]XXdebnuȯPKD1]TGZ{   $changesetfsnuȯPKD1]rJ.lslRnuȯPKD1]y<;;4uzipnuȯPKD1]aouacenuȯPKD1]<+ uulibnuȯPKD1]$AN&iso9660nuȯPKD1] :nn README.extfsnu[PKD1]3;rpms+nuȯPKD1]$$uarcnuȯPKD1]ualznuȯPKD1]8AABuzoonuȯPKD1]iU0XXmailfsnuȯPKD1]A?0  EpatchsetfsnuȯPKD1]&&READMEnu[PKD1]8u7znuȯPKD1]Wp a+nuȯPKD1]>StrpmnuȯPKD1] ʬW++s1patchfsnuȯPKD1]Yzz4]urarnuȯPKD1]rngitfs+nuȯPKD1]E;r@55&rrpmnuȯPKD1]wZucabnuȯPKD1]++luarnuȯPKD1]ʯuhanuȯPKD1]~&#&#Ƴdpkg+nuȯPKD1]j  !debanuȯPKD1]~*((WaudionuȯPKD1]砜))debdnuȯPKD1]+hwwuarjnuȯPKD1]6[%%apt+nuȯPKD1]O>ulhanuȯPKD1]A˷NbppnuȯPK""% S