xref: /aoo4110/main/solenv/bin/cwstouched.pl (revision b1cdbd2c)
1:
2eval 'exec perl -wS $0 ${1+"$@"}'
3    if 0;
4
5#**************************************************************
6#
7#  Licensed to the Apache Software Foundation (ASF) under one
8#  or more contributor license agreements.  See the NOTICE file
9#  distributed with this work for additional information
10#  regarding copyright ownership.  The ASF licenses this file
11#  to you under the Apache License, Version 2.0 (the
12#  "License"); you may not use this file except in compliance
13#  with the License.  You may obtain a copy of the License at
14#
15#    http://www.apache.org/licenses/LICENSE-2.0
16#
17#  Unless required by applicable law or agreed to in writing,
18#  software distributed under the License is distributed on an
19#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
20#  KIND, either express or implied.  See the License for the
21#  specific language governing permissions and limitations
22#  under the License.
23#
24#**************************************************************
25
26use strict;
27use Cwd;
28
29#### module lookup
30my @lib_dirs;
31BEGIN {
32    if ( !defined($ENV{SOLARENV}) ) {
33        die "No environment found (environment variable SOLARENV is undefined)";
34    }
35    push(@lib_dirs, "$ENV{SOLARENV}/bin/modules");
36}
37use lib (@lib_dirs);
38
39use Cws;
40
41# Prototypes
42sub getMinor($);
43sub getCwsWorkStamp();
44
45my $workstamp = $ENV{'WORK_STAMP'};
46my $solenv= $ENV{'SOLARENV'};
47my $cwsWorkStamp = getCwsWorkStamp();
48my $minor = getMinor($cwsWorkStamp);
49
50my $oldWorkStamp = $workstamp."_".$minor;
51my $svndiff="svn diff --summarize --old=svn://svn.services.openoffice.org/ooo/tags/".$oldWorkStamp." --new=svn://svn.services.openoffice.org/ooo/cws/".$cwsWorkStamp;
52
53my @diff = `$svndiff`;
54
55my @modules;
56foreach(@diff)
57{
58    if (/.*svn:\/\/svn.services.openoffice.org.*/)
59    {
60        $_ =~ /.*$oldWorkStamp\/(\w*)/;
61        my $newModule=$1;
62        if (defined($newModule))
63        {
64            if ( ! grep(/$newModule/,@modules))
65            {
66                push(@modules, $newModule);
67            }
68
69        }
70    }
71}
72
73foreach(@modules)
74{
75    print "$_\n";
76}
77
78exit(0);
79
80sub getMinor($)
81{
82    my $workst = shift;
83    my $min="";
84
85    if ( ! defined($ENV{'UPDMINOR'}))
86    {
87        my $cws = Cws->new();
88        $cws->child($workst);
89        $cws->master($ENV{'WORK_STAMP'});
90        my $masterws = $cws->master();
91        my $childws  = $cws->child();
92
93        # check if we got a valid child workspace
94        my $id = $cws->eis_id();
95        if ( !$id )
96        {
97            print("Child workspace '$childws' for master workspace '$masterws' not found in EIS database.\n");
98            exit(1);
99        }
100
101        my @milestones = $cws->milestone();
102        foreach (@milestones) {
103            if ( defined($_) )
104            {
105                $min=$_;
106            }
107        }
108    }
109    else
110    {
111        $min = $ENV{'UPDMINOR'};
112    }
113
114    chomp($min);
115    return $min;
116}
117
118sub getCwsWorkStamp()
119{
120    my $cwsWorkSt="";
121
122    if ( ! defined($ENV{'CWS_WORK_STAMP'}))
123    {
124        my $currPath= cwd;
125
126        chdir($ENV{'SOLARENV'});
127
128        my @info = `svn info`;
129
130        foreach(@info)
131        {
132            if ( /URL:.*/ )
133            {
134                # URL: svn+ssh://svn@svn.services.openoffice.org/ooo/cws/qadev37/solenv
135                $_ =
136~ /.*svn.services.openoffice.org(.*\/(.*))\/\w*/;
137                $cwsWorkSt=$2; #qadev37
138            }
139        }
140
141    }
142    else
143    {
144        $cwsWorkSt = $ENV{'CWS_WORK_STAMP'};
145    }
146    return $cwsWorkSt
147}
148