bump product version to 4.1.6.2
[LibreOffice.git] / qadevOOo / runner / convwatch / BuildID.java
blob50865d473f6a052fc02513d8a0e1a5721ba34a1b
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package convwatch;
21 import java.io.File;
22 import helper.OSHelper;
23 import convwatch.IniFile;
25 public class BuildID
27 public static String getBuildID(String _sApp)
29 String sOfficePath = "";
30 if (_sApp.startsWith("\""))
32 int nIdx = _sApp.indexOf("\"", 1);
33 if (nIdx == -1)
36 else
38 // leave double qoute out.
39 sOfficePath = _sApp.substring(1, nIdx);
42 else
44 // check if a space exist, so we get all until space
45 int nIdx = _sApp.indexOf(" ", 1);
46 if (nIdx == -1)
48 sOfficePath = _sApp;
50 else
52 sOfficePath = _sApp.substring(0, nIdx);
55 GlobalLogWriter.get().println("Office path: " + sOfficePath);
57 String fs = System.getProperty("file.separator");
58 String sBuildID = "";
59 File aSOfficeFile = new File(sOfficePath);
60 if (aSOfficeFile.exists())
62 int nIdx = sOfficePath.lastIndexOf(fs);
63 sOfficePath = sOfficePath.substring(0, nIdx);
64 // ok. System.out.println("directory: " + sOfficePath);
65 sBuildID = getBuildIDFromBootstrap(sOfficePath);
66 if (sBuildID.length() == 0)
68 sBuildID = getBuildIDFromVersion(sOfficePath);
71 else
73 GlobalLogWriter.get().println("soffice executable not found.");
76 return sBuildID;
79 private static String getBuildIDFromBootstrap(String _sOfficePath)
81 String fs = System.getProperty("file.separator");
82 String sBuildID = "";
83 String sOfficePath = _sOfficePath;
84 if (OSHelper.isWindows())
86 sOfficePath += fs + "bootstrap.ini";
88 else
90 sOfficePath += fs + "bootstraprc";
92 IniFile aIniFile = new IniFile(sOfficePath);
93 if (aIniFile.is())
95 sBuildID = aIniFile.getValue("Bootstrap", "buildid");
97 else
99 GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check.");
101 return sBuildID;
104 private static String getBuildIDFromVersion(String _sOfficePath)
106 String fs = System.getProperty("file.separator");
107 String sBuildID = "";
108 String sOfficePath = _sOfficePath;
109 if (OSHelper.isWindows())
111 sOfficePath += fs + "version.ini";
113 else
115 sOfficePath += fs + "versionrc";
117 IniFile aIniFile = new IniFile(sOfficePath);
118 if (aIniFile.is())
120 sBuildID = aIniFile.getValue("Version", "buildid");
122 else
124 GlobalLogWriter.get().println("Property Build, can't open file '" + sOfficePath + "', please check.");
126 return sBuildID;
128 // public static void main(String[] args)
129 // {
130 // String sApp;
131 // sApp = "/opt/staroffice8_m116/program/soffice --headless --accept=socket,host=localhost,port=8100;urp;";
132 // String sBuildID;
133 // sBuildID = getBuildID(sApp);
134 // System.out.println("BuildID is: " + sBuildID);
136 // Date aDate = new Date();
137 // long nStart = aDate.getTime();
138 // System.out.println("Time:" + nStart);
139 // // LLA: Just some more tests for getBuildID
140 // // sApp = "/opt/staroffice8_net/program/soffice";
141 // // sBuildID = getBuildID(sApp);
142 // // System.out.println("BuildID is: " + sBuildID);
143 // //
144 // // sApp = "\"/opt/staroffice8_net/program/soffice\" test blah";
145 // // sBuildID = getBuildID(sApp);
146 // //
147 // // System.out.println("BuildID is: " + sBuildID);
148 // System.exit(1);
149 // }