#!/usr/bin/perl use warnings; use strict; use FindBin; use lib "$FindBin::Bin"; use do_common; $| = 1; sub fetch { my $module = shift; my $source = shift; # Check if directory exists if (-d "$module/.git") { print "Skipping $module: detected existing git installation.\n"; return; } # Change into subdir if necessary if ($module =~ m|/|) { (my $subdir = $module) =~ s|/.*||; if (! -d $subdir) { mkdir($subdir) or die "Failed to create directory $subdir: $!\n"; } chdir($subdir) or die "Failed to change directory to $subdir: $!\n"; } # Run clone command my $cmd = "git clone git://anongit.freedesktop.org/git/$source"; print "Running command: $cmd\n"; system($cmd) == 0 or die "Operation failed!\n"; print "Operation succeeded\n"; # Change back to main dir chdir($basedir) or die "Failed to change directory to $basedir: $!\n"; } # git-clone everything chdir($basedir) or die "Failed to change directory to $basedir: $!\n"; while (@all_modules) { my $module = shift @all_modules; my $source = shift @all_modules; fetch($module, $source); }