GenInstallcfg durch perl basierte version ersetzt.

git-svn-id: svn://svn.compuextreme.de/Viitor/V962/ViitorInstall@5719 504e572c-2e33-0410-9681-be2bf7408885
This commit is contained in:
kueller 2010-06-24 09:35:07 +00:00
parent b798dec5e6
commit be932573aa
2 changed files with 277 additions and 81 deletions

241
GenInstallcfg Executable file → Normal file
View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/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
@ -28,90 +28,169 @@
#
#
export PKGLIST=.pkglist
use strict;
use Getopt::Std;
WDIR=`pwd`
my %ArgSwitches;
my $DistTarget;
my $CfgFile;
my $PkgName;
my @PkgList;
my @CheckDependics;
PKGLISTING=$1
TMPFILE=`mktemp`
TMPFILE2=`mktemp`
rm $TMPFILE
rm $TMPFILE2
NUMDEPSOLD=0
NUMDEPSNEW=0
GenDeps() {
PKGNAME=$1
echo >&2 "Generating Dependics for $PKGNAME"
PKGFILE=`grep "SN=$PKGNAME;" $DISTTARGET/$PKGLIST|\
awk -F";" '{print $2}'|sed -e "s/PF=//"`
PKGPATH=`grep "PF=$PKGFILE;" $DISTTARGET/$PKGLIST|\
awk -F";" '{print $3}'|\
sed -e "s/PP=//"`
extractvarchive $DISTTARGET/$PKGPATH/$PKGFILE dep >$TMPFILE
echo "WARN $PKGNAME" >>$TMPFILE
NUMDEPSOLD=`cat $TMPFILE|wc -l`
while [ ! $NUMDEPSOLD == $NUMDEPSNEW ]; do
NUMDEPSOLD=$NUMDEPSNEW
exec 3<$TMPFILE
while read <&3 FLAG SHNAME; do
grep "SN=$SHNAME;" $DISTTARGET/$PKGLIST|awk -F";" '{print $2}'|sed -e "s/PF=//"
done > $TMPFILE2
exec 3>&-
for i in `cat $TMPFILE2`; do
PKGPATH=`grep "PF=$i;" $DISTTARGET/$PKGLIST|\
awk -F";" '{print $3}'|\
sed -e "s/PP=//"`
extractvarchive $DISTTARGET/$PKGPATH/$i dep
done >>$TMPFILE
rm $TMPFILE2
cat $TMPFILE |sort -u >$TMPFILE2
mv $TMPFILE2 $TMPFILE
NUMDEPSNEW=`cat $TMPFILE|wc -l`
done
cat $TMPFILE
rm $TMPFILE
getopts('d:f:',\%ArgSwitches);
foreach (sort keys %ArgSwitches) {
( $_ eq "d" ) && ($DistTarget = $ArgSwitches{$_});
( $_ eq "f" ) && ($CfgFile = $ArgSwitches{$_});
}
USAGE="Usage: $0 -d <Path to Distribution Packages> -f <Path to cfg in file>"
while getopts :d:f: opt_char; do
case $opt_char in
d)
DISTTARGET=$OPTARG
;;
f)
CFGFILE=$OPTARG
;;
*)
echo $USAGE
;;
esac
done
if ( ($ArgSwitches{f}) && ($ArgSwitches{d}) ) {
my @CfgFile;
my @Dependics;
open(CFG,"$CfgFile") or die "Could not open the in file: $!";
@CfgFile=<CFG>;
foreach(@CfgFile) {
chomp($_);
}
close CFG;
open(PKGLIST,"$DistTarget/.pkglist") or die "Could no open pkglist: $!";
@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;
if [ ! -d $DISTTARGET ]; then
echo "$DISTTARGET ist not a directory"
echo $USAGE
exit 10
fi
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 = <BASE>;
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 = <ALL>;
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 = <DATA>;
close DATA;
unlink("/tmp/installpkg_bzip2_$$");
return @UnBzip2Data;
}
if [ ! -f $CFGFILE ]; then
echo "$CFGFILE does not exist"
echo $USAGE
exit 10
fi
sub GetPkgInfoList() {
my @PkgFile;
my $SearchName=$_[0];
for i in `cat $CFGFILE`; do
GenDeps $i >>/tmp/DepsList$$
done
cat /tmp/DepsList$$|sort -u >/tmp/DepsListSort$$
rm /tmp/DepsList$$
cat $DISTTARGET/../install/BaseDevel.cfg
exec 3<$DISTTARGET/../install/All.cfg
while read <&3 CDROM PKGPATH MODNAME; do
if egrep -q " ${MODNAME}$" /tmp/DepsListSort$$; then
if ! egrep -q " ${MODNAME}$" $DISTTARGET/../install/BaseDevel.cfg; then
echo "$CDROM $PKGPATH $MODNAME"
fi
fi
done
rm /tmp/DepsListSort$$
$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=<ARCH>;
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 <Distributionbinarydir> -f <cfg.in file>\n");
}

117
GenInstallcfg.sh Executable file
View File

@ -0,0 +1,117 @@
#!/bin/bash
#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 $
#
#
export PKGLIST=.pkglist
WDIR=`pwd`
PKGLISTING=$1
TMPFILE=`mktemp`
TMPFILE2=`mktemp`
rm $TMPFILE
rm $TMPFILE2
NUMDEPSOLD=0
NUMDEPSNEW=0
GenDeps() {
PKGNAME=$1
echo >&2 "Generating Dependics for $PKGNAME"
PKGFILE=`grep "SN=$PKGNAME;" $DISTTARGET/$PKGLIST|\
awk -F";" '{print $2}'|sed -e "s/PF=//"`
PKGPATH=`grep "PF=$PKGFILE;" $DISTTARGET/$PKGLIST|\
awk -F";" '{print $3}'|\
sed -e "s/PP=//"`
extractvarchive $DISTTARGET/$PKGPATH/$PKGFILE dep >$TMPFILE
echo "WARN $PKGNAME" >>$TMPFILE
NUMDEPSOLD=`cat $TMPFILE|wc -l`
while [ ! $NUMDEPSOLD == $NUMDEPSNEW ]; do
NUMDEPSOLD=$NUMDEPSNEW
exec 3<$TMPFILE
while read <&3 FLAG SHNAME; do
grep "SN=$SHNAME;" $DISTTARGET/$PKGLIST|awk -F";" '{print $2}'|sed -e "s/PF=//"
done > $TMPFILE2
exec 3>&-
for i in `cat $TMPFILE2`; do
PKGPATH=`grep "PF=$i;" $DISTTARGET/$PKGLIST|\
awk -F";" '{print $3}'|\
sed -e "s/PP=//"`
extractvarchive $DISTTARGET/$PKGPATH/$i dep
done >>$TMPFILE
rm $TMPFILE2
cat $TMPFILE |sort -u >$TMPFILE2
mv $TMPFILE2 $TMPFILE
NUMDEPSNEW=`cat $TMPFILE|wc -l`
done
cat $TMPFILE
rm $TMPFILE
}
USAGE="Usage: $0 -d <Path to Distribution Packages> -f <Path to cfg in file>"
while getopts :d:f: opt_char; do
case $opt_char in
d)
DISTTARGET=$OPTARG
;;
f)
CFGFILE=$OPTARG
;;
*)
echo $USAGE
;;
esac
done
if [ ! -d $DISTTARGET ]; then
echo "$DISTTARGET ist not a directory"
echo $USAGE
exit 10
fi
if [ ! -f $CFGFILE ]; then
echo "$CFGFILE does not exist"
echo $USAGE
exit 10
fi
for i in `cat $CFGFILE`; do
GenDeps $i >>/tmp/DepsList$$
done
cat /tmp/DepsList$$|sort -u >/tmp/DepsListSort$$
rm /tmp/DepsList$$
cat $DISTTARGET/../install/BaseDevel.cfg
exec 3<$DISTTARGET/../install/All.cfg
while read <&3 CDROM PKGPATH MODNAME; do
if egrep -q " ${MODNAME}$" /tmp/DepsListSort$$; then
if ! egrep -q " ${MODNAME}$" $DISTTARGET/../install/BaseDevel.cfg; then
echo "$CDROM $PKGPATH $MODNAME"
fi
fi
done
rm /tmp/DepsListSort$$