Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
8238953: tools/jpackage tests do not work on Ubuntu Linux
Browse files Browse the repository at this point in the history
Reviewed-by: asemenyuk, clanger
  • Loading branch information
MBaesken committed Feb 18, 2020
1 parent 7f3bbc3 commit 09f5194
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
@@ -1,5 +1,5 @@
/*
* 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
Expand Down Expand Up @@ -117,9 +117,8 @@ private static boolean isBundlerSupported(String bundlerClass) {
MAC.stream()).collect(Collectors.toUnmodifiableSet());

private final static class Inner {

private final static Set<String> DISABLED_PACKAGERS = Optional.ofNullable(
TKit.tokenizeConfigProperty("disabledPackagers")).orElse(
Collections.emptySet());
TKit.isUbuntu() ? Set.of("rpm") : Collections.emptySet());
}
}
26 changes: 25 additions & 1 deletion test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java
@@ -1,5 +1,5 @@
/*
* 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
Expand All @@ -22,7 +22,10 @@
*/
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;
Expand Down Expand Up @@ -178,6 +181,27 @@ public static boolean isLinux() {
return ((OS.contains("nix") || OS.contains("nux")));
}

public static boolean isUbuntu() {
if (!isLinux()) {
return false;
}
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) {
Expand Down

0 comments on commit 09f5194

Please sign in to comment.