2012-04-03

Installer woes

I'm preparing to release v3.0 of my Multi-tail application Svansprogram. One popular feature request is native launchers. Yeah, OK, so this one guy asked for it but since there are about 3 people in the world using svansprogram that is a substantial part of the user base.
Being a Linux guy I have to jump through a lot of hoops to even begin to create a windows EXE-file or an OS X launcher. I can't even test them properly! Anyway, Launch4j seems nice and might even have some type of integration with maven (and I'm switching back to ant + ivy when I find the strength). There is a GUI and some XML files that you can use to work up an exe-file. The GIMP did let me create an ICO-file also. As soon as I can test this somewhere I might put in the hour or so to try this out.
A pal has promised to build an OS X launcher by using some sort of maven magic and an another launcher-creator-app-thingy.

So I tackled the Linux side. I decided to distribute an installer with the TAR-ball,
disclaimer - Blogger ate the formatting and yes I KNOW there are symlinks and stuff this does not handle, write a bug report or something :-)

And this people is why I LOVE linux: a few lines of BASH and here is your installer.


#! /bin/bash

SVANSPROGRAM_HOME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
LOG_FILE=$SVANSPROGRAM_HOME/install.log

log() {
echo "$1" >> $SVANSPROGRAM_HOME/install.log
}

log "`date`"
log "Svansprogram directory: ${SVANSPROGRAM_HOME}"

#######################################
# Create executable file #
#######################################
EXECUTABLE="$SVANSPROGRAM_HOME"/svansprogram.sh
log "Creating shell script: $EXECUTABLE"
cat <<MESSAGEDELIMITER > $EXECUTABLE
java -jar $SVANSPROGRAM_HOME/svansprogram.jar
MESSAGEDELIMITER

log "Setting execute permission"
chmod +x "$EXECUTABLE"

#######################################
# Create desktop file #
#######################################
INSTALL_DIR=~/.local/share/applications
log "Install directory: ${INSTALL_DIR}"


if [ ! -d "$INSTALL_DIR" ]; then
log "Install directory does not exist"
exit 1
fi

log "Creating desktop file"
cat <<MESSAGEDELIMITER > "$SVANSPROGRAM_HOME"/svansprogram.desktop
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=3.0
Type=Application
Terminal=false
Exec=$EXECUTABLE
Name=Svansprogram
Comment=A Multi tail application
Icon=$SVANSPROGRAM_HOME/icon_128x128.png
Categories=Development
MESSAGEDELIMITER

log "Moving desktop file"
mv "$SVANSPROGRAM_HOME"/svansprogram.desktop "$INSTALL_DIR"

5 comments:

  1. And this people is why I LOVE Mac OS: a few lines of BASH and here is your application (no installer necessary).

    Try this:

    mkdir -p test.app/Contents/MacOS
    cat << END > test.app/Contents/MacOS/test
    #!/bin/sh
    echo OK > /tmp/foo
    END
    chmod +x test.app/Contents/MacOS/test

    open test.app

    ReplyDelete
    Replies
    1. Did not know that but then again I've only been a OS X user for a couple of days now. Already loving it (except the finder) :-)

      Delete
  2. Yeah so that piece of script is the actual installer that we don't need :-) Still, now that I've spent a few hours messing about with OS X I can confirm it is about as lovely as I hoped it to be, i.e. no more annoying than Gnome and in many parts a lot sweeter.

    ReplyDelete
  3. Haha, no it was just a way show you the steps to generate an application. This should be done at build time, and the .app directory put in an internet-enabled disk image (hdiutil create ...; hdiutil internet-enable ...). Then put the .dmg file up for download.

    I have a Makefile that builds an executable and packages it as described above in case you're interested.

    ReplyDelete
    Replies
    1. As long as I can run the packaging on linux - yes please.

      Delete

Note: only a member of this blog may post a comment.