Distribution, lets tackle this thing

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
tsturzl
Party member
Posts: 161
Joined: Fri Apr 08, 2011 3:24 am

Distribution, lets tackle this thing

Post by tsturzl »

A lot of people ask how to distribute there love2d games on different platforms, so here's a list of solutions for distributing your games on various platforms. Just a quick and dirty description on how to do it, the individual can determine how to go about doing it.

Windows
Windows is probably one of the easier platforms to distribute on. You can just bundle an exe and distribute the exe and the DLLs in a zip, or you can make an installer with Windows Installer, provided with the Windows Software SDK. This is probably your best option.

Linux:
Bundle the executable and .love.

Debian/Ubuntu
Use the repositories. You can use a deb file to install a repository, add your game's repository, and love's repository. The deb should then install your game, and the latest version of love. You can also add menu items and desktop shortcuts. You can use the repositories to distribute updates also.

Redhat/fedora
Use the repositories. Create a RPM to install love and game repositories. The RPM can then install love and your game.

OS X
OS X has a application distributing format a lot like love. Instead they have .app's(they're actually folders) which contain libraries and executable's. The downfall of this is often times you can't share dynamic libraries easily. For this you'll have to ship a version of love with your .app. To do this you have to bundle your executable with your engine(as seen on the wiki), you can then use xcode to bundle your engine and the libraries into a .app
User avatar
slime
Solid Snayke
Posts: 2932
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Distribution, lets tackle this thing

Post by slime »

tsturzl wrote:OS X
OS X has a application distributing format a lot like love. Instead they have .app's(they're actually folders) which contain libraries and executable's. The downfall of this is often times you can't share dynamic libraries easily. For this you'll have to ship a version of love with your .app. To do this you have to bundle your executable with your engine(as seen on the wiki), you can then use xcode to bundle your engine and the libraries into a .app
OSX is one of the simplest, actually. For basic distribution you just have to download the LÖVE .app, put your .love file into love.app/Contents/Resources/ , and it will Just Work. You will probably want to modify the .plist file to be specific to your game though, and you can swap out the .icns for a custom one too.
Last edited by slime on Tue Mar 13, 2012 5:24 pm, edited 1 time in total.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Distribution, lets tackle this thing

Post by nevon »

The next time I'm in my Linux partition, I'll share my set up for distributing a LÖVE game via a PPA.
User avatar
Jasoco
Inner party member
Posts: 3655
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Distribution, lets tackle this thing

Post by Jasoco »

slime wrote:OSX is one of the simplest, actually. For basic distribution you just have to download the LÖVE .app, put your .love file into love.app/Contents/Resources/ , and it will Just Work. You will probably want to modify the .plist file to be specific to your game though, and you can swap out the .icns for a custom one too.
It is the simplest. Since installation of Löve on OS X consists of opening the DMG and dragging the .app to the hard drive. I have 7 different versions of Löve all installed right now because each one uses its own libraries in a self-contained package. Creating a self-contained game takes the few steps you mentioned above with nothing else required at all.
Image
I'm prepared for anything.
User avatar
teh8bits
Citizen
Posts: 52
Joined: Fri Mar 09, 2012 9:18 pm
Location: The Matrix
Contact:

Re: Distribution, lets tackle this thing

Post by teh8bits »

Lol Jasoco xD
Woo OS X!
Unfortunately I'm poor so when my five year old macbook died I had to get a PC. I'm fairly happy with it though.
User avatar
thelinx
The Strongest
Posts: 852
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Distribution, lets tackle this thing

Post by thelinx »

For Arch Linux, just depend on the love package in the [community] repo, and create a simple launcher script.

See the mari0 AUR package.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Distribution, lets tackle this thing

Post by kikito »

nevon wrote:The next time I'm in my Linux partition, I'll share my set up for distributing a LÖVE game via a PPA.
I'm very interested on this. I've tried to create .deb files and ppas in the past and failed miserably.
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Distribution, lets tackle this thing

Post by Robin »

