xref: /aoo4110/main/soldep/bootstrp/minormk.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "minormk.hxx"
25 #include "prodmap.hxx"
26 #include <soldep/appdef.hxx>
27 #include <tools/fsys.hxx>
28 #include <tools/geninfo.hxx>
29 
30 //
31 // class MinorMk
32 //
33 
34 /*****************************************************************************/
MinorMk(GenericInformationList * pList,const ByteString & rVersion,const ByteString & rWorkStamp,const ByteString & rEnvironment,const ByteString & rMinor)35 MinorMk::MinorMk(
36 	GenericInformationList *pList,
37 	const ByteString &rVersion,
38 	const ByteString &rWorkStamp,
39 	const ByteString &rEnvironment,
40 	const ByteString &rMinor
41 )
42 /*****************************************************************************/
43 {
44 	String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
45 	if ( sRoot.Len()) {
46 		ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
47 		sPath += "/";
48 		sPath += rEnvironment;
49 		sPath += "/";
50 		sPath += "inc";
51 		if ( rMinor.Len()) {
52 			sPath += ".";
53 			sPath += rMinor;
54 		}
55 #ifdef UNX
56 		sPath.SearchAndReplaceAll( "\\", "/" );
57 		while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
58 #else
59 		sPath.SearchAndReplaceAll( "/", "\\" );
60 		while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
61 #endif
62 		DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
63 
64 		ByteString sFile( rWorkStamp );
65 		sFile += "minor.mk";
66 
67 		DirEntry aFile( aPath );
68 		aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
69 		if ( !aFile.Exists()) {
70 			sFile = sFile.Copy( 3 );
71 			aFile = aPath;
72 			aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
73 		}
74 		ReadMinorMk( aFile.GetFull());
75 	}
76 }
77 
78 /*****************************************************************************/
MinorMk(GenericInformationList * pList,const ByteString rVersion)79 MinorMk::MinorMk( GenericInformationList *pList, const ByteString rVersion )
80 /*****************************************************************************/
81 {
82 	String sRoot( ProductMapper::GetVersionRoot( pList, rVersion ));
83 	if ( sRoot.Len()) {
84 		ByteString sPath( sRoot, RTL_TEXTENCODING_ASCII_US );
85 		sPath += "/src/solenv/inc";
86 #ifdef UNX
87 		sPath.SearchAndReplaceAll( "\\", "/" );
88 		while( sPath.SearchAndReplace( "//", "/" ) != STRING_NOTFOUND ) {};
89 #else
90 		sPath.SearchAndReplaceAll( "/", "\\" );
91 		while( sPath.SearchAndReplace( "\\\\", "\\" ) != STRING_NOTFOUND ) {};
92 #endif
93 		DirEntry aPath( String( sPath, RTL_TEXTENCODING_ASCII_US ));
94 
95  		ByteString sFile( "minor.mk" );
96 
97 		DirEntry aFile( aPath );
98 		aFile += DirEntry( String( sFile, RTL_TEXTENCODING_ASCII_US ));
99 
100 		ReadMinorMk( aFile.GetFull());
101 	}
102 }
103 
104 /*****************************************************************************/
MinorMk(const ByteString & rMinor,const ByteString & rEnvironment)105 MinorMk::MinorMk( const ByteString &rMinor,	const ByteString &rEnvironment )
106 /*****************************************************************************/
107 				: bExists( sal_False )
108 {
109 	ByteString sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US );
110 
111 
112 	ByteString sSolver( GetEnv( "SOLARVERSION" ));
113 	sal_Bool bNewEnv = sal_True;
114 	if ( !sSolver.Len()) {
115 		sSolver = GetEnv( "SOLARVER" );
116 		bNewEnv = sal_False;
117 	}
118 	ByteString sUPD( GetEnv( "UPD" ));
119 
120 	ByteString sMinorMk( sSolver );
121 	sMinorMk += sDelimiter;
122 	if ( !bNewEnv ) {
123 		sMinorMk += sUPD;
124 		sMinorMk += sDelimiter;
125 	}
126 
127 	if ( rEnvironment.Len()) {
128 		sMinorMk += rEnvironment;
129 		sMinorMk += sDelimiter;
130 		sMinorMk += "inc";
131 		if( rMinor.Len()) {
132 			sMinorMk += ".";
133 			sMinorMk += rMinor;
134 		}
135 		sMinorMk += sDelimiter;
136 	}
137 
138 	sMinorMk += sUPD;
139 	sMinorMk += "minor.mk";
140 
141 	String sFile( sMinorMk, RTL_TEXTENCODING_ASCII_US );
142 
143 	ReadMinorMk( sFile );
144 }
145 
146 /*****************************************************************************/
ReadMinorMk(const String & rFileName)147 void MinorMk::ReadMinorMk( const String &rFileName )
148 /*****************************************************************************/
149 {
150 	if ( DirEntry( rFileName ).Exists()) {
151 		bExists = sal_True;
152 		SvFileStream aStream( rFileName, STREAM_STD_READ );
153 		while ( !aStream.IsOpen())
154 			aStream.Open( rFileName, STREAM_STD_READ );
155 
156 		ByteString sLine;
157 		while ( !aStream.IsEof()) {
158 			aStream.ReadLine( sLine );
159 
160 			if ( sLine.GetToken( 0, '=' ) == "RSCVERSION" )
161 				sRSCVERSION = sLine.GetToken( 1, '=' );
162 			else if ( sLine.GetToken( 0, '=' ) == "RSCREVISION" )
163 				sRSCREVISION = sLine.GetToken( 1, '=' );
164 			else if ( sLine.GetToken( 0, '=' ) == "BUILD" )
165 				sBUILD = sLine.GetToken( 1, '=' );
166 			else if ( sLine.GetToken( 0, '=' ) == "LAST_MINOR" )
167 				sLAST_MINOR = sLine.GetToken( 1, '=' );
168 		}
169 		aStream.Close();
170 
171 		sRSCVERSION.EraseTrailingChars();
172 		sRSCREVISION.EraseTrailingChars();
173 		sBUILD.EraseTrailingChars();
174 		sLAST_MINOR.EraseTrailingChars();
175 	}
176 }
177 
178 /*****************************************************************************/
~MinorMk()179 MinorMk::~MinorMk()
180 /*****************************************************************************/
181 {
182 }
183 
184