aboutsummaryrefslogtreecommitdiffstats
path: root/fork-distribution
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mageia.org>2011-05-29 19:13:33 +0000
committerOlivier Thauvin <nanardon@mageia.org>2011-05-29 19:13:33 +0000
commit51b8a73479b39ba617d731816dec3699285e3036 (patch)
tree4d32f7461afb5430642e501d72b8e05e9136d372 /fork-distribution
parentf07a283bf2ef6315b56bde9abcd6531f15345c46 (diff)
downloadrelease-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-xfork-distribution61
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);
+}