感谢支持
我们一直在努力

QT初级进阶2:轻轻松松打包MeeGo的QT程序

打包MeeGo的QT程序是程序员的快乐时光,看到自己的成果马上要发布了,多少天开发的劳累,多少天的抓耳挠腮的痛苦,都在此时化为美丽的故事。RPM包是MeeGo最为常用的安装包,本篇博客以RPM包为基础,讲述如何在这快乐时光中,轻轻松松打包MeeGo的QT程序。


Ubuntu是MeeGo QT程序开发的常用PC环境,那么RPM包如何生成呢?
1) 下载和安装rpmbuild。
        sudo apt-get install rpmbuild
2) 检查rpmbuild目录在安装后是否已经生成.
        cd ~
        ls | grep ‘rpmbuild’
3) 将你的SPEC文件拷贝到~/rpmbuild/SPECS/下。SPEC文件的具体内容一般如下:
        Summary:App summary
        Name:App Name
        Version:0.1
        Release:1
        Vendor:App Company
        License:Property
        Group:Applications/Text
        %description
        App description
        %prep
        %build
        %install
        %clean
        %files
        %defattr(-,root,root)
        /usr/bin/AppName
        /usr/share/applications/AppName.desktop
        /usr/share/icons/hicolor/64×64/apps/AppIcon.png
        请注意:一般只有一个二进制文件放在/usr/bin/下,一个desktop文件,和一个icon。
4) 将所有打包文件放入~/rpmbuild/BUILDROOT/—/目录下。如果按照SPEC上述文件,那么可执行文件AppName应该放到为:~/rpmbuild/BUILDROOT/AppName-0.1-1.i386/usr/bin/下;AppName.desktop放到~/rpmbuild/BUILDROOT/AppName-0.1-1.i386/usr/share/applications/下,做法一次类推。
5) 执行打包程序
        rpmbuild –ba AppName.spec
如果对rpmbuild的使用方法不熟悉,可以在Ubuntu下使用man rpmbuild方法或者直接访问http://www.linuxidc.com/Linux/2011-07/39093p2.htm。


【小结】
– RPM打包方法和工具有很多,本篇博客仅仅以rpmbuild作为实例。
– SPEC的格式一定要使用UNIX格式,否则在运行打包命令的时候会出现错误,排查比较难。如果SPEC是从windows中编辑而来,建议使用dos2unix来做一次转换。

rpmbuild

Namerpmbuild — Build RPM Package(s)

Synopsis

Building Packages:











rpmbuild {-ba|-bb|-bp|-bc|-bi|-bl|-bs} [(1) rpmbuild-options ] SPECFILE


rpmbuild {-ta|-tb|-tp|-tc|-ti|-tl|-ts} [(1) rpmbuild-options ] TARBALL


rpmbuild {–rebuild|–recompile} SOURCEPKG



Miscellaneous:







rpmbuild {–showrc}



rpmbuild-options








(1)  –buildroot DIRECTORY | –clean | –nobuild | –rmsource | –rmspec
| –short-circuit | –sign | –target PLATFORM




Description

rpmbuild is used to build both binary and source software packages. A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package. Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.


One of the following basic modes must be selected: Build Package, Build Package from Tarball, Recompile Package, Show Configuration.

General Options

These options can be used in all the different modes.



-?, –help

Print a longer usage message then normal.


–version

Print a single line containing the version number of rpm being used.


–quiet

Print as little as possible – normally only error messages will be displayed.


-v

Print verbose information – normally routine progress messages will be displayed.


-vv

Print lots of ugly debugging information.


–rcfile FILELIST

Each of the files in the colon separated FILELIST is read sequentially by rpm for configuration information. Only the first file in the list must exist, and tildes will be expanded to the value of $HOME. The default FILELIST is /usr/lib/rpm/rpmrc:/usr/lib/rpm/RedHat/rpmrc:/etc/rpmrc:~/.rpmrc.


–pipe CMD

