Skip to content

Building Software Packages (Ubuntu)

ProfessorKaos64 edited this page Jan 10, 2015 · 2 revisions

Table of Contents


About

This page serves as a landing page on information about RetroRig-ES's packaging process, statuses, and other information.


Ubuntu Packaging Status

Below is the current state of packaging:

Packaging Status Table
Program Name Version Dual Monitor Support Comments
dolphin-emu 3:4.0.2.20141109.3 ok
mednafen 1:0.9.36.2.2.2 ok
mupen64plus-core 2:2.0.1.0 ok
mupen64plus (misc. debris) 2:2.0.0.0 n.a. audio, video, data, etc.
pcsx2 2:1.2.2.2 ok
stella 2:4.0.0 ok
xbmc 3:14.0.12.2 ok
antimicro 2.5.20140905.0 n.a.
PPSSPP 0:0.9.9.1.2.2 ok
MAME 1:0.152.0 not ok
MESS 1:0.152.0 not ok
GensGS 1:2.16.7.2.2 ok fails under Ubuntu-Gnome


Tutorial on Ubuntu Packaging

To supply software in general, and to take control of the actual program versions that get installed, a Personal Package Archive (PPA) is utilized.

Firstly, not all programs have been packaged for Ubuntu. In RetroRig-ES we try to make good for that. The goal is to finally move all unpacked software to the PPA.

Secondly, we like to control the software version of each backend that gets installed. A basic idea in RetroRig-ES is to encapsulate the emulator installation and hide it from the end user. While doing so, we decide on a particular program version. By adding a prefix to its version tag, we can ensure that exactly this package gets installed, even if the official Ubuntu repositories provide a newer version. This mechanism is called superseeding.

And thirdly, we have changed the source code of many programs in use. Be it bug fixes, feature improvements, or just compatibility for abandoned programs, if we see a need for improvement, we fork programs and amend them.

Without further ado, a step-by-step tutorial will follow, that explains how the packaging process functions.

We need three thing to create a Debian package:

  • a DSC-file
  • a Debian folder
  • and the source code

Those files can be downloaded at Ubuntu packages at the right side of the page or in a Launchpad PPA under "package details". It is highly recommended to find a template project and use that as starting point, rather then starting from scratch.

Let's say we want to package MESS. Step 1 would be: dsc, debian, source

In RetroRig-ES under supplemental we create a folder named after the program to be packaged. Furthermore we duplicate one of the build-x-ppa.sh-files and rename it after the program as well.

x@y:~$ cd RetroRig-ES/supplemental/
x@y:~/RetroRig-ES/supplemental$ mkdir mame
x@y:~/RetroRig-ES/supplemental$ cp build-gens-ppa.sh build-mame-ppa.sh
x@y:~/RetroRig-ES/supplemental$ cd mame
x@y:~/RetroRig-ES/supplemental/mame$ wget http://archive.ubuntu.com/ubuntu/pool/multiverse/m/mame/mame_0.152-0ubuntu2.dsc
x@y:~/RetroRig-ES/supplemental/mame$ wget http://archive.ubuntu.com/ubuntu/pool/multiverse/m/mame/mame_0.152-0ubuntu2.debian.tar.gz
x@y:~/RetroRig-ES/supplemental/mame$ wget http://archive.ubuntu.com/ubuntu/pool/multiverse/m/mame/mame_0.152.orig.tar.xz

Now we have to rename some files and descriptions.

x@y:~/RetroRig-ES/supplemental/mame$ mv mame_0.152-0ubuntu2.dsc mame.dsc
x@y:~/RetroRig-ES/supplemental/mame$ mv mame_0.152-0ubuntu2.debian.tar.gz mame.debian.tar.gz

