diff --git a/GenPkgList.pl b/GenPkgList.pl new file mode 100755 index 0000000..02e1b8f --- /dev/null +++ b/GenPkgList.pl @@ -0,0 +1,68 @@ +#!/usr/bin/env perl + +use strict; +use Getopt::Std; +use File::Basename; +use File::Path; +use Cwd; +use Sys::Syslog; + +#my $ShortName=&GetShortName($ARGV[0]); +my $DirPath=$ARGV[0]; + +if ( -d $DirPath ) { + open(FIND,"find $DirPath -name \"\*.vpg\"|"); + my @FileList=; + #print "@FileList"; + foreach(@FileList) { + #print "$_\n"; + my $ShortName=&GetShortName($_); + my $PkgName=basename($_); + my $FilePath=dirname($_); + chomp($PkgName); + (my $PkgPath = $FilePath) =~ s/$DirPath//; + chomp($PkgPath); + print "SN=$ShortName;PF=$PkgName;PP=$PkgPath\n"; + } +} else { + print "Usage: GenPkgList "; +} + +sub GetShortName() { + my $PkgName = $_[0]; + my @StartFile; + my $MetaInfo; + my @Contents; + my @MetaInfo; + + open PACKAGE,$PkgName or die "Could ot open ViitorArchive: $! $PkgName\n"; + my $FileSizes = ; + my @FileSizes = split /\s/,$FileSizes; + unshift(@FileSizes,0); + $FileSizes[0]=tell(PACKAGE); + for ( my $j = 0; $j <= 12; $j++ ) { + for ( my $i=0; $i<=$j; $i++) { + $StartFile[$j]+=$FileSizes[$i]; + } + } + shift @FileSizes; + seek PACKAGE,$StartFile[1],0; + if ( $FileSizes[1] > 0 ) { + read PACKAGE,$MetaInfo,$FileSizes[1]; + @MetaInfo=&DeBzip2($MetaInfo); + } + (my $ShortName = $MetaInfo[0] ) =~ s/ModuleName: //; + chomp($ShortName); + return $ShortName; +} + +sub DeBzip2() { + open (UNCOMPRESS,"|bzip2 -d -c >/tmp/PkgList_bzip2_$$") or die "Can not start decompress: $!"; + print UNCOMPRESS @_; + close UNCOMPRESS; + open(DATA,"/tmp/PkgList_bzip2_$$") or die "Data File after decompression not found: $!"; + my @UnBzip2Data = ; + close DATA; + unlink("/tmp/PkgList_bzip2_$$"); + return @UnBzip2Data; +}