-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepareProject.pl
More file actions
executable file
·81 lines (64 loc) · 1.82 KB
/
prepareProject.pl
File metadata and controls
executable file
·81 lines (64 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/opt/local/bin/perl -w
use strict;
use File::Copy;
my $projectDir;
my @projectDirectories;
main();
sub main {
validateArgs();
transformEachProjectDirectory();
}
sub transformEachProjectDirectory {
# open the project directory and read all of the
# directories within it.
opendir(PROJ_DIR, $projectDir);
my @allFiles = readdir(PROJ_DIR);
foreach my $currFile (@allFiles) {
if (-d "$projectDir/$currFile" && $currFile !~ /^\./) {
push(@projectDirectories, $currFile);
}
}
foreach my $currProj (@projectDirectories) {
transformProjectDir("$projectDir/$currProj");
}
closedir(PROJ_DIR);
}
sub transformProjectDir {
my ($currProjDir) = @_;
print "Current project Directory: $currProjDir\n";
createTrunkDir($currProjDir);
mkdir("$currProjDir/branches");
mkdir("$currProjDir/tags");
# handle the initial tag dir.
my $initialTagDir = "$currProjDir/tags/v-0-initialImport";
mkdir($initialTagDir);
system("cp -r $currProjDir/trunk/* $initialTagDir");
}
sub createTrunkDir {
my ($currProjDir) = @_;
# build the list of files and directories that exist in the current project directory
opendir(CURR_PROJ_DIR, $currProjDir);
my @allFiles = readdir(CURR_PROJ_DIR);
my $trunkDir = "$currProjDir/trunk";
mkdir("$trunkDir");
mkdir("$trunkDir/logs");
mkdir("$trunkDir/data");
# move all of the files into the trunkDir
foreach my $currFile (@allFiles) {
my $fullPathCurrFile = "$currProjDir/$currFile";
if (-d $fullPathCurrFile && $currFile !~ /^\./) {
move($fullPathCurrFile, "$trunkDir/$currFile");
} else {
move($fullPathCurrFile, $trunkDir);
}
}
closedir(CURR_PROJ_DIR);
}
sub validateArgs {
my $argSize = @ARGV;
if ($argSize != 1) {
print "usage: prepareProject.pl <directoryOfProjects>\n";
exit(0);
}
$projectDir = $ARGV[0];
}