#!/usr/bin/env perl #Framework, welches ein komplettes Linux System aus den Sourcen erstellt #dieses Framework wird im CVS Repository #:pserver:cvs.compuextreme.de:/Data/cvs zur Verfügung gestellt # #Lage dieser Datei im Archiv: $HeadURL: svn://svn.compuextreme.de/Viitor/V962/ViitorMake/Scripts/GenInstallcfg $ # #(c) 2003 Harald Kueller, Germany #This program is free software; you can redistribute it and/or #modify ist under the terms of the GNU General Public License #as published by the Free Software Foundation; either version #2 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 write to the Free Software Foundation, #Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # #Script: # #Letzte Änderung von: $Author: kueller $ #Datum der letzten Änderung: $Date: 2010-01-19 12:27:40 +0100 (Di, 19 Jan 2010) $ #Version der Datei: $Revision: 5134 $ # # use strict; use Getopt::Std; my %ArgSwitches; my $DistTarget; my $CfgFile; my $PkgName; my @PkgList; my @CheckDependics; getopts('d:f:',\%ArgSwitches); foreach (sort keys %ArgSwitches) { ( $_ eq "d" ) && ($DistTarget = $ArgSwitches{$_}); ( $_ eq "f" ) && ($CfgFile = $ArgSwitches{$_}); } if ( ($ArgSwitches{f}) && ($ArgSwitches{d}) ) { my @CfgFile; my @Dependics; open(CFG,"$CfgFile") or die "Could not open the in file: $!"; @CfgFile=; foreach(@CfgFile) { chomp($_); } close CFG; open(PKGLIST,"$DistTarget/.pkglist") or die "Could no open pkglist: $!"; @PkgList = ; close PKGLIST; @CheckDependics=@CfgFile; foreach ( @CheckDependics ) { print STDERR "Generating Dependics for $_\n"; my @PkgFileInfo = &GetPkgInfoList($_); if ( ! @PkgFileInfo ) { print STDERR "Error in Config File: Shortname $_ not found!"; exit 10; } my $PkgFilePath="$DistTarget/$PkgFileInfo[1]/$PkgFileInfo[0]"; @Dependics=&GetDependicsList($PkgFilePath); foreach ( @Dependics ) { my $NotFound; chomp($_); $_ =~ s/^WARN\s(.*)$/$1/; $_ =~ s/^FORCE\s(.*)$/$1/; my $DepName=$_; $DepName =~ s/\+/\\+/g; $NotFound=0; foreach ( @CheckDependics ) { if ( /^$DepName$/ ) { $NotFound=1; last; } else { $NotFound=0; } } if ( ! $NotFound ) { push @CheckDependics,$_; } } } open (BASE,"$DistTarget/../install/BaseDevel.cfg") or die "BaseDevel.cfg not found - should be created first! :$!\n"; my @Cfg = ; close BASE; foreach ( @Cfg ) { chomp($_); my @CfgLine = split /\s/,$_; my $NotFound; my $DepName = $CfgLine[2]; $DepName=~ s/\+/\\+/g; foreach ( @CheckDependics ) { if ( /^$DepName$/ ) { $NotFound=1; last; } else { $NotFound=0; } } if ( ! $NotFound ) { push @CheckDependics, $DepName; } } open ( ALL,"$DistTarget/../install/All.cfg" ) or die "All.cfg must be created first!: $!\n"; @Cfg = ; close ALL; my @NewCfg; foreach ( @Cfg ) { chomp($_); my @CfgLine = split /\s/,$_; my $NotFound; my $DepName = $CfgLine[2]; $DepName =~ s/\+/\\+/g; foreach ( @CheckDependics ) { if ( /^$DepName$/ ) { $NotFound=1; last; } else { $NotFound=0; } } if ( $NotFound ) { push @NewCfg, $_; } } foreach ( @NewCfg ) { print "$_\n" } } else { &HELP_MESSAGE(); } sub DeBzip2() { open(UNCOMPRESS,"|bzip2 -d -c >/tmp/installpkg_bzip2_$$") or die "Can not start decompress: $!"; print UNCOMPRESS @_; close UNCOMPRESS; open(DATA,"/tmp/installpkg_bzip2_$$") or die "Data File after decompression not found: $!"; my @UnBzip2Data = ; close DATA; unlink("/tmp/installpkg_bzip2_$$"); return @UnBzip2Data; } sub GetPkgInfoList() { my @PkgFile; my $SearchName=$_[0]; $SearchName=~s/\+/\\+/g; foreach ( @PkgList ) { if ( /SN=$SearchName;PF=(.*);PP=(.*)/ ) { $PkgFile[0]=$1; $PkgFile[1]=$2; chomp($PkgFile[1]); return @PkgFile; } } return(); } sub GetDependicsList() { my $PkgFile=@_[0]; my @StartFile; open(ARCH,$PkgFile) or die "Could not open Archive File: $!"; my $ArchiveInfo=; my @FileSizes = split /\s/,$ArchiveInfo; unshift(@FileSizes,0); $FileSizes[0]=tell(ARCH); for ( my $j = 0; $j <= 11; $j++ ) { for ( my $i=0; $i <= $j; $i++ ) { $StartFile[$j]+=$FileSizes[$i]; } } shift @FileSizes; if ( $FileSizes[0] > 0 ) { read ARCH,my $Dependics, $FileSizes[0]; close ARCH; return(&DeBzip2($Dependics)); } else { close ARCH; return () ; } } sub HELP_MESSAGE() { printf("\nGenInstallcfg: Aus den *.in files *.cfg files für make_base_install erzeugen\n"); printf("usage: ./GenInstallcfg -d -f \n"); }