Ignore:
Timestamp:
11/20/08 13:04:58 (4 years ago)
Author:
CrawfordCurrie
Message:

Item175: BuildContrib now builds both Foswiki and TWiki targeted plugins. If you want to target both, then target TWiki. TWiki plugins require the TWikiCompatibilityContrib to be installed.

Location:
trunk/BuildContrib/lib/Foswiki
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/BuildContrib/lib/Foswiki/Contrib/Build.pm

    r603 r827  
    1313# http://www.gnu.org/copyleft/gpl.html 
    1414# 
    15 package TWiki::Contrib::Build; 
    16  
    17 use TWiki::Contrib::BuildContrib::BaseBuild; 
     15package Foswiki::Contrib::Build; 
     16 
     17use Foswiki::Contrib::BuildContrib::BaseBuild; 
    1818use Error qw(:try); 
    1919use CGI qw(:any); 
    2020 
    21 =begin twiki 
    22  
    23 ---++ Package TWiki::Contrib::Build 
    24  
    25 This is a base class used for making build scripts for TWiki packages. 
     21=begin foswiki 
     22 
     23---++ Package Foswiki::Contrib::Build 
     24 
     25This is a base class used for making build scripts for Foswiki packages. 
    2626 
    2727---+++ Methods 
     
    4848# It is *not* used by the build automation tools, but is reported as part 
    4949# of the version number in PLUGINDESCRIPTIONS. 
    50 our $RELEASE = 'NextWiki-1'; 
     50our $RELEASE = 'Foswiki-1'; 
    5151 
    5252our $SHORTDESCRIPTION = 
    5353  'Automate build process for Plugins, Add-ons and Contrib modules'; 
    5454 
    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"; 
     55my $UPLOADSITEPUB    = 'http://foswiki.org/pub'; 
     56my $UPLOADSITESCRIPT = 'http://foswiki.org/bin'; 
     57my $UPLOADSITESUFFIX = ''; 
     58my $UPLOADSITEBUGS   = 'http://foswiki.org/Tasks'; 
     59my $UPLOADSITEEXTENSIONSWEB = "Extensions"; 
    6060 
    6161my $GLACIERMELT = 10;    # number of seconds to sleep between uploads, 
    6262                         # to reduce average load on server 
     63 
     64my $targetProject = 'Foswiki';# May change to 'TWiki' 
    6365 
    6466my $collector;           # general purpose handle for collecting stuff 
     
    9698 
    9799    # 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; 
    100106    $libpath =~ s#/[^/]*$##; 
    101107 
     
    103109    $basedir =~ s#/[^/]*$##; 
    104110 
    105     if ( $ENV{TWIKI_LIBS} ) { 
     111    my $env = $ENV{uc($targetProject).'_LIBS'}; 
     112    if ( $env ) { 
    106113        my %known; 
    107114        map { $known{$_} = 1 } split( /:/, @INC ); 
    108         foreach my $pc ( reverse split( /:/, $ENV{TWIKI_LIBS} ) ) { 
     115        foreach my $pc ( reverse split( /:/, $env ) ) { 
    109116            unless ( $known{$pc} ) { 
    110117                unshift( @INC, $pc ); 
     
    117124} 
    118125 
    119 =begin twiki 
     126=begin foswiki 
    120127 
    121128---++++ new($project) 
     
    134141 
    135142    # Constants with internet paths 
    136     $this->{BUGSURL} = $TWIKIORGBUGS; 
     143    $this->{BUGSURL} = $UPLOADSITEBUGS; 
    137144 
    138145    $this->{project} = $project; 
     
    160167    $this->{basedir} = $basedir; 
    161168 
    162     # The following paths are all relative to the root of the twiki 
     169    # The following paths are all relative to the root of the  
    163170    # installation 
    164171 
     
    167174    $this->{libdir} = $libpath; 
    168175    if ( $this->{project} =~ /Plugin$/ ) { 
    169         $this->{libdir} .= '/TWiki/Plugins'; 
     176        $this->{libdir} .= "/$targetProject/Plugins"; 
    170177    } 
    171178    elsif ( $this->{project} =~ /(Contrib|Skin)$/ ) { 
    172         $this->{libdir} .= '/TWiki/Contrib'; 
     179        $this->{libdir} .= "/$targetProject/Contrib"; 
    173180    } 
    174181 
     
    178185 
    179186    my $stubpath = $this->{pm}; 
    180     $stubpath =~ s/.*[\\\/](TWiki[\\\/].*)\.pm/$1/; 
     187    $stubpath =~ s/.*[\\\/]($targetProject[\\\/].*)\.pm/$1/; 
    181188    $stubpath =~ s/[\\\/]/::/g; 
    182189 
    183190    # where data files live 
    184     $this->{data_twiki} = 'data/TWiki'; 
     191    $this->{data_systemdir} = 
     192      ($targetProject eq 'TWiki') ? 'data/TWiki' : 'data/System'; 
    185193 
    186194    # 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}; 
    188196 
    189197    ############################################################## 
     
    192200    my $manifest = _findRelativeTo( $buildpldir, 'MANIFEST' ); 
    193201    if (!defined($manifest)) { 
    194         #the twiki core MANIFEST is in the lib dir, not the tools dir 
     202        #the core MANIFEST is in the lib dir, not the tools dir 
    195203        $manifest = _findRelativeTo( $libpath, 'MANIFEST' ); 
    196204    } 
    197205    ( $this->{files}, $this->{other_modules} ) = 
    198       TWiki::Contrib::BuildContrib::BaseBuild::readManifest( $this->{basedir}, 
     206      Foswiki::Contrib::BuildContrib::BaseBuild::readManifest( $this->{basedir}, 
    199207        '', $manifest, sub { exit(1) } ); 
    200208 
    201     # Generate a TWiki table representing the manifest contents 
     209    # Generate a table representing the manifest contents 
    202210    # and a hash table representing the files 
    203211    my $mantable  = ''; 
     
    221229    my $dependancies = _findRelativeTo( $buildpldir, 'DEPENDENCIES' ); 
    222230    if (!defined($dependancies)) { 
    223         #the twiki core DEPENDENCIES is in the lib dir, not the tools dir 
     231        #the core DEPENDENCIES is in the lib dir, not the tools dir 
    224232        $dependancies = _findRelativeTo( $libpath, 'DEPENDENCIES' ); 
    225233    } 
     
    297305    } 
    298306    else { 
    299         $this->{UPLOADTARGETPUB} = $TWIKIORGPUB 
     307        $this->{UPLOADTARGETPUB} = $UPLOADSITEPUB 
    300308          unless defined $this->{UPLOADTARGETPUB}; 
    301         $this->{UPLOADTARGETSCRIPT} = $TWIKIORGSCRIPT 
     309        $this->{UPLOADTARGETSCRIPT} = $UPLOADSITESCRIPT 
    302310          unless defined $this->{UPLOADTARGETSCRIPT}; 
    303         $this->{UPLOADTARGETSUFFIX} = $TWIKIORGSUFFIX 
     311        $this->{UPLOADTARGETSUFFIX} = $UPLOADSITESUFFIX 
    304312          unless defined $this->{UPLOADTARGETSUFFIX}; 
    305         $this->{UPLOADTARGETWEB} = $TWIKIORGEXTENSIONSWEB 
     313        $this->{UPLOADTARGETWEB} = $UPLOADSITEEXTENSIONSWEB 
    306314          unless defined $this->{UPLOADTARGETWEB}; 
    307315    } 
     
    504512} 
    505513 
    506 =begin twiki 
     514=begin foswiki 
    507515 
    508516---++++ pushd($dir) 
     
    523531} 
    524532 
    525 =begin twiki 
     533=begin foswiki 
    526534 
    527535---++++ popd() 
     
    544552} 
    545553 
    546 =begin twiki 
     554=begin foswiki 
    547555 
    548556---++++ rm($file) 
     
    567575} 
    568576 
    569 =begin twiki 
     577=begin foswiki 
    570578 
    571579---++++ makepath($to) 
     
    580588} 
    581589 
    582 =begin twiki 
     590=begin foswiki 
    583591 
    584592---++++ cp($from, $to) 
     
    617625} 
    618626 
    619 =begin twiki 
     627=begin foswiki 
    620628 
    621629---++++ prot($perms, $file) 
     
    632640} 
    633641 
    634 =begin twiki 
     642=begin foswiki 
    635643 
    636644---++++ sys_action(@params) 
     
    656664} 
    657665 
    658 =begin twiki 
     666=begin foswiki 
    659667 
    660668---++++ perl_action($cmd) 
     
    675683} 
    676684 
    677 =begin twiki 
     685=begin foswiki 
    678686 
    679687---++++ target_build 
     
    686694} 
    687695 
    688 =begin twiki 
     696=begin foswiki 
    689697 
    690698---++++ target_compress 
     
    715723} 
    716724 
    717 =begin twiki 
     725=begin foswiki 
    718726 
    719727---++++ target_tidy 
     
    762770} 
    763771 
    764 =begin twiki 
     772=begin foswiki 
    765773 
    766774---++++ target_test 
     
    814822} 
    815823 
    816 =begin twiki 
     824=begin foswiki 
    817825 
    818826---++++ filter_txt 
     
    834842 
    835843    # Replace the SVN revision with rev 1. 
    836     # In TWiki builds this gets replaced by latest revision later. 
     844    # In release builds this gets replaced by latest revision later. 
    837845    $text =~ s/^(%META:TOPICINFO{.*)\$Rev:.*\$(.*}%)$/${1}1$2/m; 
    838846    $text =~ s/%\$(\w+)%/&_expand($this,$1)/geo; 
     
    861869} 
    862870 
    863 =begin twiki 
     871=begin foswiki 
    864872 
    865873---++++ build_js 
     
    904912} 
    905913 
    906 =begin twiki 
     914=begin foswiki 
    907915 
    908916---++++ build_css 
     
    947955} 
    948956 
    949 =begin twiki 
     957=begin foswiki 
    950958 
    951959---++++ filter_pm($from, $to) 
     
    974982} 
    975983 
    976 =begin twiki 
     984=begin foswiki 
    977985 
    978986---++++ target_release 
     
    10001008} 
    10011009 
    1002 =begin twiki 
     1010=begin foswiki 
    10031011 
    10041012---++++ target_stage 
     
    10291037        } 
    10301038    } 
    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', 
    10331041            $this->{basedir} . '/' . $project . '.txt' ); 
    10341042    } 
     
    10401048            print STDERR "Installing $module in $this->{tmpDir}\n"; 
    10411049            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 twiki 
     1050`export FOSWIKI_HOME=$this->{tmpDir}; export FOSWIKI_LIBS=$libs; cd $basedir/$module; perl build.pl handsoff_install`; 
     1051        } 
     1052    } 
     1053} 
     1054 
     1055=begin foswiki 
    10481056 
    10491057---++++ target_archive 
     
    11191127} 
    11201128 
    1121 =begin twiki 
     1129=begin foswiki 
    11221130 
    11231131---++++ copy_fileset 
     
    11461154} 
    11471155 
    1148 =begin twiki 
     1156=begin foswiki 
    11491157 
    11501158---++++ apply_perms 
     
    11641172} 
    11651173 
    1166 =begin twiki 
     1174=begin foswiki 
    11671175 
    11681176---++++ target_handsoff_install 
    1169 Install target, installs to local twiki pointed at by TWIKI_HOME. 
     1177Install target, installs to local install pointed at by FOSWIKI_HOME. 
    11701178 
    11711179Does not run the installer script. 
     
    11771185    $this->build('release'); 
    11781186 
    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); 
    11821190    $this->sys_action( 'tar', 'zxpf', 
    11831191        $this->{basedir} . '/' . $this->{project} . '.tgz' ); 
    11841192 
    11851193    # kill off the module installer 
    1186     $this->rm( $twiki . '/' . $this->{project} . '_installer' ); 
     1194    $this->rm( $home . '/' . $this->{project} . '_installer' ); 
    11871195    $this->popd(); 
    11881196} 
    11891197 
    1190 =begin twiki 
     1198=begin foswiki 
    11911199 
    11921200---++++ target_install 
    1193 Install target, installs to local twiki pointed at by TWIKI_HOME. 
     1201Install target, installs to local twiki pointed at by FOSWIKI_HOME. 
    11941202 
    11951203Uses the installer script written by target_installer 
     
    12031211} 
    12041212 
    1205 =begin twiki 
     1213=begin foswiki 
    12061214 
    12071215---++++ target_uninstall 
    1208 Uninstall target, uninstall from local twiki pointed at by TWIKI_HOME. 
     1216Uninstall target, uninstall from local twiki pointed at by FOSWIKI_HOME. 
    12091217 
    12101218Uses the installer script written by target_installer 
     
    12141222sub target_uninstall { 
    12151223    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); 
    12191227    $this->sys_action( 'perl', $this->{project} . '_installer', 'uninstall' ); 
    12201228    $this->popd(); 
     
    12231231{ 
    12241232 
    1225     package TWiki::Contrib::Build::UserAgent; 
     1233    package Foswiki::Contrib::Build::UserAgent; 
    12261234    use base qw(LWP::UserAgent); 
    12271235 
     
    12961304} 
    12971305 
    1298 =begin twiki 
     1306=begin foswiki 
    12991307 
    13001308---++++ target_upload 
     
    13511359    $this->build('release'); 
    13521360    my $userAgent = 
    1353       new TWiki::Contrib::Build::UserAgent( $this->{UPLOADTARGETSCRIPT}, 
     1361      new Foswiki::Contrib::Build::UserAgent( $this->{UPLOADTARGETSCRIPT}, 
    13541362        $this ); 
    13551363    $userAgent->agent( 'ContribBuild/' . $VERSION . ' ' ); 
     
    13931401        $newform{'text'} = <IN_FILE>; 
    13941402        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, Item3454 
    1399         $newform{'text'} =~ s/^%META:TOPICINFO{.*}%$//m; 
    14001403    } 
    14011404    else { 
     
    14101413 
    14111414    # Upload any 'Var*.txt' topics published by the extension 
    1412     my $dataDir = $this->{basedir} . '/data/TWiki'; 
     1415    my $dataDir = $this->{basedir} . '/data/System'; 
    14131416    if ( opendir( DIR, $dataDir ) ) { 
    14141417        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 ) ) 
    14161419            { 
    14171420                %newform = ( text => <IN_FILE> ); 
     
    14451448 
    14461449            $this->_uploadAttachment( $userAgent, $user, $pass, $name, 
    1447                 $this->{basedir} . '/pub/TWiki/' . $this->{project} . '/' . $name, 
     1450                $this->{basedir} . '/pub/System/' . $this->{project} . '/' . $name, 
    14481451                $comment, $attrs =~ /h/ ? 1 : 0 ); 
    14491452            $uploaded{$name} = 1; 
     
    14751478 
    14761479If you want to report an error in the topic, please raise a report at 
    1477 http://nextwiki.org/view/Tasks/$this->{project} 
     1480http://foswiki.org/view/Tasks/$this->{project} 
    14781481--> 
    14791482EXTRA 
     
    15561559# is intended for use by developers only. 
    15571560 
    1558 # POD text in =.pm= files should use TWiki syntax or HTML. Packages should be 
     1561# POD text in =.pm= files should use TML syntax or HTML. Packages should be 
    15591562# introduced with a level 1 header, ---+, and each method in the package by 
    15601563# a level 2 header, ---++. Make sure you document any global variables used 
     
    15881591} 
    15891592 
    1590 =begin twiki 
     1593=begin foswiki 
    15911594 
    15921595---++++ target_POD 
    15931596 
    15941597Print POD documentation. This target does not modify any files, it simply 
    1595 prints the (TWiki format) POD. 
    1596  
    1597 POD text in =.pm= files should use TWiki syntax or HTML. Packages should be 
     1598prints the (TML format) POD. 
     1599 
     1600POD text in =.pm= files should use TML syntax or HTML. Packages should be 
    15981601introduced with a level 1 header, ---+, and each method in the package by 
    15991602a level 2 header, ---++. Make sure you document any global variables used 
     
    16081611} 
    16091612 
    1610 =begin twiki 
     1613=begin foswiki 
    16111614 
    16121615---++++ target_installer 
    16131616 
    16141617Write an install/uninstall script that checks dependencies, and optionally 
    1615 downloads and installs required zips from twiki.org. 
     1618downloads and installs required zips from foswiki.org. 
    16161619 
    16171620The install script is templated from =contrib/TEMPLATE_installer= and 
     
    16221625 
    16231626The install script works using the dependency type and version fields. 
    1624 It will try to download from twiki.org to satisfy any missing dependencies. 
     1627It will try to download from foswiki.org to satisfy any missing dependencies. 
    16251628Downloaded modules are automatically installed. 
    16261629 
    16271630Note that the dependencies will only work if the module depended on follows 
    16281631the 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. 
     1632foswiki.org and have the same name as the topic, and must be a zip file. 
    16301633 
    16311634Dependencies on CPAN modules are also checked (type perl) but no attempt 
     
    16681671        chop($dir); 
    16691672        my $file = 
    1670           $dir . '/lib/TWiki/Contrib/BuildContrib/TEMPLATE_installer.pl'; 
     1673          $dir . '/lib/Foswiki/Contrib/BuildContrib/TEMPLATE_installer.pl'; 
    16711674        if ( -f $file ) { 
    16721675            $template = $file; 
     
    17121715} 
    17131716 
    1714 =begin twiki 
     1717=begin foswiki 
    17151718 
    17161719---++++ build($target) 
     
    17381741} 
    17391742 
    1740 =begin twiki 
     1743=begin foswiki 
    17411744 
    17421745---++++ target_manifest 
     
    17811784 
    17821785sub _manicollect { 
    1783     if (/^(CVS|\.svn|twikiplugins)$/) { 
     1786    if (/^(CVS|\.svn)$/) { 
    17841787        $File::Find::prune = 1; 
    17851788    } 
     
    17981801} 
    17991802 
    1800 =begin twiki 
     1803=begin foswiki 
    18011804 
    18021805#HistoryTarget 
     
    18121815    my $this = shift; 
    18131816 
    1814     my $f = $this->{basedir} . '/' . $this->{data_twiki_module} . '.txt'; 
     1817    my $f = $this->{basedir} . '/' . $this->{topic_root} . '.txt'; 
    18151818 
    18161819    my $cmd = "cd $this->{basedir} && svn status"; 
     
    19471950} 
    19481951 
    1949 =begin twiki 
     1952=begin foswiki 
    19501953 
    19511954---++++ target_dependencies 
     
    19661969    die "B::PerlReq is required for 'dependencies': $@" if $@; 
    19671970 
    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 ) { 
    19711984        $this->{satisfied}{$m} = 1; 
    19721985    } 
     
    20532066automatic installer script written using the Build<nop>Contrib. 
    20542067   * 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. 
    20562069   * If you have any problems, then you can still install manually from the command-line: 
    20572070      1 Download one of the =.zip= or =.tgz= archives 
Note: See TracChangeset for help on using the changeset viewer.