summaryrefslogtreecommitdiff
path: root/lib/sbin/CVSUpdate.pl
blob: cae76b6490308f7fbf17e89f2d672fd438bba292 (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#/*@@
#  @file      CVSUpdate.pl
#  @date      Tue Nov 21 2000
#  @author    Gabrielle Allen
#  @desc
#     Updates Cactus checkout
#     (avoids problems with different versions of cvs client)
#  @enddesc
#  @version $Header$
#@@*/

my $cvs_ops="-z6 -q";
my $cvs_update_ops="-d -P";
my $svn_ops="";
# Set this to eg -r TAGNAME checkout from a TAG
my $cvs_symbolic_name="";
my $svn_symbolic_name="";

require "lib/sbin/MakeUtils.pl";

$debug = 0;
if ($debug)
{
  print "DEBUG mode: cvs/svn commands not issued\n\n";
}

print("Not updating Flesh - not in CVS anymore\n");
#$command = "cvs $cvs_ops update $cvs_update_ops $cvs_symbolic_name CONTRIBUTORS COPYRIGHT Makefile lib doc src arrangements/README";
#if ($debug)
#{
#  $this_dir = `pwd`;
#  chop($this_dir);
#  print "\nIn directory $this_dir\n";
#  print "Issuing command\n  $command\n";
#  foreach $file (`ls CVS`)
#  {
#    chop($file);
#    print "Contents of $file\n";
#    open (FILE, "<CVS/$file") || die "Could not open CVS file";
#    while (<FILE>)
#    {
#      print;
#    }
#  }
#}
#if (!$debug)
#{
#  open (CS, "$command |");
#  while (<CS>)
#  {
#    print ;
#  }
#  close (CS);
#}

$home = `pwd`;
chomp ($home);

($arrangement_dir, $thornlist) = @ARGV;

$arrangement_dir = "$home/$arrangement_dir";

if ($thornlist =~ /^$/) {
   %info = &buildthorns($arrangement_dir,"thorns-to-update");
} else {
   %info = &ReadThornlist($thornlist);
}

foreach $thorn (sort keys %info)
{
  $arrangement = $thorn;
  $arrangement =~ s/[\/]+[a-zA-Z0-9_]*//;
  
  if ( ! $visited_arrangements{"\U$arrangement\E"})
  {
    $visited_arrangements{"\U$arrangement\E"} = 1;
    if( -d "$arrangement_dir/$arrangement/doc" && -d "$arrangement_dir/$arrangement/doc/CVS")
    {
      chdir ("$arrangement_dir/$arrangement/doc") ||
        die "Cannot change to arrangement directory '$arrangement_dir/$arrangement'\n";
      print("Updating arrangement $arrangement\n");
      $command = "cvs $cvs_ops update $cvs_update_ops $cvs_symbolic_name";
      if($debug)
      {
        $this_dir = `pwd`;
        chop($this_dir);
        print "In directory $this_dir\n";
        print "Issuing command\n  $command\n";
        foreach $file (`ls CVS`)
        {
          chop($file);
          print "Contents of $file\n";
          open (FILE, "<CVS/$file") || die "Could not open CVS file";
          while (<FILE>)
          {
            print;
          }
        }
      }
      if (!$debug)
      {
        open (CS, "$command |");
        while (<CS>)
        {
          print ;
        }
      }    
    }
  }

  if( -d "$arrangement_dir/$thorn/CVS")
  {
    $command = "cvs $cvs_ops update $cvs_update_ops $cvs_symbolic_name";
  }
  if( -d "$arrangement_dir/$thorn/.svn")
  {
    $command = "svn $svn_ops update $svn_symbolic_name";
  }
  if ( ! -d "$arrangement_dir/$thorn/CVS" &&
       ! -d "$arrangement_dir/$thorn/.svn" )
  {
    print "Ignoring $thorn - no CVS or .svn directory\n";
    next;
  }

  chdir ("$arrangement_dir/$thorn") ||
    die "Cannot change to thorn directory '$arrangement_dir/$thorn'\n";
  print("Updating thorn $thorn\n");
  if($debug)
  {
    $this_dir = `pwd`;
    chop($this_dir);
    print "In directory $this_dir\n";
    print "Issuing command\n  $command\n";
    if ( -d "$arrangement_dir/$thorn/CVS" )
    {
      foreach $file (`ls CVS`)
      {
        chop($file);
        print "Contents of $file\n";
        open (FILE, "<CVS/$file") || die "Could not open CVS file";
        while (<FILE>)
        {
          print;
        }
      }
    }
  }
  if (!$debug)
  {
    open (CS, "$command |");
    while (<CS>)
    {
      print ;
    }
  }
}
  chdir $home || die "Cannot change back to Cactus home directory '$home'\n";


exit;