aboutsummaryrefslogtreecommitdiff
path: root/README.specfile
blob: da382d06f6e994dab7fcb3c8bd36f57a25466c6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
                         README for libmeegotouch.spec
                         =============================

Author:  Stefan.Hundhammer@basyskom.de
Updated: 2010-04-29



RPM and spec file concepts
==========================

(skip this section if you are familiar with RPM and spec files)

libmeegotouch.spec is a spec file for creating RPM packages from the
libmeegotouch sources.

RPM ("Red Hat Package Manager") is a file format for (mostly binary) packages
for Linux distributions such as Red Hat / Fedora, openSUSE, and MeeGo.

The RPM file format is little more than a cpio (see "man 1 cpio") archive, very
similar to a tar archive. In addition to the files it contains, there are also
meta data that, among other things, specify dependencies between packages
("package A requires package B to run").

The spec file is the RPM counterpart to the debian/ subdirectory, but in one
single file: It specifies build instructions, file lists, dependencies and
administrative information like package name, version numbers etc.

RPM has the concept of "pristine sources" and patches. In general (for a Linux
distributor), the sources are taken from "upstream" (somewhere in the Internet)
as a "tarball" (a .tar or .tar.gz or .tgz or .tar.bz2 file.

To get those sources to compile and to run in that distribution's specific
environment, a distributor might have to do some (hopefully minor) changes.
Those changes are stored in "patches" (xy.patch or xy.diff) generated with the
"diff" (see "man 1 diff") command. The patches are also listed in the .spec
file; while building the package, RPM first unpacks the tarball(s) (there might
be more than one) and then applies the patches one by one.

The general idea is that these patches can be applied again if there is a newer
version of the upstream sources, so the distributor only has to fetch another
tarball and reuse the existing patches rather than having to go through the
complete source tree and make all the changes again manually.

Since this does not always work perfectly if there were major changes in the
source tree, it helps to keep separate changes in separate patches to minimize
rejected patches (patches that no longer can be cleanly applied with the
"patch" (see "man 1 pach") command.

Whenever a patch is not just specific to the specific system environment, but a
general fix, it makes a lot of sense to "send the patch upstream", i.e. to mail
it to the authors of the original sources.



Creating RPM packages with this spec file
=========================================

(1) Edit the version in the spec file. In this example:

    Version: 0.20.2



(2) Create a tarball. It is RPM file name convention to include the version
    number in both the tar file name and in the first level directory in that tar
    file:

      libmeegotouch-0.20.2.tar.bz2   containing

        libmeegotouch-0.20.2/benchmarks
        libmeegotouch-0.20.2/configure
        libmeegotouch-0.20.2/configure-win32.pl
        libmeegotouch-0.20.2/debian
        libmeegotouch-0.20.2/demos
        libmeegotouch-0.20.2/doc
        libmeegotouch-0.20.2/examples
        ...

    Also, exclude the .git subdirectory as well as any built files (.o files,
    binaries, moc files, ...) since they only blow up the tarball without any
    benefit.

    Simple approach:

      ~/projects/libmeegotouch %  git clean -dfx
      ~/projects/libmeegotouch %  cd ..
      ~/projects %  mv libmeegotouch libmeegotouch-0.20.2
      ~/projects %  tar cjvf /tmp/libmeegotouch-0.20.2.tar.bz2 libmeegotouch-0.20.2 --exclude .git
      ~/projects %  mv libmeegotouch-0.20.2 libmeegotouch


(3.1) If building with OBS:

  (3.1.1) Check out the old version of this package from OBS:

      ~/projects/obs %  osc co libmeegotouch

  (3.1.2) Go into that directory, remove the old tarball, copy the new one
          and the changed spec file there and check in those changes:

        ~/projects/obs %  cd libmeegotouch
        ~/projects/obs/libmeegotouch %  rm libmeegotouch-*.tar.bz2
        ~/projects/obs/libmeegotouch %  cp /tmp/libmeegotouch-0.20.2.tar.bz2 .
        ~/projects/obs/libmeegotouch %  cp ../../libmeegotouch/libmeegotouch.spec .
        ~/projects/obs/libmeegotouch %  osc addremove
        ~/projects/obs/libmeegotouch %  osc ci -m "Updated to version 0.20.2"

  (3.1.3) Upon "osc ci", the package will automatically be rebuilt in OBS.
          Go to the web interface and monitor the results or use the
          "osc results" and "osc buildlog" commands:

        ~/projects/obs/libmeegotouch %  osc results
        standard        armv5el    disabled   (repository is published)
        standard        armv7el    disabled   (repository is published)
        standard        i586       succeeded   (repository is published)
        ~/projects/obs/libmeegotouch %  osc buildlog standard i586 >/tmp/build.log


(3.2) If building without "rpmbuild" rather than with OBS:

  (3.2.1) Make sure the tarball and the spec file are in the same directory:

      ~ %  mkdir /tmp/libmeegotouch
      ~ %  mv /tmp/libmeegotouch-0.20.2.tar.bz2 /tmp/libmeegotouch
      ~ %  cp projects/libmeegotouch/libmeegotouch.spec /tmp/libmeegotouch
      ~ %  ls /tmp/libmeegotouch
      libmeegotouch-0.20.2.tar.bz2
      libmeegotouch.spec

  (3.2.2) Find a directory on your hard drive where you have enough disk space
          to use as a "build root" and create a build root subdirectory there:

      % df -h /work
      Filesystem            Size  Used Avail Use% Mounted on
      /dev/sda7              69G   30G   37G  45% /home
      mkdir /work/tmp/build-root/

  (3.2.3) Start a local "rpmbuild" with that build root:

      ~ %  cd /tmp/libmeegotouch
      /tmp/libmeegotouch % rpmbuild -ba --buildroot /work/tmp/build-root



libmeegotouch Subpackage strategy
=================================

The one source tarball (libmeegotouch-x.y.tar.bz2) creates a number of RPM
packages:


- libmeegotouch: This is the main package, but it only contains one single file
  (LICENSE.LGPL) to satisfy packaging conventions (as enforced in MeeGo by the
  "rpmlint" tool). The main idea behind this main package is to serve as a
  collection for the real library packages:

  - libmeegotouchcore0
  - libmeegotouchextensions0
  - libmeegotouchsettings0
  - libmeegotouchviews0

  They each contain one of the libmeegotouch libraries. The main package
  "libmeegotouch" has "requires" dependencies set up on all of them so it is
  sufficient to install libmeegotouch.rpm to get all the modularized libs.

- libmeegotouch-bin: Some binaries required by applications using libmeegotouch
  such as the theme daemon and the service mapper.

- libmeegotouch-devel: Files needed for developing libmeegotouch-based
  applications: Header files, qmake specs etc.; please notice that the RPM
  package naming convention for development subpackages is -devel, not -dev
  like in Debian-based distributions.

- meegotouch-devel-tools: Tools needed for developing libmeegotouch-based
  applications like the libmeegotouch-specific "moc" preprocessor etc.

- libmeegotouch-doc: API documentation

- meegotouch-demos: Container for the demo subpackages:

  - meegotouch-demos-widgetsgallery: Widget gallery demo
  - meegotouch-demos-widgetsgallery-tests
  - meegotouch-demos-appletinstallationsource
  - meegotouch-demos-applicationextension

- libmeegotouch-tests: Unit tests

- libmeegotouch-benchmarks: Benchmarks


- libmeegotouch-l10n- packages: Messages / translations for user-visible
  strings in the lib packages.

  - libmeegotouch-l10n-eng-en : "Engineering English"
  - libmeegotouch-l10n-en:      English
  - libmeegotouch-l10n-ar       Arabic
  - libmeegotouch-l10n-de       German
  - libmeegotouch-l10n-fi       Finnish
  - libmeegotouch-l10n-hu       Hungarian
  - libmeegotouch-l10n-ur       Urdu
  - libmeegotouch-l10n-zh-cn    Simplified Chinese

- meegotouch-demos-widgetsgallery-l10n- packages: Messages / translatiosn for
  user-visible strings in the "widgets gallery" demo. Please note that the
  "rpmlint" checking tool enforces a 64 character limit per file name component
  because of the Joliet file system that is commonly used on CDs / DVDs. Thus,
  -engineering-english had to be abbreviated to -eng-en.

  - meegotouch-demos-widgetsgallery-l10n-eng-en
  - meegotouch-demos-widgetsgallery-l10n-ar
  - meegotouch-demos-widgetsgallery-l10n-de
  - meegotouch-demos-widgetsgallery-l10n-en
  - meegotouch-demos-widgetsgallery-l10n-fi
  - meegotouch-demos-widgetsgallery-l10n-hu
  - meegotouch-demos-widgetsgallery-l10n-ur
  - meegotouch-demos-widgetsgallery-l10n-zh-cn

RPM spec file cheat sheet
=========================

RPM Variables / Macros
----------------------

Variable definition:

    %define variable_name value

Variable reference:

    %variable_name
    %{variable_name}


Dependencies
-------------

    Requires: other_pkg

This package requires package other_pkg to run (not for building!).

    BuildRequires: other_pkg

This package requires package other_pkg for building (not at runtime!).

    Provides: some_capability

This package provides a capability named "some_capability" that other packages
might require. Note: A package always provides itself, so it's pointless to
write

    Provides: mypackage

in mypackage.spec.

A package also automatically provides all shared libs it has in its file list,
and a package built with a shared lib automatically requires that shared
lib. For example, package libqt4-x11 automatically provides libQtGui.so.4,
libQtSvg.so.4 etc.; likewise, it automatically requires libX11.so.6,
libXext.so.6 etc.


Package name and subpackages
----------------------------

The name of the main package is specified in

    Name: foo

it can have any number of subpackages. A subpackage is defined with

    %package subpkg-name1
or

    %package -n subpkg-name2

Without the -n, it will be prefixed with the main package name and a dash:

    foo-subpkg-name1

With the -n, there will be no prefix:

    subpkg-name2


File lists
----------

All files generated during the build process must be listed in the file
list(s). Wildcards may be used.

    %files

is the file list of the main package.

    %files -n subpkg-name

is the file list of subpackage "subpkg-name" (same rules as with %package:
Prefixed with the main package name if specified without -n).

    %defattr(-,root,root)

specifies the default file permission and ownership (user and group) for each
item in the file list.

    %dir /usr/share/somewhere

assigns directory ownership to this package.

    %config /etc/foo

indicates that /etc/foo should be packaged as a configuration file with special
rules what to do if it already exists when the package is installed so changes
by the system administrator don't simply get lost during package update.

    %doc /usr/share/doc/packages/foo/*

marks files as documentation.


Build section
-------------

    %prep
    %setup mysource-47.11.tar.bz2

This removes an existing build directory for that package, creates a new one
and unpacks the tarball there.

    %build

This executes the commands following %build inside the build directory.
The convention is to only build (compile and link) the project in that section,
not install any files there.

    %install

This is similar to %build, but the intention is to do "make install" and
whatever else is required to install files to the target system in this
section. IMPORTANT: Make sure to prefix all target paths with %{buildroot},
e.g. use

    %{buildroot}/usr/lib/whatever

and not just /usr/lib/whatever.


Misc
----

    Group: System Environment/Libraries

This specifies the RPM "group tag", a tree of categories where this package
belongs to. Different distributions may have different predefined such
categories.

-devel subpackages should go to a category below "Development/".



Further reading
===============

http://www.rpm.org/max-rpm-snapshot/
http://docs.fedoraproject.org/drafts/rpm-guide-en/