Creating Easy-to-Deploy Unix Applications for OS X
by Mark Roseman10/24/2003
Rather than Mac OS X bringing an explosion of exciting Unix software to Mac users, we're instead seeing countless articles on Mac web sites describing the arcana of command lines and configuration files, .tar files and Perl scripts. What happened?
As an example, Giles Turnbull wrote a long article for MacDevCenter.com describing the steps needed to get PHPWiki, a very nice Wiki server application written in the Unix scripting language PHP, up and running on Mac OS X. Originally designed for "standard" Unix platforms such as Linux rather than Mac OS X, many pages were needed to describe in excruciating detail the steps needed to get PHPWiki running. These included:
|
Related Reading
Mac OS X Panther for Unix Geeks |
- Download and unpack the latest source in your Sites directory.
- In Terminal, use
viundersudoto edit Apache's configuration file to allow it to use PHP, and then restart Apache. - Download and install MySQL, and using several more command lines, set up a database password and database tables for PHPWiki to use.
- Modify one of PHPWiki's code files to tell it about the database.
In contrast, my company's Wiki application, ProjectForum, has simpler instructions: Double-click.
With OS X's Unix foundations came the promise of access to thousands of Unix applications for Mac users. But if those applications are hard to install, configure, and use, everyone loses. Potential users may waste a lot of time, get frustrated, and eventually even give up on a fundamentally useful piece of software, while developers lose the opportunity to see their hard work benefit many more people.
So what to do? This article describes some of the most common obstacles to deploying Unix software on Mac OS X. The good news is that software developers can remove these obstacles for users, often with only small changes to their development practices.
I'll illustrate some of these with ProjectForum, which was developed primarily with Tcl, a typical Unix scripting language. ProjectForum is a powerful cross-platform Wiki server (Figure 1) that needed to be extremely easy to install and use by our target audience.
|
|
Deployment Obstacle #1: Dependencies
Unix applications, whether written in C, C++, Java, Perl, Python, Tcl, PHP or another language, tend to depend on many other packages and code libraries. By leveraging other people's code, developers save time by focusing on the code unique to their own application. Most Wikis, for example, rely on external databases (e.g. MySQL), web servers (e.g. Apache), version control systems (e.g. CVS), scripting language interpreters, web-form processing libraries, and more.
While you as a developer save time, whenever someone wants to try your application, they are often forced to locate, download, install, and configure each of these packages, if they aren't already available on the system. These may be non-trivial steps, particularly on platforms like Mac OS X where users aren't generally knowledgeable about installing Unix software. Any hesitation, problem, or error will result in the user abandoning your application.
Removing the Dependencies
If we can reduce the dependencies on large external packages, we remove some big obstacles in front of users trying to install and run our applications. Two approaches can be helpful here: using embeddable tools, and developing new, minimal subset tools.
Replacing an external tool that must be set up separately with one that can be bundled right into our application means that the user need not have to install it separately. Databases are a great example; while some applications certainly do need all of the power of external databases like MySQL or Oracle, for most applications with modest storage needs, they are complete overkill.
There are some great embeddable database libraries out there, such as MetaKit (which we used in ProjectForum) and SQLite. With an embeddable database, your application links directly with a library that manipulates the database, rather than communicating with an external database server process. The database is part of your application, not a separate process.
Similarly, do you really need all the flexibility and power of the Apache web server? For your particular application, could a simpler, embeddable web server (e.g. TclHttpd, Twisted, etc.) suffice? Again, by making the web server part of your application, your users don't have to make sure Apache is set up and configured with the right settings, and that your application files are placed in exactly the location where Apache expects to see them.
When embeddable tools aren't already available, you may benefit from building your own minimal subset library, to be included as part of your program. For the five percent of CVS functionality we wanted to have available in ProjectForum, it made more sense developing a small code module in Tcl and MetaKit, rather than asking all of our users to install CVS.
While some applications may truly need all of the flexibility and power of external tools, the decision to include each one should be carefully considered, taking into account developer effort and technical feasibility, as well as the size and skill level of the target audience. Do the benefits obtained by the developer outweigh the costs to each user?
Relying on embeddable tools (whether existing ones or those you develop) means everything can be bundled with your application. Users don't have to install and configure a variety of other packages separately just to use your application.
Deployment Obstacle #2: Packaging
Most Unix applications are made available as "tar balls" of
source code, which need to be unpacked, compiled by users (e.g.
via command-line tools), and then installed. Applications written
in scripting languages can skip the compilation step, but often
must be carefully installed, with different pieces going into
particular directories (e.g. a web server's documents directory),
often scattered across the disk.
For Mac users, this is foreign territory. Compilers and other developer tools are typically not installed in the first place; nor are users expected to even have knowledge of the Unix shell. Native Mac applications can be installed by simply dragging them anywhere on the user's machine, and run by double-clicking them. Anything else invites hesitation, frustration, and errors, with your application landing in the Trash Can, not the Applications folder.
Package for Your Users
Even if you're also making the source code for your application available, providing pre-compiled binaries directly to your users is a smart thing to do.
This is absolutely essential for applications written in compiled languages, but usually makes sense for applications written in scripting languages, too. Most scripting languages have tools (e.g. FreeWrap and Python's Freeze) you can use to "wrap up" all of your scripts and other data, along with the scripting language interpreter itself (removing yet another dependency!), into a single binary.
A particularly nice wrapper for Tcl is Starkit, which allows you to wrap up an entire directory tree into a single file "virtual filesystem," so that the application is structured the same on the user's machine as it is in the development environment. End users see just a single file application, while other developers can easily access the underlying code. When source code protection is needed, additional tools like Tcl Dev Kit's Compiler are also available.
Rather than receiving tar balls, Mac users expect to download
their applications as disk images, which are mounted on their
desktops as CDs would be. The application on the disk image can
then be dragged to its own hard disk. Installers can be used
when multiple files must be installed in different places on the
disk, or for other complex needs, but if possible, restructuring
your application to reduce this need is preferred. But anything
is better than having users manually copy multiple files around!
Both disk images and installers can be easily created using free
utilities.
For ProjectForum, we take the same cross-platform Starkit used for other Unix and Windows platforms, bind it with the OS-X-specific runtime to create a standard Mac application, and then stuff the whole thing into an OS X disk image, all from a 50-line shell script. The result is a single, self-contained application, shipped as a disk image, well under 2Mb in size.
The end goal is that your users shouldn't need to know that your application was written with standard Unix tools; it should be indistinguishable from a native OS X application.
Deployment Obstacle #3: Configuration
Once everything is compiled and installed, there is still the matter of getting an application configured. Here too, Unix applications often tend to make things more difficult than they need to be.
Many Unix tools rely on hand editing of configuration files, i.e. the user must open up a text editor and modify some parameters in a file located at a particular place on disk. It's not unusual for this process to change some variables at the top of a program's code. Needless to say, one wrong keystroke, and the program might stop working altogether.
Reduce and Simplify Configuration
Most applications can benefit from reducing the amount of configuration that is required before running. With sensible defaults and, possibly, judicious examination of the environment in which the program is running, there shouldn't be much need for any required configuration.
After the program has started, it's better to handle any subsequent optional configuration changes within the program itself, preferably via a well-presented, standard Aqua user interface. For network applications, configuration via a web browser interface is another option. Regardless, your configuration interface should be designed to meet your users' needs and expectations, providing sensible choices for changing options in a safe and robust manner.
Deployment Obstacle #4: Is it Running?
A final obstacle, particularly for many network server applications, is providing the user with decent feedback that the program is running. Server applications, and many other types of software on Unix, are usually designed to run without any kind of user interface. They are started (from a command line) and simply run, with no feedback to the user.
If you've followed the recommendations on packaging, your application already looks like a regular Mac application that is double-clicked in the Finder, rather than run from a command line. But what happens when you double-click an application with no user interface? It starts, but nothing shows up. How can the average user differentiate this from an application that just crashed on startup? What do they do next? How can they stop the thing?
Provide Feedback, Even for Servers
In ProjectForum, which is a typical server application, we display a small user interface when the application is running (Figure 2).
|
|
Providing this very simple user interface provides a number of benefits to the user:
- It provides immediate feedback that the program is running, even for users who may not be familiar with running servers.
- In case of serious startup problems (e.g. network port conflicts), we can offer the option of selecting a different port.
- There is an obvious mechanism for stopping the server.
- The "Open in Browser" button provides an easy way for the user to access the application, rather than needing to know a particular URL to type into his or her web browser.
"Great," you're thinking, "now I have to go learn details about Mac programming just to build a special user interface for my server application." Relax, it's easier than you think. Using Apple's excellent (and free!) developer tools like Project Builder and Interface Builder, we put together the simple Cocoa front end for ProjectForum in less than a day -- including time spent learning Cocoa and the developer tools!
This front end became the main application that is launched when the user double-clicks ProjectForum. The Cocoa application then executes the underlying wrapped Tcl application (a single Unix-style executable), communicating with it using standard Unix pipes. Simple textual commands are sent to start the server on a given port, stop it, and so on.
More experienced users can run the underlying Unix executable directly, without the user interface. This can be useful when the program needs to be run without user intervention; e.g., when the computer first boots (which is done using special shell scripts called "Startup Items" on OS X).
Deployment Counts
While historically there was some element of "if it was difficult to write, it should be difficult to install and use" bravado in the Unix culture, for modern Unix users (and especially Mac OS X users wanting to take advantage of some excellent Unix software), this attitude is best left in the past.
For Unix developers, this article has suggested some important deployment obstacles that can prevent Mac users from fully taking advantage of your software, and provided techniques to overcome those obstacles.
In our case, using those techniques has allowed us to continue to use high-productivity development tools such as Tcl to build ProjectForum, while still producing an application that is extremely easy to install and use for Mac OS X users.
Users would be hard-pressed to distinguish it from an application built exclusively with native Mac tools, and isn't that really the point? Ultimately, the design decisions we took resulted in an application that was easier to deploy, and that benefited our Unix and Windows versions, as well.
Decisions about deployment very often result in tradeoffs for developers. If you use a particular technology, it may provide a lot of advantages, but may make deployment more difficult. I'm not suggesting you never use such technologies, but make sure that it's a conscious decision -- one that factors in the true deployment costs to users. Because these decisions have a huge effect on your development, it's critical they be considered very early in the development process.
Context matters too, of course: a one-off custom application that you will be installing yourself is a lot different than a mainstream application that thousands of users may download and try to install themselves. If your application could benefit a wide audience, you owe it to yourself and your potential users to spend a little bit of extra time thinking about deployment.
There are some great Unix applications out there, and many more still to be written. Let's hope that some of the techniques discussed here will help make them easier to install and use so that everyone, including Mac users, can reap the benefits.
Mark Roseman is a senior software developer currently living in Ontario, Canada. He founded and runs CourseForum Technologies, while contributing to several open source projects.
Return to the Mac DevCenter
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 18 of 18.
-
From deployment engineering to GUI design...
2003-10-25 16:17:26 anonymous2 [Reply | View]
-
From deployment engineering to GUI design...
2003-10-26 04:39:24 roseman [Reply | View]
Hi Patrick, thanks for your comments and appreciate the suggestions!
Having been developing Mac software since 1989 I'm somewhat familiar with the HIG. ;-) Were this coming up as a dialog in the middle of using the program, I'd certainly agree with all your improvements, but instead its the sole window launched at start, and meant to hang around fairly low-key. That it's different from dialog windows is therefore good (I know everytime I see a dialog my first instinct is to do what I can to deal with it and move on, which is exactly what we don't want to see happen here).
Our users have been actually quite happy with that interface and the way it works for them... never gotten comments about it being 'different'. I think that's the difference when you use it in context versus just see a screenshot in the middle of an article!
Mark -
From deployment engineering to GUI design...
2003-10-26 15:00:49 anonymous2 [Reply | View]
Mark,
I have a theory why you never get complaints; your customers are all Unix users too ;-) But seriously, if this panel is the only interface of your program (i.e. no menu bar) you could leave the icon out, and the title would even be o.k (but not great...). But the font size is really too small, and the alignment of the buttons is a clear give-away.
What if you would combine the start and stop buttons into one button with alternating title, like in the 'sharing' panel of system preferences? It may seem like nitpicking, but in my view this is really what Macintosh is all about: usability and paying attention to details.
Patrick -
From deployment engineering to GUI design...
2003-10-27 03:15:03 roseman [Reply | View]
Far more Mac (and Windows) customers than Linux or FreeBSD, as one would expect (it's not a port of a Unix app, but was built cross-platform from the ground up). Again, very much appreciate your suggestions for improving the UI. -
From deployment engineering to GUI design...
2003-10-29 05:18:00 shryn [Reply | View]
Patrick,
As a long time Mac user, who has just started to delve into the mysteries of UNIX , I chose to recommend to my school board ProjectForum over the free, but complex to install and run OpenSource solutions. As much as I enjoy learning PHP, mysql and other UNIX based software, I usually don't have the time to download, install and configure all the different packages.
ProjectForum's server interface is, as stated, just something to fire up and have in the background, out of sight. Where PF shines, is in the front-end user interface, which as it is dependent on a browser, doesn't have to adhere to Apple's interface guidelines.
So I must agree with Mark's article and hope that more developers port UNIX software solutions to the Mac with easy to install and configure packages.
Stephen Hryncewicz
-
good point but...
2003-10-26 04:34:36 anonymous2 [Reply | View]
I like this article, and agree with the main gist of what it says -- as a longtime Mac user who eventually went through the Unix school of hard knocks (Unox?), I see it from both perspectives. But, since the article makes a few references to network applications, I think it would also be prudent to keep in mind some of the security reasons that many traditionally Unix-based web applications use external components rather than providing an integrated all-in-one solution.
While the author makes a case for alternative, and more lightweight, HTTP servers, one of the reasons to stick with Apache is simply its resilience to most HTTP-based attacks. That's not to say that other servers like Twisted are insecure, but Apache is heavily scrutinized and monitored since so many sites are using it. The same is true of heavyweight database servers like Oracle -- obviously it's overkill for a low-key nonprofit wiki to have the user purchase Oracle9i (or perhaps even to install and configure [My|Postgre]SQL), but these database servers are more reliable for network applications that need security protections.
Also, the suggestion of offering a web page for users to configure the application is a good one, but a local-only UI for doing this would be better. By default Apache cannot serve its configuration files since they are outside of the document root (or name-blocked such as ".htaccess"), but the tradeoff is that the files cannot be edited via the web.
Just a few thoughts.
-
Use the same GUI on UNIX and Mac...
2003-10-26 11:50:25 anonymous2 [Reply | View]
You built the tool with Tcl, why not build the user interface the same way? Tk on the Mac uses native Cocoa buttons and widgets, and with a little care can't be told from a native app... and now all of a sudden the same application gets the same GUI on the rest of the UNIX world... and if you're careful in Windows as well. -
Use the same GUI on UNIX and Mac...
2003-10-26 12:34:56 roseman [Reply | View]
The Windows version of ProjectForum actually does use Tk. Unfortunately, Tk on Mac OS X is "not quite there yet", though improving fast. As well, a couple of things we do (like asking for admin authentication, but only if the user wants to listen on priveleged ports) need some native calls (so we'd have needed to do a wrapper anyway), and benefit from having the app split into two separate processes. Besides, doing something like this in Cocoa was just trivial, so having both the Tk version and the Cocoa version isn't much trouble at all.
-
Why write your own app?
2003-10-26 11:56:58 anonymous2 [Reply | View]
Use Platypus (at http://sveinbjorn.vefsyn.is/software ) to build the launcher, and stick the Tcl scripts in the resources directory of the application. -
Why write your own app?
2003-10-26 12:24:16 roseman [Reply | View]
Thanks for the link - Platypus looks like it would be helpful for a lot of apps. In this case, the needs are a bit more complex than what it would support: shipping a custom interpreter (the Starpack) rather than relying on an existing interpreter and just scripts, more complex interaction between the GUI and the underlying server (both feedback and control), etc. So its a bit more than just a simple launcher.
-
Excellent article!
2003-10-26 18:41:43 macservers [Reply | View]
The deployment obstacles mentioned are exactly why we have to put together lengthy, convoluted tutorials on MacServers (www.macservers.org). If more developers took Mark's advice, we could spend our time talking about which tool is best for the job instead of describing how to get them installed and configured.
Thanks for the terrific article, Mark. We've linked to it from the MacServers site.
-
I'm still confused on where to start
2003-10-27 07:07:53 edwardd20 [Reply | View]
I'm sure this is off topic but I though this article was going to get me started on the right track but it missed.
I'm a long time Mac user and an experienced Windows and UNIX developer. I'm trying to port my companies products over to Mac (on my own time). Where is a good starting point for porting DLL's (Windows) and shared libraries (UNIX) to a Mac arena? If I compile the whole thing as a big command line executable it works but stinks.
Thanks.
Ed -
I'm still confused on where to start
2003-10-27 11:22:29 roseman [Reply | View]
Yeah, its a bit off the topic of this article, but make sure to check out the documentation on the Apple site. This one in particular has some info on compiling dynamic libraries and a variety of other topics that you are probably going to run into: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/
-
Another Perspective
2003-11-02 21:17:13 anonymous2 [Reply | View]
While the ideals behind the article are good ones for the most part I think it is very unrealistic to expect unix to blossom into a user friendly flower. Unix is not user friendly and I don't think a change on the behalf of developers alone would be enough to reverse that.
Fink simplifies the installation of unix applications on Mac OS X. I think the number of unix apps mainstream mac users would or could benefit from are few. If an app is beyond command line complexity the interfaces be it TCL or whatever have you will be other worldly to mac users.
I mean its a nice idea but I think its fairly impractical. Fink makes it about as easy as it will get with what is already out there and thats the real core of this problem. I have a hard time understanding why the author is encouraging new apps to be developed in a more friendly way as a solution to "the promise of thousands of unix apps". I mean - if we are only talking about new software - that kind of kills off the notion of anything legacy which is the core of this problem.
So ... in a word ... fink.
Even in the world of "real" Unix they use package managers - I can think of at least three off the top of my head. It is the standard way of dealing with most of these problems. While it doesn't address the issue of configuration I think tweaking a powerful unix app is part of the fun. I mean its even considerable as an issue separate from getting these thousands of unix apps running. You don't configure it unless it is already running, right? To that end some unix configuration files are a real #$#@$ but I don't think that will change any time soon. I find that to be the real merit of the article - encouragement to simplify configuration. If need be developers can provide a "basic" and "advanced" set of configuration files limiting the work that needs to be done while allowing the fine tuning that more complex unix configuration files tend to offer.
/ramble -
Another Perspective
2003-11-03 03:20:00 roseman [Reply | View]
Well, that's certainly one point of view, though not one I particularly agree with (and don't get me started on package managers!). The interesting challenge to me, and what the article was about, was how developers can retain the fantastics productivity benefits associated with some Unix developer tools, while still producing apps that are targeted at more mainstream users. Using primarily Unix technologies needn't restrict applications to the Unix elite audience. Fink and friends solve one problem, but not the problem mainstream users are interested in.
-
Another Perspective
2003-11-03 12:20:01 anonymous2 [Reply | View]
Well I suppose my own perspective is skewed. I consider myself to be a mainstream user but I'm also a hobbyist programmer. I find the subject to be very interesting so I hope I wasn't insulting with my first comment.
Fink coupled with Apple's X11 it makes harvesting the available applications easy. I guess I was confused about the point of the article because it mentions a missing "explosion" of unix apps on the mac platform.
I agree that the development and deployment process could be simplified but I think there are some other things that need to happen before that can.
Specifically look at the problem and suggested solution for dependencies. You suggested developers bundle the libs with the application. Specifically look at the problem and suggested solution for dependencies. You suggested developers bundle the libs with the application. I don't have much personal experience with embedding sqlite or any other technology in an app binary but in most Cocoa situations developers simply include the program in the app bundle. This isn't applicable to generic unix coding so including a subset is the best advice. I must say though when dealing with some of the more dependent libs on Unix it is difficult to separate the necessary functionality and I wonder how much this would add in terms of time to deployment.
If we are to use subsets where should they be installed? I'm not posing this question as an obstacle. I am honestly curious about solutions. Where should developers install these library subsets. With many versions of the various libs out there some apps may rely upon features not found in certain versions of a given library so these would have to be installed to application dependent locations. This could develop a good deal of bloat.
Might be an interesting project to develop a standard set of embed-able unix libs. Isn't that where a majority of the problem lies?
Perspective Anonny
-
great, but...
2003-11-03 12:28:56 anonymous2 [Reply | View]
Most of this stuff is pretty intuitive. I would really
love to see an article explaining why so many unix
packages fail to install on MacOS X and what I can
do to fix them. Since Fink is currently broken for
Mac OS 10.3, I'm kind of hosed until they get my
packages working.






However, being a Mac Application takes more than easy installation. Take a look at your user interface for instance. In a single window you manage to do _everyting_ wrong ;-), making it clear to most Mac users that 'something is different' with your software.
I guess that's not what you want.
Some suggested improvements:
* the window title should be more discriptive.
* the fontsize of the message is too small.
* you probably should display a warning icon, or your apps icon.
* the buttons are in the wrong order, and should be aligned to the _right_ edge.
Apple provides Human Interface Guidelines that go into this kind of stuff.
Otherwise your article makes perfect sense and I wish every developer coming from (presumably) Linux would take your words to heart.
Patrick Machielse