Changeset 827 for trunk/BuildContrib/lib/Foswiki/Contrib/Build.pm
- Timestamp:
- 11/20/08 13:04:58 (4 years ago)
- Location:
- trunk/BuildContrib/lib/Foswiki
- Files:
-
- 1 edited
- 1 moved
-
. (moved) (moved from trunk/BuildContrib/lib/TWiki)
-
Contrib/Build.pm (modified) (59 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BuildContrib/lib/Foswiki/Contrib/Build.pm
r603 r827 13 13 # http://www.gnu.org/copyleft/gpl.html 14 14 # 15 package TWiki::Contrib::Build;16 17 use TWiki::Contrib::BuildContrib::BaseBuild;15 package Foswiki::Contrib::Build; 16 17 use Foswiki::Contrib::BuildContrib::BaseBuild; 18 18 use Error qw(:try); 19 19 use CGI qw(:any); 20 20 21 =begin twiki22 23 ---++ Package TWiki::Contrib::Build24 25 This is a base class used for making build scripts for TWiki packages.21 =begin foswiki 22 23 ---++ Package Foswiki::Contrib::Build 24 25 This is a base class used for making build scripts for Foswiki packages. 26 26 27 27 ---+++ Methods … … 48 48 # It is *not* used by the build automation tools, but is reported as part 49 49 # of the version number in PLUGINDESCRIPTIONS. 50 our $RELEASE = ' NextWiki-1';50 our $RELEASE = 'Foswiki-1'; 51 51 52 52 our $SHORTDESCRIPTION = 53 53 'Automate build process for Plugins, Add-ons and Contrib modules'; 54 54 55 my $ TWIKIORGPUB = 'http://nextwiki.org/pub';56 my $ TWIKIORGSCRIPT = 'http://nextwiki.org/bin';57 my $ TWIKIORGSUFFIX = '';58 my $ TWIKIORGBUGS = 'http://nextwiki.org/Tasks';59 my $ TWIKIORGEXTENSIONSWEB = "Extensions";55 my $UPLOADSITEPUB = 'http://foswiki.org/pub'; 56 my $UPLOADSITESCRIPT = 'http://foswiki.org/bin'; 57 my $UPLOADSITESUFFIX = ''; 58 my $UPLOADSITEBUGS = 'http://foswiki.org/Tasks'; 59 my $UPLOADSITEEXTENSIONSWEB = "Extensions"; 60 60 61 61 my $GLACIERMELT = 10; # number of seconds to sleep between uploads, 62 62 # to reduce average load on server 63 64 my $targetProject = 'Foswiki';# May change to 'TWiki' 63 65 64 66 my $collector; # general purpose handle for collecting stuff … … 96 98 97 99 # Find the lib root 98 $libpath = _findRelativeTo( $buildpldir, 'lib/TWiki' ); 99 die 'Could not find lib/TWiki' unless $libpath; 100 $libpath = _findRelativeTo( $buildpldir, 'lib/Foswiki' ); 101 unless ($libpath) { 102 $libpath = _findRelativeTo( $buildpldir, 'lib/TWiki' ); 103 $targetProject = 'TWiki'; 104 } 105 die 'Could not find lib/Foswiki or lib/TWiki' unless $libpath; 100 106 $libpath =~ s#/[^/]*$##; 101 107 … … 103 109 $basedir =~ s#/[^/]*$##; 104 110 105 if ( $ENV{TWIKI_LIBS} ) { 111 my $env = $ENV{uc($targetProject).'_LIBS'}; 112 if ( $env ) { 106 113 my %known; 107 114 map { $known{$_} = 1 } split( /:/, @INC ); 108 foreach my $pc ( reverse split( /:/, $ ENV{TWIKI_LIBS}) ) {115 foreach my $pc ( reverse split( /:/, $env ) ) { 109 116 unless ( $known{$pc} ) { 110 117 unshift( @INC, $pc ); … … 117 124 } 118 125 119 =begin twiki126 =begin foswiki 120 127 121 128 ---++++ new($project) … … 134 141 135 142 # Constants with internet paths 136 $this->{BUGSURL} = $ TWIKIORGBUGS;143 $this->{BUGSURL} = $UPLOADSITEBUGS; 137 144 138 145 $this->{project} = $project; … … 160 167 $this->{basedir} = $basedir; 161 168 162 # The following paths are all relative to the root of the twiki169 # The following paths are all relative to the root of the 163 170 # installation 164 171 … … 167 174 $this->{libdir} = $libpath; 168 175 if ( $this->{project} =~ /Plugin$/ ) { 169 $this->{libdir} .= '/TWiki/Plugins';176 $this->{libdir} .= "/$targetProject/Plugins"; 170 177 } 171 178 elsif ( $this->{project} =~ /(Contrib|Skin)$/ ) { 172 $this->{libdir} .= '/TWiki/Contrib';179 $this->{libdir} .= "/$targetProject/Contrib"; 173 180 } 174 181 … … 178 185 179 186 my $stubpath = $this->{pm}; 180 $stubpath =~ s/.*[\\\/]( TWiki[\\\/].*)\.pm/$1/;187 $stubpath =~ s/.*[\\\/]($targetProject[\\\/].*)\.pm/$1/; 181 188 $stubpath =~ s/[\\\/]/::/g; 182 189 183 190 # where data files live 184 $this->{data_twiki} = 'data/TWiki'; 191 $this->{data_systemdir} = 192 ($targetProject eq 'TWiki') ? 'data/TWiki' : 'data/System'; 185 193 186 194 # the root of the name of data files 187 $this->{ data_twiki_module} = $this->{data_twiki} . '/' . $this->{project};195 $this->{topic_root} = $this->{data_systemdir} . '/' . $this->{project}; 188 196 189 197 ############################################################## … … 192 200 my $manifest = _findRelativeTo( $buildpldir, 'MANIFEST' ); 193 201 if (!defined($manifest)) { 194 #the twikicore MANIFEST is in the lib dir, not the tools dir202 #the core MANIFEST is in the lib dir, not the tools dir 195 203 $manifest = _findRelativeTo( $libpath, 'MANIFEST' ); 196 204 } 197 205 ( $this->{files}, $this->{other_modules} ) = 198 TWiki::Contrib::BuildContrib::BaseBuild::readManifest( $this->{basedir},206 Foswiki::Contrib::BuildContrib::BaseBuild::readManifest( $this->{basedir}, 199 207 '', $manifest, sub { exit(1) } ); 200 208 201 # Generate a TWikitable representing the manifest contents209 # Generate a table representing the manifest contents 202 210 # and a hash table representing the files 203 211 my $mantable = ''; … … 221 229 my $dependancies = _findRelativeTo( $buildpldir, 'DEPENDENCIES' ); 222 230 if (!defined($dependancies)) { 223 #the twikicore DEPENDENCIES is in the lib dir, not the tools dir231 #the core DEPENDENCIES is in the lib dir, not the tools dir 224 232 $dependancies = _findRelativeTo( $libpath, 'DEPENDENCIES' ); 225 233 } … … 297 305 } 298 306 else { 299 $this->{UPLOADTARGETPUB} = $ TWIKIORGPUB307 $this->{UPLOADTARGETPUB} = $UPLOADSITEPUB 300 308 unless defined $this->{UPLOADTARGETPUB}; 301 $this->{UPLOADTARGETSCRIPT} = $ TWIKIORGSCRIPT309 $this->{UPLOADTARGETSCRIPT} = $UPLOADSITESCRIPT 302 310 unless defined $this->{UPLOADTARGETSCRIPT}; 303 $this->{UPLOADTARGETSUFFIX} = $ TWIKIORGSUFFIX311 $this->{UPLOADTARGETSUFFIX} = $UPLOADSITESUFFIX 304 312 unless defined $this->{UPLOADTARGETSUFFIX}; 305 $this->{UPLOADTARGETWEB} = $ TWIKIORGEXTENSIONSWEB313 $this->{UPLOADTARGETWEB} = $UPLOADSITEEXTENSIONSWEB 306 314 unless defined $this->{UPLOADTARGETWEB}; 307 315 } … … 504 512 } 505 513 506 =begin twiki514 =begin foswiki 507 515 508 516 ---++++ pushd($dir) … … 523 531 } 524 532 525 =begin twiki533 =begin foswiki 526 534 527 535 ---++++ popd() … … 544 552 } 545 553 546 =begin twiki554 =begin foswiki 547 555 548 556 ---++++ rm($file) … … 567 575 } 568 576 569 =begin twiki577 =begin foswiki 570 578 571 579 ---++++ makepath($to) … … 580 588 } 581 589 582 =begin twiki590 =begin foswiki 583 591 584 592 ---++++ cp($from, $to) … … 617 625 } 618 626 619 =begin twiki627 =begin foswiki 620 628 621 629 ---++++ prot($perms, $file) … … 632 640 } 633 641 634 =begin twiki642 =begin foswiki 635 643 636 644 ---++++ sys_action(@params) … … 656 664 } 657 665 658 =begin twiki666 =begin foswiki 659 667 660 668 ---++++ perl_action($cmd) … … 675 683 } 676 684 677 =begin twiki685 =begin foswiki 678 686 679 687 ---++++ target_build … … 686 694 } 687 695 688 =begin twiki696 =begin foswiki 689 697 690 698 ---++++ target_compress … … 715 723 } 716 724 717 =begin twiki725 =begin foswiki 718 726 719 727 ---++++ target_tidy … … 762 770 } 763 771 764 =begin twiki772 =begin foswiki 765 773 766 774 ---++++ target_test … … 814 822 } 815 823 816 =begin twiki824 =begin foswiki 817 825 818 826 ---++++ filter_txt … … 834 842 835 843 # Replace the SVN revision with rev 1. 836 # In TWikibuilds this gets replaced by latest revision later.844 # In release builds this gets replaced by latest revision later. 837 845 $text =~ s/^(%META:TOPICINFO{.*)\$Rev:.*\$(.*}%)$/${1}1$2/m; 838 846 $text =~ s/%\$(\w+)%/&_expand($this,$1)/geo; … … 861 869 } 862 870 863 =begin twiki871 =begin foswiki 864 872 865 873 ---++++ build_js … … 904 912 } 905 913 906 =begin twiki914 =begin foswiki 907 915 908 916 ---++++ build_css … … 947 955 } 948 956 949 =begin twiki957 =begin foswiki 950 958 951 959 ---++++ filter_pm($from, $to) … … 974 982 } 975 983 976 =begin twiki984 =begin foswiki 977 985 978 986 ---++++ target_release … … 1000 1008 } 1001 1009 1002 =begin twiki1010 =begin foswiki 1003 1011 1004 1012 ---++++ target_stage … … 1029 1037 } 1030 1038 } 1031 if ( -e $this->{tmpDir} . '/' . $this->{ data_twiki_module} . '.txt' ) {1032 $this->cp( $this->{tmpDir} . '/' . $this->{ data_twiki_module} . '.txt',1039 if ( -e $this->{tmpDir} . '/' . $this->{topic_root} . '.txt' ) { 1040 $this->cp( $this->{tmpDir} . '/' . $this->{topic_root} . '.txt', 1033 1041 $this->{basedir} . '/' . $project . '.txt' ); 1034 1042 } … … 1040 1048 print STDERR "Installing $module in $this->{tmpDir}\n"; 1041 1049 print 1042 `export TWIKI_HOME=$this->{tmpDir}; export TWIKI_LIBS=$libs; cd $basedir/$module; perl build.pl handsoff_install`;1043 } 1044 } 1045 } 1046 1047 =begin twiki1050 `export FOSWIKI_HOME=$this->{tmpDir}; export FOSWIKI_LIBS=$libs; cd $basedir/$module; perl build.pl handsoff_install`; 1051 } 1052 } 1053 } 1054 1055 =begin foswiki 1048 1056 1049 1057 ---++++ target_archive … … 1119 1127 } 1120 1128 1121 =begin twiki1129 =begin foswiki 1122 1130 1123 1131 ---++++ copy_fileset … … 1146 1154 } 1147 1155 1148 =begin twiki1156 =begin foswiki 1149 1157 1150 1158 ---++++ apply_perms … … 1164 1172 } 1165 1173 1166 =begin twiki1174 =begin foswiki 1167 1175 1168 1176 ---++++ target_handsoff_install 1169 Install target, installs to local twiki pointed at by TWIKI_HOME.1177 Install target, installs to local install pointed at by FOSWIKI_HOME. 1170 1178 1171 1179 Does not run the installer script. … … 1177 1185 $this->build('release'); 1178 1186 1179 my $ twiki = $ENV{TWIKI_HOME};1180 die ' TWIKI_HOME not set' unless $twiki;1181 $this->pushd($ twiki);1187 my $home = $ENV{FOSWIKI_HOME}; 1188 die 'FOSWIKI_HOME not set' unless $home; 1189 $this->pushd($home); 1182 1190 $this->sys_action( 'tar', 'zxpf', 1183 1191 $this->{basedir} . '/' . $this->{project} . '.tgz' ); 1184 1192 1185 1193 # kill off the module installer 1186 $this->rm( $ twiki. '/' . $this->{project} . '_installer' );1194 $this->rm( $home . '/' . $this->{project} . '_installer' ); 1187 1195 $this->popd(); 1188 1196 } 1189 1197 1190 =begin twiki1198 =begin foswiki 1191 1199 1192 1200 ---++++ target_install 1193 Install target, installs to local twiki pointed at by TWIKI_HOME.1201 Install target, installs to local twiki pointed at by FOSWIKI_HOME. 1194 1202 1195 1203 Uses the installer script written by target_installer … … 1203 1211 } 1204 1212 1205 =begin twiki1213 =begin foswiki 1206 1214 1207 1215 ---++++ target_uninstall 1208 Uninstall target, uninstall from local twiki pointed at by TWIKI_HOME.1216 Uninstall target, uninstall from local twiki pointed at by FOSWIKI_HOME. 1209 1217 1210 1218 Uses the installer script written by target_installer … … 1214 1222 sub target_uninstall { 1215 1223 my $this = shift; 1216 my $ twiki = $ENV{TWIKI_HOME};1217 die ' TWIKI_HOME not set' unless $twiki;1218 $this->pushd($ twiki);1224 my $home = $ENV{FOSWIKI_HOME}; 1225 die 'FOSWIKI_HOME not set' unless $home; 1226 $this->pushd($home); 1219 1227 $this->sys_action( 'perl', $this->{project} . '_installer', 'uninstall' ); 1220 1228 $this->popd(); … … 1223 1231 { 1224 1232 1225 package TWiki::Contrib::Build::UserAgent;1233 package Foswiki::Contrib::Build::UserAgent; 1226 1234 use base qw(LWP::UserAgent); 1227 1235 … … 1296 1304 } 1297 1305 1298 =begin twiki1306 =begin foswiki 1299 1307 1300 1308 ---++++ target_upload … … 1351 1359 $this->build('release'); 1352 1360 my $userAgent = 1353 new TWiki::Contrib::Build::UserAgent( $this->{UPLOADTARGETSCRIPT},1361 new Foswiki::Contrib::Build::UserAgent( $this->{UPLOADTARGETSCRIPT}, 1354 1362 $this ); 1355 1363 $userAgent->agent( 'ContribBuild/' . $VERSION . ' ' ); … … 1393 1401 $newform{'text'} = <IN_FILE>; 1394 1402 close(IN_FILE); 1395 1396 # Hack to avoid revisions being overwritten on twiki.org.1397 # Can be removed when twiki.org is upgraded to 4.1.0.1398 # Item3216, Item34541399 $newform{'text'} =~ s/^%META:TOPICINFO{.*}%$//m;1400 1403 } 1401 1404 else { … … 1410 1413 1411 1414 # Upload any 'Var*.txt' topics published by the extension 1412 my $dataDir = $this->{basedir} . '/data/ TWiki';1415 my $dataDir = $this->{basedir} . '/data/System'; 1413 1416 if ( opendir( DIR, $dataDir ) ) { 1414 1417 foreach my $f ( grep( /^Var\w+\.txt$/, readdir DIR ) ) { 1415 if ( open( IN_FILE, '<' . $this->{basedir} . '/data/ TWiki/' . $f ) )1418 if ( open( IN_FILE, '<' . $this->{basedir} . '/data/System/' . $f ) ) 1416 1419 { 1417 1420 %newform = ( text => <IN_FILE> ); … … 1445 1448 1446 1449 $this->_uploadAttachment( $userAgent, $user, $pass, $name, 1447 $this->{basedir} . '/pub/ TWiki/' . $this->{project} . '/' . $name,1450 $this->{basedir} . '/pub/System/' . $this->{project} . '/' . $name, 1448 1451 $comment, $attrs =~ /h/ ? 1 : 0 ); 1449 1452 $uploaded{$name} = 1; … … 1475 1478 1476 1479 If you want to report an error in the topic, please raise a report at 1477 http:// nextwiki.org/view/Tasks/$this->{project}1480 http://foswiki.org/view/Tasks/$this->{project} 1478 1481 --> 1479 1482 EXTRA … … 1556 1559 # is intended for use by developers only. 1557 1560 1558 # POD text in =.pm= files should use T Wikisyntax or HTML. Packages should be1561 # POD text in =.pm= files should use TML syntax or HTML. Packages should be 1559 1562 # introduced with a level 1 header, ---+, and each method in the package by 1560 1563 # a level 2 header, ---++. Make sure you document any global variables used … … 1588 1591 } 1589 1592 1590 =begin twiki1593 =begin foswiki 1591 1594 1592 1595 ---++++ target_POD 1593 1596 1594 1597 Print POD documentation. This target does not modify any files, it simply 1595 prints the (T Wikiformat) POD.1596 1597 POD text in =.pm= files should use T Wikisyntax or HTML. Packages should be1598 prints the (TML format) POD. 1599 1600 POD text in =.pm= files should use TML syntax or HTML. Packages should be 1598 1601 introduced with a level 1 header, ---+, and each method in the package by 1599 1602 a level 2 header, ---++. Make sure you document any global variables used … … 1608 1611 } 1609 1612 1610 =begin twiki1613 =begin foswiki 1611 1614 1612 1615 ---++++ target_installer 1613 1616 1614 1617 Write an install/uninstall script that checks dependencies, and optionally 1615 downloads and installs required zips from twiki.org.1618 downloads and installs required zips from foswiki.org. 1616 1619 1617 1620 The install script is templated from =contrib/TEMPLATE_installer= and … … 1622 1625 1623 1626 The install script works using the dependency type and version fields. 1624 It will try to download from twiki.org to satisfy any missing dependencies.1627 It will try to download from foswiki.org to satisfy any missing dependencies. 1625 1628 Downloaded modules are automatically installed. 1626 1629 1627 1630 Note that the dependencies will only work if the module depended on follows 1628 1631 the naming standards for zips i.e. it must be attached to the topic in 1629 twiki.org and have the same name as the topic, and must be a zip file.1632 foswiki.org and have the same name as the topic, and must be a zip file. 1630 1633 1631 1634 Dependencies on CPAN modules are also checked (type perl) but no attempt … … 1668 1671 chop($dir); 1669 1672 my $file = 1670 $dir . '/lib/ TWiki/Contrib/BuildContrib/TEMPLATE_installer.pl';1673 $dir . '/lib/Foswiki/Contrib/BuildContrib/TEMPLATE_installer.pl'; 1671 1674 if ( -f $file ) { 1672 1675 $template = $file; … … 1712 1715 } 1713 1716 1714 =begin twiki1717 =begin foswiki 1715 1718 1716 1719 ---++++ build($target) … … 1738 1741 } 1739 1742 1740 =begin twiki1743 =begin foswiki 1741 1744 1742 1745 ---++++ target_manifest … … 1781 1784 1782 1785 sub _manicollect { 1783 if (/^(CVS|\.svn |twikiplugins)$/) {1786 if (/^(CVS|\.svn)$/) { 1784 1787 $File::Find::prune = 1; 1785 1788 } … … 1798 1801 } 1799 1802 1800 =begin twiki1803 =begin foswiki 1801 1804 1802 1805 #HistoryTarget … … 1812 1815 my $this = shift; 1813 1816 1814 my $f = $this->{basedir} . '/' . $this->{ data_twiki_module} . '.txt';1817 my $f = $this->{basedir} . '/' . $this->{topic_root} . '.txt'; 1815 1818 1816 1819 my $cmd = "cd $this->{basedir} && svn status"; … … 1947 1950 } 1948 1951 1949 =begin twiki1952 =begin foswiki 1950 1953 1951 1954 ---++++ target_dependencies … … 1966 1969 die "B::PerlReq is required for 'dependencies': $@" if $@; 1967 1970 1968 foreach my $m 1969 qw(strict vars diagnostics base bytes constant integer locale overload warnings Assert TWiki) 1970 { 1971 foreach my $m ( 1972 'strict', 1973 'vars', 1974 'diagnostics', 1975 'base', 1976 'bytes', 1977 'constant', 1978 'integer', 1979 'locale', 1980 'overload', 1981 'warnings', 1982 'Assert', 1983 $targetProject ) { 1971 1984 $this->{satisfied}{$m} = 1; 1972 1985 } … … 2053 2066 automatic installer script written using the Build<nop>Contrib. 2054 2067 * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions) 2055 * See the [[http:// nextwiki.org/Extensions/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.2068 * See the [[http://foswiki.org/Extensions/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information. 2056 2069 * If you have any problems, then you can still install manually from the command-line: 2057 2070 1 Download one of the =.zip= or =.tgz= archives
Note: See TracChangeset
for help on using the changeset viewer.
