Changeset 473 in ProjectBuilder
- Timestamp:
- Jun 4, 2008, 3:04:36 AM (17 years ago)
- Location:
- devel
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/pb-modules/lib/ProjectBuilder/Base.pm
r471 r473 126 126 The first parameter is the shell command to call. 127 127 The second parameter is the message to print on screen. If none is given, then the command is printed. 128 The third parameter print the result of the command after correct execution if value is verbose. If value is noredir, it avoids redirecting outputs (e.g. for vi). 128 129 This function returns the result the return value of the system command. 129 130 … … 137 138 my $cmt=shift || $cmd; 138 139 my $verbose=shift || undef; 140 my $redir = ""; 139 141 140 142 pb_log(0,"$cmt... "); 141 143 pb_log(1,"Executing $cmd\n"); 142 system("$cmd 2>&1 > $ENV{'PBTMP'}/system.log"); 144 $redir = "2>&1 > $ENV{'PBTMP'}/system.log" if ((! defined $verbose) || ($verbose ne "noredir")); 145 system("$cmd $redir"); 143 146 my $res = $?; 144 147 if ($res == -1) { 145 148 pb_log(0,"failed to execute ($cmd): $!\n"); 146 pb_display_file("$ENV{'PBTMP'}/system.log") ;149 pb_display_file("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log"); 147 150 } elsif ($res & 127) { 148 151 pb_log(0, "child ($cmd) died with signal ".($? & 127).", ".($? & 128) ? 'with' : 'without'." coredump\n"); 149 pb_display_file("$ENV{'PBTMP'}/system.log") ;152 pb_display_file("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log"); 150 153 } elsif ($res == 0) { 151 154 pb_log(0,"OK\n"); 152 pb_display_file("$ENV{'PBTMP'}/system.log") if ( defined $verbose);155 pb_display_file("$ENV{'PBTMP'}/system.log") if ((defined $verbose) && (-f "$ENV{'PBTMP'}/system.log")); 153 156 } else { 154 157 pb_log(0, "child ($cmd) exited with value ".($? >> 8)."\n"); 155 pb_display_file("$ENV{'PBTMP'}/system.log") ;158 pb_display_file("$ENV{'PBTMP'}/system.log") if (-f "$ENV{'PBTMP'}/system.log"); 156 159 } 157 160 return($res); -
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 -
devel/pb/lib/ProjectBuilder/Changelog.pm
r415 r473 133 133 $tmp = <INPUT>; 134 134 if ($dtype eq "announce") { 135 print $OUTPUT $tmp; 135 chomp($tmp); 136 print $OUTPUT "$tmp<br>\n"; 136 137 } 137 138 $tmp = <INPUT>; 138 139 if ($dtype eq "announce") { 139 print $OUTPUT $tmp; 140 chomp($tmp); 141 print $OUTPUT "$tmp<br>\n"; 140 142 } 141 143 … … 180 182 print $OUTPUT "$tmp"; 181 183 } else { 182 print $OUTPUT "$tmp"; 184 chomp($tmp); 185 print $OUTPUT "$tmp<br>\n"; 183 186 } 184 187 last if (eof(INPUT)); -
devel/pb/lib/ProjectBuilder/Filter.pm
r462 r473 166 166 pb_log(2,"DEBUG: From $f to $destfile\n"); 167 167 pb_mkdir_p(dirname($destfile)) if (! -d dirname($destfile)); 168 open(DEST,"> $destfile") || die "Unable to create $destfile ";168 open(DEST,"> $destfile") || die "Unable to create $destfile: $!"; 169 169 open(FILE,"$f") || die "Unable to open $f: $!"; 170 170 while (<FILE>) {
Note:
See TracChangeset
for help on using the changeset viewer.