Changeset 331


Ignore:
Timestamp:
03/02/08 00:25:28 (5 years ago)
Author:
bruno
Message:
  • Improvements for CMS support in 0.9.x serie (lots on CVS)
  • Use pod for pb documentation (modules to be done)
  • Use Getopt::Long and support now long options
  • pb_syntax now uses pod2usage
Location:
devel/pb
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb/bin/pb

    r329 r331  
    1111 
    1212use strict 'vars'; 
    13 use Getopt::Std; 
     13use Getopt::Long qw(:config auto_abbrev no_ignore_case); 
     14use Pod::Usage; 
    1415use Data::Dumper; 
    1516use English; 
     
    4041my $pbport;                 # Port to use to connect to the VM 
    4142my $newver;                 # New version to create 
    42 my $iso;                    # ISO iage for the VM to create 
     43my $iso;                    # ISO image for the VM to create 
    4344 
    4445my @date = pb_get_date(); 
    4546my $pbdate = strftime("%Y-%m-%d", @date); 
    4647 
    47 getopts('a:fhi:l:m:P:p:qr:s:tvV:',\%opts); 
     48# --------------------------------------------------------------------------- 
     49 
     50=pod 
     51 
     52=head1 NAME 
     53 
     54pb, aka project-builder.org - builds packages for your projects 
     55 
     56=head1 DESCRIPTION 
     57 
     58pb helps you build various packages directly from your project sources.  
     59Those sources could be handled by a CMS (Configuration Management System) 
     60such as Subversion, CVS, ... or being a simple reference to a compressed tar file. 
     61It's based on a set of configuration files, a set of provided macros to help  
     62you keeping build files as generic as possible. For example, a single .spec 
     63file should be required to generate for all rpm based distributions, even  
     64if you could also have multiple .spec files if required. 
     65 
     66=head1 SYNOPSIS 
     67 
     68pb [-vhq][-r pbroot][-p project][[-s script -a account -P port] -m \"mach-1[,...]\"][-i iso] <action> [<pkg1> ...] 
     69 
     70pb [--verbose][--help][--man][--quiet][--revision pbroot][--project project][[--script script --account account --port port] --machine \"mach-1[,...]\"][--iso iso] <action> [<pkg1> ...] 
     71 
     72=head1 OPTIONS 
     73 
     74=over 4 
     75 
     76=item B<-v|--verbose> 
     77 
     78Print a brief help message and exits. 
     79 
     80=item B<-q|--quiet> 
     81 
     82Do not print any output. 
     83 
     84=item B<-h|--help> 
     85 
     86Print a brief help message and exits. 
     87 
     88=item B<--man> 
     89 
     90Prints the manual page and exits. 
     91 
     92=item B<-m|--machine machine1[,machine2,...]> 
     93 
     94Name of the Virtual Machines (VM) or Virtual Environments (VE) you want to build on (coma separated).  
     95All if none precised (or use the env variable PBV). 
     96 
     97=item B<-s|--script script> 
     98 
     99Name of the script you want to execute on the related VMs or VEs. 
     100 
     101=item B<-i|--iso iso_image> 
     102 
     103Name of the ISO image of the distribution you want to install on the related VMs. 
     104 
     105=item B<-a|--account account> 
     106 
     107Name of the account to use to connect on the related VMs. 
     108 
     109=item B<-P|--port port_number> 
     110 
     111Port number to use to connect on the related VMs.\n"; 
     112 
     113=item B<-p|--project project_name> 
     114 
     115Name of the project you're working on (or use the env variable PBPROJ) 
     116 
     117=item B<-r|--revision revision> 
     118 
     119Path Name of the project revision under the CMS (or use the env variable PBROOT) 
     120 
     121=item B<-V|--version new_version> 
     122 
     123New version of the project to create based on the current one. 
     124 
     125=back  
     126 
     127=head1 ARGUMENTS 
     128 
     129<action> can be: 
     130 
     131=over 4 
     132 
     133=item B<cms2build> 
     134 
     135Create tar files for the project under your CMS.  
     136CMS supported are SVN and CVS 
     137parameters are packages to build 
     138if not using default list 
     139 
     140=item B<build2pkg> 
     141 
     142Create packages for your running distribution 
     143 
     144=item B<cms2pkg> 
     145 
     146cms2build + build2pkg 
     147 
     148=item B<build2ssh> 
     149 
     150Send the tar files to a SSH host 
     151 
     152=item B<cms2ssh> 
     153 
     154cms2build + build2ssh 
     155 
     156=item B<pkg2ssh> 
     157 
     158Send the packages built to a SSH host 
     159 
     160=item B<build2vm> 
     161 
     162Create packages in VMs, launching them if needed 
     163and send those packages to a SSH host once built 
     164VM type supported are QEMU 
     165 
     166=item B<build2ve> 
     167 
     168Create packages in VEs, creating it if needed 
     169and send those packages to a SSH host once built 
     170 
     171=item B<cms2vm> 
     172 
     173cms2build + build2vm 
     174 
     175=item B<cms2ve> 
     176 
     177cms2build + build2ve 
     178 
     179=item B<launchvm> 
     180 
     181Launch one virtual machine 
     182 
     183=item B<launchve> 
     184 
     185Launch one virtual environment 
     186 
     187=item B<script2vm> 
     188 
     189Launch one virtual machine if needed 
     190and executes a script on it 
     191 
     192=item B<script2ve> 
     193 
     194Execute a script in a virtual environment 
     195 
     196=item B<newvm> 
     197 
     198Create a new virtual machine 
     199 
     200=item B<newve> 
     201 
     202Create a new virtual environment 
     203 
     204=item B<newver> 
     205 
     206Create a new version of the project derived 
     207from the current one 
     208 
     209=item B<newproj> 
     210 
     211Create a new project and a template set of 
     212configuration files under pbconf 
     213 
     214=back  
     215 
     216<pkgs> can be a list of packages, the keyword 'all' or nothing, in which case the default list of packages is taken (corresponding to the defpkgdir list of arguments in the configuration file). 
     217 
     218=head1 WEB SITES 
     219 
     220The main Web site of the project is available at L<http://www.project-builder.org/>. Bug reports should be filled using the trac instance of the project at L<http://trac.project-builder.org/>. 
     221 
     222=head1 USER MAILING LIST 
     223 
     224None exists for the moment. 
     225 
     226=head1 CONFIGURATION FILES 
     227 
     228Each pb user may have a configuration in F<$HOME/.pbrc>. The values in this file may overwrite any other configuration file value.  
     229 
     230Here is an example of such a configuration file: 
     231 
     232 # 
     233 # Define for each project the URL of its pbconf repository 
     234 # No default option allowed here as they need to be all different 
     235 # 
     236 # URL of the pbconf content 
     237 # This is the format of a classical URL with the extension of additional schema such as  
     238 # svn+ssh, cvs+ssh, ... 
     239 # 
     240 pbconfurl linuxcoe = cvs+ssh://:ext:bcornec@linuxcoe.cvs.sourceforge.net:/cvsroot/linuxcoe/pbconf 
     241 
     242 # This is normaly defined in the project's configuration file 
     243 # Url of the project 
     244 # 
     245 pburl linuxcoe = cvs+ssh://:ext:bcornec@linuxcoe.cvs.sourceforge.net:/cvsroot/linuxcoe 
     246  
     247 # All these URLs needs to be defined here as the are the entry point  
     248 # for how to build packages for the project 
     249 # 
     250 pbconfurl pb = svn+ssh://svn.project-builder.org/mondo/svn/pb/pbconf 
     251 pbconfurl mondorescue = svn+ssh://svn.project-builder.org/mondo/svn/project-builder/mondorescue/pbconf 
     252 pbconfurl collectl = svn+ssh://bruno@svn.mondorescue.org/mondo/svn/project-builder/collectl/pbconf 
     253 pbconfurl netperf = svn+ssh://svn.mondorescue.org/mondo/svn/project-builder/netperf/pbconf 
     254  
     255 # Under that dir will take place everything related to pb 
     256 # If you want to use VMs/chroot/..., then use $ENV{'HOME'} to make it portable 
     257 # to your VMs/chroot/... 
     258 # if not defined then /var/cache 
     259 pbdefdir default = $ENV{'HOME'}/project-builder 
     260 pbdefdir pb = $ENV{'HOME'} 
     261 pbdefdir linuxcoe = $ENV{'HOME'}/LinuxCOE/cvs 
     262 pbdefdir mondorescue = $ENV{'HOME'}/mondo/svn 
     263  
     264 # pbconfdir points to the directory where the CMS content of the pbconfurl is checked out 
     265 # If not defined, pbconfdir is under pbdefdir/pbproj/pbconf 
     266 pbconfdir linuxcoe = $ENV{'HOME'}/LinuxCOE/cvs/pbconf 
     267 pbconfdir mondorescue = $ENV{'HOME'}/mondo/svn/pbconf 
     268  
     269 # pbdir points to the directory where the CMS content of the pburl is checked out 
     270 # If not defined, pbdir is under pbdefdir/pbproj 
     271 # Only defined if we have access to the dev of the project 
     272 pbdir linuxcoe = $ENV{'HOME'}/LinuxCOE/cvs 
     273 pbdir mondorescue = $ENV{'HOME'}/mondo/svn 
     274  
     275 # -daemonize doesn't work with qemu 0.8.2 
     276 vmopt default = -m 384 
     277 
     278=head1 AUTHORS 
     279 
     280The Project-Builder.org team L<http://trac.project-builder.org/> lead by Bruno Cornec L<mailto:bruno@project-builder.org>. 
     281 
     282=head1 COPYRIGHT 
     283 
     284Project-Builder.org is distributed under the GPL v2.0 license 
     285described in the file C<COPYING> included with the distribution. 
     286 
     287=cut 
     288 
     289# --------------------------------------------------------------------------- 
     290 
     291# Old syntax 
     292#getopts('a:fhi:l:m:P:p:qr:s:vV:',\%opts); 
    48293 
    49294my ($projectbuilderver,$projectbuilderrev) = pb_version_init(); 
     295 
     296GetOptions("help|?|h" => \$opts{'h'},  
     297        "man" => \$opts{'man'}, 
     298        "verbose|v+" => \$opts{'v'}, 
     299        "quiet|q" => \$opts{'q'}, 
     300        "log-files|l=s" => \$opts{'l'}, 
     301        "force|f" => \$opts{'f'}, 
     302        "account|a=s" => \$opts{'a'}, 
     303        "revision|r=s" => \$opts{'r'}, 
     304        "script|s=s" => \$opts{'s'}, 
     305        "machines|mock|m=s" => \$opts{'m'}, 
     306        "port|P=i" => \$opts{'P'}, 
     307        "project|p=s" => \$opts{'p'}, 
     308        "iso|i=s" => \$opts{'i'}, 
     309        "version|V=s" => \$opts{'V'}, 
     310) || pb_syntax(-1,0); 
     311 
    50312if (defined $opts{'h'}) { 
    51     pb_syntax(); 
    52     exit(0); 
     313    pb_syntax(0,1); 
     314} 
     315if (defined $opts{'man'}) { 
     316    pb_syntax(0,2); 
    53317} 
    54318if (defined $opts{'v'}) { 
    55     $debug = 2; 
    56     #$debug = $opts{'v'}; 
     319    $debug = $opts{'v'}; 
    57320    pb_log(0,"Debug value: $debug\n"); 
    58321} 
     
    70333pb_log_init($debug, $LOG); 
    71334 
    72 # Handles test option 
    73 if (defined $opts{'t'}) { 
    74     $test = "TRUE"; 
    75     # Works only for SVN 
    76     $option = "-r BASE"; 
    77 } 
    78  
    79335# Handle root of the project if defined 
    80336if (defined $opts{'r'}) { 
     
    103359# Get Action 
    104360$action = shift @ARGV; 
    105 die pb_syntax() if (not defined $action); 
     361die pb_syntax(-1,1) if (not defined $action); 
    106362 
    107363my ($filteredfiles, $supfiles, $defpkgdir, $extpkgdir); 
     
    170426} else { 
    171427    pb_log(0,"\'$action\' is not available\n"); 
    172     pb_syntax(); 
     428    pb_syntax(-2,1); 
    173429} 
    174430 
     
    177433    my $ptr = pb_get_pkg($defpkgdir,$extpkgdir); 
    178434    @pkgs = @$ptr; 
    179     my ($scheme,$uri)=pb_cms_init($ENV{'PBPROJ'}); 
     435    my ($uri) = pb_conf_get("pburl"); 
     436    my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri->{$ENV{'PBPROJ'}}); 
    180437 
    181438    # 
    182439    # Check project cms compliance 
    183440    # 
    184     pb_cms_compliant("pbdir",'PBDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}",$uri,$pbinit); 
     441    pb_cms_compliant("pbdir",'PBDIR',"$ENV{'PBDEFDIR'}/$ENV{'PBPROJ'}",$uri->{$ENV{'PBPROJ'}},$pbinit); 
     442 
     443    # Some variable initialization depending on CMS type 
     444    pb_cms_init($scheme); 
    185445 
    186446    my ($pkgv, $pkgt) = pb_conf_get_if("pkgver","pkgtag"); 
     
    225485 
    226486        # If it isn't a flat CMS, then we have the choice to export subdir 
    227         #$dir = "$uri/$dir" if ($ENV{'PBREVISION'} ne "flat"); 
    228         pb_cms_export($uri,"$ENV{'PBDIR'}/$pbprojver/$dir",$dest); 
     487        pb_cms_export($uri->{$ENV{'PBPROJ'}},"$ENV{'PBDIR'}/$pbprojver/$dir",$dest); 
    229488 
    230489        # Get project info on authors and log file 
     
    9051164    my $res = pb_cms_isdiff($scheme); 
    9061165    die "You need to have no differences before creating a new version" if ($res != 0); 
    907     my $cmsurl = pb_cms_getinfo($scheme,$ENV{'PBROOT'},"URL:"); 
     1166    my $cmsurl = pb_cms_get_uri($scheme,$ENV{'PBROOT'}); 
    9081167    my $newurl = dirname($cmsurl)."/$newver"; 
    9091168    pb_cms_copy($scheme,$cmsurl,$newurl); 
     
    11411400} 
    11421401 
     1402 
    11431403sub pb_syntax { 
    11441404 
    1145     print "pb (aka project-builder) Version $projectbuilderver-$projectbuilderrev\n"; 
    1146     print "\n"; 
    1147     print "Syntax: pb [-vhqt][-r pbroot][-p project][[-s script -a account -P port] -m \"mach-1[,...]\"][-i iso] <action> [<pkg1> ...]\n"; 
    1148     print "\n"; 
    1149     print "-h: This help file\n"; 
    1150     print "-q: Quiet mode\n"; 
    1151     print "-t: Test mode (not done yet)\n"; 
    1152     print "-v: Verbose mode\n"; 
    1153     print "\n"; 
    1154     print "-m machine: Name of the Virtual Machines (VM) you want\n"; 
    1155     print "            to build on (coma separated). All if none precised\n"; 
    1156     print "            (or use the env variable PBV)       \n"; 
    1157     print "\n"; 
    1158     print "-s script:  Name of the script you want\n"; 
    1159     print "            to execute on the related VMs.\n"; 
    1160     print "\n"; 
    1161     print "-i iso:     Name of the ISO image of the distribution you want\n"; 
    1162     print "            to install on the related VMs.\n"; 
    1163     print "\n"; 
    1164     print "-a account: Name of the account to use\n"; 
    1165     print "            to connect on the related VMs.\n"; 
    1166     print "\n"; 
    1167     print "-P port:    Port number to use\n"; 
    1168     print "            to connect on the related VMs.\n"; 
    1169     print "\n"; 
    1170     print "-p project: Name of the project you're working on\n"; 
    1171     print "            (or use the env variable PBPROJ)     \n"; 
    1172     print "\n"; 
    1173     print "-r pbroot:  Path Name of project under the CMS \n"; 
    1174     print "            (or use the env variable PBROOT)   \n"; 
    1175     print "\n"; 
    1176     print "-V newver:  New version of the project to create\n"; 
    1177     print "            from the current one.              \n"; 
    1178     print "\n"; 
    1179     print "<action> can be:\n"; 
    1180     print "\n"; 
    1181     print "\tcms2build:    Create tar files for the project under your CMS\n"; 
    1182     print "\t              CMS supported are SVN and CVS\n"; 
    1183     print "\t              parameters are packages to build\n"; 
    1184     print "\t              if not using default list\n"; 
    1185     print "\n"; 
    1186     print "\tbuild2pkg:    Create packages for your running distribution  \n"; 
    1187     print "\n"; 
    1188     print "\tcms2pkg:      cms2build + build2pkg\n"; 
    1189     print "\n"; 
    1190     print "\tbuild2ssh:    Send the tar files to a SSH host               \n"; 
    1191     print "\n"; 
    1192     print "\tcms2ssh:      cms2build + build2ssh\n"; 
    1193     print "\n"; 
    1194     print "\tpkg2ssh:      Send the packages built to a SSH host          \n"; 
    1195     print "\n"; 
    1196     print "\tbuild2vm:     Create packages in VMs, launching them if needed\n"; 
    1197     print "\t              and send those packages to a SSH host once built\n"; 
    1198     print "\t              VM type supported are QEMU            \n"; 
    1199     print "\n"; 
    1200     print "\tbuild2ve:     Create packages in VEs, creating it if needed\n"; 
    1201     print "\t              and send those packages to a SSH host once built\n"; 
    1202     print "\n"; 
    1203     print "\tcms2vm:       cms2build + build2vm\n"; 
    1204     print "\n"; 
    1205     print "\tcms2ve:       cms2build + build2ve\n"; 
    1206     print "\n"; 
    1207     print "\tlaunchvm:     Launch one virtual machine\n"; 
    1208     print "\n"; 
    1209     print "\tlaunchve:     Launch one virtual environment\n"; 
    1210     print "\n"; 
    1211     print "\tscript2vm:    Launch one virtual machine if needed        \n"; 
    1212     print "\t              and executes a script on it                 \n"; 
    1213     print "\n"; 
    1214     print "\tscript2ve:    Execute a script in a virtual environment       \n"; 
    1215     print "\n"; 
    1216     print "\tnewvm:        Create a new virtual machine\n"; 
    1217     print "\n"; 
    1218     print "\tnewve:        Create a new virtual environment\n"; 
    1219     print "\n"; 
    1220     print "\tnewver:       Create a new version of the project derived \n"; 
    1221     print "\t              from the current one                        \n"; 
    1222     print "\n"; 
    1223     print "\tnewproj:      Create a new project and a template set of  \n"; 
    1224     print "\t              configuration files under pbconf            \n"; 
    1225     print "\n"; 
    1226 } 
     1405my $exit_status = shift || -1; 
     1406my $verbose_level = shift || 0; 
     1407 
     1408my $filehandle = \*STDERR; 
     1409 
     1410$filehandle = \*STDOUT if ($exit_status == 0); 
     1411 
     1412pod2usage( { -message => "pb (aka project-builder.org) Version $projectbuilderver-$projectbuilderrev\n", 
     1413             -exitval => $exit_status  , 
     1414             -verbose => $verbose_level, 
     1415             -output  => $filehandle } ); 
     1416} 
     1417 
     1418 
  • devel/pb/lib/ProjectBuilder/Base.pm

    r328 r331  
    3232 
    3333our @ISA = qw(Exporter); 
    34 our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg pb_cms_compliant $debug $LOG); 
     34our @EXPORT = qw(pb_env_init pb_conf_read pb_conf_read_if pb_conf_get pb_conf_get_if pb_cms_init pb_mkdir_p pb_system pb_rm_rf pb_get_filters pb_filter_file pb_filter_file_pb pb_filter_file_inplace pb_cms_export pb_cms_log pb_cms_isdiff pb_cms_copy pb_cms_checkout pb_get_date pb_log pb_log_init pb_get_pkg pb_cms_compliant pb_get_uri pb_cms_get_uri $debug $LOG); 
    3535 
    3636$ENV{'PBETC'} = "$ENV{'HOME'}/.pbrc"; 
     
    8787# Tree will look like this: 
    8888# 
    89 #             maint pbdefdir                         PBDEFDIR            dev dir (optional)   PBDEVDIR 
     89#             maint pbdefdir                         PBDEFDIR            dev dir (optional) 
    9090#                  |                                                        | 
    9191#            ------------------------                                -------------------- 
    9292#            |                      |                                |                  | 
    93 #         pbproj1                pbproj2             PBPROJ       pbproj1           pbproj2   PBDEVPROJ 
     93#         pbproj1                pbproj2             PBPROJ       pbproj1           pbproj2 
    9494#            |                                                       | 
    9595#  ---------------------------------------------                ---------- 
    9696#  *      *        *       |        |          |                *        * 
    97 # tag    dev    pbconf    ...     build     delivery PBCONF    dev      tag                   PBDEVROOT 
     97# tag    dev    pbconf    ...     build     delivery PBCONF    dev      tag                   
    9898#  |               |                           |     PBDESTDIR           | 
    9999#  ---          ------                        pbrc   PBBUILDDIR       ------- 
    100100#    |          |    |                                                |     | 
    101 #   1.1        dev  tag                              PBROOT          1.0   1.1 
     101#   1.1        dev  tag                              PBROOT          1.0   1.1                PBDIR 
    102102#                    | 
    103103#                 ------- 
     
    989989sub pb_cms_init { 
    990990 
    991 my $proj = shift || undef; 
    992  
    993 # Use the project URI 
    994 my ($uri) = pb_conf_get("pburl"); 
    995  
    996 # Extract values from that URI 
    997 my ($scheme, $account, $host, $port, $path) = pb_get_uri($uri->{$ENV{'PBPROJ'}}); 
     991my $scheme = shift || undef; 
    998992 
    999993if ($scheme =~ /^svn/) { 
    1000     $ENV{'PBREVISION'}= pb_cms_getinfo($scheme,$uri->{$ENV{'PBPROJ'}},"Revision:"); 
    1001     #$ENV{'PBREVISION'}=`(cd "$ENV{'PBDEVDIR'}" ; svnversion .)`; 
     994    # svnversion more precise than svn info 
     995    my $tmp = `(cd "$ENV{'PBDIR'}" ; svnversion .)`; 
     996    chomp($tmp); 
     997    $ENV{'PBREVISION'}=$tmp; 
    1002998    $ENV{'PBCMSLOGFILE'}="svn.log"; 
    1003999} elsif (($scheme eq "file") || ($scheme eq "ftp") || ($scheme eq "http")) { 
    10041000    $ENV{'PBREVISION'}="flat"; 
    10051001    $ENV{'PBCMSLOGFILE'}="flat.log"; 
    1006 } elsif ($scheme eq "cvs") { 
     1002} elsif ($scheme =~ /^cvs/) { 
    10071003    # Way too slow 
    10081004    #$ENV{'PBREVISION'}=`(cd "$ENV{'PBROOT'}" ; cvs rannotate  -f . 2>&1 | awk '{print \$1}' | grep -E '^[0-9]' | cut -d. -f2 |sort -nu | tail -1)`; 
    10091005    #chomp($ENV{'PBREVISION'}); 
    1010     $ENV{'PBREVISION'}="CVS"; 
     1006    $ENV{'PBREVISION'}="cvs"; 
    10111007    $ENV{'PBCMSLOGFILE'}="cvs.log"; 
    1012     # 
    1013     # Export content if needed 
    1014     # 
    1015     my ($cvsrsh) = pb_conf_get_if("cvsrsh"); 
    1016     $ENV{'CVS_RSH'} = $cvsrsh->{$proj} if (defined $cvsrsh->{$proj}); 
     1008    $ENV{'CVS_RSH'} = "ssh" if ($scheme =~ /ssh/); 
    10171009} else { 
    10181010    die "cms $scheme unknown"; 
    10191011} 
    1020  
    1021 return($scheme,$uri->{$ENV{'PBPROJ'}}); 
    10221012} 
    10231013 
     
    10991089        pb_rm_rf("$destdir/$d0"); 
    11001090    } 
    1101 } elsif ($scheme eq "cvs") { 
     1091} elsif ($scheme =~ /^cvs/) { 
     1092    # CVS needs a relative path ! 
    11021093    my $dir=dirname($destdir); 
    11031094    my $base=basename($destdir); 
     1095    # CVS also needs a modules name not a dir 
    11041096    if (-d $source) { 
    11051097        $tmp1 = $source; 
    11061098        $tmp1 =~ s|$ENV{'PBROOT'}/||; 
     1099        $tmp1 =~ s|$ENV{'PBDIR'}/||; 
    11071100    } else { 
    11081101        $tmp1 = dirname($source); 
    11091102        $tmp1 =~ s|$ENV{'PBROOT'}/||; 
     1103        $tmp1 =~ s|$ENV{'PBDIR'}/||; 
    11101104        $tmp1 = $tmp1."/".basename($source); 
    11111105    } 
    1112     # CVS needs a relative path ! 
    1113     my ($cvsroot) = pb_conf_get("cvsroot"); 
    11141106    my $pbdate = strftime("%Y-%m-%d %H:%M:%S", @date); 
    1115     pb_system("cd $dir ; cvs -d $cvsroot->{$ENV{'PBPROJ'}} export -D \"$pbdate\" -d $base $tmp1","Exporting $source from CVS to $destdir"); 
     1107    pb_system("cd $dir ; cvs -d $account\@$host:$path export -D \"$pbdate\" -d $base $tmp1","Exporting $source from CVS to $destdir"); 
    11161108} else { 
    11171109    die "cms $scheme unknown"; 
     
    11681160    if (! -f "$dest/ChangeLog") { 
    11691161        if (-x "/usr/bin/svn2cl") { 
     1162            # In case we have no network, just create an empty one before to allow correct build 
     1163            open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog"; 
     1164            close(CL); 
    11701165            pb_system("/usr/bin/svn2cl --group-by-day --authors=$authors -i -o $dest/ChangeLog $pkgdir","Generating ChangeLog from SVN with svn2cl"); 
    11711166        } else { 
     
    11781173        pb_system("echo ChangeLog for $pkgdir > $dest/ChangeLog","Empty ChangeLog file created"); 
    11791174    } 
    1180 } elsif ($scheme eq "cvs") { 
     1175} elsif ($scheme =~ /^cvs/) { 
    11811176    my $tmp=basename($pkgdir); 
    11821177    # CVS needs a relative path ! 
    11831178    if (! -f "$dest/ChangeLog") { 
    11841179        if (-x "/usr/bin/cvs2cl") { 
     1180            # In case we have no network, just create an empty one before to allow correct build 
     1181            open(CL,"> $dest/ChangeLog") || die "Unable to create $dest/ChangeLog"; 
     1182            close(CL); 
    11851183            pb_system("/usr/bin/cvs2cl --group-by-day -U $authors -f $dest/ChangeLog $pkgdir","Generating ChangeLog from CVS with cvs2cl"); 
    11861184        } else { 
     
    11941192} 
    11951193 
    1196 sub pb_cms_getinfo { 
     1194sub pb_cms_get_uri { 
    11971195 
    11981196my $scheme = shift; 
    11991197my $dir = shift; 
    1200 my $info = shift || "URL:"; 
    12011198 
    12021199my $res = ""; 
     
    12061203    open(PIPE,"LANGUAGE=C svn info $dir |") || return(""); 
    12071204    while (<PIPE>) { 
    1208         ($void,$res) = split(/^$info/) if (/^$info/); 
     1205        ($void,$res) = split(/^URL:/) if (/^URL:/); 
    12091206    } 
    12101207    $res =~ s/^\s*//; 
     
    12121209    chomp($res); 
    12131210} elsif ($scheme eq "flat") { 
    1214 } elsif ($scheme eq "cvs") { 
     1211    $res = "flat"; 
     1212} elsif ($scheme =~ /^cvs/) { 
     1213    # This path is always the root path of CVS, but we may be below 
     1214    open(FILE,"$dir/CVS/Root") || die "$dir isn't CVS controlled"; 
     1215    $res = <FILE>; 
     1216    chomp($res); 
     1217    close(FILE); 
     1218    # Find where we are in the tree 
     1219    my $rdir = $dir; 
     1220    while ((! -d "$rdir/CVSROOT") && ($rdir ne "/")) { 
     1221        $rdir = dirname($rdir); 
     1222    } 
     1223    die "Unable to find a CVSROOT dir in the parents of $dir" if (! -d "$rdir/CVSROOT"); 
     1224    #compute our place under that root dir - should be a relative path 
     1225    $dir =~ s|^$rdir||; 
     1226    my $suffix = ""; 
     1227    $suffix = "$dir" if ($dir ne ""); 
     1228 
     1229    my $prefix = ""; 
     1230    if ($scheme =~ /ssh/) { 
     1231        $prefix = "cvs+ssh://"; 
     1232    } else { 
     1233        $prefix = "cvs://"; 
     1234    } 
     1235    $res = $prefix.$res.$suffix; 
    12151236} else { 
    12161237    die "cms $scheme unknown"; 
     
    12251246my $newurl = shift; 
    12261247 
    1227 if ($scheme eq "svn") { 
     1248if ($scheme =~ /^svn/) { 
    12281249    pb_system("svn copy -m \"Creation of $newurl from $oldurl\" $oldurl $newurl","Copying $oldurl to $newurl "); 
    12291250} elsif ($scheme eq "flat") { 
    1230 } elsif ($scheme eq "cvs") { 
     1251} elsif ($scheme =~ /^cvs/) { 
    12311252} else { 
    12321253    die "cms $scheme unknown"; 
     
    12421263    pb_system("svn co $url $destination","Checking out $url to $destination "); 
    12431264} elsif ($scheme eq "flat") { 
    1244 } elsif ($scheme eq "cvs") { 
     1265} elsif ($scheme =~ /^cvs/) { 
    12451266} else { 
    12461267    die "cms $scheme unknown"; 
     
    12531274 
    12541275my $ver = basename($dir); 
    1255 if ($scheme eq "svn") { 
     1276if ($scheme =~ /^svn/) { 
    12561277    pb_system("svn ci -m \"Updated to $ver\" $dir","Checking in $dir"); 
    12571278    pb_system("svn up $dir","Updating $dir"); 
    12581279} elsif ($scheme eq "flat") { 
    1259 } elsif ($scheme eq "cvs") { 
     1280} elsif ($scheme =~ /^cvs/) { 
    12601281} else { 
    12611282    die "cms $scheme unknown"; 
     
    12661287my $scheme = shift; 
    12671288 
    1268 if ($scheme eq "svn") { 
     1289if ($scheme =~ /^svn/) { 
    12691290    open(PIPE,"svn diff $ENV{'PBROOT'} |") || die "Unable to get svn diff from $ENV{'PBROOT'}"; 
    12701291    my $l = 0; 
     
    12741295    return($l); 
    12751296} elsif ($scheme eq "flat") { 
    1276 } elsif ($scheme eq "cvs") { 
     1297} elsif ($scheme =~ /^cvs/) { 
    12771298} else { 
    12781299    die "cms $scheme unknown"; 
     
    15291550} else { 
    15301551    pb_log(1,"$uri found locally, checking content\n"); 
    1531     my $cmsurl = pb_cms_getinfo($scheme,$ENV{$envar},"URL:"); 
     1552    my $cmsurl = pb_cms_get_uri($scheme,$ENV{$envar}); 
    15321553    my ($scheme2, $account2, $host2, $port2, $path2) = pb_get_uri($cmsurl); 
    15331554    if ($cmsurl ne $uri) { 
Note: See TracChangeset for help on using the changeset viewer.