RPM Package Learning

Source: Internet
Author: User
Tags file url svn rpmbuild

The most recent work needs to do with the Freescale IMX5 and iMX6 platform to do some of the system core packages under the ARM platform integration, such as glib, Dbus, Pkg-config, LIBXML2, Pixman, GDB, libpng, GCC, GStreamer, FFmpeg, BlueZ and other software source code for the arm platform packaged into a binary RPM package and binary source code package. src.rpm.

First, why to package the source code into the RPM format of the binary package.

1, because of different computer architecture, such as arm and X86 on the binary is not the same. I've tried to put a simple Hello world of the C language program, When using ubuntu12.04 's own GCC compile to generate the Hello executable, you can't run on ARM's board; Compile and build an arm-based executable using the ARM-LINUX-GCC cross compiler in the Scratchbox environment hello on the arm board can run. So in Linux we sometimes need to download the source code to compile, such as Qt4.8.4 source code, I have downloaded qt-everywhere-opensource-src-4.8.4.tar.gz source code, using their own 2G of memory, It takes two or three hours for the T5900 processor to compile and install Qt4.8.4. But if your own machine architecture (such as the general PC is I386 system) to package the QT source code into RPM, and then use the RPM tool installation, should be much faster, this is the benefits of RPM packaging.

2. Linux operating system publishers usually package the source code into binary rpm for their release, which is easy for developers or software users to install, so you don't have to use the source code directly. Of course the Reahat series provides yum installation or the installation of the user interface, and Ubuntu provides the corresponding apt-get and Ubuntu Software Center software installation method.

3, in the embedded, the need for their own board platform, the Third-party source code or write their own code into the rpm binary RPM package, published to the customer use.

Ii. How to package the source code of the. tar.gz,. Tar.xz into RPM packages.

1, first from the Blfs website http://www.linuxfromscratch.org/blfs/view/svn/index.html or http://sourceforge.net/and other Open-source web site download source code.

2, and then the preparation of the spec file, this is a very important link. Use Autotools (automake+autoconf) or cmake to generate the corresponding makefile files for the source code, and then compile and install them according to makefile and package them into RPM. About the preparation of the spec file, you can refer to the following articles:

Spec file Detailed: http://blog.csdn.net/hncomputer/article/details/7162339

Spec file specifically written: http://cpbest.blog.163.com/blog/static/412415192009917477295/

RPM Package Rpmbuild Spec File depth Description: http://hlee.iteye.com/blog/343499

Spec File Guide: Http://zh.opensuse.org/index.php?title=openSUSE:Specfile_guidelines&variant=zh

RPM Packaging Technology and typical spec file analysis: http://www.cnblogs.com/cnland/archive/2013/02/08/2909301.html

3, configure a good RPM packaging directory structure, generally in the Rpmbuild directory has build, SOURCES, RPMS, Srpms, specs these several directories.

4, play the RPM package.

To from http://www.linuxfromscratch.org/blfs/view/svn/general/ libpng.html Download libpng-1.6.2 As an example, for i386 environment packaging, writing a corresponding libpng.spec file, then use Rmpbuild-ba Libpng.spec to perform the 2nd step of the spec file packaging, if in the spec file%package-n description has Libpng-tools, Libpng-runtime, libpng-devel three packages, Then after the completion of the contents of the spec file, you can see the corresponding libpng-tools-1.6.2-1.i386.rpm, libpng-runtime-1.6.2-1.i386.rpm, and RPMs directory. libpng-devel-1.6.2-1.i386.rpm and generate libpng.src.rpm binary source packages under Srpms.

You can find some common software spec files from https://review.tizen.org/git/website, such as libpng corresponding spec file URL as: https://review.tizen.org/git/?p= external/libpng.git;a=tree;f=packaging;hb=refs/heads/tizen_2.1

Tizen's official website gives the Libpng.spec content as follows:

#sbs-git:slp/unmodified/libpng libpng 1.2.46 fcaa793c53a17a30625312c0e4e6de51383f2deb name:libpng summary:a Lib Rary of functions for manipulating PNG image format Files version:1.2.50 release:1 group:system/libraries Li Cense:zlib Url:http://www.libpng.org/pub/png/source0:ftp://ftp.simplesystems.org/pub/png/src/libpng-%{ver SION}.TAR.BZ2 Requires (POST):/sbin/ldconfig Requires (Postun):/sbin/ldconfig buildrequires:zlib-devel-%description T He libpng package contains a of functions for creating and manipulating PNG (Portable network Graphics) Image form  at files.  The PNG is a bit-mapped graphics format similar to the GIF format.

PNG is created to replace the GIF format, since GIF uses a patented data compression algorithm.



Libpng should be installed if your need to manipulate PNG format image files. %package devel summary:development Tools for programs to manipulate PNG image format Files Group:development/lib Raries Requires:   %{name} =%{version}-%{release} requires:libpng =%{version}-%{release} requires:zlib-devel%description devel T He libpng-devel package contains header files and documentation necessary for developing programs using the PNG (portable



Network Graphics) Library. %prep%setup-q-N%{name}-%{version}%build%configure--disable-static make%{?jobs:-j%jobs}%install rm-rf%{buildr Oot}%make_install rm-rf $RPM _build_root/usr/share/man mkdir-p%{buildroot}/usr/share/license CP license%{buildroot}/  Usr/share/license/%{name}%post-p/sbin/ldconfig%postun-p/sbin/ldconfig%files/usr/share/license/%{name}%manifest Libpng.manifest%{_libdir}/libpng*.so.*%files devel%{_bindir}/*%{_includedir}/*%{_libdir}/libpng*.so%{_libdir}/

 pkgconfig/*


Of course, we should modify it according to our own needs, and then we can pack and release our own software.

5, finally can use RPM-IVH libpng-1.6.2-1.i386.rpm on their own X86 machine to install the corresponding RPM package.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.