Meego Wiki
Views

SDK/Docs/1.2/MeeGo SDK 1.2 Preview for Linux/Create RPM Package For MeeGo Application

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
(Useful link)
Line 227: Line 227:
== Useful link ==
== Useful link ==
-
[[SDK/Docs/1.0/Packaging/Tutorial]]
+
[[SDK/Docs/1.0/Packaging/Tutorial]]<br>
-
[[Packaging/Guidelines]]
+
[[Packaging/Guidelines]]<br>
-
[[http://standards.freedesktop.org/desktop-entry-spec/latest/index.html Desktop Entry Specification]]
+
[[http://standards.freedesktop.org/desktop-entry-spec/latest/index.html Desktop Entry Specification]]<br>

Revision as of 11:13, 6 May 2011

Contents

Introduction

This page will create a MeeGo rpm package from an existing qt project - an OpenGL application called "textures" in qt examples. The original project is just a qt example project and has no icon and can not be launched from MeeGo UI. We will make it more like a stand alone application which can be launched from MeeGo applications panel and create a rpm package which can be installed on MeeGo device.
We will introduce how to package app as RPM by Qt Creator or Linux cmd.

Preparation

The textures is one example of Qt demo and included in qt-examples package. The project is at /usr/lib/qt4/example/opengl/textures.

  • Copy it to a separate folder $workspace as a stand-alone project. You can do it either in MeeGo SDK chroot or normal Linux machine with qt-examples installed.
cp -a /usr/lib/qt4/examples/opengl/textures $workspace/textures-0.0.1
cd $workspace/textures-0.0.1
  • Add an icon for the application. We reuse an image inside the project as the application icon.
cp images/side6.png textures.png
  • Add a desktop file so we can find the application from MeeGo applications panel.
vi textures.desktop

with following contents:

[Desktop Entry]
Name=QtDemoTextures
Comment=Qt Demo Textures
Exec=textures
Categories=Development;
Icon=textures
Type=Application
Terminal=false
StartupNotify=true
  • Edit textures.pro to remove some defines for Qt Example and add icon, desktop installation.
vi textures.pro

The contents will be:

HEADERS       = glwidget.h \
                window.h
SOURCES       = glwidget.cpp \
                main.cpp \
                window.cpp
RESOURCES     = textures.qrc
QT           += opengl

# install
#target.path = $$[QT_INSTALL_EXAMPLES]/opengl/textures
#sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS textures.pro images
#sources.path = $$[QT_INSTALL_EXAMPLES]/opengl/textures
target.path = $$[install_prefix]/bin
icon.files = textures.png
icon.path = $$[install_prefix]/share/icons
desktop.files = textures.desktop
desktop.path = $$[install_prefix]/share/applications

INSTALLS += target icon desktop

Create spec file

MeeGo recommends to use Spectacle to either create MeeGo spec file or convert existing spec file to MeeGo spec file.

Install Spectacle

  • On MeeGo platform or MeeGo chroot environment, you can install it directly.
yum install python-cheetah
yum install spectacle
  • If you are behind proxy then before running the above commands,
export http_proxy=http://proxy_server:port

Create YAML package meta-data file

Spectacle uses a package meta-data file as the input to generate MeeGo spec file. The meta-data file is in YAML format. Spectacle defines specific Syntax of Spectacle YAML.

  • We create the textures.yaml in the $workspace/ folder
vi $workspace/textures.yaml

with the following content:

Name: textures
Summary: Qt Demo - OpenGL Textures
Version: 0.0.1
Release: 1
Group: Development/Tools
License: LGPLv2.1
URL: http://qt.nokia.com
Sources:
    - "%{name}-%{version}.tar.bz2"
Description: Qt Demo OpenGL Textures 

PkgConfigBR:
    - QtCore >= 4.6.0
    - QtOpenGL
    - QtGui
Configure: none
Builder: none
Files:
    - "%{_bindir}/textures"
    - "%{_datadir}/applications/*.desktop"
    - "%{_datadir}/icons/*.png"
  • An YAML file can also be created from an existing spec file:
spec2spectacle package_name.spec

Generate spec file from YAML meta-data file

With the YAML file, the spec file can be easily generated:

specify textures.yaml

The generated $workspace/textures.spec file is:

# 
# Do not Edit! Generated by:
# spectacle version 0.15
# 
# >> macros
# << macros

Name:       textures
Summary:    Qt Demo - OpenGL Textures
Version:    0.0.1
Release:    1
Group:      Amusements/Graphics
License:    LGPLv2.1
URL:        http://qt.nokia.com
Source0:    %{name}-%{version}.tar.bz2
Source100:  textures.yaml
Requires(post): desktop-file-utils
Requires(post): /bin/touch
Requires(postun): desktop-file-utils
BuildRequires:  pkgconfig(QtCore) >= 4.6.0
BuildRequires:  pkgconfig(QtOpenGL)
BuildRequires:  pkgconfig(QtGui)
BuildRequires:  desktop-file-utils

%description
Qt Demo OpenGL Textures



%prep
%setup -q -n %{name}-%{version}

# >> setup
# << setup

%build
# >> build pre
# << build pre



# >> build post
# << build post
%install
rm -rf %{buildroot}
# >> install pre
# << install pre

# >> install post
# << install post
desktop-file-install --delete-original       \
  --dir %{buildroot}%{_datadir}/applications             \
   %{buildroot}%{_datadir}/applications/*



%post
/bin/touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache \
  --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
update-desktop-database %{_datadir}/applications &> /dev/null || :

%postun
/bin/touch --no-create %{_datadir}/icons/hicolor || :
%{_bindir}/gtk-update-icon-cache \
  --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
update-desktop-database %{_datadir}/applications &> /dev/null || :


%files
%defattr(-,root,root,-)
%{_bindir}/textures
%{_datadir}/applications/*.desktop
%{_datadir}/icons/*.png
# >> files
# << files
  • Modify the textures.spec to add qt build in "build pre" and "install post" sections.

Note: In textures.yaml, we put "none" for the "Builder" option since the spectacle v0.15 does not support qt build well so we have to manually change the textures.spec. That limitation has been fixed in latest spectacle, which however is not included in MeeGo 1.0.

# >> build pre
export PATH=/usr/lib/qt4/bin:$PATH
qmake PREFIX=%{_prefix}
# << build pre
# >> install post
make INSTALL_ROOT=%{buildroot}/usr install
# << install post

Creating RPM package by Qt Creator

launch Qt Creator MeeGo SDK 1.2 Preview -> MeeGo SDK Qt Creator

  • Open the project
  • If you run the application, an .rpm package is created automatically.
  • If you want to create a package of your application without running it, click Build All or select Build > Build Project "<project name>".

Creating RPM package by Linux cmd

Under Linux, a tool called "build" is used to create rpm packages directly from spec file.

  • Install build on your Linux host machine. You can find the repo link and packages at MeeGo Tools Repo. Following Lnux distributions are supported
   * MeeGo
   * Fedora 10,11,12,13,14
   * openSUSE(s)    
   * xUbuntu 8.10/9.04/9.10/10.04/10.10
   * Debian 5.0   
  • Create rpm package with build and spec file
sudo build --repository http://repo.meego.com/MeeGo/releases/1.1/core/repos/ia32/packages/ --arch i686 textures.spec

The packages will be generated at /var/tmp/build-root/home/abuild/rpmbuild/RPMS/ and /var/tmp/build-root/home/abuild/rpmbuild/SRPMS/ You may configure your http_proxy to make sure the repo can be accessed.

export http_proxy=http://proxy_server:port

Verify the rpm package

The rpm package can be installed on MeeGo devices or MeeGo SDK simulator directly. Copy the rpm to target device or simulator and run:

zypper --no-gpg-checks install textures-0.0.1-1.i586.rpm

Then you can find QtDemoTextures in applications under Programming. It's ready to be distributed.

Useful link

SDK/Docs/1.0/Packaging/Tutorial
Packaging/Guidelines
[Desktop Entry Specification]

Personal tools