Changeset 471 for devel/pb/bin/pb


Ignore:
Timestamp:
06/03/08 02:49:42 (5 years ago)
Author:
bruno
Message:

announce function - begining of coding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r465 r471  
    220220Create a new project and a template set of 
    221221configuration files under pbconf 
     222 
     223=item B<announce> 
     224 
     225Announce the availability of the project through various means 
    222226 
    223227=back  
     
    431435    # Nothing to do - already done in pb_env_init 
    432436} elsif ($action =~ /^clean$/) { 
     437    # TBC 
     438} elsif ($action =~ /^announce$/) { 
     439    pb_announce(); 
    433440} else { 
    434441    pb_log(0,"\'$action\' is not available\n"); 
     
    679686            $made="$made RPMS/*/$pbpkg-$pbver-$pbtag$pbsuf.*.rpm SRPMS/$pbpkg-$pbver-$pbtag$pbsuf.src.rpm"; 
    680687            if (-f "/usr/bin/rpmlint") { 
    681                 pb_system("rpmlint $made","Checking validity of rpms with rpmlint"); 
     688                pb_system("rpmlint $made","Checking validity of rpms with rpmlint","verbose"); 
    682689            } 
    683690        } elsif ($dtype eq "deb") { 
     
    814821    } 
    815822    my $cmd = ""; 
    816  
    817     my $ptr = pb_get_pkg(); 
    818     @pkgs = @$ptr; 
    819  
    820     # Get the running distro to consider 
     823    my $src = ""; 
    821824    my ($odir,$over,$oarch) = (undef, undef, undef); 
    822     if (defined $v) { 
    823         ($odir,$over,$oarch) = split(/-/,$v); 
    824     } 
    825     my ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over); 
    826     pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n"); 
    827  
    828     # Get list of packages to build 
    829     # Get content saved in cms2build 
    830     my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg"); 
    831     $pkg = { } if (not defined $pkg); 
    832  
    833     my $src = ""; 
    834     chdir "$ENV{'PBBUILDDIR'}"; 
    835     foreach my $pbpkg (@pkgs) { 
    836         my $vertag = $pkg->{$pbpkg}; 
    837         # get the version of the current package - maybe different 
    838         ($pbver,$pbtag) = split(/-/,$vertag); 
    839  
    840         if (($cmt eq "Sources") || ($cmt eq "vm") || ($cmt eq "ve")) { 
    841             $src = "$src $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz"; 
    842             if ($cmd eq "") { 
    843                 $cmd = "ln -sf $pbpkg-$pbver.tar.gz $pbpkg-latest.tar.gz"; 
    844             } else { 
    845                 $cmd = "$cmd ; ln -sf $pbpkg-$pbver.tar.gz $pbpkg-latest.tar.gz"; 
    846             } 
    847         } 
    848     } 
    849     # Adds conf file for availability of conf elements 
    850     pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb"); 
     825    my ($ddir, $dver, $dfam, $dtype, $pbsuf); 
     826 
     827    if ($cmt ne "Announce") { 
     828        my $ptr = pb_get_pkg(); 
     829        @pkgs = @$ptr; 
     830 
     831        # Get the running distro to consider 
     832        if (defined $v) { 
     833            ($odir,$over,$oarch) = split(/-/,$v); 
     834        } 
     835        ($ddir, $dver, $dfam, $dtype, $pbsuf) = pb_distro_init($odir,$over); 
     836        pb_log(2,"DEBUG: distro tuple: ".join(',',($ddir, $dver, $dfam, $dtype, $pbsuf))."\n"); 
     837 
     838        # Get list of packages to build 
     839        # Get content saved in cms2build 
     840        my ($pkg) = pb_conf_read("$ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb","pbpkg"); 
     841        $pkg = { } if (not defined $pkg); 
     842 
     843        chdir "$ENV{'PBBUILDDIR'}"; 
     844        foreach my $pbpkg (@pkgs) { 
     845            my $vertag = $pkg->{$pbpkg}; 
     846            # get the version of the current package - maybe different 
     847            ($pbver,$pbtag) = split(/-/,$vertag); 
     848 
     849            if (($cmt eq "Sources") || ($cmt eq "vm") || ($cmt eq "ve")) { 
     850                $src = "$src $ENV{'PBDESTDIR'}/$pbpkg-$pbver.tar.gz"; 
     851                if ($cmd eq "") { 
     852                    $cmd = "ln -sf $pbpkg-$pbver.tar.gz $pbpkg-latest.tar.gz"; 
     853                } else { 
     854                    $cmd = "$cmd ; ln -sf $pbpkg-$pbver.tar.gz $pbpkg-latest.tar.gz"; 
     855                } 
     856            } 
     857        } 
     858        # Adds conf file for availability of conf elements 
     859        pb_conf_add("$ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb"); 
     860    } 
    851861 
    852862    if (($cmt eq "vm") || ($cmt eq "ve")) { 
    853863        $src="$src $ENV{'PBROOTDIR'}/$ENV{'PBPROJ'}.pb $ENV{'PBDESTDIR'}/$ENV{'PBPROJVER'}-$ENV{'PBPROJTAG'}.pb $ENV{'PBETC'} $ENV{'PBDESTDIR'}/pbrc $ENV{'PBDESTDIR'}/pbscript"; 
    854     } elsif ($cmt eq "Script") { 
    855         $src="$src $ENV{'PBDESTDIR'}/pbscript"; 
     864    } elsif (($cmt eq "Script") || ($cmt eq "Announce")) { 
     865        $src="$src $ENV{'PBTMP'}/pbscript"; 
    856866    } elsif ($cmt eq "Packages") { 
    857867        # Get package list from file made during build2pkg 
     
    889899    my $bdir; 
    890900    if (($cmt eq "Sources") || ($cmt eq "Script")) { 
    891         $tdir = "$sshdir->{$ENV{'PBPROJ'}}/src"; 
     901        $tdir = $sshdir->{$ENV{'PBPROJ'}}."/src"; 
    892902        if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) { 
    893903            # This is a test pkg => target dir is under test 
    894             $tdir = "$sshdir->{$ENV{'PBPROJ'}}/test/src"; 
     904            $tdir = $sshdir->{$ENV{'PBPROJ'}}."/test/src"; 
    895905        } 
    896906    } elsif (($cmt eq "vm") || ($cmt eq "ve")) { 
     
    899909        # Remove a potential $ENV{'HOME'} as bdir should be relative to pb's home 
    900910        $bdir =~ s|\$ENV.+\}/||; 
    901     } elsif ($cmt eq "Packages") { 
    902         $tdir = "$sshdir->{$ENV{'PBPROJ'}}/$ddir/$dver"; 
    903  
     911    } elsif ($cmt eq "Announce") { 
     912        $tdir = "$sshdir->{$ENV{'PBPROJ'}}"; 
    904913        if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) { 
    905914            # This is a test pkg => target dir is under test 
    906             $tdir = "$sshdir->{$ENV{'PBPROJ'}}/test/$ddir/$dver"; 
     915            $tdir = $sshdir->{$ENV{'PBPROJ'}}."/test"; 
     916        } 
     917    } elsif ($cmt eq "Packages") { 
     918        $tdir = $sshdir->{$ENV{'PBPROJ'}}."/$ddir/$dver"; 
     919 
     920        if ((defined $testver) && (defined $testver->{$ENV{'PBPROJ'}}) && ($testver->{$ENV{'PBPROJ'}} =~ /true/i)) { 
     921            # This is a test pkg => target dir is under test 
     922            $tdir = $sshdir->{$ENV{'PBPROJ'}}."/test/$ddir/$dver"; 
    907923        } 
    908924 
     
    10051021    } 
    10061022 
    1007     pb_system("$shcmd \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\ ; $cmd' | bash\"","Preparing $tdir on $cptarget"); 
     1023    my $logres = ""; 
     1024    # Do not touch when just announcing 
     1025    if ($cmt ne "Announce") { 
     1026        pb_system("$shcmd \"mkdir -p $tdir ; cd $tdir ; echo \'for i in $basesrc; do if [ -f \$i ]; then rm -f \$i; fi; done\ ; $cmd' | bash\"","Preparing $tdir on $cptarget"); 
     1027    } else { 
     1028        $logres = "> "; 
     1029    } 
    10081030    pb_system("cd $ENV{'PBBUILDDIR'} ; $cpcmd $src $cptarget 2> /dev/null","$cmt delivery in $cptarget"); 
    10091031 
     
    16881710} 
    16891711 
     1712sub pb_announce { 
     1713 
     1714    die "-V Version parameter needed" if ((not defined $newver) || ($newver eq "")); 
     1715 
     1716    my ($pbrepo) = pb_conf_get("pbrepo"); 
     1717    my ($pkgv, $pkgt, $testver) = pb_conf_get_if("pkgver","pkgtag","testver"); 
     1718    my $pkg = pb_cms_get_pkg($defpkgdir,$extpkgdir); 
     1719    my @pkgs = @$pkg; 
     1720    my %pkgs; 
     1721    my $first = 0; 
     1722 
     1723    my $findstr = "find . "; 
     1724 
     1725    foreach my $pbpkg (@pkgs) { 
     1726        if ($first != 0) { 
     1727            $findstr .= "-o "; 
     1728        } 
     1729        $first++; 
     1730        if ((defined $pkgv) && (defined $pkgv->{$pbpkg})) { 
     1731            $pbver = $pkgv->{$pbpkg}; 
     1732        } else { 
     1733            $pbver = $ENV{'PBPROJVER'}; 
     1734        } 
     1735        if ((defined $pkgt) && (defined $pkgt->{$pbpkg})) { 
     1736            $pbtag = $pkgt->{$pbpkg}; 
     1737        } else { 
     1738            $pbtag = $ENV{'PBPROJTAG'}; 
     1739        } 
     1740 
     1741        $findstr .= "-name \'$pbpkg-$pbver-$pbtag\.*.rpm\' -o -name \'$pbpkg"."_$pbver*\.deb\' -o -name \'$pbpkg-$pbver\.ebuild\' "; 
     1742    } 
     1743    $findstr .= " | grep -Ev \'src.rpm\'"; 
     1744    if ((not defined $testver) || (not defined $testver->{$ENV{'PBPROJ'}}) || ($testver->{$ENV{'PBPROJ'}} !~ /true/i)) { 
     1745        $findstr .= " | grep -v ./test/"; 
     1746    } 
     1747 
     1748    # Prepare the command to run and execute it 
     1749    open(PBS,"> $ENV{'PBTMP'}/pbscript") || die "Unable to create $ENV{'PBTMP'}/pbscript"; 
     1750    print PBS "$findstr\n"; 
     1751    close(PBS); 
     1752    chmod 0755,"$ENV{'PBTMP'}/pbscript"; 
     1753    pb_send2target("Announce"); 
     1754 
     1755    # Prepare a template of announce 
     1756    open(ANN,"> $ENV{'PBTMP'}/pbannounce") || die "Unable to create $ENV{'PBTMP'}/pbannounce: $!"; 
     1757    print ANN << "EOF"; 
     1758Project $ENV{'PBPROJ'} version $newver is now available</p> 
     1759 
     1760<p>The project team is happy to announce the availability of a newest version of $ENV{'PBPROJ'} $newver. Enjoy it as usual!</p> 
     1761<p> 
     1762Now available at <a href="$pbrepo->{$ENV{'PBPROJ'}}">$pbrepo->{$ENV{'PBPROJ'}}</a> 
     1763</p> 
     1764<p> 
     1765EOF 
     1766    open(LOG,"$ENV{'PBTMP'}/system.log") || die "Unable to read $ENV{'PBTMP'}/system.log: $!"; 
     1767    while (<LOG>) { 
     1768        print ANN $_; 
     1769    } 
     1770    close(LOG); 
     1771 
     1772    close(ANN); 
     1773    pb_display_file("$ENV{'PBTMP'}/pbannounce"); 
     1774} 
     1775 
    16901776# Return the SSH key file to use 
    16911777# Potentially create it if needed 
Note: See TracChangeset for help on using the changeset viewer.