Merge branch '2751_gputils_lib'

* 2751_gputils_lib:
  Ticket #2751: Support *.lib artifacts generated by gputils utility
This commit is contained in:
Slava Zanko 2012-06-12 14:36:30 +03:00
commit c13eed8d81
7 changed files with 163 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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}"
;;

View File

@ -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://

View File

@ -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

View File

@ -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

View File

@ -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 (<PIPE>)
{
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 (<PIPE>)
{
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);
}