Changeset 473 in ProjectBuilder for devel/pb/bin
- Timestamp:
- Jun 4, 2008, 3:04:36 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb/bin/pb
r471 r473 27 27 use ProjectBuilder::Env; 28 28 use ProjectBuilder::Filter; 29 use ProjectBuilder::Changelog; 30 31 use DBI; 29 32 30 33 # Global variables … … 1712 1715 sub pb_announce { 1713 1716 1714 die "-V Version parameter needed" if ((not defined $newver) || ($newver eq "")); 1715 1716 my ($pbrepo) = pb_conf_get("pbrepo"); 1717 # Get all required parameters 1718 my ($pbpackager,$pbrepo,$pbml) = pb_conf_get("pbpackager","pbrepo","pbml"); 1717 1719 my ($pkgv, $pkgt, $testver) = pb_conf_get_if("pkgver","pkgtag","testver"); 1718 1720 my $pkg = pb_cms_get_pkg($defpkgdir,$extpkgdir); … … 1721 1723 my $first = 0; 1722 1724 1725 # Command to find packages on repo 1723 1726 my $findstr = "find . "; 1727 # Generated announce files 1728 my @files; 1724 1729 1725 1730 foreach my $pbpkg (@pkgs) { … … 1740 1745 1741 1746 $findstr .= "-name \'$pbpkg-$pbver-$pbtag\.*.rpm\' -o -name \'$pbpkg"."_$pbver*\.deb\' -o -name \'$pbpkg-$pbver\.ebuild\' "; 1747 1748 my $chglog; 1749 1750 # Get project info on log file and generate tmp files used later on 1751 pb_cms_init($pbinit); 1752 $chglog = "$ENV{'PBROOTDIR'}/$pbpkg/pbcl"; 1753 $chglog = "$ENV{'PBROOTDIR'}/pbcl" if (! -f $chglog); 1754 $chglog = undef if (! -f $chglog); 1755 1756 open(OUT,"> $ENV{'PBTMP'}/$pbpkg.ann") || die "Unable to create $ENV{'PBTMP'}/$pbpkg.ann: $!"; 1757 pb_changelog("announce",$pbpkg,$pbver,"N/A","N/A","N/A",\*OUT,"yes",$chglog); 1758 close(OUT); 1759 push(@files,"$ENV{'PBTMP'}/$pbpkg.ann"); 1742 1760 } 1743 1761 $findstr .= " | grep -Ev \'src.rpm\'"; … … 1754 1772 1755 1773 # Prepare a template of announce 1756 open(ANN,"> $ENV{'PBTMP'}/ pbannounce") || die "Unable to create $ENV{'PBTMP'}/pbannounce: $!";1774 open(ANN,"> $ENV{'PBTMP'}/announce.html") || die "Unable to create $ENV{'PBTMP'}/announce.html: $!"; 1757 1775 print ANN << "EOF"; 1758 Project $ENV{'PBPROJ'} version $ newveris 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>1776 Project $ENV{'PBPROJ'} version $ENV{'PBPROJVER'} is now available</p> 1777 1778 <p>The project team is happy to announce the availability of a newest version of $ENV{'PBPROJ'} $ENV{'PBPROJVER'}. Enjoy it as usual!</p> 1761 1779 <p> 1762 1780 Now available at <a href="$pbrepo->{$ENV{'PBPROJ'}}">$pbrepo->{$ENV{'PBPROJ'}}</a> … … 1765 1783 EOF 1766 1784 open(LOG,"$ENV{'PBTMP'}/system.log") || die "Unable to read $ENV{'PBTMP'}/system.log: $!"; 1785 my $col = 2; 1786 my $i = 1; 1787 print ANN << 'EOF'; 1788 <TABLE WIDTH="700" CELLPADDING="0" CELLSPACING="0" BORDER="0"> 1789 <TR> 1790 EOF 1767 1791 while (<LOG>) { 1768 print ANN $_; 1792 print ANN "<TD>$_</TD>"; 1793 $i++; 1794 if ($i > $col) { 1795 print ANN "</TR>\n<TR>"; 1796 $i = 1; 1797 } 1769 1798 } 1770 1799 close(LOG); 1771 1800 print ANN << "EOF"; 1801 </TR> 1802 </TABLE> 1803 </p> 1804 1805 <p>As usual source packages are also available in the same directory.</p> 1806 1807 <p> 1808 Changes are : 1809 </p> 1810 <p> 1811 EOF 1812 # Get each package changelog content 1813 foreach my $f (sort(@files)) { 1814 open(IN,"$f") || die "Unable to read $f:$!"; 1815 while (<IN>) { 1816 print ANN $_; 1817 } 1818 close(IN); 1819 print ANN "</p><p>\n"; 1820 } 1821 print ANN "</p>\n"; 1772 1822 close(ANN); 1773 pb_display_file("$ENV{'PBTMP'}/pbannounce"); 1823 1824 # Allow for modification 1825 pb_system("vi $ENV{'PBTMP'}/announce.html","Allowing modification of the announce","noredir"); 1826 1827 # Store it in DB for external usage (Web pages generation) 1828 my $db = "$ENV{'PBCONFDIR'}/announces3.sql"; 1829 1830 my $precmd = ""; 1831 if (! -f $db) { 1832 $precmd = "CREATE TABLE announces (id INTEGER PRIMARY KEY AUTOINCREMENT, date DATE, announce VARCHAR[65535])"; 1833 } 1834 1835 my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","", 1836 { RaiseError => 1, AutoCommit => 1 }) 1837 || die "Unable to connect to $db"; 1838 1839 if ($precmd ne "") { 1840 my $sth = $dbh->prepare(qq{$precmd}) 1841 || die "Unable to create table into $db"; 1842 $sth->execute(); 1843 } 1844 1845 # To read whole file 1846 local $/; 1847 open(ANN,"$ENV{'PBTMP'}/announce.html") || die "Unable to read $ENV{'PBTMP'}/announce.html: $!"; 1848 my $announce = <ANN>; 1849 close(ANN); 1850 1851 pb_log(2,"INSERT INTO announces VALUES (NULL, $pbdate, $announce)"); 1852 my $sth = $dbh->prepare(qq{INSERT INTO announces VALUES (NULL,?,?)}) 1853 || die "Unable to insert into $db"; 1854 $sth->execute($pbdate, $announce); 1855 $dbh->disconnect; 1856 1857 # Then deliver it on the Web 1858 # $TOOLHOME/livwww www 1859 1860 # Mail it to project's ML 1861 open(ML,"| w3m -dump -T text/html > $ENV{'PBTMP'}/announce.txt") || die "Unable to create $ENV{'PBTMP'}/announce.txt: $!"; 1862 print ML << 'EOF'; 1863 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x html1/DTD/xhtml1-strict.dtd"> 1864 1865 <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en"> 1866 <head> 1867 </head> 1868 <body> 1869 <p> 1870 EOF 1871 open(ANN,"$ENV{'PBTMP'}/announce.html") || die "Unable to read $ENV{'PBTMP'}/announce.html: $!"; 1872 while(<ANN>) { 1873 print ML $_; 1874 } 1875 print ML << 'EOF'; 1876 </body> 1877 </html> 1878 EOF 1879 close(ML); 1880 1881 pb_system("export EMAIL=\'$pbpackager->{$ENV{'PBPROJ'}}\' ; mutt -s \"ANNOUNCE: Project $ENV{'PBPROJ'} version $ENV{'PBPROJVER'} is now available\" $pbml->{$ENV{'PBPROJ'}} < $ENV{'PBTMP'}/announce.txt","Mailing announce to $pbml->{$ENV{'PBPROJ'}}"); 1774 1882 } 1775 1883
Note:
See TracChangeset
for help on using the changeset viewer.