简介

本文将教你怎样将你写的Qt项目打包并安装在MeeGo设备上运行。这里通过Qt示例中一个名叫"textures"的OpenGL项目来为例来讲述。这个原始项目是一个没有图标不能从MeeGo UI 启动的Qt例子,我们将使它看起来更像一个独立的应用程序,可以从MeeGo 应用程序面板中直接启动并且以rpm包格式安装在MeeGo设备上。

前期准备

准备材料是一个包含在qt-example包中的Qt demo例子,具体位置在 /usr/lib/qt4/example/opengl/textures。

将它拷贝到你的$workspace目录下做为一个独立的项目。既可以是MeeGo SDK chroot下也可以是安装qt-examples的linux机器上。代码:

  1. cp -a /usr/lib/qt4/examples/opengl/textures $workspace/textures-0.0.1
  2. cd $workspace/textures-0.0.1

复制代码

为程序添加图标,此处我们使用例子中的项目图标作为我们的应用程序图标。

  1. cp images/side6.png textures.png

复制代码

添加一个桌面文件,可以使我们在MeeGo应用程序面板中找到我们的程序。

  1. vim textures.desktop

复制代码

内容是:

  1. [Desktop Entry]
  2. Name=QtDemoTextures
  3. Comment=Qt Demo Textures
  4. Exec=textures
  5. Categories=Development;
  6. Icon=textures
  7. Type=Application
  8. Terminal=false
  9. StartupNotify=true

复制代码

编辑textures.pro文件,去除一些用于Qt Example中的定义并且加入图标、桌面安装。

  1. vim textures.pro

复制代码

修改后的内容如下:

  1. HEADERS = glwidget.h /
  2. window.h
  3. SOURCES = glwidget.cpp /
  4. main.cpp /
  5. window.cpp
  6. RESOURCES = textures.qrc
  7. QT += opengl
  8. # install
  9. #target.path = $[QT_INSTALL_EXAMPLES]/opengl/textures
  10. #sources.files = $SOURCES $HEADERS $RESOURCES $FORMS textures.pro images
  11. #sources.path = $[QT_INSTALL_EXAMPLES]/opengl/textures
  12. target.path = $[install_prefix]/bin
  13. icon.files = textures.png
  14. icon.path = $[install_prefix]/share/icons
  15. desktop.files = textures.desktop
  16. desktop.path = $[install_prefix]/share/applications
  17. INSTALLS += target icon desktop

复制代码

如果你想在打包之前测试下,你可以在MeeGo SDK chroot下构建调试,请参考: Hello World - Linux上的 MeeGo x86 开发

  1. qmake PREFIX=/usr
  2. make
  3. make install

复制代码

清理项目,创建源码压缩包,准备打包。

  1. make distclean
  2. cd ..
  3. tar jcvf textures-0.0.1.tar.bz2 textures-0.0.1

复制代码


创建spec文件

MeeGo推荐使用Spectacle工具创建MeeGo spec文件或者将一个存在的spec文件转换成MeeGo spec文件。

安装Spectacle

在MeeGo 平台 或 MeeGo chroot 环境,可以直接安装。

  1. yum install python-cheetah
  2. yum install spectacle

复制代码

如果您是代理,那么在运行上面命令之前需要设置:

  1. export http_proxy=http://proxy_server:port

复制代码

在Linux主机上安装,可以参考: Spectacle Installation

创建 YAML 包元数据文件

Spectacle使用包元数据文件作为输入来产生MeeGo spec 文件,这个元数据文件是YAML格式的,语法参见: Syntax of Spectacle YAML.

我们在$workspace/folder下创建一个textures.yaml文件

  1. vim $workspace/textures.yaml

复制代码

