]> git.openfabrics.org - ~aditr/build.git/commitdiff
Extended support for pre|post build scripts
authorVladimir Sokolovsky <vlad@mellanox.co.il>
Tue, 2 Feb 2010 10:17:06 +0000 (12:17 +0200)
committerVladimir Sokolovsky <vlad@mellanox.co.il>
Tue, 2 Feb 2010 10:17:06 +0000 (12:17 +0200)
Signed-off-by: Vladimir Sokolovsky <vlad@mellanox.co.il>
build.pl

index b15dc97f63395e215ff9e617fc00877d7e35e693..dbd81a0e609bd0ef244e3819b83348fb2802006c 100755 (executable)
--- a/build.pl
+++ b/build.pl
@@ -45,6 +45,10 @@ my $distribution = 'OFED';
 my $builddir = '/tmp/' . $user;
 my $tmpdir = '/tmp/' . $user;
 my $TOPDIR = $builddir . "/topdir";
+my $prebuild = "./pre-build";
+my $skip_prebuild = 0;
+my $postbuild = "./post-build";
+my $skip_postbuild = 0;
 my $destdir;
 my $version;
 my $release;
@@ -59,6 +63,10 @@ sub usage
        print "\nUsage: $0 --version <version> [-r|--release]|[--daily] [-d|--distribution <distribution name>] [-v|--verbose]\n";
        print "\t\t[-b|--builddir <build directory>]\n";
        print "\t\t[-p|--packagesdir <packages directory>]\n";
+       print "\t\t[--pre-build <pre-build script>]\n";
+       print "\t\t[--skip-prebuild]\n";
+       print "\t\t[--post-build <post-build script>]\n";
+       print "\t\t[--skip-postbuild]\n";
        print "\n";
        exit 0;
 }
@@ -316,12 +324,12 @@ sub get_from_git
                }
 
                if (not -f "$name.spec" and -f "configure") {
-                       ex "./configure";
+                       ex "./configure --disable-check-modules --disable-libcheck";
                }
        }
 
        if (not $packages{$name}{'version'}) {
-               $packages{$name}{'version'} = `grep "^Version:" $name.spec | cut -d ' ' -f 2`;
+               $packages{$name}{'version'} = `grep "^Version:" $name.spec | awk '{print \$NF}'`;
                chomp $packages{$name}{'version'};
        }
        if (not $packages{$name}{'release'}) {
@@ -438,6 +446,14 @@ while ( $#ARGV >= 0 ) {
                $verbose = 1;
        } elsif ($cmd_flag eq "-b" or $cmd_flag eq "--builddir") {
                $builddir = shift(@ARGV);
+       } elsif ($cmd_flag eq "--pre-build") {
+               $prebuild = shift(@ARGV);
+       } elsif ($cmd_flag eq "--post-build") {
+               $postbuild = shift(@ARGV);
+       } elsif ($cmd_flag eq "--skip-prebuild") {
+               $skip_prebuild = 1;
+       } elsif ($cmd_flag eq "--skip-postbuild") {
+               $skip_postbuild = 1;
        } else {
                &usage();
                exit 1;
@@ -456,7 +472,9 @@ if (not -d "$CWD/$packages_dir") {
 }
 
 if ($build_release) {
-       $release = $distribution . $version;
+       $release = $distribution . 
+                       '.' . (split '-',$version)[0] .
+                       '.' . (split '-',$version)[1];
 } elsif ($build_daily) {
        $version .= '-' . $starttime;
 } else {
@@ -465,12 +483,12 @@ if ($build_release) {
 
 $log = "$CWD/$distribution.build.log";
 rmtree $log;
-open (LOG, "+> $log") or die "Can't open $log: $!\n";
+open (LOG, ">$log") or die "Can't open $log: $!\n";
 
 chdir $CWD;
-if (-f "./pre-build") {
+if (not $skip_prebuild and -f "$prebuild") {
        print_and_log "Running pre-build script";
-       ex "./pre-build";
+       ex "$prebuild";
 }
 
 # Create Distribution directory structure
@@ -567,9 +585,9 @@ ex "tar czf $distribution-$version.tgz $distribution-$version";
 print_green "$destdir.tgz is ready";
 
 chdir $CWD;
-if (-f "./post-build") {
+if (not $skip_postbuild and -f $postbuild) {
        print_and_log "Running post-build script";
-       ex "./post-build $destdir.tgz $distribution $version";
+       ex "$postbuild $destdir.tgz $distribution $version";
 }
 
 print_and_log "Build finished at ". localtime(time);