All pastes #524046 Raw Edit

Untitled

public text v1 · immutable
#524046 ·published 2007-05-30 23:50 UTC
rendered paste body
#!/usr/bin/perl -w

#
# build script for building the LTSP build environment
#
# Copyright (c) 2003 by James A. McQuillan (McQuillan Systems, LLC)
#
# This software is licensed under the Gnu General Public License.
# The full text of which can be found at http://www.LTSP.org/license.txt
#


use strict;
use Getopt::Long;

my $version            = "0.3";
my $clean_only         = 0;
my $makepkgs           = 0;
my $cpus               = 0;

my $start_time         = time();
my %times;
my @packages  = ( "crosscomp-src",
                  "lbe-src",
                  "ltsp-src",
                  "initramfs-src" );

my @opts;
my $getopt_result;

if( ! -f "build_all" ){
  die "Your current directory MUST be where this script is!";
}

$getopt_result = GetOptions(
          "clean"      => sub { push @opts, "--clean"; $clean_only=1    },
          "cpus=i"     => sub { push @opts, sprintf("--cpus=%d",$_[1]); },
          "gcc=s"      => sub { push @opts, "--gcc"        },
          "fetch"      => sub { push @opts, "--fetch";     },
          "unpack"     => sub { push @opts, "--unpack";    },
          "prepatch"   => sub { push @opts, "--prepatch";  },
          "configure"  => sub { push @opts, "--configure"; },
          "postpatch"  => sub { push @opts, "--postpatch"; },
          "build"      => sub { push @opts, "--build";     },
          "makepkg"    => sub { push @opts, "--makepkg"; $makepkgs=1   },
        );

if ( ! $getopt_result ){
  printf("\n");
  exit 1;
}

my $optlist = join( " ", @opts );

my $catalog_file = "catalog.dat";

my $catalog_cmd = "./catalog_it.pl"
                . " ./"
                . " base"
                . " base";

system("$catalog_cmd");

$ENV{LBE_BUILDALL} = 1;

foreach my $pkg ( @packages ){

    my $start_time = time();
    chdir($pkg) or die "Unable to chdir($pkg): $!\n";

    printf("\n$pkg:\n");
    my $rs = system( "./build $optlist" );
    if( $rs ){
        exit;
    }

    #
    # leave the package directory
    #
    chdir("..") || die "Unable to chdir(".."): $!\n";
    my $end_time = time();

    my $diff_time = $end_time - $start_time;
    $times{$pkg} = $diff_time;
}

printf("\n");

if( $clean_only ){
  my $dirlist = join ( " ", qw ( bin
                                 catalog.dat
                                 dev
                                 doc
                                 etc
                                 i386-linux
                                 i386-linux-crosscomp
                                 include
                                 info
                                 ltsp_kernel_kit
                                 lib
                                 libexec
                                 man
                                 opt
                                 proc
                                 sbin
                                 share
                                 tmp
                                 usr
                                 var ) );
  system("rm -rf $dirlist");
  printf("\n");
}

my $end_time = time();
push @packages, "Total";
$times{"Total"} = $end_time - $start_time;

printf("Processing time to run ./build_all %s:\n\n", $optlist );

foreach my $pkg ( @packages ){
    my $total_secs = $times{$pkg};
    my $elapsed_mins = int( $total_secs / 60 );
    my $elapsed_secs = $total_secs - ( $elapsed_mins * 60 );
    if($pkg eq "Total"){
        printf("  %-20s =======\n", "" );
    }
    printf("  %-20s %4d:%02d\n", $pkg, $elapsed_mins, $elapsed_secs);
}

exit 0;