Installer for a simple Mac OS command-line tool? - macos

How can I build a novice-usable (clickable download) installer for a Mac OS X command-line tool, and where should the binary be installed so that a novice user with no knowledge of shell paths can just open the Terminal app and type "foo" to run the freshly installed foo tool?
Can the installer also install documentation so that the user can type "man foo"?
Are there any other options that should be considered to make the use of a pure command-line (stdin, stdout) tool accessible to a novice Mac user?

What's the minimum version of OS X you're targeting? 10.6 (and IIRC 10.5) include /usr/local/bin in the default PATH, but 10.4 did not. As long as you don't need to support 10.4, you should just put the executable in /usr/local/bin and the man page in /usr/local/share/man/man1 (or whatever the appropriate chapter number is).
For building the installer itself, you can use Apple's PackageMaker utility (part of Xcode). Create a prototype local folder with bin and share/man/man1 subfolders and populate them with your files. Create a package project in PackageMaker, and choose your organization name and minimum target OS. Drag the prototype folder into the project's Contents sidebar. Set the Destination to /usr/local. Switch to the Contents tab and edit the ownership and permissions the files should be installed with (the owner/group should probably all be root/admin, with rwxrwxr-x perms on the folders and executable, rw-rw-r-- on the man page). If any irrelevant files (e.g. .DS_Store) snuck in, exclude them. Look around for any other settings you want to change, then save the project and build the installer. Then test it, to make sure it does what you expect.

Related

How To Find $EXIST_HOME in eXist-db

I am trying to edit my config file, which I am told is located at $EXIST_HOME/conf.xml. However, when I type $EXIST_HOME into my terminal nothing happens, and I have no idea where to look for the file in my file system. I am using OSX, and installed eXist using the standalone GUI, and was not asked where to install files at setup.
How can I get to the config file?
$EXIST_HOME is just used to represent wherever you installed eXist to. On many Linux/Unix based systems (including Mac OS X) it is recommended to set this environment variable in your profile to the location where you installed eXist. If you do not, when you try to start eXist it will try and self-determine this from the location of its binaries.
If you installed eXist from the .dmg file which is provided for Mac OS X users, then you can drag and drop eXist to wherever you wish, however typically this would be /Applications/eXist-db.
If you installed eXist from the .jar installer by running java -jar eXist-db-setup-2.2.jar or double-clicking the Jar file (if your computer is configured to execute Jar files), then the second screen of the installer prompts you for the location to install eXist to. The default location set for Mac OS X is /Applications/eXist-db.
So if you didn't change the defaults, your $EXIST_HOME would be /Applications/eXist-db.
On OS X, as adamretter correctly states, the default installation directory when using the Exist-DB installation disk image (.dmg) is /Applications/eXist-db. However, when you navigate to the /Applications/eXist-db folder and click on the exist-db icon, as if to open the directory for further browsing, all that happens is that the Exist-DB server starts. Less experienced Mac users might not realise that you have to right-click with the mouse on the Exist-DB icon in the Applications folder and choose 'Show Package Contents' from the menu in order to view the directories that sit beneath it.
The config.xml file can be found at:
/Applications/eXist-db.app/Contents/Resources/etc/config.xml
P.S. Don't forget to make a backup copy before you start editing :)

Creating package in mac os x

What is the equivalent of .deb and .rpm in Mac OS X?
I am trying to create a package in Mac OS X which will include necessary libraries and scripts.
There are several approaches for Mac installation.
Simplest: self-contained application (Foo.app). You put everything in a directory (in a particular hierarchy), give the directory the .app extension, and ask the user to copy it into /Applications. All necessary libraries and scripts should be included inside the directory. It is commonly distributed inside a .dmg file, which is a disk image.
Installer: Uses a .pkg archive, which will be opened by Apple's Installer. It has capability to install libraries in root-restricted areas (after asking the user for the password).
Homebrew/Fink/MacPorts - open-source projects that provide functionality ranging from that of Debian's Aptitude to that of BSD's Ports. Authors write down recipes that the installer executes, which resolve dependencies and install necessary related packages. I believe Homebrew is now the most popular of these, with recipes being written in a Ruby DSL.

