Changeset 328 in ProjectBuilder for devel/pb/lib/ProjectBuilder/Base.pm


Ignore:
Timestamp:
Feb 22, 2008, 12:00:13 PM (16 years ago)
Author:
Bruno Cornec
Message:
  • pb_changelog back in Base.pm (removal of Changelog.pm)
  • cms2build begins to work for pb
File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/lib/ProjectBuilder/Base.pm

    r327 r328  
    1818use POSIX qw(strftime);
    1919use Time::localtime qw(localtime);
    20 
    21 use ProjectBuilder::Changelog qw (pb_changelog);
     20use Date::Manip;
     21use English;
    2222
    2323# Inherit from the "Exporter" module which handles exporting functions.
     
    889889    if (not defined $p2) {
    890890        # No ref in CMS project conf file so use the home dir one.
    891         $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (not defined $p1->{$ENV{'PBPROJ'}});
     891        $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if ((not defined $p1->{$ENV{'PBPROJ'}}) && (defined $p1->{'default'}));
    892892    } else {
    893893        # Ref found in CMS project conf file
    894894        if (not defined $p1) {
    895895            # No ref in home dir project conf file so use the CMS one.
    896             $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if (not defined $p2->{$ENV{'PBPROJ'}});
     896            $p2->{$ENV{'PBPROJ'}} = $p2->{'default'} if ((not defined $p2->{$ENV{'PBPROJ'}}) && (defined $p2->{'default'}));
    897897            $p1 = $p2;
    898898        } else {
     
    906906            if (not defined $p1->{$ENV{'PBPROJ'}}) {
    907907                if (defined $p2->{$ENV{'PBPROJ'}}) {
    908                     $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}};
     908                    $p1->{$ENV{'PBPROJ'}} = $p2->{$ENV{'PBPROJ'}} if (defined $p2->{$ENV{'PBPROJ'}});
    909909                } else {
    910                     $p1->{$ENV{'PBPROJ'}} = $p1->{'default'};
     910                    $p1->{$ENV{'PBPROJ'}} = $p1->{'default'} if (defined $p1->{'default'});
    911911                }
    912912            }
     
    15441544}
    15451545
     1546sub pb_changelog {
     1547
     1548my $dtype = shift;
     1549my $pkg = shift;
     1550my $pbver = shift;
     1551my $pbtag = shift;
     1552my $dsuf = shift;
     1553my $path = shift;
     1554my $OUTPUT = shift;
     1555my $doit = shift;
     1556my $chglog = shift || undef;
     1557
     1558my $log = "";
     1559
     1560# For date handling
     1561$ENV{LANG}="C";
     1562
     1563if ((not (defined $dtype)) || ($dtype eq "") ||
     1564        (not (defined $pkg)) || ($pkg eq "") ||
     1565        (not (defined $pbver)) || ($pbver eq "") ||
     1566        (not (defined $pbtag)) || ($pbtag eq "") ||
     1567        (not (defined $dsuf)) || ($dsuf eq "") ||
     1568        (not (defined $path)) || ($path eq "") ||
     1569        (not (defined $OUTPUT)) || ($OUTPUT eq "") ||
     1570        (not (defined $doit)) || ($doit eq "")) {
     1571    print $OUTPUT "\n";
     1572    return;
     1573}
     1574
     1575if (((not defined $chglog) || (! -f $chglog)) && ($doit eq "yes")) {
     1576    #pb_log(2,"No ChangeLog file ($chglog) for $pkg\n";
     1577    print $OUTPUT "\n";
     1578    return;
     1579}
     1580
     1581my $date;
     1582my $ndate;
     1583my $n2date;
     1584my $ver;
     1585my $ver2;
     1586my ($packager) = pb_conf_get("pbpackager");
     1587
     1588# If we don't need to do it, or don't have it fake something
     1589if (((not defined $chglog) || (! -f $chglog)) && ($doit ne "yes")) {
     1590    my @date=(localtime->sec(), localtime->min(), localtime->hour(), localtime->mday(), localtime->mon(), localtime->year(), localtime->wday(), localtime->yday(), localtime->isdst());
     1591    $date = strftime("%Y-%m-%d", @date);
     1592    $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
     1593    $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
     1594    if (($dtype eq "rpm") || ($dtype eq "fc")) {
     1595        $ver2 = "$pbver-$pbtag$dsuf";
     1596        print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
     1597        print $OUTPUT "- Updated to $pbver\n";
     1598        }
     1599    if ($dtype eq "deb") {
     1600        print $OUTPUT "$pkg ($pbver) unstable; urgency=low\n";
     1601        print $OUTPUT "\n";
     1602        print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}}  $n2date\n\n\n";
     1603        }
     1604    return;
     1605}
     1606
     1607open(INPUT,"$chglog") || die "Unable to open $chglog (read)";
     1608
     1609# Skip first 4 lines
     1610my $tmp = <INPUT>;
     1611$tmp = <INPUT>;
     1612$tmp = <INPUT>;
     1613if ($dtype eq "announce") {
     1614    print $OUTPUT $tmp;
     1615}
     1616$tmp = <INPUT>;
     1617if ($dtype eq "announce") {
     1618    print $OUTPUT $tmp;
     1619}
     1620
     1621my $first=1;
     1622
     1623# Handle each block separated by newline
     1624while (<INPUT>) {
     1625    ($ver, $date) = split(/ /);
     1626    $ver =~ s/^v//;
     1627    chomp($date);
     1628    $date =~ s/\(([0-9-]+)\)/$1/;
     1629    #pb_log(2,"**$date**\n";
     1630    $ndate = UnixDate($date,"%a", "%b", "%d", "%Y");
     1631    $n2date = &UnixDate($date,"%a, %d %b %Y %H:%M:%S %z");
     1632    #pb_log(2,"**$ndate**\n";
     1633
     1634    if (($dtype eq "rpm") || ($dtype eq "fc")) {
     1635        if ($ver !~ /-/) {
     1636            if ($first eq 1) {
     1637                $ver2 = "$ver-$pbtag$dsuf";
     1638                $first=0;
     1639            } else {
     1640                $ver2 = "$ver-1$dsuf";
     1641            }
     1642        } else {
     1643            $ver2 = "$ver$dsuf";
     1644        }
     1645        print $OUTPUT "* $ndate $packager->{$ENV{'PBPROJ'}} $ver2\n";
     1646        print $OUTPUT "- Updated to $ver\n";
     1647        }
     1648    if ($dtype eq "deb") {
     1649        print $OUTPUT "$pkg ($ver) unstable; urgency=low\n";
     1650        print $OUTPUT "\n";
     1651        }
     1652
     1653    $tmp = <INPUT>;
     1654    while ($tmp !~ /^$/) {
     1655        if ($dtype eq "deb") {
     1656            $tmp =~ s/^- //;
     1657            print $OUTPUT "  * $tmp";
     1658        } elsif ($dtype eq "rpm") {
     1659            print $OUTPUT "$tmp";
     1660        } else {
     1661            print $OUTPUT "$tmp";
     1662        }
     1663        last if (eof(INPUT));
     1664        $tmp = <INPUT>;
     1665    }
     1666    print $OUTPUT "\n";
     1667
     1668    if ($dtype eq "deb") {
     1669        # Cf: http://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog
     1670        print $OUTPUT " -- $packager->{$ENV{'PBPROJ'}}  $n2date\n\n\n";
     1671        }
     1672
     1673    last if (eof(INPUT));
     1674    last if ($dtype eq "announce");
     1675}
     1676close(INPUT);
     1677}
    154616781;
Note: See TracChangeset for help on using the changeset viewer.