内容如下:

  1. Name: textures
  2. Summary: Qt Demo - OpenGL Textures
  3. Version: 0.0.1
  4. Release: 1
  5. Group: Development/Tools
  6. License: LGPLv2.1
  7. URL: [url=http://qt.nokia.com]http://qt.nokia.com[/url]
  8. Sources:
  9. - "%{name}-%{version}.tar.bz2"
  10. Description: Qt Demo OpenGL Textures
  11. PkgConfigBR:
  12. - QtCore >= 4.6.0
  13. - QtOpenGL
  14. - QtGui
  15. Configure: none
  16. Builder: none
  17. Files:
  18. - "%{_bindir}/textures"
  19. - "%{_datadir}/applications/*.desktop"
  20. - "%{_datadir}/icons/*.png"

复制代码

YAML文件也可以从已存在的spec文件创建

  1. spec2spectacle package_name.spec

复制代码

Spectacle详细用法请参考: Spectacle Usage

从YAML文件生成spec文件

使用YAML文件,很容易生成spec 文件:

  1. specify textures.yaml

复制代码

生成的$workspace/textures.spec 文件内容是:

  1. #
  2. # Do not Edit! Generated by:
  3. # spectacle version 0.15
  4. #
  5. # >> macros
  6. # << macros
  7. Name:       textures
  8. Summary:    Qt Demo - OpenGL Textures
  9. Version:    0.0.1
  10. Release:    1
  11. Group:      Amusements/Graphics
  12. License:    LGPLv2.1
  13. URL:        [url=http://qt.nokia.com]http://qt.nokia.com[/url]
  14. Source0:    %{name}-%{version}.tar.bz2
  15. Source100:  textures.yaml
  16. Requires(post): desktop-file-utils
  17. Requires(post): /bin/touch
  18. Requires(postun): desktop-file-utils
  19. BuildRequires:  pkgconfig(QtCore) >= 4.6.0
  20. BuildRequires:  pkgconfig(QtOpenGL)
  21. BuildRequires:  pkgconfig(QtGui)
  22. BuildRequires:  desktop-file-utils
  23. %description
  24. Qt Demo OpenGL Textures
  25. %prep
  26. %setup -q -n %{name}-%{version}
  27. # >> setup
  28. # << setup
  29. %build
  30. # >> build pre
  31. # << build pre
  32. # >> build post
  33. # << build post
  34. %install
  35. rm -rf %{buildroot}
  36. # >> install pre
  37. # << install pre
  38. # >> install post
  39. # << install post
  40. desktop-file-install --delete-original       /
  41. --dir %{buildroot}%{_datadir}/applications             /
  42. %{buildroot}%{_datadir}/applications/*
  43. %post
  44. /bin/touch --no-create %{_datadir}/icons/hicolor || :
  45. %{_bindir}/gtk-update-icon-cache /
  46. --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
  47. update-desktop-database %{_datadir}/applications &> /dev/null || :
  48. %postun
  49. /bin/touch --no-create %{_datadir}/icons/hicolor || :
  50. %{_bindir}/gtk-update-icon-cache /
  51. --quiet %{_datadir}/icons/hicolor 2> /dev/null|| :
  52. update-desktop-database %{_datadir}/applications &> /dev/null || :
  53. %files
  54. %defattr(-,root,root,-)
  55. %{_bindir}/textures
  56. %{_datadir}/applications/*.desktop
  57. %{_datadir}/icons/*.png
  58. # >> files
  59. # << files

复制代码

修改textures.spec文件添加qt 建构信息:"build pre"和"install post" 段。

  1. # >> build pre
  2. export PATH=/usr/lib/qt4/bin: $PATH
  3. qmake PREFIX=%{_prefix}
  4. # << build pre

复制代码

  1. # >> install post
  2. make INSTALL_ROOT=%{buildroot}/usr install
  3. # << install post

复制代码

在MeeGo SDK chroot 下构建rpm

对于应用程序开发者来说,他们可以在MeeGo SDK chroot环境下直接创建包,通过rpmbuild是非常容易的。

首先进入chroot环境。
安装rpmbuild和MeeGo rpm 构建配置

  1. zypper install rpm-build
  2. zypper install meego-rpm-config

复制代码

拷贝源码和spec文件到正确的地方

  1. cp textures-0.0.1.tar.bz2 ~/rpmbuild/SOURCES/
  2. cp textures.yaml ~/rpmbuild/SOURCES/
  3. cp textures.spec ~/rpmbuild/SPECS/

复制代码

生成rpm包

  1. cd ~/rpmbuild/SPECS
  2. rpmbuild -ba textures.spec

复制代码

这个rpm包将生成在:

  1. ~/rpmbuild/RPMS/i586/textures-0.0.1-1.i586.rpm
  2. ~/rpmbuild/SRPMS/textures-0.0.1-1.src.rpm

复制代码

更多的rpmbuild使用参拷:rpmbuild

不用chroot 或 OBS 构建 rpm包

对于一些构建或release的人来说,他们可能想去构建不需要MeeGo SDK chroot环境的rpm包,那么步骤如下:

Linux

在Linux下,有一个工具叫“build”可以直接从spec文件创建rpm包。

@在你的主机上安装build。
@利用build工具和spec文件创建rpm包

  1. sudo build --repository [url=http://repo.meego.com/MeeGo/release/1.0/core/repo/ia32/os/]http://repo.meego.com/MeeGo/release/1.0/core/repo/ia32/os/[/url] --arch i686 textures.spec

复制代码

这个包将被生成在/var/tmp/build-root/home/abuild/rpmbuild/RPMS/ 和 /var/tmp/build-root/home/abuild/rpmbuild/SRPMS/目录下,你可以配置你的http_proxy来确保repo成功。

  1. export http_proxy=http://proxy_server:port

复制代码

验证rpm包

rpm包可以被直接安装在MeeGo设备上或MeeGo SDK模拟程序中,拷贝rpm到目标设备或模拟器上并运行。

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

复制代码

此时你可以在applications下的Programming中找到QtDemoTextures,它已经被列入其中了。

源文: http://wiki.meego.com/Packaging/Tutorial

教你如何将你的Qt项目打包安装在MeeGo系统中相关推荐

  1. 如何将你的Qt项目打包安装在MeeGo系统中

    简介 本文将教你怎样将你写的Qt项目打包并安装在MeeGo设备上运行.这里通过Qt示例中一个名叫"textures"的OpenGL项目来为例来讲述.这个原始项目是一个没有图标不能从 ...

  2. 教你如何3分钟把VUE项目打包成apk,真的只要3分钟

    前提准备 使用vue-cli3搭建的项目 工具 HBuilder X,他的图标长这个样子,点击下载 做前端的大多数小伙伴们都应该知道,使用起来轻巧.急速,但是他主要是针对于VUE生态打造的,相对于 v ...

  3. 使用idea打包war包和maven项目打包war包放到tomcat中运行,以及报404错误的解决

    使用idea打包war包和maven项目打包war包放到tomcat中运行,以及报404错误的解决 在tomcat下运行打包的war包,访问时显示404 浅谈打包war包的方式 第一种: 第一步: 第 ...

  4. Qt项目打包发布超详细教程

    文章目录 前期准备工作 一.发布方式 (一)手动发布 (二)windeployqt发布 二.打包成.exe安装包 注意:后面的所有语句中涉及到编译器的,请大家自行替换成自己用的编译器,我这里使用的是M ...

  5. 转:教大家如何用HBuilder将web项目打包成apk

    链接:https://www.jianshu.com/p/d86bf569295d 将我们的web项目打包成一个apk文件并不难,首先准备好软件HBuilder还有你的项目,注意这里只献给那些不是真正 ...

  6. python项目打包部署到linux系统_把python项目打包到linux执行-女性时尚流行美容健康娱乐mv-ida网...

    女性时尚流行美容健康娱乐mv-ida网 mvida时尚娱乐网 首页 美容 护肤 化妆技巧 发型 服饰 健康 情感 美体 美食 娱乐 明星八卦 首页 > 高级搜索 webpack 打包 node. ...

  7. Qt 5.14 安装,windows10系统,64位,详细步骤,非常简单!

    下载地址:http://download.qt.io/archive/qt/5.14/5.14.2/ 直接选择windows系统或mac兄或Linux系统对应版本即可. 这里解释一下 Qt 的版本号, ...

  8. linux java jar包项目如何安装在win系统 设置开机自启等配置 - jar包配置不用改

    大家都知道  linux 是没有c盘或者d盘 我们部署linux项目的时候  , java 上传的文件都是在当前项目的目录下, 我们需要把项目部署到win系统的时候 在不改其jar包的配置下,在指定盘 ...

  9. vs2019中如何创建qt项目_在VS2015中创建Qt项目【VS+Qt项目开发系列】(二)

    在VS2015中创建Qt项目[VS+Qt项目开发系列](二) 发布时间:2018-04-20 22:44, 浏览次数:1269 , 标签: VS Qt 在上一篇[VS+Qt项目开发](一)在VS201 ...

最新文章

  1. LINQ to SQL 运行时动态构建查询条件
  2. Python的装饰器
  3. mysql嵌套实战_艰难的mysql嵌套表结果挑战
  4. Spring 使用 JSR303自定义校验注解+分组校验
  5. 从十四五规划看 物联网(NB-IoT、Cat.1、5G)将何去何从?
  6. Docker容器数据卷讲解
  7. 单链表的回文判断(O(n)时间复杂度和O(1)的空间复杂度)
  8. WINDOWS XP数字总线补丁 KB888111
  9. 计算机无法连上网怎么办,电脑显示已连接上但是无法上网怎么办
  10. linux内核的挂载,通过Linux内核使用RDT
  11. OSPO Summit 2022 正式启动!OSPO Summit 2022 Launched!
  12. sicily 9562 SUME
  13. 아 / 어/여서与고 的区别
  14. 以水稻为例教你如何使用BSA方法进行遗传定位(上篇)
  15. 国际标准SHARE78七级灾难备份方案
  16. SLIC超像素分割的算法介绍和源码分析
  17. 网吧看电影你们都用什么IT网站看网吧电影会员免费免VIP的那种
  18. 计算机电路板 接地,pcb电路板接地怎么接
  19. “大数据”挖出老鼠仓的政治价值
  20. 计算机ipad手机组成,如何为自适应手机,计算机和iPad制作网页的摘要

热门文章

  1. 网站域名备案需要多长时间?个人经验分享
  2. 2021年电工(初级)考试内容及电工(初级)模拟考试题
  3. 7个半月股价涨了40%多,DXC做对了什么?
  4. 一起做RGB-D SLAM(4)
  5. 卡牌游戏源代码(原创)(控制台)
  6. Python中既有列表,何必再有数组(NumPy‘s ndarray)?
  7. MATLAB强化学习工具箱(一)-在网格环境中使用Q-learning and SARSA
  8. 先谈云计算再谈云大会
  9. [免费专栏] Android安全之Android so文件分析「详细版」
  10. Vue2 的 diff 算法