8273595: tools/jpackage tests do not work on apt-based Linux distros like Debian

Co-authored-by: Sun Xu <sunxu01@loongson.cn>
Reviewed-by: asemenyuk, herrick
This commit is contained in:
Ao Qi 2021-09-10 23:13:18 +00:00 committed by Jie Fu
parent 922e86f4ff
commit f189dff5cb
2 changed files with 5 additions and 20 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2021, 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
@ -119,6 +119,6 @@ public enum PackageType {
private final static class Inner {
private final static Set<String> DISABLED_PACKAGERS = Optional.ofNullable(
TKit.tokenizeConfigProperty("disabledPackagers")).orElse(
TKit.isUbuntu() ? Set.of("rpm") : Collections.emptySet());
TKit.isLinuxAPT() ? Set.of("rpm") : Collections.emptySet());
}
}

View File

@ -22,10 +22,8 @@
*/
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;
@ -184,25 +182,12 @@ final public class TKit {
return ((OS.contains("nix") || OS.contains("nux")));
}
public static boolean isUbuntu() {
public static boolean isLinuxAPT() {
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;
File aptFile = new File("/usr/bin/apt-get");
return aptFile.exists();
}
private static String addTimestamp(String msg) {