diff options
author | Olivier Thauvin <nanardon@mageia.org> | 2011-05-29 19:13:33 +0000 |
---|---|---|
committer | Olivier Thauvin <nanardon@mageia.org> | 2011-05-29 19:13:33 +0000 |
commit | 51b8a73479b39ba617d731816dec3699285e3036 (patch) | |
tree | 4d32f7461afb5430642e501d72b8e05e9136d372 /fork-distribution | |
parent | f07a283bf2ef6315b56bde9abcd6531f15345c46 (diff) | |
download | release-51b8a73479b39ba617d731816dec3699285e3036.tar release-51b8a73479b39ba617d731816dec3699285e3036.tar.gz release-51b8a73479b39ba617d731816dec3699285e3036.tar.bz2 release-51b8a73479b39ba617d731816dec3699285e3036.tar.xz release-51b8a73479b39ba617d731816dec3699285e3036.zip |
- initiate script to fork distrib
Diffstat (limited to 'fork-distribution')
-rwxr-xr-x | fork-distribution | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/fork-distribution b/fork-distribution new file mode 100755 index 0000000..b91c8eb --- /dev/null +++ b/fork-distribution @@ -0,0 +1,61 @@ +#!/bin/env perl + +# $Id$ + +use strict; +use warnings; +use Pod::Usage; +use Getopt::Long; +use MDV::Distribconf; +use Cwd; + +GetOptions( +) or pod2usage(1); + +my ($source,$dest) = @ARGV; + +$dest or do { + warn "No dest given"; + pod2usage(1); +}; + +# Constant: + +{ + my @distribdir = find_distrib($source); + warn join(' ', @distribdir); + fork_tree($source, $dest); +} + +sub find_distrib { + my ($topdir) = @_; + my @distpath; + if (opendir(my $handle, $topdir)) { + while (my $subdir = readdir($handle)) { + $subdir eq '..' and next; + my $d = MDV::Distribconf->new("$topdir/$subdir"); + if ($d->load){ + push(@distpath, $subdir); + } + } + closedir($handle) + } else { + die "Cannot open $topdir: $!"; + } + return @distpath; +} + +sub fork_tree { + my ($source, $dest) = @_; + + my $abs_source = Cwd::abs_path($source) || $source; + my $abs_dest = Cwd::abs_path($dest) || $dest; + + my @basecmd = (qw(rsync -avPHS), ("$abs_source/"), ("$abs_dest/")); + my @cmd; + + @cmd = (@basecmd, qw(--exclude *.rpm)); + system(@cmd); + @cmd = (@basecmd, '--link-dest', "$abs_source/"); + system(@cmd); +} |