| 1 | package LCFG::Build::VCS::None; # -*-perl-*- | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # $Id: None.pm.in 35424 2019-01-18 10:01:16Z squinney@INF.ED.AC.UK $ | ||||||||||
| 6 | # $Source: /var/cvs/dice/LCFG-Build-VCS/lib/LCFG/Build/VCS/None.pm.in,v $ | ||||||||||
| 7 | # $Revision: 35424 $ | ||||||||||
| 8 | # $HeadURL: https://svn.lcfg.org/svn/source/tags/LCFG-Build-VCS/LCFG_Build_VCS_0_3_8/lib/LCFG/Build/VCS/None.pm.in $ | ||||||||||
| 9 | # $Date: 2019-01-18 10:01:16 +0000 (Fri, 18 Jan 2019) $ | ||||||||||
| 10 | |||||||||||
| 11 | 1 | our $VERSION = '0.3.8'; | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use v5.10; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use File::Copy::Recursive v0.36 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use File::HomeDir v0.58 (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 1 | ▶ | use File::Path (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 1 | ▶ | use File::Spec (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use IO::Dir (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | with 'LCFG::Build::VCS'; | |||||||||
| 23 | |||||||||||
| 24 | has 'tagdir' => ( | ||||||||||
| 25 | is => 'rw', | ||||||||||
| 26 | isa => 'Str', | ||||||||||
| 27 | lazy => 1, | ||||||||||
| 28 | 0 | ▶ | default => sub { File::Spec->catdir( File::HomeDir->my_home(), | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 29 | 'lcfgbuild', 'tags' ) }, | ||||||||||
| 30 | 1 | ); | |||||||||
| 31 | |||||||||||
| 32 | 1 | has '+id' => ( default => 'None' ); | |||||||||
| 33 | |||||||||||
| 34 | # This should give a speed-up in loading | ||||||||||
| 35 | |||||||||||
| 36 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 37 | |||||||||||
| 38 | sub checkcommitted { | ||||||||||
| 39 | 0 | ▶ | return 1; | ||||||||
|
Subroutine
checkcommitted: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | sub genchangelog { | ||||||||||
| 43 | 0 | ▶ | return; | ||||||||
|
Subroutine
genchangelog: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | sub run_cmd { | ||||||||||
| 47 | 0 | ▶ | return; | ||||||||
|
Subroutine
run_cmd: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub tagversion { | ||||||||||
| 51 | 0 | ▶ | my ( $self, $version ) = @_; | ||||||||
|
Subroutine
tagversion: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | my $module = $self->module; | |||||||||
| 54 | |||||||||||
| 55 | 0 | $self->update_changelog($version); | |||||||||
| 56 | |||||||||||
| 57 | 0 | my $tag = $self->gen_tag($version); | |||||||||
| 58 | 0 | my $tagdir = File::Spec->catdir( $self->tagdir, $module, $tag ); | |||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | if ( !$self->dryrun ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 61 | 0 | ▶ | if ( -d $tagdir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 0 | File::Path::rmtree($tagdir); | |||||||||
| 63 | } | ||||||||||
| 64 | 0 | ▶ | File::Copy::Recursive::dircopy( $self->workdir, $tagdir ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | or die "Could not tag $module at $version\n"; | ||||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | return; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | sub export { | ||||||||||
| 72 | 0 | ▶ | my ( $self, $version, $builddir ) = @_; | ||||||||
|
Subroutine
export: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||
| 73 | |||||||||||
| 74 | 0 | my $module = $self->module; | |||||||||
| 75 | |||||||||||
| 76 | 0 | my $tag = $self->gen_tag($version); | |||||||||
| 77 | 0 | my $storedir = File::Spec->catdir( $self->tagdir, $module, $tag ); | |||||||||
| 78 | |||||||||||
| 79 | 0 | ▶ | if ( !-d $storedir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 80 | 0 | die "Could not find stored tag for $version of $module in $storedir\n"; | |||||||||
| 81 | } | ||||||||||
| 82 | |||||||||||
| 83 | 0 | my $target = join q{-}, $module, $version; | |||||||||
| 84 | 0 | my $exportdir = File::Spec->catdir( $builddir, $target ); | |||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | if ( !$self->dryrun ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | 0 | ▶ | if ( -d $exportdir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 88 | 0 | File::Path::rmtree($exportdir); | |||||||||
| 89 | } | ||||||||||
| 90 | 0 | ▶ | File::Copy::Recursive::dircopy( $storedir, $exportdir ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | or die "Could not copy $storedir to $exportdir\n"; | ||||||||||
| 92 | } | ||||||||||
| 93 | |||||||||||
| 94 | 0 | return $exportdir; | |||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | sub export_devel { | ||||||||||
| 98 | 0 | ▶ | my ( $self, $version, $builddir ) = @_; | ||||||||
|
Subroutine
export_devel: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 99 | |||||||||||
| 100 | 0 | my $module = $self->module; | |||||||||
| 101 | |||||||||||
| 102 | 0 | my $target = join q{-}, $module, $version; | |||||||||
| 103 | 0 | my $exportdir = File::Spec->catdir( $builddir, $target ); | |||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | if ( !$self->dryrun ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 106 | 0 | ▶ | if ( -d $exportdir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 107 | 0 | File::Path::rmtree($exportdir); | |||||||||
| 108 | } | ||||||||||
| 109 | 0 | my $workdir = $self->workdir; | |||||||||
| 110 | 0 | ▶ | File::Copy::Recursive::dircopy( $workdir, $exportdir ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 111 | or die "Could not copy $workdir to $exportdir\n"; | ||||||||||
| 112 | } | ||||||||||
| 113 | |||||||||||
| 114 | 0 | return $exportdir; | |||||||||
| 115 | |||||||||||
| 116 | } | ||||||||||
| 117 | |||||||||||
| 118 | sub checkout_project { | ||||||||||
| 119 | 0 | ▶ | my ( $self, $version, $outdir ) = @_; | ||||||||
|
Subroutine
checkout_project: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||
| 120 | |||||||||||
| 121 | 0 | my $module = $self->module; | |||||||||
| 122 | 0 | my $basedir = File::Spec->catdir( $self->tagdir, $module ); | |||||||||
| 123 | |||||||||||
| 124 | 0 | ▶ | if ( !-d $basedir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 125 | 0 | die "Could not find the tag directory for $module\n"; | |||||||||
| 126 | } | ||||||||||
| 127 | |||||||||||
| 128 | 0 | my $tag; | |||||||||
| 129 | 0 | ▶ | if ( defined $version ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 130 | 0 | $tag = $self->gen_tag($version); | |||||||||
| 131 | } | ||||||||||
| 132 | else { | ||||||||||
| 133 | 0 | tie my %dir, 'IO::Dir', $basedir; | |||||||||
| 134 | 0 | $tag = (sort grep { !m/^\./} keys %dir)[-1]; | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | 0 | my $tagdir = File::Spec->catdir( $basedir, $tag ); | |||||||||
| 138 | |||||||||||
| 139 | 0 | ▶ | if ( !-d $tagdir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 140 | 0 | die "Could not find the tag $tag for $module\n"; | |||||||||
| 141 | } | ||||||||||
| 142 | |||||||||||
| 143 | 0 | ▶ | if ( !defined $outdir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 144 | 0 | $outdir = $module; | |||||||||
| 145 | } | ||||||||||
| 146 | |||||||||||
| 147 | 0 | ▶ | if ( !$self->dryrun ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 0 | ▶ | File::Copy::Recursive::dircopy( $tagdir, $outdir ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 149 | or die "Could not checkout $module tag $tag\n"; | ||||||||||
| 150 | } | ||||||||||
| 151 | |||||||||||
| 152 | 0 | return; | |||||||||
| 153 | } | ||||||||||
| 154 | |||||||||||
| 155 | sub import_project { | ||||||||||
| 156 | 0 | ▶ | my ( $self, $dir, $version, $message ) = @_; | ||||||||
|
Subroutine
import_project: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 157 | |||||||||||
| 158 | 0 | my $module = $self->module; | |||||||||
| 159 | |||||||||||
| 160 | 0 | my $tag = $self->gen_tag($version); | |||||||||
| 161 | |||||||||||
| 162 | 0 | my $tagdir = File::Spec->catdir( $self->tagdir, $module, $tag ); | |||||||||
| 163 | |||||||||||
| 164 | 0 | ▶ | if ( !$self->dryrun ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 165 | 0 | ▶ | if ( -d $tagdir ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 166 | 0 | File::Path::rmtree($tagdir); | |||||||||
| 167 | } | ||||||||||
| 168 | 0 | ▶ | File::Copy::Recursive::dircopy( $dir, $tagdir ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 169 | or die "Could not import $dir\n"; | ||||||||||
| 170 | } | ||||||||||
| 171 | |||||||||||
| 172 | 0 | return; | |||||||||
| 173 | } | ||||||||||
| 174 | |||||||||||
| 175 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 176 | 1 | 1; | |||||||||
| 177 | __END__ | ||||||||||
| 178 | |||||||||||
| 179 | =head1 NAME | ||||||||||
| 180 | |||||||||||
| 181 | LCFG::Build::VCS::None - LCFG build tools for filesystem based version-control | ||||||||||
| 182 | |||||||||||
| 183 | =head1 VERSION | ||||||||||
| 184 | |||||||||||
| 185 | This documentation refers to LCFG::Build::VCS::None version 0.3.8 | ||||||||||
| 186 | |||||||||||
| 187 | =head1 SYNOPSIS | ||||||||||
| 188 | |||||||||||
| 189 | my $dir = "."; | ||||||||||
| 190 | |||||||||||
| 191 | my $spec = LCFG::Build::PkgSpec->new_from_metafile("$dir/lcfg.yml"); | ||||||||||
| 192 | |||||||||||
| 193 | my $vcs = LCFG::Build::VCS::None->new( module => $spec->fullname, | ||||||||||
| 194 | workdir => $dir ); | ||||||||||
| 195 | |||||||||||
| 196 | $vcs->genchangelog(); | ||||||||||
| 197 | |||||||||||
| 198 | if ( $vcs->checkcommitted() ) { | ||||||||||
| 199 | $vcs->tagversion(); | ||||||||||
| 200 | } | ||||||||||
| 201 | |||||||||||
| 202 | =head1 DESCRIPTION | ||||||||||
| 203 | |||||||||||
| 204 | This is part of a suite of tools designed to provide a standardised | ||||||||||
| 205 | interface to version-control systems so that the LCFG build tools can | ||||||||||
| 206 | deal with project version-control in a high-level abstract fashion. | ||||||||||
| 207 | |||||||||||
| 208 | This module implements the interface specified by | ||||||||||
| 209 | L<LCFG::Build::VCS>. It provides support for a really simple | ||||||||||
| 210 | filesystem-based version-control system. The working copy can be | ||||||||||
| 211 | "tagged" at a particular release with copies of the source tree being | ||||||||||
| 212 | made in a tag directory. Support is also provided for exporting these | ||||||||||
| 213 | tagged releases. The aim of this module is to provide the minimum | ||||||||||
| 214 | necessary to manage the release and build of LCFG packages without | ||||||||||
| 215 | requiring a true version-control system such as CVS. | ||||||||||
| 216 | |||||||||||
| 217 | More information on the LCFG build tools is available from the website | ||||||||||
| 218 | http://www.lcfg.org/doc/buildtools/ | ||||||||||
| 219 | |||||||||||
| 220 | =head1 ATTRIBUTES | ||||||||||
| 221 | |||||||||||
| 222 | =over 4 | ||||||||||
| 223 | |||||||||||
| 224 | =item module | ||||||||||
| 225 | |||||||||||
| 226 | The name of the software package in this repository. This is required | ||||||||||
| 227 | and there is no default value. | ||||||||||
| 228 | |||||||||||
| 229 | =item workdir | ||||||||||
| 230 | |||||||||||
| 231 | The directory in which the commands should be carried out. This is | ||||||||||
| 232 | required and if none is specified then it will default to '.', the | ||||||||||
| 233 | current working directory. This must be an absolute path but if you | ||||||||||
| 234 | pass in a relative path coercion will automatically occur based on the | ||||||||||
| 235 | current working directory. | ||||||||||
| 236 | |||||||||||
| 237 | =item tagdir | ||||||||||
| 238 | |||||||||||
| 239 | This is the directory into which exported 'tags' of the working copy | ||||||||||
| 240 | should be placed. If it is not specified then the directory above the | ||||||||||
| 241 | specified the working directory will be used. This should be an | ||||||||||
| 242 | absolute path, if a relative path is given it will be converted. | ||||||||||
| 243 | |||||||||||
| 244 | =item quiet | ||||||||||
| 245 | |||||||||||
| 246 | This is a boolean value which controls the quietness of the various | ||||||||||
| 247 | methods. By default it is false. This currently does not have much | ||||||||||
| 248 | effect on this module but it might in the future. | ||||||||||
| 249 | |||||||||||
| 250 | =item dryrun | ||||||||||
| 251 | |||||||||||
| 252 | This is a boolean value which controls whether the commands will | ||||||||||
| 253 | actually have a real effect or just print out what would be done. By | ||||||||||
| 254 | default it is false. | ||||||||||
| 255 | |||||||||||
| 256 | =item logname | ||||||||||
| 257 | |||||||||||
| 258 | The name of the logfile to which information should be directed when | ||||||||||
| 259 | doing version updates. This is also the name of the logfile to be used | ||||||||||
| 260 | if you utilise the automatic changelog generation option. The default | ||||||||||
| 261 | file name is 'ChangeLog'. | ||||||||||
| 262 | |||||||||||
| 263 | =back | ||||||||||
| 264 | |||||||||||
| 265 | =head1 SUBROUTINES/METHODS | ||||||||||
| 266 | |||||||||||
| 267 | =over 4 | ||||||||||
| 268 | |||||||||||
| 269 | =item checkcommitted() | ||||||||||
| 270 | |||||||||||
| 271 | This is a no-op for simple filesystem-based version control as there | ||||||||||
| 272 | is no concept of changes to a file having been committed to a | ||||||||||
| 273 | repository. | ||||||||||
| 274 | |||||||||||
| 275 | =item genchangelog() | ||||||||||
| 276 | |||||||||||
| 277 | This is a no-op for simple filesystem-based version control as there | ||||||||||
| 278 | is no revision-control system log from which to generate the logfile. | ||||||||||
| 279 | |||||||||||
| 280 | =item tagversion($version) | ||||||||||
| 281 | |||||||||||
| 282 | This method is used to tag a set of files for a project at a | ||||||||||
| 283 | particular version. The source tree will be copied into a directory | ||||||||||
| 284 | named after the tag within the directory specified with the C<tagdir> | ||||||||||
| 285 | option. It will also update the changelog appropriately. Tags are | ||||||||||
| 286 | generated using the I<gen_tag()> method, see below for details. | ||||||||||
| 287 | |||||||||||
| 288 | =item gen_tag($version) | ||||||||||
| 289 | |||||||||||
| 290 | Tags are generated from the name and version details passed in by | ||||||||||
| 291 | replacing any hyphens or dots with underscores and joining the two | ||||||||||
| 292 | fields with an underscore. For example, lcfg-foo and 1.0.1 would | ||||||||||
| 293 | become lcfg_foo_1_0_1. | ||||||||||
| 294 | |||||||||||
| 295 | =item run_cmd(@args) | ||||||||||
| 296 | |||||||||||
| 297 | This is a no-op as the simple filesystem-based version control does | ||||||||||
| 298 | not require a separate binary to carry out commands. | ||||||||||
| 299 | |||||||||||
| 300 | =item export( $version, $builddir ) | ||||||||||
| 301 | |||||||||||
| 302 | This will export a particular tagged version of the module. You need | ||||||||||
| 303 | to specify the target "build" directory into which the exported tree | ||||||||||
| 304 | will be put. The exported tree will be named like | ||||||||||
| 305 | "modulename-version". For example: | ||||||||||
| 306 | |||||||||||
| 307 | my $vcs = LCFG::Build::VCS::None->new(module => "lcfg-foo"); | ||||||||||
| 308 | $vcs->export( "1.2.3", "/tmp" ); | ||||||||||
| 309 | |||||||||||
| 310 | Would give you an exported tree of code for the lcfg-foo module tagged | ||||||||||
| 311 | as lcfg_foo_1_2_3 and it would be put into /tmp/lcfg-foo-1.2.3/ | ||||||||||
| 312 | |||||||||||
| 313 | For the export method to be successful you must have already "tagged" | ||||||||||
| 314 | a release using the C<tagversion> method. | ||||||||||
| 315 | |||||||||||
| 316 | This method returns the name of the directory into which the tree was | ||||||||||
| 317 | exported. | ||||||||||
| 318 | |||||||||||
| 319 | =item export_devel( $version, $builddir ) | ||||||||||
| 320 | |||||||||||
| 321 | This is similar to the export method. It takes the current working | ||||||||||
| 322 | tree for a module and exports it directly to another tree based in the | ||||||||||
| 323 | specified target "build" directory. For example: | ||||||||||
| 324 | |||||||||||
| 325 | my $vcs = LCFG::Build::VCS::None->new(module => "lcfg-foo"); | ||||||||||
| 326 | $vcs->export_devel( "1.2.3_dev", "/tmp" ); | ||||||||||
| 327 | |||||||||||
| 328 | Would give you an exported tree of code for the lcfg-foo module | ||||||||||
| 329 | directory and it would be put into /tmp/lcfg-foo-1.2.3_dev/ | ||||||||||
| 330 | |||||||||||
| 331 | This method returns the name of the directory into which the tree was | ||||||||||
| 332 | exported. | ||||||||||
| 333 | |||||||||||
| 334 | =item logfile() | ||||||||||
| 335 | |||||||||||
| 336 | This is a convenience method which returns the full path to the | ||||||||||
| 337 | logfile based on the workdir and logname attributes. | ||||||||||
| 338 | |||||||||||
| 339 | =item checkout_project() | ||||||||||
| 340 | |||||||||||
| 341 | This is not currently supported. You probably want to use the | ||||||||||
| 342 | C<export> method instead. | ||||||||||
| 343 | |||||||||||
| 344 | =item import_project() | ||||||||||
| 345 | |||||||||||
| 346 | This is a no-op as there is no concept of "importing" a project into | ||||||||||
| 347 | the simple filesystem-based version control system. | ||||||||||
| 348 | |||||||||||
| 349 | =back | ||||||||||
| 350 | |||||||||||
| 351 | =head1 DEPENDENCIES | ||||||||||
| 352 | |||||||||||
| 353 | This module is L<Moose> powered and it depends on | ||||||||||
| 354 | L<LCFG::Build::VCS>. It also requires L<File::Copy::Recursive> | ||||||||||
| 355 | |||||||||||
| 356 | =head1 SEE ALSO | ||||||||||
| 357 | |||||||||||
| 358 | L<LCFG::Build::PkgSpec>, L<LCFG::Build::VCS::CVS>, L<LCFG::Build::Tools> | ||||||||||
| 359 | |||||||||||
| 360 | =head1 PLATFORMS | ||||||||||
| 361 | |||||||||||
| 362 | This is the list of platforms on which we have tested this | ||||||||||
| 363 | software. We expect this software to work on any Unix-like platform | ||||||||||
| 364 | which is supported by Perl. | ||||||||||
| 365 | |||||||||||
| 366 | FedoraCore5, FedoraCore6, ScientificLinux5 | ||||||||||
| 367 | |||||||||||
| 368 | =head1 BUGS AND LIMITATIONS | ||||||||||
| 369 | |||||||||||
| 370 | There are no known bugs in this application. Please report any | ||||||||||
| 371 | problems to bugs@lcfg.org, feedback and patches are also always very | ||||||||||
| 372 | welcome. | ||||||||||
| 373 | |||||||||||
| 374 | =head1 AUTHOR | ||||||||||
| 375 | |||||||||||
| 376 | Stephen Quinney <squinney@inf.ed.ac.uk> | ||||||||||
| 377 | |||||||||||
| 378 | =head1 LICENSE AND COPYRIGHT | ||||||||||
| 379 | |||||||||||
| 380 | Copyright (C) 2008 University of Edinburgh. All rights reserved. | ||||||||||
| 381 | |||||||||||
| 382 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 383 | it under the terms of the GPL, version 2 or later. | ||||||||||
| 384 | |||||||||||
| 385 | =cut | ||||||||||