Skip to content

Build local app bundle#37

Open
ChristopherSchultz wants to merge 12 commits into
TheCase:mainfrom
ChristopherSchultz:build-local-app
Open

Build local app bundle#37
ChristopherSchultz wants to merge 12 commits into
TheCase:mainfrom
ChristopherSchultz:build-local-app

Conversation

@ChristopherSchultz
Copy link
Copy Markdown
Contributor

Builds IPMIview.app locally instead of into ~/Applications.

Detects architecture and requires x86-64 on aarm64.

Saves the connection properties from the old application bundle.

Also auto-detect the architecture of the machine and the JVM.
Stop and require the use of x86-64 and Rosetta on aarch64.
@ChristopherSchultz
Copy link
Copy Markdown
Contributor Author

I may have put too many things together in one PR so let me know if you want me to re-work it.

It's including a .class file which is super yucky, but I included the source there, too. The script with re-generate the .class file from the .java file if it's not there, but only if JAVA_HOME points to a JDK...

Comment thread script.sh Outdated
Comment thread script.sh Outdated
Comment thread script.sh
Comment on lines +108 to +112
if arch -x86_64 /usr/bin/true 2> /dev/null; then
echo "Rosetta 2 appears to be installed, so you will already be able to run the x86-64 JRE/JDK."
else
echo "You may also need to install Rosetta 2 to run an x86-64 Java Runtime Environment."
fi
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the above echo seems to guide the user that they need to re-run the script, yet these two messages seem to guide them to different steps. is there perhaps a more clear way to surface the information to the user so it's clear what action(s) they need to take?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe.

In order to run IPMIView and use the KVM (which is pretty important), the prerequisites include an x86-64 JVM. You can do that on aarch64 as long as you (a) have the JVM (!!) and (b) have Rosetta 2 installed.

I'm not 100% sure if the "Rosetta 2 detection scheme" I have above will always work. I know it works for me, but it's entirely possible it won't work for others, or maybe it won't work in the future, so I hedged the language with "You may need to install..." rather than stating that it is absolutely a TODO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to be more descriptive. In the first case, Rosetta 2 is definitely installed and all you need is the JVM.

In the second case, you probably need to download and install both.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not 100% sure if the "Rosetta 2 detection scheme" I have above will always work. I know it works for me, but it's entirely possible it won't work for others,

Yeah, that's fair - I'd honestly just lean on the community to help test this detection scheme to confirm one way or the other. I'm not suggesting this NEEDS to happen before this PR gets merged, but if folks are willing/able to ahead of the merge, that'd be great.

How about something like this as a straw man proposal:

  if [ "x86_64" != "$jarch" ] ; then

    rosetta_install_required=0
    if ! arch -x86_64 /usr/bin/true 2> /dev/null; then
      echo "[ERROR] On ${arch}, Rosetta 2 is needed to run an x86-64 Java Runtime Environment."
      rosetta_install_required=1
    fi

    echo "[ERROR] The Java architecture for JAVA_HOME=$JAVA_HOME is $jarch. This application bundle requires an x86-64 JRE."

    echo
    echo "[FAILED] IPMIView.app was not built. Take the below step(s) and re-run the script."
    echo "    - Set JAVA_HOME to an x86-64 JRE."
    
    if [ $rosetta_install_required -eq 1 ]; then
      echo "    - Install Rosetta 2."
    fi

    exit 1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Have a look at my most recent changes. I'm happy to change over to a bulleted-list of instructions if you think it's "too much to read".

Comment thread script.sh
echo "Completed."
echo
echo "You can now open ~/Applications/IPMIView.app"
echo "You can now open ./IPMIView.app or copy it into ~/Applications"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we keep this contract (that the script yields ~/Applications/IPMIView.app) the same? any particular reason to change it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not married to local-only build, but this is the only product I know of that really wants to put itself into ~/Applications.

There's no reason to require it to go there other than it gets into Launchpad (eventually). You could also install it into /Applications if you chose to.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Understand - ultimately, it's up to the person running this script to decide where they ultimately want the app to live (in /Applications, or elsewhere). My point is that the change here is moving where it is currently stored, which might be unexpected by users who have known the script to generate the app into ~/Applications directory. If that's something that we really really want to change, then I'd recommend we also update all other references to this, and put a clear notification to folks in the README stating that the location the app is generated to has moved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll fix this and maybe make it a completely separate PR.

Comment thread script.sh Outdated
Comment thread PropertyPrint.java Outdated
@TheCase
Copy link
Copy Markdown
Owner

TheCase commented Jan 5, 2025

@ChrisCarini and @ChristopherSchultz, you have both be added as invited collaborators on this project. Feel free to take it under your collective wings. I'll remain a bystander but will probably not be able to contribute in the near term. If you have any issues with access for making changes, reviewing or merging - please do let me know.

@ChrisCarini
Copy link
Copy Markdown
Collaborator

@ChrisCarini and @ChristopherSchultz, you have both be added as invited collaborators on this project. Feel free to take it under your collective wings. I'll remain a bystander but will probably not be able to contribute in the near term. If you have any issues with access for making changes, reviewing or merging - please do let me know.

Thanks @TheCase - you had actually already added me as a collaborator a while back :P But appreciate the sentiment again! ❤️

@TheCase
Copy link
Copy Markdown
Owner

TheCase commented Jan 5, 2025

Also, if either of you would prefer to host a new active fork under either of your accounts, I can adjust the project notes to direct folks to the project repo that is under active development.

@ChrisCarini
Copy link
Copy Markdown
Collaborator

Also, if either of you would prefer to host a new active fork under either of your accounts, I can adjust the project notes to direct folks to the project repo that is under active development.

