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

[Feature Request] Create App Package for MacOS #688

Open
gonzonia opened this issue Jan 1, 2025 · 4 comments
Open

[Feature Request] Create App Package for MacOS #688

gonzonia opened this issue Jan 1, 2025 · 4 comments

Comments

@gonzonia
Copy link
Contributor

gonzonia commented Jan 1, 2025

I'm creating a ticket so I can hopefully collaborate with others working on this.

I'm currently able to create a package with the jpackage tool. However, when I try to launch the app it doesn't work.

This is the command I'm currently trying

I suspect two potential problems.

jpackage --name VPin-Studio --input . --app-version 3.11.2 --main-jar vpin-studio-ui.jar --main-class Launcher
--resource-dir package/macos --type dmg --icon VpinStudio.icns

  1. The main-class I'm passing to the tool is wrong.

  2. I need to provide a specific JRE runtime.

Attached is the jpackage help file.
jpackage-help.txt

@gonzonia gonzonia changed the title Create App Package for MacOS [Feature Request] Create App Package for MacOS Jan 1, 2025
@karlsnyder0
Copy link
Collaborator

karlsnyder0 commented Jan 1, 2025

I'm actually working on this. One of the issues that you will encounter is related to attributes through xattr. I'm on the road at the moment and I don't recall the syntax, however a MacOS needs to set these attributes once the App folder is on the client machine. This is important because of Apple's new security

@gonzonia
Copy link
Contributor Author

gonzonia commented Jan 1, 2025

When you're back take a look and post what you're referring to here. I'm not sure we're taking the same path to the solution.

@karlsnyder0
Copy link
Collaborator

karlsnyder0 commented Jan 1, 2025

I messaged you in Discord with some background info.

Here's a possible starting point as a script to run on the macOS client to create a working App from a pre-generated bundle-

#!/bin/bash

# Function to request sudo password using a dialog
request_sudo() {
  osascript -e 'Tell application "System Events" to display dialog "This operation requires administrative privileges to install VPin Studio. Please enter your password:" default answer "" with hidden answer buttons {"Cancel", "OK"} default button "OK"' \
    -e 'text returned of result' 2>/dev/null
}

# Prompt for sudo password and cache it
SUDO_PASS=$(request_sudo)
if [[ -z "$SUDO_PASS" ]]; then
  echo "Operation cancelled by user."
  exit 1
fi

# Validate the password
echo "$SUDO_PASS" | sudo -S echo "" >/dev/null 2>&1
if [[ $? -ne 0 ]]; then
  echo "Invalid password. Exiting."
  exit 1
fi

# Create a unique temporary directory
TEMP_DIR=$(mktemp -d)

# Ensure the directory is created
if [[ ! -d "$TEMP_DIR" ]]; then
  echo "Failed to create a temporary directory. Exiting."
  exit 1
fi

# GitHub download URL for the VPin Studio zip file
GITHUB_URL="https://github.com/your-repo/vpin-studio/releases/latest/download/VPinStudio.zip"

# Path to the downloaded zip file
ZIP_FILE="$TEMP_DIR/VPinStudio.zip"

# Download the zip file
echo "Downloading VPin Studio from GitHub..."
curl -L -o "$ZIP_FILE" "$GITHUB_URL"
if [[ $? -ne 0 ]]; then
  echo "Error: Failed to download the zip file."
  rm -rf "$TEMP_DIR"
  exit 1
fi

# Extract the zip file into the temporary directory
echo "Extracting VPin Studio..."
unzip -d "$TEMP_DIR" "$ZIP_FILE"

# Find the .app directory inside the extracted contents
APP_BUNDLE=$(find "$TEMP_DIR" -name "*.app" -type d | head -n 1)

if [[ -z "$APP_BUNDLE" ]]; then
  echo "Error: No .app bundle found in the zip file."
  rm -rf "$TEMP_DIR"
  exit 1
fi

# Define the target application name and path
APP_NAME="VPin Studio"
DEST_PATH="/Applications/$APP_NAME.app"

# Copy the .app bundle to the /Applications directory
echo "$SUDO_PASS" | sudo -S cp -R "$APP_BUNDLE" "$DEST_PATH"

# Remove extended attributes to ensure the app can run
echo "$SUDO_PASS" | sudo -S xattr -cr "$DEST_PATH"

# Clean up temporary files
rm -rf "$TEMP_DIR"

# Notify the user
echo "VPin Studio has been successfully installed at: $DEST_PATH"

@gonzonia
Copy link
Contributor Author

gonzonia commented Jan 2, 2025

Started pull request. I created a config file with parameters to be passed to the package app on a mac to correctly bundle everything. I'll zip up and add the app bundle it created to the directory as well. I used this file to create an app bundle with a clean install folder that only had the jar, resources folder, and files necessary for the icons. I'm not sure how to integrate this into the larger build process.

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

No branches or pull requests

2 participants