Index: trunk/technical/common/build/buildall.pl
===================================================================
--- trunk/technical/common/build/buildall.pl	(revision 660)
+++ trunk/technical/common/build/buildall.pl	(revision 664)
@@ -2,5 +2,5 @@
 # automatisches buildskript fuer smartclient
 # liest die konfiguration aus der mit -b übergebenen Datei
-# $Id: buildall.pl,v 1.18 2003/08/18 13:34:39 joergs Exp $
+# $Id: buildall.pl,v 1.19 2003/09/01 13:34:07 joergs Exp $
 # Philipp Storz, SuSE Linux AG 
 # pstorz@suse.de
@@ -16,5 +16,5 @@
 
 format TABELLE =
-@<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+@<<<<<<<<<<<<<<<<<< @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 $wert1, $wert2, $wert3
 .
@@ -22,6 +22,7 @@
 
 # Programmoptionen: 
-#	-b (buildlist) 
-#	-x (buildlog im seperaten xtern
+#	-b 	(buildlist) 
+#	-x 	(buildlog im seperaten xtern
+#	-d	Zielpfad um Install Source zu erzeugen
 
 my $workdir=`pwd`;
@@ -34,19 +35,31 @@
 #$workdir="";
 
-my $DEST_DIR="/tmp/smartclient_build/";
-
+my $BUILD_DEST_DIR="/tmp/smartclient_build/";
+my $INSTALL_SRC_SKEL_DIR="/net/dist/data/dist/sles/8/skeleton-i386/smartclient/";
 
 my $build = "build.sh";
-our ($opt_b, $opt_x);
+our ( $opt_x, $opt_b, $opt_d );
 my @ArrayofBuilds;
-getopts('b:x');
-
-
-if (!$opt_b) {
-  $opt_b = "buildlist";
-  print "using default buildlist: buildlist\n\n";
-  print "other buildlist can be specified with -b buildlist\n\n";
+getopts('xb:d:');
+
+
+
+if (!$opt_b && !$opt_d)  {
+	print <<EOF
+Usage:
+  -b BUILDLIST
+     compiles packages specified in BUILDLIST
+  -d INSTALL_SRC_DEST_DIR
+     creates a new install source in INSTALL_SRC_DEST_DIR
+EOF
 };
 
+
+
+#
+# build packages from buildlist
+#
+
+if( $opt_b ) {
 (open(BUILDLIST,$opt_b)) || die "Die Buildlist $opt_b  konnte nicht gefunden werden";
 
@@ -71,11 +84,10 @@
 
 print "What will be done:\n\n";
-($wert1,$wert2,$wert3)= ("Path","Distribuition","Buildoptions");
+($wert1,$wert2,$wert3)= ("BUILD_DIST","BUILD_MODE","Package");
 $~="TABELLE";
 write;
-print "\n";
 for my $i (0 .. $#ArrayofBuilds)
   {
-    ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2]);
+    ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][1],$ArrayofBuilds[$i][2],$ArrayofBuilds[$i][0]);
     $~="TABELLE";
     write;
@@ -88,5 +100,5 @@
 if ($answer ne "y") {die("canceled")};
 
-$ENV{'DEST_DIR'}=$DEST_DIR;
+$ENV{'DEST_DIR'}=$BUILD_DEST_DIR;
 
 my $mypath;
@@ -110,6 +122,6 @@
   print "$_ \n";
   tr/\//\_/;
-  `mkdir -p $DEST_DIR`;
-  my $logfilename = "$DEST_DIR/$_$ArrayofBuilds[$i][1].log";
+  `mkdir -p $BUILD_DEST_DIR`;
+  my $logfilename = "$BUILD_DEST_DIR/$_$ArrayofBuilds[$i][1].log";
 
   my $build_cmd="cd $mypath && $build";
@@ -122,5 +134,5 @@
   }
 
-  # if mypath is not a directory, so it is a src.rpm (hopefully)
+  # if mypath is not a directory, so it is a .src.rpm (hopefully)
   if( ! -d $mypath ) {
     my $base 	= basename($mypath);
@@ -154,5 +166,5 @@
   if ( $retval == 0 )
    {
-     $ArrayofBuilds[$i][3]= "SUCCESS $ArrayofBuilds[$i][0]: OK";
+     $ArrayofBuilds[$i][3] = "OK";
      print"******                                                      ******\n";
      print"******   building of $ArrayofBuilds[$i][0]: OK                    \n" ;
@@ -161,5 +173,5 @@
   else
    {
-     $ArrayofBuilds[$i][3]="ERROR  $ArrayofBuilds[$i][0]: *FAILED*\n";
+     $ArrayofBuilds[$i][3] = "*FAILED*";
      print"******                                                      ******\n";
      print"\n\n\nERROR: building of $ArrayofBuilds[$i][0]: *FAILED*\n";
@@ -172,12 +184,12 @@
 
 
-($wert1,$wert2,$wert3)= ("Path","Distribuition","Result");
+($wert1,$wert2,$wert3)= ("BUILD_DIST","Result","Package");
 $~="TABELLE";
 write;
-print "\n";
 
 for my $i (0 .. $#ArrayofBuilds)
   {
-    ($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
+    #($wert1,$wert2,$wert3)= ($ArrayofBuilds[$i][0],$ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3]);
+	($wert1,$wert2,$wert3) = ($ArrayofBuilds[$i][1],$ArrayofBuilds[$i][3],$ArrayofBuilds[$i][0]);
     $~="TABELLE";
     write;
@@ -186,2 +198,59 @@
 
 print "buildall.pl terminated\n";
+}
+
+
+
+#
+# generating install source 
+#
+
+if( $opt_d ) {
+
+	my $INSTALL_SRC_DEST_DIR=$opt_d;
+	chomp $INSTALL_SRC_DEST_DIR;
+	
+	# create target directory
+	run_command( "mkdir -p $INSTALL_SRC_DEST_DIR" );
+	# copy skeletion to dest
+	run_command( "rsync -av $INSTALL_SRC_SKEL_DIR $INSTALL_SRC_DEST_DIR" );
+	
+	# copy build packages to dest
+	foreach my $i ( "i386", "i486", "i586", "i686", "noarch", "src" ) {
+		run_command( "mkdir -p $INSTALL_SRC_DEST_DIR/suse/$i" );
+		run_command( "rsync -av $BUILD_DEST_DIR/*/*.$i.rpm $INSTALL_SRC_DEST_DIR/suse/$i/" );
+	}
+	
+	# create_package_descr (do that has to run on target distribution?)
+	run_command( "cd $INSTALL_SRC_DEST_DIR/suse/; /usr/lib/YaST2/bin/create_package_descr -o $INSTALL_SRC_DEST_DIR/setup/descr" );
+}
+
+
+#
+# functions
+#
+
+# executes a command (single string).
+# returns 
+# 	the returncode 
+# 	and (combined) stdout and stderr
+
+sub run_command
+{
+  my $command = shift;
+
+  print "executing command: " . $command . "\n";
+
+  open(RESULT, $command . ' 2>&1 |' );
+  my @result = <RESULT>;
+  close(RESULT);
+  my $retcode = $?>>8;
+
+  print @result;  
+  if( $retcode ) { print "return code: " . $retcode . "\n"; }
+
+  return($retcode, @result);
+}
+
+
+
