8295111: dpkg appears to have problems resolving symbolically linked native libraries
Reviewed-by: almatvee
This commit is contained in:
parent
6ee8407758
commit
32946e1882
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2024, 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
|
||||
@ -201,6 +201,24 @@ public class LinuxDebBundler extends LinuxPackageBundler {
|
||||
Map<String, ? super Object> params,
|
||||
LibProvidersLookup libProvidersLookup) {
|
||||
|
||||
libProvidersLookup.setPackageLookup(file -> {
|
||||
Path realPath = file.toRealPath();
|
||||
|
||||
try {
|
||||
// Try the real path first as it works better on newer Ubuntu versions
|
||||
return findProvidingPackages(realPath);
|
||||
} catch (IOException ex) {
|
||||
// Try the default path if differ
|
||||
if (!realPath.toString().equals(file.toString())) {
|
||||
return findProvidingPackages(file);
|
||||
} else {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Stream<String> findProvidingPackages(Path file) throws IOException {
|
||||
//
|
||||
// `dpkg -S` command does glob pattern lookup. If not the absolute path
|
||||
// to the file is specified it might return mltiple package names.
|
||||
@ -243,32 +261,30 @@ public class LinuxDebBundler extends LinuxPackageBundler {
|
||||
// 4. Arch suffix should be stripped from accepted package names.
|
||||
//
|
||||
|
||||
libProvidersLookup.setPackageLookup(file -> {
|
||||
Set<String> archPackages = new HashSet<>();
|
||||
Set<String> otherPackages = new HashSet<>();
|
||||
Set<String> archPackages = new HashSet<>();
|
||||
Set<String> otherPackages = new HashSet<>();
|
||||
|
||||
Executor.of(TOOL_DPKG, "-S", file.toString())
|
||||
.saveOutput(true).executeExpectSuccess()
|
||||
.getOutput().forEach(line -> {
|
||||
Matcher matcher = PACKAGE_NAME_REGEX.matcher(line);
|
||||
if (matcher.find()) {
|
||||
String name = matcher.group(1);
|
||||
if (name.endsWith(":" + DEB_ARCH)) {
|
||||
// Strip arch suffix
|
||||
name = name.substring(0,
|
||||
name.length() - (DEB_ARCH.length() + 1));
|
||||
archPackages.add(name);
|
||||
} else {
|
||||
otherPackages.add(name);
|
||||
}
|
||||
Executor.of(TOOL_DPKG, "-S", file.toString())
|
||||
.saveOutput(true).executeExpectSuccess()
|
||||
.getOutput().forEach(line -> {
|
||||
Matcher matcher = PACKAGE_NAME_REGEX.matcher(line);
|
||||
if (matcher.find()) {
|
||||
String name = matcher.group(1);
|
||||
if (name.endsWith(":" + DEB_ARCH)) {
|
||||
// Strip arch suffix
|
||||
name = name.substring(0,
|
||||
name.length() - (DEB_ARCH.length() + 1));
|
||||
archPackages.add(name);
|
||||
} else {
|
||||
otherPackages.add(name);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (!archPackages.isEmpty()) {
|
||||
return archPackages.stream();
|
||||
}
|
||||
return otherPackages.stream();
|
||||
});
|
||||
if (!archPackages.isEmpty()) {
|
||||
return archPackages.stream();
|
||||
}
|
||||
return otherPackages.stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user