Friday, March 1, 2013

Ubuntu - How to package Qt application (part 2)

Creating Debian folder

 

 After the first part is finished now we need to make Debian folder which contains crucial informations for building your app. In this tutorial I'll use simple Qt application, it just displays Hello World on screen.





To make packaging easier make the folder on desktop and inside that folder create folder with name like this: name-version (in mine case name will go like this: hello-1.2). Now we need to make .orig file. In order to do that make archive of your newly created folder and name it hello_1.2.orig.tar.gz (notice we now use " _ " instead of " - ", if you use " - " you'll get error).

Now we need to make Debian folder. But before that, we'll change .pro file so it install files where we need them. Locate your .pro file and open it with text editor, look at mine example:


#-------------------------------------------------
#
# Project created by QtCreator 2013-02-28T23:14:55
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = HelloWorld
TEMPLATE = app
target.path = /usr/bin
shortcutfiles.files += data/hello.desktop
shortcutfiles.path = /usr/share/applications/
data.files = hello.png
data.path = /usr/share/helloworld/

INSTALLS += target
INSTALLS += shortcutfiles
INSTALLS += data

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

FORMS    += mainwindow.ui
As you can see I added some text to my .pro file.

We need our binary file in /usr/bin folder, shortcut file in /usr/share/applications and data files in /usr/share/helloworld so I added instructions to .pro file. After we added instructions now we need to install them by adding INSTALLS command like on above example.
We can now proceed to creation of Debian folder.

 Open Terminal and go to location of your package folder like this:


cd /home/alen/Radna površina/package/hello-1.2
After locating your folder run this command:


dh_make -s 
You now see notification about type of your package, version, owner etc. Just confirm by hitting ENTER. Your new folder Debian is created inside hello-1.2 folder. Go to Debian folder and delete all files with extension .ex and source folder. You only need  changelog, compat, control, copyright and rules.


Changelog file


 Changelog file contains information about your changes in application and your gpg key information. Tweak changelog file as needed, mine looks like this:



hello (1.2-ubuntu1) precise; urgency=low

  * Initial release.

 -- Alen Masic (novi) <alenn.masic@gmail.com>  Thu, 28 Feb 2013 23:36:02 +0100

First line defines name of your binary file, ubuntu version and urgency. Second line contains information about your changes, since this is mine first release I have no changes, so I'll leave it as it is. And third line contains information about your gpg key. You must type this correctly otherwise packaging process will fail.

Control file


Control file contains information which are needed for tools you use to package application. It provides information about name of your binary file, maintainer, build-depends, architecture etc. Fill this file with your information like on this example:

Source: hello
Section: util
Priority: extra
Maintainer: Alen Masic<alenn.masic@gmail.com>
Build-Depends: debhelper (>= 8.0.0), qtbase5-dev, qt5-qmake, qtchooser
Standards-Version: 3.9.2
Homepage: <insert the upstream URL, if relevant>
#Vcs-Git: git://git.debian.org/collab-maint/hello.git
#Vcs-Browser: http://git.debian.org/?p=collab-maint/hello.git;a=summary

Package: hello
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: <insert up to 60 chars description>
 <insert long description, indented with spaces>
Build-depends let you specify which libraries your application use. I placed common libraries for basic Qt5 application, if you use other libraries include them here. Everything else is simple to understand so I won't go any further. If you want to include description make sure you delete < >.


Rules file


Rules file contains commands for installation of your app. But that's different story. In this tutorial we won't change rules file. So it should look like this:



#!/usr/bin/make -f
# -*- makefile -*-

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

%:
    dh $@

Copyright file

 

 This file contains licence information.  You don't need to change this file since it's already filled with nessesary information. You should add your information like your name and e-mail adress in corresponding fields. After you finish with editing save your file.

We are done with preparations and we can start packaging our application.

No comments:

Post a Comment