aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Youri/Upload/Action/Link.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Youri/Upload/Action/Link.pm')
-rw-r--r--lib/Youri/Upload/Action/Link.pm63
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/Youri/Upload/Action/Link.pm b/lib/Youri/Upload/Action/Link.pm
new file mode 100644
index 0000000..eaadec1
--- /dev/null
+++ b/lib/Youri/Upload/Action/Link.pm
@@ -0,0 +1,63 @@
+# $Id: /local/youri/soft/trunk/lib/Youri/Upload/Action/Sign.pm 1543 2006-03-21T20:22:54.334939Z guillaume $
+package Youri::Upload::Action::Link;
+
+=head1 NAME
+
+Youri::Upload::Action::Link - Noarch packages linking
+
+=head1 DESCRIPTION
+
+This action plugin ensures linking of noarch packages between arch-specific
+directories.
+
+=cut
+
+use warnings;
+use strict;
+use Carp;
+use File::Spec;
+use base qw/Youri::Upload::Action/;
+
+sub _init {
+ my $self = shift;
+ my %options = (
+ symbolic => 0, # use symbolic linking
+ @_
+ );
+
+ $self->{_symbolic} = $options{symbolic};
+}
+
+sub run {
+ my ($self, $package, $repository, $target, $define) = @_;
+ croak "Not a class method" unless ref $self;
+
+ # only needed for noarch packages
+ return unless $package->get_arch() eq 'noarch';
+
+ my $dest_dir = $repository->get_install_dir($package, $target, $define);
+ my (undef, $parent_dir, $relative_dir) = File::Spec->splitpath($dest_dir);
+ my $file = $package->get_file_name();
+
+ foreach my $other_dir (grep { -d } <$parent_dir/*>) {
+ next if $other_dir eq $dest_dir;
+ chdir $other_dir;
+ my $source_file = "../$relative_dir/$file";
+ if ($self->{_symbolic}) {
+ symlink $source_file, $file unless $self->{_test};
+ } else {
+ link $source_file, $file unless $self->{_test};
+ }
+ chdir '..';
+ }
+}
+
+=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;