If that's desired/preferred, I'd be happy to volunteer to take it. I think for the time being, it should be ok - should we run into other problems where we need to consider a transfer/fork, I'd vote we have that conversation then. WDYT @TheCase ?

@TheCase
Copy link
Copy Markdown
Owner

TheCase commented Jan 5, 2025

Works for me :)

@ChristopherSchultz
Copy link
Copy Markdown
Contributor Author

@TheCase @ChrisCarini I think this is ready. The last part was ensuring that JAVA_HOME is set in the application launcher.

Can I get a review -- even if only to confirm that the build works in your environments and the app bundle ends up being usable?

I had another emergency this morning, and so IPMIView.app came back to the forefront of my mind :)

Copy link
Copy Markdown
Collaborator

@ChrisCarini ChrisCarini left a comment

Choose a reason for hiding this comment

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

Generally looks good.

However when I tried testing this (using the quick start instructions, modifying the clone to use your fork + this PR branch before invoking the script), I just got an application that would appear to take a while to open, but not actually open anything. Did you happen to notice anything like this at all when you were developing?

Comment thread script.sh

if [ "x86_64" != "$jarch" ] ; then
echo "*"
echo "* This application bundle requires on x86-64 Java Runtime Environment (JRE/JDK)"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "* This application bundle requires on x86-64 Java Runtime Environment (JRE/JDK)"
echo "* This application bundle requires a x86-64 Java Runtime Environment (JRE/JDK)"

Comment thread script.sh
Comment on lines +101 to +102
echo "* In order to run an x86-64 JRE/JDK on your ${arch} computer, you will"
echo "* need to install Apple's Rosetta 2 software."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "* In order to run an x86-64 JRE/JDK on your ${arch} computer, you will"
echo "* need to install Apple's Rosetta 2 software."
echo "* In order to run an x86-64 JRE/JDK on your ${arch} computer,"
echo "* Apple's Rosetta 2 software is required."

Comment thread script.sh
Comment on lines +107 to +108
echo "* the x86-64 JRE/JDK once you install it (if necessary) and set JAVA_HOME"
echo "* to point to it."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "* the x86-64 JRE/JDK once you install it (if necessary) and set JAVA_HOME"
echo "* to point to it."
echo "* the x86-64 JRE/JDK once installed and JAVA_HOME is set to point to it."

Comment thread script.sh
else
echo "* Rosetta 2 can't be detected on this system, so it is probably not installed."
echo "* You can install it using this command:"
echo
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo
echo "*"

(for consistency 😄)

Comment thread README.md
```

You should now have an application icon in your home directory's Applications (aka `~/Applications`) folder.
You should now have an application icon in the current directory. You can copy it into `/Applications/` or into `~/Applications/` ror run it from the current location if you'd like.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
You should now have an application icon in the current directory. You can copy it into `/Applications/` or into `~/Applications/` ror run it from the current location if you'd like.
You should now have an application icon in the current directory. You can copy it into `/Applications/`, `~/Applications/`, or run it from the git repo root, if you'd like.

Comment thread script.sh
echo "Extracting contents of downloaded IPMIView archive..."
if [[ -d Contents/Resources/IPMIView ]]; then
rm -rf Contents/Resources/IPMIView
echo "Using Java from $JAVA_HOME"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's move this entire block/check to the top so the script can fail fast - right now the script will download files (which can take a bit, depending on the user's internet connection), and then show this message to the user; its be better UX to fail fast.

Comment thread script.sh
echo "* This application bundle requires on x86-64 Java Runtime Environment (JRE/JDK)"
echo "* to run properly."
echo "*"
echo "* The Java platform is $jarch for JAVA_HOME=$JAVA_HOME"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
echo "* The Java platform is $jarch for JAVA_HOME=$JAVA_HOME"
echo "* The Java platform is ${jarch} for JAVA_HOME=${JAVA_HOME}"

(personal pref, but suggesting this for consistency sake)

Comment thread script.sh
Comment on lines +84 to +87
if [ "$arch" = "x86_64" ] ; then
echo "Using ${arch} platform."
elif [ "$arch" = "arm64" -o "$arch" = "aarch64" ] ; then
echo "Using ${arch} platform. Checking Java version..."
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if [ "$arch" = "x86_64" ] ; then
echo "Using ${arch} platform."
elif [ "$arch" = "arm64" -o "$arch" = "aarch64" ] ; then
echo "Using ${arch} platform. Checking Java version..."
echo "Using ${arch} platform."
if [ "$arch" = "arm64" -o "$arch" = "aarch64" ] ; then
echo "Checking Java version..."

Comment thread README.md
@@ -9,7 +9,7 @@ cd IPMIView.app
bash script.sh
```
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At the very least, let's get a short **Note:** ... here guiding users how to invoke this on arm64 Macs; we're close enough to EOL that it's worth doing, IMO.

Comment thread script.sh
echo "Falling back to last known version."
echo "Please file an issue at https://github.com/TheCase/IPMIView.app/issues regarding latest version discovery."
DOWNLOAD_FILENAME="IPMIView_2.21.1_build.230720_bundleJRE_Linux_x64.tar.gz"
DOWNLOAD_FILENAME="IPMIView_2.24.0_build.251224_bundleJRE_Linux_x64.tar.gz"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for updating the version! 💪

@wsantos1
Copy link
Copy Markdown

Hi, I know this is pretty old but any chance this makes it to a new version? As I was troubleshooting this same issue, I manually added the export JAVA_HOME=... to the Contents/MacOS/IPMIView and found this PR when I was going to create a related issue/PR.

Thanks to all that have contributed to this. It saved me from a lot of walking!

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.

4 participants