diff options
author | Florent Villard <warly@mandriva.com> | 2006-10-16 11:30:28 +0000 |
---|---|---|
committer | Florent Villard <warly@mandriva.com> | 2006-10-16 11:30:28 +0000 |
commit | 02381cd87e37dc5d6df37e56eef5f1e222a794cd (patch) | |
tree | fec5b8db1aba238ca91f5506239dec3ac37d3929 /lib/Youri/Submit/Action/CVS.pm | |
parent | 597e5f1d49cb0cc96a5655aeaa84a6fc4a83b041 (diff) | |
download | mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar.gz mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar.bz2 mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.tar.xz mga-youri-submit-02381cd87e37dc5d6df37e56eef5f1e222a794cd.zip |
add new youri subsections (from upstream)
Diffstat (limited to 'lib/Youri/Submit/Action/CVS.pm')
-rw-r--r-- | lib/Youri/Submit/Action/CVS.pm | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/lib/Youri/Submit/Action/CVS.pm b/lib/Youri/Submit/Action/CVS.pm new file mode 100644 index 0000000..c0488ea --- /dev/null +++ b/lib/Youri/Submit/Action/CVS.pm @@ -0,0 +1,135 @@ +# $Id$ +package Youri::Upload::Action::CVS; + +=head1 NAME + +Youri::Upload::Action::CVS - CVS versionning + +=head1 DESCRIPTION + +This action plugin ensures CVS versionning of package sources. + +=cut + +use warnings; +use strict; +use Carp; +use Cwd; +use File::Temp qw/tempdir/; +use base qw/Youri::Upload::Action/; + +sub _init { + my $self = shift; + my %options = ( + exclude => '\.(tar(\.(gz|bz2))?|zip)$', + perms => 644, + @_ + ); + + $self->{_exclude} = $options{exclude}; + $self->{_perms} = $options{perms}; +} + +sub run { + my ($self, $package, $repository, $target, $define) = @_; + croak "Not a class method" unless ref $self; + + return unless $package->is_source(); + + my $name = $package->get_name(); + my $version = $package->get_version(); + my $release = $package->get_release(); + + my $root = $repository->get_version_root(); + my $path = $repository->get_version_path($package, $target, $define); + + # remember original directory + my $original_dir = cwd(); + + # get a safe temporary directory + my $dir = tempdir( CLEANUP => 1 ); + chdir $dir; + + # first checkout base directory only + system("cvs -Q -d $root co -l $path"); + + # try to checkout package directory + my $dest = $path . '/' . $name; + system("cvs -Q -d $root co $dest"); + + # create directory if previous import failed + unless (-d $dest) { + print "adding directory $dest\n" if $self->{_verbose}; + system("install -d -m " . ($self->{_perms} + 111) . " $dest"); + system("cvs -Q -d $root add $dest"); + } + + chdir $dest; + + # remove all files + unlink grep { -f } glob '*'; + + # extract all rpm files locally + $package->extract(); + + # remove excluded files + if ($self->{_exclude}) { + unlink grep { -f && /$self->{_exclude}/ } glob '*'; + } + + # uncompress all compressed files + system("bunzip2 *.bz2 2>/dev/null"); + system("gunzip *.gz 2>/dev/null"); + + my (@to_remove, @to_add, @to_add_binary); + foreach my $line (`cvs -nq update`) { + if ($line =~ /^\? (\S+)/) { + if (-B $1) { + push(@to_add_binary, $1); + } else { + push(@to_add, $1); + } + } + if ($line =~ /^U (\S+)/) { + push(@to_remove, $1); + } + } + if (@to_remove) { + my $to_remove = join(' ', @to_remove); + print "removing file(s) $to_remove\n" if $self->{_verbose}; + system("cvs -Q remove $to_remove"); + } + if (@to_add) { + my $to_add = join(' ', @to_add); + print "adding text file(s) $to_add\n" if $self->{_verbose}; + system("cvs -Q add $to_add"); + } + if (@to_add_binary) { + my $to_add_binary = join(' ', @to_add_binary); + print "adding binary file(s) $to_add_binary\n" if $self->{_verbose}; + system("cvs -Q add -kb $to_add_binary"); + } + + print "committing current directory\n" if $self->{_verbose}; + system("cvs -Q commit -m $version-$release") unless $self->{_test}; + + # tag new release + my $tag = "r$version-$release"; + $tag =~ s/\./_/g; + print "tagging current directory as $tag\n" if $self->{_verbose}; + system("cvs -Q tag $tag") unless $self->{_test}; + + # get back to original directory + chdir $original_dir; + +} + +=head1 COPYRIGHT AND LICENSE + +Copyright (C) 2002-2006, YOURI project + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; |