The source should be uploaded to the libregeek server. It could directly be linked to a third-party server, but after it's not guarantied that this server will keep the file, it's safer to use libregeek. Furthermore, Github is an excellent place to store or retrieve source code from. If the source code must be altered, Github is actually the only choice. To achieve reproducible compile results, a baseline naming scheme should be used with .retrorig-es-pl0` for the original version and then counting for the patch levels. Like just explained for third party servers, also on Github we firstly fork external projects into our own repositories, create the necessary tags or branches there and refer to those in the build scripts.

In addition we need to change the build script to the new program name.

x@y:~/RetroRig-ES/supplemental/mame$ sed -i "s|gens|mame|g" ../build-mame-ppa.sh

Now we need to adapt some files to our project.

debian/changelog holds the package name, program version and the name of the target Ubuntu distribution. It contains the uploaders e-mail and will only be accepted by Launchpad if the e-mail address corresponds to the GPG key we will later use to sign it with. The actual version is replaced by the string version_placeholder.

First we unpack the debian template archive, then we move the file to supplemental/program/

x@y:~/RetroRig-ES/supplemental/mame$ tar xfz mame.debian.tar.gz 
x@y:~/RetroRig-ES/supplemental/mame$ mv debian/changelog .
x@y:~/RetroRig-ES/supplemental/mame$ gedit changelog

It should then look like

mame (version_placeholder) trusty; urgency=medium

  * Packaged for project RetroRig-ES

 -- Frank Drebin <[email protected]>  Thu, 18 Sep 2014 23:00:00 +0200

If an earlier version of the package has been uploaded to the PPA before, don't forget to merge its log entry into the new changelog version!

x@y:~/RetroRig-ES/supplemental/mame$ gedit mame.dsc

Delete the signing header and everything after the package list, starting with the checkums. The format is native, meaning that we upload the source code rather then using bzr or any other source control system. The version tag will later be processed by sed, same as in the change log: Version: version_placeholder As maintainer use RetroRig-ES Dev Team plus your mail address. Delete the VCS entries.

Format: 3.0 (native)
Source: mame
Binary: mame, mame-tools, mess, mess-data
Architecture: any all
Version: version_placeholder
Maintainer: RetroRig-ES Development Team <[email protected]>
Homepage: http://mamedev.org/
Standards-Version: 3.9.4
Build-Depends: debhelper (>= 9), libexpat1-dev, libflac-dev, libfontconfig1-dev, libjpeg8-dev, libportmidi-dev, libqt4-dev (>= 4.7), libsdl-ttf2.0-dev, libsdl1.2-dev, libxinerama-dev, subversion, python-dev, zlib1g-dev
Package-List: 
 mame deb non-free/games optional
 mame-tools deb non-free/utils optional
 mess deb non-free/games optional
 mess-data deb non-free/games optional

Copy the build dependencies into the clip board, we will need it in the next step.

x@y:~/RetroRig-ES/supplemental/mame$ gedit ../build-mame-ppa.sh

Adjust the header and versions:

#========================================================================
# Build Script for custom mame RetroRig-ES PPA
#======================================================================== 
#
# Author      : beaumanvienna @ jc techno labs 2014
# Date        : 20140918
# Version     : 1:0.152
# Description : Version 0.152-0ubuntu1, patch level 0
#               
# ========================================================================

#define base version
PRE=1
BASE=0.152

# define patch level
PL=0
BRANCH=unpatched

In this case we could skip stating a branch because we don't get the source from Github. The version prefix is used to superseed the existing official version. In this example the existing version is 0.152. When we now call our version 1:0.152 the Ubuntu package manager apt-get will decide to install MESS from our repository, not from the official server. It will still use our version if the official version gets updated.

Only keep the 32bit operating system check if needed. For MESS we can delete it.

Adjust the compile dependencies, that you copied into the clipboard in the previous step. These dependencies will only be used to test-compile the package on your local rig. The PPA build server will later determine the dependencies by the statements in the dsc-file. Keep the first line until binutils-dev and don't forget to delete all the comma and version requirements.

  #apt-get install packages
  sudo apt-get install -y build-essential fakeroot devscripts  autoconf autotools-dev binutils-dev \
                          debhelper libexpat1-dev libflac-dev libfontconfig1-dev libjpeg8-dev libportmidi-dev \
                          libqt4-dev libsdl-ttf2.0-dev libsdl1.2-dev libxinerama-dev subversion python-dev zlib1g-dev

Further down in the build script we need to extract the source code. The template build script build-gens-ppa.sh we used is using git. This needs to be changed to tar.

Make sure to get the folder name right of the extracted source package! Open the downloaded tarball manually to see to which folder it extracts and enter that name in the build script accordingly.

echo "original tarball"
wget http://archive.ubuntu.com/ubuntu/pool/multiverse/m/mame/mame_0.152.orig.tar.xz
tar xfJ mame_0.152.orig.tar.xz
rm mame_0.152.orig.tar.xz

file mame-0.152/

if [ $? -eq 0 ]; then  
    echo "successfully cloned"
else  
    echo "cloning failed, aborting"
    exit
fi 

mv mame-0.152/ $SRC_FOLDER

Again, if you are not using Github as source code server, delete any git commands.

Unpack the Debian files in the source folder:

#change to source folder
cd $SRC_FOLDER

echo ""
echo "##########################################"
echo "Unpacking debian files"
echo "##########################################"
echo ""

#unpack
echo "unpacking template mame.debian.tar.gz"
tar xfz ~/RetroRig-ES/supplemental/mame/mame.debian.tar.gz

Copy format file:

echo "format"
rm -rf debian/source 
mkdir debian/source
cp ~/RetroRig-ES/supplemental/mame/format debian/source/

We don't need the file debian/watch, it's used to look out for new upstream source code. Neither do we want to use the series file in debian/patches. We use git to track the latest changes, or if we patch, then we do that locally and upload the patched code. So no patches needed in the package itself:

echo "patches"
rm -rf debian/patches

echo "clean up"
rm -rf debian/upstream/
rm -f debian/upstream-signing-key.pgp
rm -f debian/watch
rm -rf debian/backports

Delete

#get Makefiles straight
aclocal && autoconf && autoreconf -i && automake --add-missing

Further down in the script there is a PPA stated where to upload the Debian package. Adjust it to your liking.

x@y:~/RetroRig-ES/supplemental/mame$ mv debian/control .
x@y:~/RetroRig-ES/supplemental/mame$ gedit control

Adjust the maintainer and delete any VCS entries.

x@y:~/RetroRig-ES/supplemental/mame$ mv debian/source/format .
x@y:~/RetroRig-ES/supplemental/mame$ gedit format

Change the format to native.

This is a good moment to revert your build operating system to a scratch install. Only this way you can make sure that all dependencies are satisfied correctly. For the very first compile run you can have the script fetch the build environment by using a second command line argument. Later on you can skip the second option ("update").

x@y:~/RetroRig-ES/supplemental/mame$ cd
x@y:~$ ./RetroRig-ES/supplemental/build-mame-ppa.sh compile update

You should see something like this:

##########################################
Building finished
##########################################

total 65M
drwxrwxr-x  3 yo yo 4,0K Sep 19 02:00 .
drwxrwxr-x  4 yo yo 4,0K Sep 19 01:24 ..
drwxr-xr-x 11 yo yo 4,0K Sep 19 01:59 mame-0.152.0
-rw-r--r--  1 yo yo 265K Sep 19 02:01 mame_0.152.0_amd64.build
-rw-r--r--  1 yo yo 2,3K Sep 19 02:00 mame_0.152.0_amd64.changes
-rw-r--r--  1 yo yo  14M Sep 19 02:00 mame_0.152.0_amd64.deb
-rw-r--r--  1 yo yo  955 Sep 19 01:24 mame_0.152.0.dsc
-rw-r--r--  1 yo yo  38M Sep 19 01:24 mame_0.152.0.tar.gz
-rw-rw-r--  1 yo yo  613 Sep 19 01:24 mame-1:0.152.0.dsc
-rw-r--r--  1 yo yo 383K Sep 19 02:00 mame-tools_0.152.0_amd64.deb
-rw-r--r--  1 yo yo 7,0M Sep 19 02:00 mess_0.152.0_amd64.deb
-rw-r--r--  1 yo yo 6,2M Sep 19 02:00 mess-data_0.152.0_all.deb

If it compiles, proceed to the next step. If not, jump back to the previous step and amend it.

Get your GPG keys ready as described here.

Run

x@y:~/RetroRig-ES/supplemental/mame$ cd
x@y:~$ ./RetroRig-ES/supplemental/build-mame-ppa.sh 

and press y when being asked to upload.

Check your mail account. Launchpad will send you an e-mail, to inform you about the package being accepted or rejected. If accepted, check the log files in your Launchpad repository. It can take quite a long time to compile. If compiled successfully, it can take another 10 minutes until the package is published. Only then you can do a sudo apt-get update to inform your operating system about the new software being available.

Finally, we need to commit the changes to RetroRig-ES:

x@y:~$ cd ~/RetroRig-ES
x@y:~/RetroRig-ES$ rm -rvf supplemental/mame/debian/ supplemental/mame/*orig* supplemental/*~ supplemental/*~
x@y:~/RetroRig-ES$ git status
x@y:~/RetroRig-ES$ git add supplemental/build-mame-ppa.sh supplemental/mame/
x@y:~/RetroRig-ES$ git commit -m "build script for packages mess and mame"
[Ubuntu-14.04-Beta 29fc0af] build script for packages mess and mame
 6 files changed, 743 insertions(+)
 create mode 100755 supplemental/build-mame-ppa.sh
 create mode 100644 supplemental/mame/changelog
 create mode 100644 supplemental/mame/control
 create mode 100644 supplemental/mame/format
 create mode 100644 supplemental/mame/mame.debian.tar.gz
 create mode 100644 supplemental/mame/mame.dsc


Resources

Clone this wiki locally