diff --git a/configure.ac b/configure.ac index 4b39f16e5..bf22dfdbf 100644 --- a/configure.ac +++ b/configure.ac @@ -520,6 +520,7 @@ misc/Makefile misc/skins/Makefile misc/ext.d/Makefile misc/ext.d/doc.sh +misc/ext.d/misc.sh misc/ext.d/text.sh misc/ext.d/web.sh misc/macros.d/Makefile @@ -562,6 +563,7 @@ src/vfs/extfs/helpers/uc1541 src/vfs/extfs/helpers/ucab src/vfs/extfs/helpers/uha src/vfs/extfs/helpers/ulha +src/vfs/extfs/helpers/ulib src/vfs/extfs/helpers/urar src/vfs/extfs/helpers/uzip src/vfs/extfs/helpers/uzoo diff --git a/misc/ext.d/Makefile.am b/misc/ext.d/Makefile.am index 506141229..f92bb07ea 100644 --- a/misc/ext.d/Makefile.am +++ b/misc/ext.d/Makefile.am @@ -2,18 +2,19 @@ extdir = $(EXTHELPERSDIR) SCRIPTS_IN = \ doc.sh.in \ + misc.sh.in \ text.sh.in \ web.sh.in SCRIPTS_OUT = \ doc.sh \ + misc.sh \ text.sh \ web.sh SCRIPTS_UNTOUCHED = \ archive.sh \ image.sh \ - misc.sh \ package.sh \ sound.sh \ video.sh diff --git a/misc/ext.d/misc.sh b/misc/ext.d/misc.sh.in similarity index 87% rename from misc/ext.d/misc.sh rename to misc/ext.d/misc.sh.in index af47be75e..53b4821da 100644 --- a/misc/ext.d/misc.sh +++ b/misc/ext.d/misc.sh.in @@ -20,6 +20,10 @@ do_view_action() { ar) file "${MC_EXT_FILENAME}" && nm -C "${MC_EXT_FILENAME}" ;; + lib) + gplib -t "${MC_EXT_FILENAME}" || >&2 | \ + @PERL@ -e '@a=split /[\s\t]+/, <>; printf ("%-30s | %10d | %s.%s.%02d | %s\n", $a[0], ($a[1]*1),$a[7], lc($a[4]), $a[5], $a[6]);' + ;; so) file "${MC_EXT_FILENAME}" && nm -C -D "${MC_EXT_FILENAME}" ;; diff --git a/misc/mc.ext.in b/misc/mc.ext.in index 47bbfcbaf..9fa66a4a2 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -270,6 +270,12 @@ regex/\.s?a$ #Open=%view{ascii} ar tv %f View=%view{ascii} @EXTHELPERSDIR@/misc.sh view ar +# gplib +regex/\.([Ll][Ii][Bb])$ + Open=%cd %p/ulib:// + View=%view{ascii} @EXTHELPERSDIR@/misc.sh view lib + + # Mailboxes type/^ASCII\ mail\ text Open=%cd %p/mailfs:// diff --git a/src/vfs/extfs/helpers/Makefile.am b/src/vfs/extfs/helpers/Makefile.am index 6e30e179c..06ea7898d 100644 --- a/src/vfs/extfs/helpers/Makefile.am +++ b/src/vfs/extfs/helpers/Makefile.am @@ -33,6 +33,7 @@ EXTFS_IN = \ ucab.in \ uha.in \ ulha.in \ + ulib.in \ urar.in \ uzip.in \ uzoo.in @@ -62,6 +63,7 @@ EXTFS_OUT = \ ucab \ uha \ ulha \ + ulib \ urar \ uzip \ uzoo diff --git a/src/vfs/extfs/helpers/README.extfs b/src/vfs/extfs/helpers/README.extfs index de013735c..22ac8dfbb 100644 --- a/src/vfs/extfs/helpers/README.extfs +++ b/src/vfs/extfs/helpers/README.extfs @@ -70,3 +70,6 @@ s3+ gitfs - browse the git repo changesetfs - list of versions of current file patchsetfs - list of patches of current file + +# Gputils lib archives. +ulib diff --git a/src/vfs/extfs/helpers/ulib.in b/src/vfs/extfs/helpers/ulib.in new file mode 100644 index 000000000..cabcc4685 --- /dev/null +++ b/src/vfs/extfs/helpers/ulib.in @@ -0,0 +1,144 @@ +#! @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 ($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); +}