Using productbuild for mac os x app with additional tools and files

For one of my projects i used building script using packagemaker. Packagemaker allows specify all files i need install from root, so my root had following structure:
Applications
My Application.app
Library
Preferences
MyCompanyName
some.xml
another.xml
tmp
default.p12
usr
local
bin
sometool
I.e. it had following features:
Some configuration files preinstalled for all users, to global Preferences (some.xml, another.xml)
Some command line tool being used as by main app as user in /usr/local/bin
Program uses certificates and there is one default certificate which will be moved to right place in postflight
How to do same with productbuild? Possible?
The basic tool that does the packaging you want is pkgbuild, not productbuild. pkgbuild will let you specify a root directory that, upon installation, will be expanded to '/'. So, you can use that for all of what you discuss in your question (though an installer putting something in /tmp is a bit weird - I'd suggest baking the cert right into your postinstall script).

Mac .app Fails in a function call to 3rd party lib on Lion. But works when run from the .app/Contents/MacOs/executable

I am trying to run our App on Mac Lion. App is built on Snow Leopard 10.6.8, packaged using package maker. We are linking dynamically to libCurl(3rd party lib). On snow leopard it works. On Lion when I install and click the app icon it fails in call to curl_easy_perform (from libCurl). But when I right click the app icon, click show package contents, and goto /Applications/MyDir/OurApp.app/Contents/MacOS/OurApp and then try to run that unix executable, then it works. I used otool to check the lib paths and they all seem correct.
Can someone help me why it fails when I click the .app? I thought .app is a soft link to the main executable. so if the executable works, then .app should also work.
Do I have to tell the path of the lib in .app? if so, how?
The dynamic linker "dyld" and related programs such as "otool" are influenced by environment variables. Environment variables can vary by process: the Finder has a unique copy of environment variable settings, and so does each shell in a terminal window.
As you can see if you run "man dyld", there are many variables that can influence the behavior of these programs.
If you're seeing different behavior from the command line than in the Finder, I imagine that at least one of the special linker variables has been set in your terminal. It is probably instructing the linker to look in places for libraries that are different from the linker's defaults (or whatever the Finder uses).
You can run "env | sort" from your terminal to see what's been set.

What is the correct directory layout for a web server under Mac OS X?

I'm packing the Cherokee Web Server, a very very fast webserver with a nice web-based GUI for configuration written by the spanish hacker Alvaro Lopez Herrera and available from http://www.cherokee-project.com.
So far, I've managed to create a .pkg installer using Apple's PackageMaker.app that comes with Xcode but i'm installing everything under /opt/cherokee.
I guess I'd like to have the binaries go to a dir that is already in the path and the same for the manpages and other stuff.
I looks like installing everything with prefix=/usr could work nicely, except for the config files that should go to /etc/cherokee and the document root with could go to /var/www but i'm not sure.
Would that work or should I use some directory structure under /Library? like /Library/Cherokee/VERSION/ ???
Apple's bundled Apache seems to be instaling with prefix=/usr but config files in /etc/apache2 and CGIs and the manual to /Library/WebServer with the document root in /Library/WebServer/Documents.
Maybe my docroot should be /Library/Cherokee/Documents or something like that...
For reference, Cherokee's default layout is like this: (only dirs)
http://pastebin.com/f57bc2d21
Thanks for the help in advance! :)
Do not install it directly in /usr. That's Apple's domain. Though /opt might be okay, it will not be in the default path and is not commonly used as a default installation location for third-party Unix software in Mac OS X.
My advice is to install everything under /usr/local. Apple will not touch this area (e.g., during system updates, etc.), /usr/local/bin should be in the default path for users, and I have observed many other Mac OS X server software packages using this location.
Most Mac OS X packages I've used (and most software I've built from source on Mac OS X) will create a /usr/local/whatever/... containing directory, however. So, for example, all of MySQL would be under /usr/local/mysql/... That means the MySQL binaries are in /usr/local/mysql/bin/... which is not in the default path for users. But I think the improved isolation of that extra level of directory structure is worth this sacrifice. (Another option is to install everything under /usr/local/whatever/... but then add symlinks to your most important executable(s) under /usr/local/bin)

Resources