Differences between revisions 7 and 8
Revision 7 as of 2013-09-01 15:55:50
Size: 9264
Editor: OsamuAoki
Comment:
Revision 8 as of 2013-09-01 16:08:36
Size: 9654
Editor: OsamuAoki
Comment:
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:

<!> This is not the same as repackaging of the binary RPM file using the [[http://packages.qa.debian.org/a/alien.html|alien]] package.
Line 76: Line 78:
Their meanings are quite intuitive but you can find eleswhere: Their meanings are quite intuitive but you can find them eleswhere:
Line 82: Line 84:
For now, let's recall very basics. For now, let's recall the very basics.
Line 96: Line 98:
This section of configuration is CPP conditional section and means: The above example section of configuration is like CPP conditional section and means:
Line 237: Line 239:
For example, libtool archive files are removed in the ibus.spec file in install phase after the execution of the standard "make install" as: For example, libtool archive files are removed in the "ibus.spec" file in install phase after the execution of the standard "make install" as:
Line 247: Line 249:
This is translated into debian/rules by removing such files before install as: This can be translated into debian/rules by removing such files before install as:
Line 256: Line 258:
Please note the purpose of the manual repackaging is not the line-by-line conversion. It is to create a new Debian package in the most natural form while reusing the known-good-packaging-idea used in the RPM world.
Line 258: Line 262:
I strongly recommend to see the actual example: ibus 1.5.3-4 Debian package and its FC19 src.rpm. I strongly recommend to see the actual example: ibus 1.5.3-* Debian package and its FC19 src.rpm.

Repackage src.rpm

Here are some hints for repackaging a src.rpm package manually into a proper Debian source package.

<!> This is not the same as repackaging of the binary RPM file using the alien package.

How to find src.rpm from Fedora project

Redhat kindly publishes their latest src.rpm packages of Fedora project to the public. They can be searched at:

For example, searching on "ibus*" glob returns "Search Results for packages matching "ibus*" with 47 sets of ID and Name starting with a set "3103" and "ibus".

Clicking on package name "ibus" leads to "Information for package ibus" with many build results. Here, "NVR" value such as "ibus-1.5.3-1.fc19" roughly means:

  • The upstream package name: ibus
  • The upstream package version: 1.5.3
  • The target Fedora release: 1FC19 (the first release for the FC19 distribution)

Clicking on NVR "ibus-1.5.3-1.fc19" leads to "Information for build ibus-1.5.3-1.fc19".

This page lists information on the src.rpm, the binary rpm (armv7hl and noarch) and Changelog.

The URL of the src.rpm is linked from "RPMs" -> "src" -> "(download)".

The outline information page of src.rpm containing build dependency indicated in the SPEC file and files bundled is linked from "RPMs" -> "src" -> "(info)".

How to download and extract src.rpm from Fedora project

I have created a "rget" script as:

# vim:se tw=0 sts=4 ts=4 et si:
FCURL=$1
FCSRPM=$(basename $FCURL)

mkdir ${FCSRPM}
cd ${FCSRPM}/
wget ${FCURL}
rpm2cpio ${FCSRPM} | cpio -dium

Using right click on "(download)" to "Copy link address" and pasting to the console, I run "rget" command as:

 $ rget http://arm.koji.fedoraproject.org//packages/ibus-anthy/1.5.3/1.fc19/src/ibus-anthy-1.5.3-1.fc19.src.rpm

This performs the following:

  • This creates the "ibus-anthy-1.5.3-1.fc19.src.rpm" directory and cd into it.
  • This downloads the "ibus-anthy-1.5.3-1.fc19.src.rpm".
  • This extracts contents of this src.rpm.
    • ibus-1.5.3.tar.gz
    • ibus-530711-preload-sys.patch
    • ibus-541492-xkb.patch
    • ibus-810211-no-switch-by-no-trigger.patch
    • ibus.spec
    • ibus-xinput
    • ibus-xx-setup-frequent-lang.patch

How to read the build info

spec file

The build info for the src.rpm is found in the spec file. For "ibus", the spec file is "ibus.spec".

Debian packaging system stores package information in multiple files under the "debian" directory.

Instead, the spec file stores them all in a file sectioned by lines starting with "%" such as "%package", "%description", "%patch", "%build", "%configure", "%install", "%files", ... Basically, each section embeds shell script lines and text data lines.

Their meanings are quite intuitive but you can find them eleswhere:

For now, let's recall the very basics.

The "#" character is used to put comment like a shell program

The "%" character has many other functions other than sectioning the spec file. Let's see them by the example.

%if (0%{?fedora} > 18 || 0%{?rhel} > 6)
%global with_python_pkg 1
%else
%global with_python_pkg 0
%endif

The above example section of configuration is like CPP conditional section and means:

If (the target fedora version is larger than 18 or the rhel version is larger than 6 in number):
    set global variable with_python_pkg to 1
else:
    set global variable with_python_pkg to 0
endif

The global variables are string and can be used as the argument of "%if" for this CPP like conditional section. The string value 1 means True and the string value 0 means False.

How to set up source tree

The most interesting sections of the spec file are sections describing how to setup the source tree. You need to read several sections to get the idea. For example in "ibus.spec":

%global with_preload_xkb_engine 1

... [skip lines]

Name:       ibus
Version:    1.5.3
Release:    1%{?dist}
Summary:    Intelligent Input Bus for Linux OS
License:    LGPLv2+
Group:      System Environment/Libraries
URL:        http://code.google.com/p/ibus/
Source0:    http://ibus.googlecode.com/files/%{name}-%{version}.tar.gz
Source1:    %{name}-xinput
# Upstreamed patches.
# Patch0:     %{name}-HEAD.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=810211
Patch1:     %{name}-810211-no-switch-by-no-trigger.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=541492
Patch2:     %{name}-541492-xkb.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=530711
Patch3:     %{name}-530711-preload-sys.patch
# Hide minor input method engines on ibus-setup by locale
Patch4:     %{name}-xx-setup-frequent-lang.patch

... [skip lines]

%prep
%setup -q

# %%patch0 -p1
cp client/gtk2/ibusimcontext.c client/gtk3/ibusimcontext.c ||
%patch1 -p1 -b .noswitch
%if %with_preload_xkb_engine
%patch2 -p1 -b .preload-xkb
rm -f bindings/vala/ibus-1.0.vapi
rm -f data/dconf/00-upstream-settings
%endif
%patch3 -p1 -b .preload-sys
%patch4 -p1 -b .setup-frequent-lang

This means:

  • set %{name} to "ibus"
  • set %{version} to "1.5.3"
  • set %{release} to "1FC19"
  • URL of upstream site: http://code.google.com/p/ibus/

  • URL to obtain the main Source0: http://ibus.googlecode.com/files/ibus-1.5.3.tar.gz

  • Additional file Source1: ibus-xinput
  • setup source tree as:
    • extract ibus-1.5.3.tar.gz
    • skip name-HEAD.patch (commented out)
    • copy client/gtk2/ibusimcontext.c to client/gtk3/ibusimcontext.c
    • apply ibus-810211-no-switch-by-no-trigger.patch
    • apply ibus-541492-xkb.patch
    • remove bindings/vala/ibus-1.0.vapi
    • remove data/dconf/00-upstream-settings
    • apply ibus-530711-preload-sys.patch
    • apply ibus-xx-setup-frequent-lang.patch

The file removals can be implemented in the override_dh_auto_clean target.

option for ./configure

Another interesting section is "%configure". For example in "ibus.spec":

%global with_pygobject2 1

... [skip lines]

%configure \
    --disable-static \
    --enable-gtk2 \
    --enable-gtk3 \
    --enable-xim \
    --enable-gtk-doc \
    --with-no-snooper-apps='gnome-do,Do.*,firefox.*,.*chrome.*,.*chromium.*' \
    --enable-surrounding-text \
%if %with_pygobject2
    --enable-python-library \
%endif
    --enable-introspection

The global variable "with_pygobject2" is 1 (True). So when building package, this spec file asks to execute:

./configure \
    --disable-static \
    --enable-gtk2 \
    --enable-gtk3 \
    --enable-xim \
    --enable-gtk-doc \
    --with-no-snooper-apps='gnome-do,Do.*,firefox.*,.*chrome.*,.*chromium.*' \
    --enable-surrounding-text \
    --enable-python-library \
    --enable-introspection

This usually goes to debian/rules under "override_dh_configure:" as:

override_dh_configure:
 [TAB]  dh_configure -- \
        --disable-static \
        --enable-gtk2 \
        --enable-gtk3 \
        --enable-xim \
        --enable-gtk-doc \
        --with-no-snooper-apps='gnome-do,Do.*,firefox.*,.*chrome.*,.*chromium.*' \
        --enable-surrounding-text \
        --enable-python-library \
        --enable-introspection

If cdbs is used, these flags are added by "DEB_CONFIGURE_EXTRA_FLAGS +=" in the debian/rules file.

install

Just like Debian packaging system have <bin_package>.install to pick files to be installed into a particular binary package, src.rpm have a section "%file <bin_package_suffix>" section. Please note that only suffix is used to identify the binary package name in the spec file.

If you need to execute command to generate installed files, execute them in the override_dh_auto_install target etc..

For example, libtool archive files are removed in the "ibus.spec" file in install phase after the execution of the standard "make install" as:

%install
make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'
rm -f $RPM_BUILD_ROOT%{_libdir}/libibus-%{ibus_api_version}.la
rm -f $RPM_BUILD_ROOT%{_libdir}/gtk-2.0/%{gtk2_binary_version}/immodules/im-ibus.la
rm -f $RPM_BUILD_ROOT%{_libdir}/gtk-3.0/%{gtk3_binary_version}/immodules/im-ibus.la

This can be translated into debian/rules by removing such files before install as:

override_dh_install:
        # skip other things implemented for now here (see real example)
        find . -name *.la -delete
        dh_install --fail-missing

Please note the purpose of the manual repackaging is not the line-by-line conversion. It is to create a new Debian package in the most natural form while reusing the known-good-packaging-idea used in the RPM world.

Example of repackage

I strongly recommend to see the actual example: ibus 1.5.3-* Debian package and its FC19 src.rpm.

This can be done as:

$ git clone git://anonscm.debian.org/pkg-ime/ibus.git
$ cd ibus
$ gitk --all

There are much more details needed to be handled than described in the above.