Pipes the output of rpm to the command CMD.


–dbpath DIRECTORY

Use the database in DIRECTORY rather than the default path /var/lib/rpm


–root DIRECTORY

Use the file system tree rooted at DIRECTORY for all operations. Note that this means the database within DIRECTORY will be used for dependency checks and any scriptlet(s) (e.g. %post if installing, or %prep if building, a package) will be run after a chroot(2) to DIRECTORY.

Build Options

The general form of an rpm build command is



rpmbuild {-bSTAGE|-tSTAGE} [(1) rpmbuild-options ] FILE



The argument used is -b if a spec file is being used to build the package and -t if rpmbuild should look inside of a (possibly compressed) tar file for the spec file to use. After the first argument, the next character (STAGE) specifies the stages of building and packaging to be done and is one of:


-ba

Build binary and source packages (after doing the %prep, %build, and %install stages).


-bb

Build a binary package (after doing the %prep, %build, and %install stages).


-bp

Executes the “%prep” stage from the spec file. Normally this involves unpacking the sources and applying any patches.


-bc

Do the “%build” stage from the spec file (after doing the %prep stage). This generally involves the equivalent of a “make”.


-bi

Do the “%install” stage from the spec file (after doing the %prep and %build stages). This generally involves the equivalent of a “make install”.


-bl

Do a “list check”. The “%files” section from the spec file is macro expanded, and checks are made to verify that each file exists.


-bs

Build just the source package.



The following options may also be used:



–buildroot DIRECTORY

When building a package, override the BuildRoot tag with directory DIRECTORY.


–clean

Remove the build tree after the packages are made.


–nobuild

Do not execute any build stages. Useful for testing out spec files.


–rmsource

Remove the sources after the build (may also be used standalone, e.g. “rpmbuild –rmsource foo.spec“).


–rmspec

Remove the spec file after the build (may also be used standalone, eg. “rpmbuild –rmspec foo.spec“).


–short-circuit

Skip straight to specified stage (i.e., skip all stages leading up to the specified stage). Only valid with -bc and -bi.


–sign

Embed a GPG signature in the package. This signature can be used to verify the integrity and the origin of the package. See the section on GPG SIGNATURES in rpm(8) for configuration details.


–target PLATFORM

When building the package, interpret PLATFORM as arch-vendor-os and set the macros %_target, %_target_cpu, and %_target_os accordingly.

Rebuild and Recompile Options

There are two other ways to invoke building with rpm:



rpmbuild {–rebuild|–recompile} SOURCEPKG



When invoked this way, rpmbuild installs the named source package, and does a prep, compile and install. In addition, –rebuild builds a new binary package. When the build has completed, the build directory is removed (as in –clean) and the the sources and spec file for the package are removed.

Showrc

The command



rpmbuild –showrc



shows the values rpmbuild will use for all of the options are currently set in rpmrc and macros configuration file(s).

Files

rpmrc Configuration












/usr/lib/rpm/rpmrc
/usr/lib/rpm/redhat/rpmrc
/etc/rpmrc
~/.rpmrc


Macro Configuration












/usr/lib/rpm/macros
/usr/lib/rpm/redhat/macros
/etc/rpm/macros
~/.rpmmacros


Database


































/var/lib/rpm/Basenames
/var/lib/rpm/Conflictname
/var/lib/rpm/Dirnames
/var/lib/rpm/Filemd5s
/var/lib/rpm/Group
/var/lib/rpm/Installtid
/var/lib/rpm/Name
/var/lib/rpm/Packages
/var/lib/rpm/Providename
/var/lib/rpm/Provideversion
/var/lib/rpm/Requirename
/var/lib/rpm/Requireversion
/var/lib/rpm/Sha1header
/var/lib/rpm/Sigmd5
/var/lib/rpm/Triggername


Temporary






/var/tmp/rpm*

赞(0) 打赏
转载请注明出处:服务器评测 » QT初级进阶2:轻轻松松打包MeeGo的QT程序
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