Skip to content

Commit

Permalink
8295111: dpkg appears to have problems resolving symbolically linked …
Browse files Browse the repository at this point in the history
…native libraries

Reviewed-by: almatvee
  • Loading branch information
Alexey Semenyuk committed Apr 18, 2024
1 parent 6ee8407 commit 32946e1
Showing 1 changed file with 41 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -201,6 +201,24 @@ protected void initLibProvidersLookup(
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.
Expand Down Expand Up @@ -243,32 +261,30 @@ protected void initLibProvidersLookup(
// 4. Arch suffix should be stripped from accepted package names.
//

libProvidersLookup.setPackageLookup(file -> {
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);
}
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);
}
});
}
});

if (!archPackages.isEmpty()) {
return archPackages.stream();
}
return otherPackages.stream();
});
if (!archPackages.isEmpty()) {
return archPackages.stream();
}
return otherPackages.stream();
}

@Override
Expand Down

9 comments on commit 32946e1

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexeysemenyukoracle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk22u

@openjdk
Copy link

@openjdk openjdk bot commented on 32946e1 Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexeysemenyukoracle the backport was successfully created on the branch backport-alexeysemenyukoracle-32946e18 in my personal fork of openjdk/jdk22u. To create a pull request with this backport targeting openjdk/jdk22u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 32946e18 from the openjdk/jdk repository.

The commit being backported was authored by Alexey Semenyuk on 18 Apr 2024 and was reviewed by Alexander Matveev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk22u:

$ git fetch https://github.com/openjdk-bots/jdk22u.git backport-alexeysemenyukoracle-32946e18:backport-alexeysemenyukoracle-32946e18
$ git checkout backport-alexeysemenyukoracle-32946e18
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk22u.git backport-alexeysemenyukoracle-32946e18

@vpa1977
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u

@openjdk
Copy link

@openjdk openjdk bot commented on 32946e1 May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vpa1977 the backport was successfully created on the branch backport-vpa1977-32946e18 in my personal fork of openjdk/jdk21u. To create a pull request with this backport targeting openjdk/jdk21u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 32946e18 from the openjdk/jdk repository.

The commit being backported was authored by Alexey Semenyuk on 18 Apr 2024 and was reviewed by Alexander Matveev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u:

$ git fetch https://github.com/openjdk-bots/jdk21u.git backport-vpa1977-32946e18:backport-vpa1977-32946e18
$ git checkout backport-vpa1977-32946e18
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u.git backport-vpa1977-32946e18

⚠️ @vpa1977 You are not yet a collaborator in my fork openjdk-bots/jdk21u. An invite will be sent out and you need to accept it before you can proceed.

@vpa1977
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 32946e1 May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vpa1977 the backport was successfully created on the branch backport-vpa1977-32946e18 in my personal fork of openjdk/jdk21u-dev. To create a pull request with this backport targeting openjdk/jdk21u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 32946e18 from the openjdk/jdk repository.

The commit being backported was authored by Alexey Semenyuk on 18 Apr 2024 and was reviewed by Alexander Matveev.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk21u-dev:

$ git fetch https://github.com/openjdk-bots/jdk21u-dev.git backport-vpa1977-32946e18:backport-vpa1977-32946e18
$ git checkout backport-vpa1977-32946e18
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk21u-dev.git backport-vpa1977-32946e18

@vpa1977
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 32946e1 May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vpa1977 Could not automatically backport 32946e18 to openjdk/jdk17u-dev due to conflicts in the following files:

  • src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-vpa1977-32946e18

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 32946e1882e9b22c983cbba3c6bda3cc7295946a

# Backport the commit
$ git cherry-pick --no-commit 32946e1882e9b22c983cbba3c6bda3cc7295946a
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 32946e1882e9b22c983cbba3c6bda3cc7295946a'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport 32946e1882e9b22c983cbba3c6bda3cc7295946a.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 32946e18 from the openjdk/jdk repository.

The commit being backported was authored by Alexey Semenyuk on 18 Apr 2024 and was reviewed by Alexander Matveev.

Thanks!

Please sign in to comment.