kikito wrote:
nevon wrote:The next time I'm in my Linux partition, I'll share my set up for distributing a LÖVE game via a PPA.
I'm very interested on this. I've tried to create .deb files and ppas in the past and failed miserably.
Me too. I have made a single .deb package (for a dice roll program) and I failed to make a PPA for it. (Also, I couldn't get anything .deb related to work for SELÖVE.)
Help us help you: attach a .love.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Distribution, lets tackle this thing

Post by nevon »

Alright, here we go. This is not a guide on how to create a stand-alone deb (though I could probably do that as well, if I can remember how). It's a guide on how to set up a PPA. The script I'll provide requires you to have your code available from a remote repository. In my case it's a git repo. You also need to have created a user account on Launchpad, accepted the Ubuntu Code of Conduct, created a PPA (you can do that in the web UI), and generated a gpg key and uploaded it to Launchpad.

It's been quite a while since me and Bart wrote this, so I don't honestly recall what everything does. Maybe Bart can chime in and explain what I don't remember. I'm not going to go into too much depth on what everything does, so I'd highly recommend that you look things up in the Ubuntu Wiki Packaging Guide.

In this example, I'm going to be using "appname", "launcher", "iconname" and so on. Replace those with names that are specific to your application.

First of all, we need to set up a directory structure with some metadata and various control files for the package. This is what the directory should look like when we're done:

Code: Select all

├── base
│   ├── icons
│   │   ├── 22x22
│   │   │   └── apps
│   │   │       └── iconname.png
│   │   ├── 24x24
│   │   │   └── apps
│   │   │       └── iconname.png
│   │   ├── 32x32
│   │   │   └── apps
│   │   │       └── iconname.png
│   │   ├── 48x48
│   │   │   └── apps
│   │   │       └── iconname.png
│   │   └── scalable
│   │       └── apps
│   │           └── iconname.svg
│   ├── Makefile
│   ├── launcher
│   └── appname.desktop
└── debian
    ├── compat
    ├── control
    ├── copyright
    ├── menu
    ├── rules
    └── source
        └── format
base
Base contains icons, a launcher script, a desktop file and a makefile. I'll go through each in order.

icons
Within the icons folder, you should basically replicate the structure found in /usr/share/icons/. Not much else to say, really. I've only included a few icon sizes, but you can have as many or as few as you'd like.

launcher
The launcher is what's going to end up in /usr/bin, and is used to launch your game.

Code: Select all

#!/usr/bin/env bash
love /usr/lib/gamename/appname.love
appname.desktop
A desktop file contains information that will be shown in the desktop menu. It gives the menu entry a name, a description, a path to the launcher, an icon, etc. Remember that Exec should point to the launcher, and iconname should be the same as the icons you added to icons/SIZExSIZE/

Code: Select all

[Desktop Entry]
Name=appname
Comment=A description of your game.
Exec=/usr/bin/launcher
Type=Application
Categories=Game;
Terminal=false
Icon=iconname
Makefile
The makefile contains commands to run when the package is installed or removed. What needs to be done is different in every case, but I'll give you an example nonetheless. During the installation, it basically creates the directories we need, as well as copies the files we need into those directories. Similarly, during uninstallation, it removes said files and directories.

Code: Select all

CP=cp -r
ZIP=zip -r
RM=rm -rIf
MKDIR=mkdir -p
RMDIR=rmdir -p --ignore-fail-on-non-empty

appname.love:
	cd love; \
	$(ZIP) ../appname.love *

install: all
	$(MKDIR) $(DESTDIR)/usr/bin/
	$(MKDIR) $(DESTDIR)/usr/lib/appname/
	$(MKDIR) $(DESTDIR)/usr/share/applications/
	$(MKDIR) $(DESTDIR)/usr/share/icons/hicolor
	$(CP) appname.love $(DESTDIR)/usr/lib/appname/
	$(CP) launcher $(DESTDIR)/usr/bin/
	$(CP) appname.desktop $(DESTDIR)/usr/share/applications/
	$(CP) icons/* $(DESTDIR)/usr/share/icons/hicolor/

uninstall:
	$(RM) $(DESTDIR)/usr/lib/appname/appname.love
	$(RM) $(DESTDIR)/usr/bin/launcher
	$(RM) $(DESTDIR)/usr/share/applications/appname.desktop
	$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/32x32/apps/iconname.png
	$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/22x22/apps/iconname.png
	$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/24x24/apps/iconname.png
	$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/48x48/apps/iconname.png
	$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/scalable/apps/iconname.svg
	$(RMDIR) $(DESTDIR)/usr/lib/appname
	$(RMDIR) $(DESTDIR)/usr/bin/
	$(RMDIR) $(DESTDIR)/usr/share/applications/
	$(RMDIR) $(DESTDIR)/usr/share/icons/hicolor

clean:
	$(RM) appname.love

distclean: clean

all: appname.love launcher appname.desktop
debian
The debian directory (this is back in the root level. Check the directory tree) contains a bunch of data about the package. Again, I'll go through each file separately.

compat
This sets the debhelper compatibility level. More info on that here. For now, this is what it should look like:

Code: Select all

7
control
The control file contains data that will be used by the package manager. It's here that you'll list dependencies, for example.

Code: Select all

Source: appname
Section: games
Priority: optional
Maintainer: Your Name <[email protected]>
Build-Depends: debhelper (>= 7), zip
Standards-Version: 3.8.4
Homepage: http://url.to/your-applications-website/

Package: appname
Architecture: any
Depends: love (>= 0.7.2), ${shlibs:Depends}, ${misc:Depends}
Description: App Title On Its Own Line
 A multiline description where each line is indented by two spaces.
copyright
Pretty self-explanatory. Just throw your copyright information in here.

menu
In case the window manager doesn't use desktop files, you can use the menu file to define that stuff as well.

Code: Select all

?package(appname):needs="X11|text|vc|wm" section="Games" title="apptitle" command="/usr/bin/launcher"
rules
I'm not even going to pretend that I know what this does. The rules file is a separate makefile for the application that actually builds the package. I'm fairly sure this one just tells dh to go fuck itself.

Code: Select all

#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

%:
	dh  [email protected]
source/format
(source is a directory within the debian directory. It contains a file named format)
format contains information regarding the desired format for the source package. We want a native debian package, so it should just contain:

Code: Select all

3.0 (native)
That's it for the directories and shit. Onto the build process itself!

Building

Note: In this example, I'm cloning from a git repo. You can just as well copy from a local directory, download via wget or whatever.

Code: Select all

#!/bin/bash


### Configuration ###

#repo location
REPO="git://github.com/username/yourrepo.git"
#ppa
PPA=ppa:launchpadusername/ppaname

#Here you define the target distribution version. In this example, we're telling Launchpad that this should be for Ubuntu 12.04, Precise Pangolin.
if [ "x$DISTRIBUTION" == "x" ]; then
    DISTRIBUTION=precise
    DISTRIBVERSION=12.04
fi

#Package version
VERSION=1.0.0

#path to the prepared directories
DEBIANDIR=$HOME/emptypackagedir/debian
BASEDIR=$HOME/emptypackagedir/base

#maintainer data
MAINTAINER="Your Name"
MAINTAINEREMAIL="[email protected]"

### The Script ###

export LC_ALL=C

#Create a temporary directory where we'll put everything together.
TEMPDIR=`mktemp -d /tmp/omgwordsppa.XXXXXX` || exit 1
pushd $TEMPDIR

#Clone the game from the repo
git clone $REPO appname
cd appname

#Prepare a changelog from the latest git commit
REVDESC=$(git log HEAD^1..HEAD | tail -n 1)

cd ..

DIRNAME="appname-${VERSION}~${DISTRIBVERSION}ppa3"
mkdir $DIRNAME
cd $DIRNAME
mkdir love
cp -r ../appname/* love/
cp -r $BASEDIR/* .

#dh_make takes the directory we've just created and "debianizes" it.
#More information: http://manpages.ubuntu.com/manpages/karmic/man8/dh_make.8.html
dh_make -s -e $MAINTAINEREMAIL --createorig

rm -r debian
cp -r $DEBIANDIR .

#Here we actually create the changelog
(echo "omgwords (${VERSION}~${DISTRIBVERSION}ppa3) ${DISTRIBUTION}; urgency=low" && echo "" && echo "  * $REVDESC" && echo "" && echo -n " -- $MAINTAINER <$MAINTAINEREMAIL> " && date -R) | cat > debian/changelog
 
#Now we build. -S specifies that we want to build a source package. I don't remember what -sa does, and I can't seem to find it either.
debuild -S -sa
cd ..

#Upload the changes to the ppa
dput $PPA omgwords_${VERSION}~${DISTRIBVERSION}ppa3_source.changes

popd
#cleanup
rm -rf $TEMPDIR
Packaging is so unlovely. I suggest that you try running each of the commands in the script manually and try to follow along with it. I have a feeling that'll make things more clear.
Last edited by nevon on Wed Mar 14, 2012 9:51 am, edited 1 time in total.
User avatar
thelinx
The Strongest
Posts: 852
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Distribution, lets tackle this thing

Post by thelinx »

Great guide, nevon. One error, though:
nevon wrote: Makefile

Code: Select all

uninstall:
	$(RM) $(DESTDIR)/usr/lib/omgwords/appname.love
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 36 guests