Changeset 1597 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
May 26, 2012, 2:13:12 AM (12 years ago)
Author:
Bruno Cornec
Message:
  • Adds option pbshowsudo (false by default) to check whether we display the detail of sudo commands (to match security requiremetns) or not (to have a nicer output)
  • Fix a template generation error in Env.pm for deb rules file (line was split)
  • In VE.pm fix modes of the chroot after the snapshot phase detection to avoid error which make the code die
  • In pb create the RPM build dirs before entering in the parallel loop as sometimes 2 identical were created simultaneously, leading to an error leading to a die
  • In pb revert the code added by Eric to check deb content creation as it was failing in my environement (naming issues). Could be added after 0.12.1 is out as an additional check, but anyway as the files are copied after, it's not that important.
  • Use full path of chown in sudo for pb
  • Make the test account a variable in pbtest
  • Start to add test case for a VM in pbtest
  • This patch makes pb build back in a debian 6 VE.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r1595 r1597  
    4242
    4343# Global variables
    44 $Global::pb_stop_on_error = 1;
     44$Global::pb_stop_on_error = 1;  # True by default
     45$Global::pb_show_sudo = 0;      # False by default
     46
    4547my %opts;                   # CLI Options
    4648my $action;                 # action to realize
     
    739741# Check for command requirements
    740742#
    741 my ($req,$opt,$pbpara) = pb_conf_get_if("oscmd","oscmdopt","pbparallel");
     743my ($req,$opt,$pbpara,$pbshowsudo) = pb_conf_get_if("oscmd","oscmdopt","pbparallel","pbshowsudo");
    742744pb_check_requirements($req,$opt,$appname);
     745
     746$Global::pb_show_sudo = 1 if ((defined $pbshowsudo) && (defined $pbshowsudo->{$ENV{'PBPROJ'}}) && ($pbshowsudo->{$ENV{'PBPROJ'}} =~ /true/oi));
    743747
    744748#
     
    14321436    pb_mkdir_p($tmpd) if (defined $pbparallel);
    14331437
     1438    # Do it here as this doesn't work in // mode as itdies if it fails
     1439    if ($pbos->{'type'} eq "rpm") {
     1440        foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
     1441                if (! -d "$ENV{'PBBUILDDIR'}/$d") {
     1442                    pb_mkdir_p("$ENV{'PBBUILDDIR'}/$d");
     1443                }
     1444            }
     1445    }
     1446
    14341447    foreach my $pbpkg (@pkgs) {
    14351448        $pm->start and next if (defined $pbparallel);
     
    14471460        pb_log(2,"Working directory: $ENV{'PBBUILDDIR'}\n");
    14481461        if ($pbos->{'type'} eq "rpm") {
    1449             foreach my $d ('RPMS','SRPMS','SPECS','SOURCES','BUILD') {
    1450                 if (! -d "$ENV{'PBBUILDDIR'}/$d") {
    1451                     pb_mkdir_p("$ENV{'PBBUILDDIR'}/$d");
    1452                 }
    1453             }
    1454 
    14551462            # Remove in case a previous link/file was there
    14561463            unlink "$ENV{'PBBUILDDIR'}/SOURCES/".basename($src);
     
    15481555            #pb_extract_build_files($src2,"$pbpkg-$pbver$pbextdir/pbconf/$pbos->{'name'}-$pbos->{'version'}-$pbos->{'arch'}/pbsrc/","$ENV{'PBBUILDDIR'}/debian","src");
    15491556
     1557            # This can create problems in // mode as well
    15501558            pb_distro_installdeps("debian/control",$pbos);
    15511559            pb_system("dpkg-buildpackage -us -uc -rfakeroot","Building package","verbose");
     1560
    15521561            # Get the name of the generated packages
    15531562            open(LOG,"$ENV{'PBTMP'}/system.$$.log") || die "Unable to open $ENV{'PBTMP'}/system.$$.log";
    1554             my $tmp = "";
    15551563            while (<LOG>) {
    15561564                chomp();
     1565                pb_log(3,"In loop: $_\n");
    15571566                next unless (/^dpkg-deb.*:\s+building\s+package\s+.*\s+in\s+\`\.\.\/(\S+)\'\./o);
    1558                 $tmp = $1;
    1559                 die "Missing file $tmp" if (not -f $tmp);
     1567                my $tmp = $1;
     1568                #doesn't work in my case
     1569                #die "Missing file $tmp" if (not -f "../$tmp");
    15601570                $made = "$made $tmp";
    15611571            }
    15621572            close(LOG);
    1563             open(CTRL,"debian/control") or die "Unable to open debian/control: $!";
    1564             #$made="$made $tmp.dsc $tmp.tar.gz $tmp"."_*.deb $tmp"."_*.changes";
     1573            pb_log(2,"Now made is: $made\n");
     1574
     1575            open(CTRL,"debian/control") || die "Unable to open debian/control: $!";
    15651576            while (<CTRL>) {
     1577                pb_log(3,"In loop: $_\n");
    15661578                next unless (/^Source: (\S+)/o);
    1567                 foreach my $glob (("$1\_*.changes", "$1\_*.dsc", "$1\_*.tar.gz")) {
    1568                     my @file = glob($glob);
    1569                     die "Missing file for $glob" unless @file > 0;
    1570                     die "Too many files for $glob" if @file > 1;
    1571                     die "Missing file $file[0]" if (not -f $file[0]);
    1572                     $made .= " $file[0]";
    1573                 }
     1579                my $tmp = $1;
     1580                $made = "$made $tmp"."_*.dsc $tmp"."_*.tar.gz $tmp"."_*.deb $tmp"."_*.changes";
     1581                #doesn't work in my case
     1582                #foreach my $glob (("$1\_*.changes", "$1\_*.dsc", "$1\_*.tar.gz")) {
     1583                    #my @file = glob($glob);
     1584                    #die "Missing file for $glob" unless (@file > 0);
     1585                    #die "Too many files for $glob" if (@file > 1);
     1586                    #die "Missing file $file[0]" if (not -f $file[0]);
     1587                    #$made .= " $file[0]";
     1588                #}
    15741589            }
    15751590            close(CTRL);
    1576             pb_display_file("$ENV{'PBTMP'}/system.$$.log");
     1591            #pb_display_file("$ENV{'PBTMP'}/system.$$.log");
     1592            pb_log(2,"Finally made is: $made\n");
    15771593
    15781594            chdir ".." || die "Unable to chdir to parent dir";
    1579             pb_rm_rf("$pbpkg-$pbver");
     1595            pb_rm_rf("$pbpkg-$pbver$pbextdir");
    15801596        } elsif ($pbos->{'type'} eq "ebuild") {
    15811597            my @ebuildfile;
     
    23452361        # For VE we need to change the owner manually
    23462362        if ($cmt eq "VEbuild") {
    2347             pb_system("sudo chown $UID $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$","Adapt owner in $tdir to $UID");
     2363            my $command = pb_check_req("chown",0);
     2364            pb_system("sudo $command $UID $ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$","Adapt owner in $tdir to $UID");
    23482365        }
    23492366        if (not -f "$ENV{'PBBUILDDIR'}/pbgen-$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.$$") {
     
    27332750        $i++;
    27342751    }
    2735     print SCRIPT "set -e\n" if $Global::pb_stop_on_error;
     2752    print SCRIPT "set -e\n" if ($Global::pb_stop_on_error);
    27362753    # Activate script verbosity if at least 2 for pbdebug
    27372754    print SCRIPT "set -x\n" if ($i gt 1);
Note: See TracChangeset for help on using the changeset viewer.