< prev index next >
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java
Print this page
rev 58025 : 8238953: tools/jpackage tests do not work on Ubuntu Linux
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -20,11 +20,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.jpackage.test;
+import java.io.BufferedReader;
+import java.io.File;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.*;
import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
@@ -176,10 +179,28 @@
public static boolean isLinux() {
return ((OS.contains("nix") || OS.contains("nux")));
}
+ public static boolean isUbuntu() {
+ File releaseFile = new File("/etc/os-release");
+ if (releaseFile.exists()) {
+ try (BufferedReader lineReader = new BufferedReader(new FileReader(releaseFile))) {
+ String lineText = null;
+ while ((lineText = lineReader.readLine()) != null) {
+ if (lineText.indexOf("NAME=\"Ubuntu") != -1) {
+ lineReader.close();
+ return true;
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
static void log(String v) {
System.out.println(v);
if (extraLogStream != null) {
extraLogStream.println(v);
}
< prev index next >