Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing jpackage options #5227

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

StefanLobbenmeier
Copy link

@StefanLobbenmeier StefanLobbenmeier commented Feb 9, 2025

Describe proposed changes and the issue being fixed

Adds additional jpackage options, introduced in jdk 17 and 21:

  • --win-shortcut-prompt (from jdk 17)
  • --win-update-url (from jdk 17)
  • --linux-package-deps (from jdk 17) - (although I am unsure how to use that option, naming suggests an argument but there is no argument documented)
  • --mac-dmg-content (from jdk 21)

Fixes

Testing

Describe how you tested your changes. If possible and needed:

  • Test it on a sample project
  • Write unit tests
  • Provide a code snippet

This should be tested by QA

Release Notes

Fixes - Desktop

  • Added jpackage options --win-shortcut-prompt, --win-update-url, --linux-package-deps and --mac-dmg-content

@@ -36,6 +36,8 @@ abstract class AbstractMacOSPlatformSettings : AbstractPlatformSettings() {
var appCategory: String? = null
var minimumSystemVersion: String? = null

var dmgContents = ArrayList<String>()
Copy link
Author

Choose a reason for hiding this comment

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

since this is supported from 21 onwards, I considered having this option opt-in to make sure people are aware that this only works when building with jdk 21

But possibly I am overthinking this, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to check the toolchain here, and issue a warning (and ignore the property) if current JDK is older than 21?

Copy link
Author

Choose a reason for hiding this comment

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

it probably is possible, but I would need a pointer to somewhere this has been done to make sure I get it right

Copy link
Author

Choose a reason for hiding this comment

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

I found if (jvmRuntimeInfo.majorVersion >= 18) { on my own 😄

@StefanLobbenmeier StefanLobbenmeier marked this pull request as ready for review February 9, 2025 17:02
@StefanLobbenmeier
Copy link
Author

Not tested yet, only made sure to copy the values from documentation. Not sure how I can make a snapshot build from this to test in a sample projects. If there is an easy way to publish this as snapshot I have a sample repo to test these changes

@StefanLobbenmeier StefanLobbenmeier changed the title Add missing jpackage options, fix cmp 7580 Add missing jpackage options Feb 9, 2025
@MatkovIvan MatkovIvan requested a review from kropp February 14, 2025 09:05
@kropp
Copy link
Member

kropp commented Feb 14, 2025

Please add a reference to https://youtrack.jetbrains.com/issue/CMP-2236 in the PR description

@kropp
Copy link
Member

kropp commented Feb 14, 2025

I haven't used jpackage on Linux, but https://github.com/petr-panteleyev/jpackage-gradle-plugin/ suggests that the --linux-package-deps option might be boolean.
Could you please verify it and update documentation, or remove it until its meaning is clear.

@@ -36,6 +36,8 @@ abstract class AbstractMacOSPlatformSettings : AbstractPlatformSettings() {
var appCategory: String? = null
var minimumSystemVersion: String? = null

var dmgContents = ArrayList<String>()
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to check the toolchain here, and issue a warning (and ignore the property) if current JDK is older than 21?

@StefanLobbenmeier
Copy link
Author

I agree, the documentation is bad there. I just spun up an ubuntu docker container to check this.

I could confirm that the option accepts parameters and those affect the output .deb:

This is the .deb I got with this jpackage command: jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar --linux-package-deps ffmpeg

dpkg -I yt-dlp-compose_1.0_arm64-ffmpeg-dep.deb
 new Debian package, version 2.0.
 size 37176504 bytes: control archive=1127 bytes.
     531 bytes,    11 lines      control
     867 bytes,    38 lines   *  postinst             #!/bin/sh
     819 bytes,    31 lines   *  postrm               #!/bin/sh
     631 bytes,    35 lines   *  preinst              #!/bin/sh
     789 bytes,    39 lines   *  prerm                #!/bin/sh
 Package: yt-dlp-compose
 Version: 1.0
 Section: misc
 Maintainer: Unknown <Unknown>
 Priority: optional
 Architecture: arm64
 Provides: yt-dlp-compose
 Description: yt-dlp-compose
 Depends: libasound2t64, libbrotli1, libbsd0, libbz2-1.0, libc6, libfreetype6, libgcc-s1, libgif7, libglib2.0-0t64, libgraphite2-3, libharfbuzz0b, libjpeg-turbo8, liblcms2-2, libmd0, libpcre2-8-0, libpcsclit
e1, libpng16-16t64, libstdc++6, libx11-6, libxau6, libxcb1, libxdmcp6, libxext6, libxi6, libxrender1, libxtst6, zlib1g , ffmpeg
 Installed-Size: 160957

While the .deb without dependencies does not have this dependency (jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar):

dpkg -I yt-dlp-compose_1.0_arm64-without-deps.deb
 new Debian package, version 2.0.
 size 37177420 bytes: control archive=1122 bytes.
     523 bytes,    11 lines      control
     867 bytes,    38 lines   *  postinst             #!/bin/sh
     819 bytes,    31 lines   *  postrm               #!/bin/sh
     631 bytes,    35 lines   *  preinst              #!/bin/sh
     789 bytes,    39 lines   *  prerm                #!/bin/sh
 Package: yt-dlp-compose
 Version: 1.0
 Section: misc
 Maintainer: Unknown <Unknown>
 Priority: optional
 Architecture: arm64
 Provides: yt-dlp-compose
 Description: yt-dlp-compose
 Depends: libasound2t64, libbrotli1, libbsd0, libbz2-1.0, libc6, libfreetype6, libgcc-s1, libgif7, libglib2.0-0t64, libgraphite2-3, libharfbuzz0b, libjpeg-turbo8, liblcms2-2, libmd0, libpcre2-8-0, libpcsclite1, libpng16-16t64, libstdc++6, libx11-6, libxau6, libxcb1, libxdmcp6, libxext6, libxi6, libxrender1, libxtst6, zlib1g
 Installed-Size: 161654

Somewhat incomplete history of commands in case you want to reproduce (missing apt install openjdk tmux, but this will depend on the image)

    1  git clone https://github.com/StefanLobbenmeier/yt-dlp-compose.git
    2  apt install git
    3  git clone https://github.com/StefanLobbenmeier/yt-dlp-compose.git
    4  cd yt-dlp-compose/
    5  ./gradlew assemble
    6  ls
    7  ls build
    8  ls build/libs/
    9  ls build/libs/yt-dlp-compose-1.0.0.jar
   10  jpackage build/libs/yt-dlp-compose-1.0.0.jar
   11  jpackage --type jlink --name yt-dlp-compose --main-jar build/libs/yt-dlp-compose-1.0.0.jar
   12  jpackage --type jlink --name yt-dlp-compose --main-jar build/libs/yt-dlp-compose-1.0.0.jar --input build/libs
   13  apt search jlink
   14  jpackage --type deb --name yt-dlp-compose --main-jar build/libs/yt-dlp-compose-1.0.0.jar --input build/libs
   15  jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar
   16  apt install fakeroot
   17  jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar
   18  apt install objcopy
   19  apt search objcopy
   20  apt install binutils
   21  jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar
   22  ls
   23  mv yt-dlp-compose_1.0_arm64.deb yt-dlp-compose_1.0_arm64-without-deps.deb
   24  jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar --linux-package-deps openjdk-21-jdk
   25  mv yt-dlp-compose_1.0_arm64.deb yt-dlp-compose_1.0_arm64-openjdk-dep.deb
   26  jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar --linux-package-deps ffmpeg
   27  dpkg -I package.deb
   28  dpkg -I yt-dlp-compose_1.0_arm64-openjdk-dep.deb
   29  mv yt-dlp-compose_1.0_arm64.deb yt-dlp-compose_1.0_arm64-ffmpeg-dep.deb
   30  dpkg -I yt-dlp-compose_1.0_arm64-ffmpeg-dep.deb
   31  history

@StefanLobbenmeier
Copy link
Author

Just some more tests, you can add multiple dependencies separated by comma: --linux-package-deps "foo, bar"

Depends: libasound2t64, libbrotli1, libbsd0, libbz2-1.0, libc6, libfreetype6, libgcc-s1, libgif7, libglib2.0-0t64, libgraphite2-3, libharfbuzz0b, libjpeg-turbo8, liblcms2-2, libmd0, libpcre2-8-0, libpcsclite1, libpng16-16t64, libstdc++6, libx11-6, libxau6, libxcb1, libxdmcp6, libxext6, libxi6, libxrender1, libxtst6, zlib1g , foo, bar

And just putting it there without arguments does not add any binaries:

jpackage --type deb --name yt-dlp-compose --input build/libs --main-jar yt-dlp-compose-1.0.0.jar --linux-package-deps

Depends: libasound2t64, libbrotli1, libbsd0, libbz2-1.0, libc6, libfreetype6, libgcc-s1, libgif7, libglib2.0-0t64, libgraphite2-3, libharfbuzz0b, libjpeg-turbo8, liblcms2-2, libmd0, libpcre2-8-0, libpcsclit
e1, libpng16-16t64, libstdc++6, libx11-6, libxau6, libxcb1, libxdmcp6, libxext6, libxi6, libxrender1, libxtst6, zlib1g

But this only works when its the last argument, otherwise it consumes the next one:

jpackage --type deb --name yt-dlp-compose --input build/libs --linux-package-deps --main-jar yt-dlp-compose-1.0.0.jar
Error: Invalid Option: [yt-dlp-compose-1.0.0.jar]

@StefanLobbenmeier
Copy link
Author

One more evidence that behaviour is different from documentation - this is the definition of the argument in code, its a string argument:

https://github.com/openjdk/jdk/blob/fea5f2b1458cdd53f437e59caaffaa6e22fb59a7/src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxPackageBundler.java#L366-L372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants