Introduction
This article will teach you how to package your QT project and install it on the meego device. Here, we use an OpenGL project named "Textures" in the QT example as an example. This original project is a QT example without icons that cannot be started from the meego UI. We will make it look more like an independent application.Program, Which can be started directly from the meego application panel and installed on the meego device in RPM package format.
Preparations
The preparation material is an example of QT demo contained in the QT-example package, which is located in/usr/lib/qt4/example/OpenGL/textures.
Copy it to your $ workspace directory as an independent project. It can be either meego SDK chroot or a Linux machine with QT-examples installed.Code:
- CP-A/usr/lib/qt4/examples/OpenGL/textures $ workspace/textures-0.0.1
- CD $ workspace/textures-0.0.1
Copy code
Add an icon for the program. Here we use the project icon in the example as our application icon.
- CP images/side6.png textures.png
Copy code
Add a desktop file so that we can find our program in the meego application panel.
- Vim textures. Desktop
Copy code
Content:
- [Desktop entry]
- Name = qtdemotextures
- Comment = QT demo textures
- Exec = textures
- Categories = development;
- Icon = textures
- Type = Application
- Terminal = false
- Startupnotify = true
Copy code
Edit the textures. Pro file to remove some definitions used in QT example and add icons and desktop installation.
- Vim textures. Pro
Copy code
The modified content is as follows:
- 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
- Instols + = target icon Desktop
Copy code
If you want to test it before packaging, you can build and debug it under meego SDK chroot. For details, see meego x86 development on Hello world-Linux.
- Qmake prefix =/usr
- Make
- Make install
Copy code
Clean up the project, create the source code compressed package, and prepare for packaging.
- Make distclean
- CD ..
- Tar jcvf textures-0.0.1.tar.bz2 textures-0.0.1
Copy code
Create a spec File
Meego recommends that you use the spectacle tool to create a meego spec file or convert an existing spec file to a meego spec file.
Install spectacle
You can install it directly on the meego platform or meego chroot environment.
- Yum install Python-Cheetah
- Yum install spectacle
Copy code
If you are a proxy, you need to set it before running the preceding command:
- Export http_proxy = http: // proxy_server: Port
Copy code
For details about how to install the software on a Linux host, see spectacle installation.
Create a yaml package Metadata File
Spectacle uses the package metadata file as the input to generate the meego spec file. This metadata file is in yaml format. For syntax, see Syntax of spectacle yaml.
Create a textures. yaml file under $ workspace/folder.
- Vim $ workspace/textures. yaml
Copy code
The content is as follows:
- Name: textures
- Summary: QT demo-OpenGL textures
- Version: 0.0.1
- Release: 1
- GROUP: Development/tools
- License: lgplv2.1
- URL: [url = http://qt.nokia.com] http://qt.nokia.com [/url]
- Sources:
- -"Registry.name=-registry.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"
Copy code
The yaml file can also be created from an existing spec file.
- Spec2spectacle package_name.spec
Copy code
For details about spectacle usage, see spectacle usage.
Generate a spec file from the yaml File
Using the yaml file, it is easy to generate the spec file:
- Specify textures. yaml
Copy code
The generated $ workspace/textures. spec file contains the following content:
-
- #
-
- # Do not edit! Generated:
-
- # 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: [url = http://qt.nokia.com] http://qt.nokia.com [/url]
-
- Source0: registry.name=-registry.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
Copy code
Modify the textures. spec file to add the QT construction information: "build pre" and "Install Post" segments.
- #>> Build pre
- Export Path =/usr/lib/qt4/bin: $ path
- Qmake prefix =%{_ prefix}
- # <Build pre
Copy code
- #>> Install post
- Make install_root = % {buildroot}/usr install
- # <Install post
Copy code
Build RPM under meego SDK chroot
For application developers, it is very easy to directly create packages in the meego SDK chroot environment through rpmbuild.
First, enter the chroot environment.
Install rpmbuild and meego RPM build configuration
- Zypper install rpm-build
- Zypper install meego-rpm-config
Copy code
Copy the source code and spec file to the correct location
- CP textures-0.0.1.tar.bz2 ~ /Rpmbuild/sources/
- CP textures. yaml ~ /Rpmbuild/sources/
- CP textures. spec ~ /Rpmbuild/specs/
Copy code
Generate RPM package
- Cd ~ /Rpmbuild/specs
- Rpmbuild-Ba textures. spec
Copy code
This RPM package will be generated in:
- ~ // Rpmbuild/RPMS/i586/textures-0.0.1-1.i586.rpm
- ~ /Rpmbuild/srpms/textures-0.0.1-1.src.rpm
Copy code
More rpmbuild use parameter copy: rpmbuild
Create an RPM package without using chroot or obs
For some build or release users, they may want to build RPM packages that do not require the meego SDK chroot environment. The steps are as follows:
Linux
In Linux, a tool called "build" can directly create an RPM package from the spec file.
@ Install build on your host.
@ Create an RPM package using the build tool and spec File
- Sudo build -- repository [url = repository -- arch i686 textures. spec
Copy code
This package will be generated in/var/tmp/build-root/home/abuild/rpmbuild/RPMS/AND/var/tmp/build-root/home/abuild/rpmbuild/srpms /directory, you can configure your http_proxy to ensure the repo is successful.
- Export http_proxy = http: // proxy_server: Port
Copy code
Verify RPM package
The RPM package can be directly installed on the meego device or in the meego SDK simulation program, copied to the target device or simulator, and run.
- Zypper -- no-GPG-Checks install textures-0.0.1-1.i586.rpm
Copy code
In this case, you can find qtdemotextures in programming under applications, which has been included.