Installing .pkg: determining if the app being updated is presently running? - macos

I'm using the brilliant Mac OS X "Packages" to generate an install a .pkg, and wondered how one constructs a shell script to make sure the application file being updated over isn't presently running (which would seem like a Very Bad Idea).

Normally this would be handled by using a pre-install script, or installer plug-in. It's unclear what you plan on doing though if the application is running.

Related

How to create application to launch wine and Windows application

I'm trying to use "wine" on MAC osX Sierra version 10.12, wine is version 1.9.19
In the terminal I can launch Windows applications, however its a pain to have to keep typing in:
/Applications/Wine\ Staging.app/Contents/MacOS/wine ~/.wine/drive_c/Program\ Files/HeidiSQL/heidisql.exe
I've searched around for a post on how to create shortcuts/applications to add to the launchpad, but so far none of the information has led me to a working end result. Either the locations of wine is different or it just doesn't work.
I've tried creating an application script:
do shell script "/Applications/Wine Staging.app/Contents/MacOS/wine ~/.wine/drive_c/Program Files/HeidiSQL/heidisql.exe"
But this won't run either.
For anyone having the same problem, in the end I created scripts which reside in my home folder:
Launch vi, create a file called HeidiSQL, insert:
wine ~/.wine/drive_c/Program\ Files/HeidiSQL/heidisql.exe
Save and exit file, grant file execute permissions:
chmod +x HeidiSQL
Launch wine terminal and type in ./HeidiSQL to launch, I then did the same for PSPad.exe:
wine ~/.wine/drive_c/Program\ Files\ \(x86\)/PSPad\ editor/PSPad.exe
I know this thread is a little old but I was just looking for something like this to launch HeidiSQL and I came up with these three solutions which I have tried and all of them work. I am putting my findings down here for it may help someone:
Wineskin (http://wineskin.urgesoftware.com), Playonmac (https://www.playonmac.com/en) and Winebottler
(http://winebottler.kronenberg.org)
Wineskin is a mac app that download and install (and manages, updates, etc) "wine" for you. It then creates a HeidiSQL.app (any name you want with any icon you want - but you need to configure it) around the windows.exe that includes the wine version selected and is completely self contained (does not need wine installed separately). Personally this is the neatest solution and my preferred even though there its a little more technical than Playonmac and similar to Winebottler. You need to read the instructions (which are very good) and you have choices to make as to the wine version to use and to configure the app. Noteworthy is that you need to change the windows version to XP rather than 7 or some buttons won't work.
Playonmac on the other hand is very user friendly. It has HeidiSQL listed on its website as compatible and its almost a single click install. You just select HeidiSQL from the list of programs and it will download everything you need for you. The only reason I prefer Wineskin is that it does not create a true self contained HeidiSQL.app. You can create a shortcut for it in your Applications folder but this will launch Playonmac and the app needs to be installed inside Playonmac. On the plus side, Playonmac will chose all the right settings for you to run the app correctly, the correct windows and wine version etc which is something you need to fiddle with with with Wineskin.
Winebottler again makes an app like Wineskin. The only real difference I could see is that with Wineskin the configuration app is actually part of the package whereas in Winebottler you have to recreate the package each time you make a change. I stuck with Wineskin. YMMV.

qt program deployed on mac. config file not writing when standalone app launched, works when run from within qt creator

I have a program that I have developed for mac osx. When the program is run from within Qt creator, a log file and a config.cfg file are created in the myapp.app/Contents/MacOS folder, alongside the executable. This is the correct behaviour, the program needs these files.
When I deploy the app to run standalone (by linking the required libraries using macdeploymentqt tool) the app launches and runs correctly however the log and config.cfg file do not get written to the myapp.app/Contents/MacOS folder and so settings can't be read in.
Is there anyway to get around this? Has anyone encountered this before?
Mitch
osx will likely not allow you writing to your bundle location on installed apps, for security reasons and because it may conflict when multiple users are using your app.
To be cross platform, you could write instead to:
QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)
which resolves to
~/Library/Application Support/<APPNAME>
and
C:/Users/<USER>/AppData/Local/<APPNAME>
or equivalent on windows.
You're never supposed to write to the application bundle, whether on Mac or on Windows. Even on Windows, it will not work if your user isn't an administrator. This idea last made sense on Windows 95 - not even on Windows NT. Don't do it.

How do I package my appjs app?

I'm trying to release a package for my appjs app but there doesn't seem to be any easy way for end users to "just run" the application without a terminal.
Is there anyway to do this that is fool proof?
So I've found an easy way to do this, not necessarily the easiest way but it works.
OSx
I use this bash script to convert my folder to a .app folder (which is all OSx needs apparently)
Windows
and on Windows I use IsTools to create my in/un-staller and shortcuts.
Linux
I've not found an easy peasy way to do this on Linux yet but we don't have a customer base on Linux so it doesn't matter. I have however found this but it seems awefully convoluted. Shan't bother for now.
If you download the distributable for your platform from: http://appjs.org/#download. Then it includes a launch script -- app.exe for windows and app.sh for linux / mac os which launches everything without a console.
There is also an addition to appjs that installs appjs as a platform feature (rather than having the whole runtime in each application you distribute). Using this you can compile your application into a single file which you can then distribute to end users. This functionality is being actively developed and improved. http://appjs.delightfulsoftware.com/. see also screenshot tour for windows: http://appjs.delightfulsoftware.com/win.htm and for ubuntu linux: http://appjs.delightfulsoftware.com/ubuntu.htm.
/Simon

What is the Ruby tool that allows for bootstrapping an OS X environment?

For the life of me I can't find the tool I ran across yesterday. It's not Homebrew (I already use Homebrew) what I found was a tool that I think was built in Ruby that allowed for installing regular .app applications and otherwise scripting most of an OS X config (I assume preferences and other things). I already have a script based on the Thoughtbot Ruby environment that I'm able to run successfully but I'd love the ability to script installing the other 20-30 apps that I use so that it would make reformatting a little easier.
Thanks!
You might be thinking of a configuration management tool like Chef. You can use this to bring up a system from a bare OS to the configured state defined in your recipes.
Personally I've only used it for setting up linux servers, but I think it would work just as well for launching installers and running configuration scripts on a Mac.
This is the tool I was looking for.
https://github.com/benhoskings/babushka

Uninstaller for package on Mac OS X

As a service to my users I would like to provide an uninstall script to completely remove all traces of my application on Mac OS X. The application is installed using a package rather than just being dragged into the Applications folder because it is a daemon-type app that also requires to run a script at installation to be launched.
My thinking is to include a file called uninstall.sh and place it into /Library/Application Support/com.<mycompany>.<myapplication>/ and refer to this from the application documentation. The purpose is basically to stop the daemon if running, unload and delete the corresponding plist as well as remove any application files. Does this sound reasonable or are there better methods to accomplish this?
Also I am wondering if it is good practice to also remove traces of the package using pkgutil --forget - if I don't do this, the next time the package is installed it shows up as being upgraded instead of installed. Any recommendations or pointers to best-practice information?
Is there no standard way of doing this on OS X?
There is no standard way of doing this on OS X. Yes, shocking, I know. Apple consistently warns everyone away from package installers (among other things by providing insufficient documentation for them). They then exclusively use package installers for their own standalone apps.... go figure.
Yes, you should include pkgutil --forget.
If your customers are comfortable with this kind of script, then your approach sounds fine. If they want a "double-click-on-it" then you should probably put the uninstaller in /Applications, but avoid that if you can.
If you have a GUI, Status Item, or Preference Panel, then it's nice to put a "Uninstall" button or menu item there rather than requiring them to go mess around with Terminal.
BTW, if you go looking for the Software Delivery Guide, it's been moved for a year or so now, while they "update" it.
the inability to remove packages has bugged me for years, so i've written a tool to uninstall packages:
http://www.corecode.at/uninstallpkg/index.html
its a bit better than the shell scripts to do it floating around because it makes sure never to remove any files that are used by any other installed packages
The way I solved this was to use Automator, create an application document and then add dialog and script actions. Finally save your Automator application document and you end up with a simple GUI application to run the uninstall.
Often the uninstall action requires administrator privileges - I solved this in Automator by running a shell script action that generates another shell script that can then by run in an applescript action as follows:
on run {input, parameters}
do shell script "/tmp/uninstaller.sh" with administrator privileges
return input
end run
I have a similar application and came across the same issue. The approach I took was one that I have seen other applications use. Rather than simply distributing the .pkg installer, wrap it up in a .dmg file. The uninstall script can be included with the .pkg in the .dmg.
The uninstall script is then renamed to "uninstall.tool". The .tool extension allows users to run the script by double clicking, rather than having to run it from the command line.
Slightly unconventional, but aren't these all. I have Homebrew and cask installed. I was able to uninstall a .pkg with the following:
brew cask uninstall --force <pkg_name>
ex. brew cask uninstall --force dockertools

Resources