Changeset 721


Ignore:
Timestamp:
03/06/09 18:09:05 (4 years ago)
Author:
bruno
Message:
  • Adds support for pre and post scripts for VM/VE launched before and after the build to allow for local setup.
  • Adds additional repo support for debian type as well.
  • Fix a bug around architecture compatibility check.
  • Transmit verbosity level
  • Adds support for proxy environment variables at setup and build time
  • Do not reinstall a repo which was already there (except for urpmi)
Location:
devel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/lib/ProjectBuilder/Distribution.pm

    r717 r721  
    514514    if ($dtype eq "rpm") { 
    515515        if ($bn =~ /\.rpm$/) { 
    516         pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repostory"); 
    517     } elsif ($bn =~ /\.repo$/) { 
     516            my $pn = $bn; 
     517            $pn =~ s/\.rpm//; 
     518            if (pb_system("rpm -q --quiet $pn","","quiet") != 0) { 
     519                pb_system("sudo rpm -Uvh $ENV{'PBTMP'}/$bn","Adding package to setup repository"); 
     520            } 
     521        } elsif ($bn =~ /\.repo$/) { 
    518522            # Yum repo 
    519             pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repo.d","Adding yum repository"); 
     523            pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/yum.repos.d","Adding yum repository") if (not -f "/etc/yum.repos.d/$bn"); 
    520524        } elsif ($bn =~ /\.addmedia/) { 
    521525            # URPMI repo 
     526            # We should test that it's not already a urpmi repo 
    522527            pb_system("chmod 755 $ENV{'PBTMP'}/$bn ; sudo $ENV{'PBTMP'}/$bn 2>&1 > /dev/null","Adding urpmi repository"); 
    523528        } else { 
     
    525530        } 
    526531    } elsif ($dtype eq "deb") { 
    527         if ($bn =~ /\.sources.list$/) { 
     532        if (($bn =~ /\.sources.list$/) && (not -f "/etc/apt/sources.list.d/$bn")) { 
    528533            pb_system("sudo mv $ENV{'PBTMP'}/$bn /etc/apt/sources.list.d","Adding apt repository"); 
    529534            pb_system("sudo apt-get update","Updating apt repository"); 
  • devel/pb/bin/pb

    r714 r721  
    745745        } 
    746746 
     747        # Do we have additional script to run to prepare the environement for the project ?  
     748        # Then include it in the pbconf delivery 
     749        foreach my $pbvf ("pbvebuild.pre","pbvmbuild.pre","pbvebuild.post","pbvmbuild.post") { 
     750            if (-x "$ENV{'PBROOTDIR'}/$pbvf") { 
     751                pb_filter_file("$ENV{'PBROOTDIR'}/$pbvf",$ptr,"$ENV{'PBDESTDIR'}/$pbvf",\%pb); 
     752                chmod 0755,"$ENV{'PBDESTDIR'}/$pbvf"; 
     753            } 
     754        } 
     755 
    747756        # Archive dest dir 
    748757        chdir "$ENV{'PBDESTDIR'}" || die "Unable to change dir to $ENV{'PBDESTDIR'}"; 
     
    872881            chmod 0755,"debian/rules"; 
    873882 
     883            my $darch = pb_get_arch(); 
     884            pb_distro_setuprepo($ddir,$dver,$darch,$dtype); 
    874885            pb_distro_installdeps("debian/control",$dtype,$pbupd); 
    875886            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose"); 
     
    15151526            # Architecture consistency 
    15161527            if ($arch ne $darch) { 
    1517                 die "Unable to launch a VE of architecture $darch on a $arch platform" if (not (($darch eq "x86_64") && ($arch =~ /i?86/))); 
     1528                die "Unable to launch a VE of architecture $darch on a $arch platform" if (($darch eq "x86_64") && ($arch =~ /i?86/)); 
    15181529            } 
    15191530 
     
    16211632    open(SCRIPT,"> $ENV{'PBDESTDIR'}/pbscript") || die "Unable to create $ENV{'PBDESTDIR'}/pbscript"; 
    16221633    print SCRIPT "#!/bin/bash\n"; 
     1634 
     1635    # Transmit the verbosity level to the virtual env/mach. 
     1636    my $verbose = ""; 
     1637    my $i = 0;                          # minimal debug level 
     1638    while ($i lt $pbdebug) { 
     1639        $verbose .= "-v "; 
     1640        $i++; 
     1641    } 
     1642    # Activate script verbosity if at least 2 for pbdebug 
     1643    print SCRIPT "set -x\n" if ($i gt 1); 
     1644    # Quiet if asked to be so on the original system 
     1645    $verbose = "-q" if ($pbdebug eq -1); 
     1646 
    16231647    print SCRIPT "echo ... Execution needed\n"; 
    16241648    print SCRIPT "# This is in directory delivery\n"; 
     
    16491673        print SCRIPT "$dateline\n"; 
    16501674    } 
    1651  
    1652     # Transmit the verbosity level to the virtual env/mach. 
    1653     my $verbose = ""; 
    1654     my $i = 0;                          # minimal debug level 
    1655     while ($i lt $pbdebug) { 
    1656         $verbose .= "-v "; 
    1657         $i++; 
    1658     } 
    1659     # Quiet if asked to be so on the original system 
    1660     $verbose = "-q" if ($pbdebug eq -1); 
     1675    # Use potential local proxy declaration in case we need it to download repo, pkgs, ... 
     1676    if (defined $ENV{'http_proxy'}) { 
     1677        print SCRIPT "export http_proxy=\"$ENV{'http_proxy'}\"\n"; 
     1678    } 
     1679 
     1680    if (defined $ENV{'ftp_proxy'}) { 
     1681        print SCRIPT "export ftp_proxy=\"$ENV{'ftp_proxy'}\"\n"; 
     1682    } 
     1683 
     1684 
     1685    # We may need to do some other tasks before building. Read a script here to finish setup 
     1686    if (-x "$ENV{'PBDESTDIR'}/pb$vtype"."build.pre") { 
     1687        print SCRIPT "# Special pre-build instructions to be launched\n"; 
     1688        print SCRIPT pb_get_content("$ENV{'PBDESTDIR'}/pb$vtype"."build.pre"); 
     1689    } 
    16611690 
    16621691    print SCRIPT "# Build\n"; 
     
    16661695        print SCRIPT "sudo umount /proc\n"; 
    16671696    } 
     1697 
     1698    # We may need to do some other tasks after building. Read a script here to exit properly 
     1699    if (-x "$ENV{'PBDESTDIR'}/pb$vtype"."build.post") { 
     1700        print SCRIPT "# Special post-build instructions to be launched\n"; 
     1701        print SCRIPT pb_get_content("$ENV{'PBDESTDIR'}/pb$vtype"."build.post"); 
     1702    } 
     1703 
    16681704    close(SCRIPT); 
    16691705    chmod 0755,"$ENV{'PBDESTDIR'}/pbscript"; 
     
    21222158print "distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n"; 
    21232159 
     2160# We may need a proxy configuration. Get it from the local env 
     2161EOF 
     2162 
     2163if (defined $ENV{'http_proxy'}) { 
     2164    print SCRIPT "\$ENV\{'http_proxy'\}=\"$ENV{'http_proxy'}\";\n"; 
     2165} 
     2166 
     2167if (defined $ENV{'ftp_proxy'}) { 
     2168    print SCRIPT "\$ENV\{'ftp_proxy'\}=\"$ENV{'ftp_proxy'}\";\n"; 
     2169} 
     2170 
     2171print {$SCRIPT} << 'EOF'; 
    21242172# Get and install pb 
    21252173my $insdm = "rm -rf Date-Manip* ; wget http://search.cpan.org/CPAN/authors/id/S/SB/SBECK/Date-Manip-5.54.tar.gz ; tar xvfz Date-Manip-5.54.tar.gz ; cd Date-Manip* ; perl Makefile.PL ; make ; make install ; cd .. ; rm -rf Date-Manip*"; 
Note: See TracChangeset for help on using the changeset viewer.