1
                         README for libmeegotouch.spec
2
                         =============================
3
4
Author:  Stefan.Hundhammer@basyskom.de
5
Updated: 2010-04-29
6
7
8
9
RPM and spec file concepts
10
==========================
11
12
(skip this section if you are familiar with RPM and spec files)
13
14
libmeegotouch.spec is a spec file for creating RPM packages from the
15
libmeegotouch sources.
16
17
RPM ("Red Hat Package Manager") is a file format for (mostly binary) packages
18
for Linux distributions such as Red Hat / Fedora, openSUSE, and MeeGo.
19
20
The RPM file format is little more than a cpio (see "man 1 cpio") archive, very
21
similar to a tar archive. In addition to the files it contains, there are also
22
meta data that, among other things, specify dependencies between packages
23
("package A requires package B to run").
24
25
The spec file is the RPM counterpart to the debian/ subdirectory, but in one
26
single file: It specifies build instructions, file lists, dependencies and
27
administrative information like package name, version numbers etc.
28
29
RPM has the concept of "pristine sources" and patches. In general (for a Linux
30
distributor), the sources are taken from "upstream" (somewhere in the Internet)
31
as a "tarball" (a .tar or .tar.gz or .tgz or .tar.bz2 file.
32
33
To get those sources to compile and to run in that distribution's specific
34
environment, a distributor might have to do some (hopefully minor) changes.
35
Those changes are stored in "patches" (xy.patch or xy.diff) generated with the
36
"diff" (see "man 1 diff") command. The patches are also listed in the .spec
37
file; while building the package, RPM first unpacks the tarball(s) (there might
38
be more than one) and then applies the patches one by one.
39
40
The general idea is that these patches can be applied again if there is a newer
41
version of the upstream sources, so the distributor only has to fetch another
42
tarball and reuse the existing patches rather than having to go through the
43
complete source tree and make all the changes again manually.
44
45
Since this does not always work perfectly if there were major changes in the
46
source tree, it helps to keep separate changes in separate patches to minimize
47
rejected patches (patches that no longer can be cleanly applied with the
48
"patch" (see "man 1 pach") command.
49
50
Whenever a patch is not just specific to the specific system environment, but a
51
general fix, it makes a lot of sense to "send the patch upstream", i.e. to mail
52
it to the authors of the original sources.
53
54
55
56
Creating RPM packages with this spec file
57
=========================================
58
59
(1) Edit the version in the spec file. In this example:
60
61
    Version: 0.20.2
62
63
64
65
(2) Create a tarball. It is RPM file name convention to include the version
66
    number in both the tar file name and in the first level directory in that tar
67
    file:
68
69
      libmeegotouch-0.20.2.tar.bz2   containing
70
71
        libmeegotouch-0.20.2/benchmarks
72
        libmeegotouch-0.20.2/configure
73
        libmeegotouch-0.20.2/configure-win32.pl
74
        libmeegotouch-0.20.2/debian
75
        libmeegotouch-0.20.2/demos
76
        libmeegotouch-0.20.2/doc
77
        libmeegotouch-0.20.2/examples
78
        ...
79
80
    Also, exclude the .git subdirectory as well as any built files (.o files,
81
    binaries, moc files, ...) since they only blow up the tarball without any
82
    benefit.
83
84
    Simple approach:
85
86
      ~/projects/libmeegotouch %  git clean -dfx
87
      ~/projects/libmeegotouch %  cd ..
88
      ~/projects %  mv libmeegotouch libmeegotouch-0.20.2
89
      ~/projects %  tar cjvf /tmp/libmeegotouch-0.20.2.tar.bz2 libmeegotouch-0.20.2 --exclude .git
90
      ~/projects %  mv libmeegotouch-0.20.2 libmeegotouch
91
92
93
(3.1) If building with OBS:
94
95
  (3.1.1) Check out the old version of this package from OBS:
96
97
      ~/projects/obs %  osc co libmeegotouch
98
99
  (3.1.2) Go into that directory, remove the old tarball, copy the new one
100
          and the changed spec file there and check in those changes:
101
102
        ~/projects/obs %  cd libmeegotouch
103
        ~/projects/obs/libmeegotouch %  rm libmeegotouch-*.tar.bz2
104
        ~/projects/obs/libmeegotouch %  cp /tmp/libmeegotouch-0.20.2.tar.bz2 .
105
        ~/projects/obs/libmeegotouch %  cp ../../libmeegotouch/libmeegotouch.spec .
106
        ~/projects/obs/libmeegotouch %  osc addremove
107
        ~/projects/obs/libmeegotouch %  osc ci -m "Updated to version 0.20.2"
108
109
  (3.1.3) Upon "osc ci", the package will automatically be rebuilt in OBS.
110
          Go to the web interface and monitor the results or use the
111
          "osc results" and "osc buildlog" commands:
112
113
        ~/projects/obs/libmeegotouch %  osc results
114
        standard        armv5el    disabled   (repository is published)
115
        standard        armv7el    disabled   (repository is published)
116
        standard        i586       succeeded   (repository is published)
117
        ~/projects/obs/libmeegotouch %  osc buildlog standard i586 >/tmp/build.log
118
119
120
(3.2) If building without "rpmbuild" rather than with OBS:
121
122
  (3.2.1) Make sure the tarball and the spec file are in the same directory:
123
124
      ~ %  mkdir /tmp/libmeegotouch
125
      ~ %  mv /tmp/libmeegotouch-0.20.2.tar.bz2 /tmp/libmeegotouch
126
      ~ %  cp projects/libmeegotouch/libmeegotouch.spec /tmp/libmeegotouch
127
      ~ %  ls /tmp/libmeegotouch
128
      libmeegotouch-0.20.2.tar.bz2
129
      libmeegotouch.spec
130
131
  (3.2.2) Find a directory on your hard drive where you have enough disk space
132
          to use as a "build root" and create a build root subdirectory there:
133
134
      % df -h /work
135
      Filesystem            Size  Used Avail Use% Mounted on
136
      /dev/sda7              69G   30G   37G  45% /home
137
      mkdir /work/tmp/build-root/
138
139
  (3.2.3) Start a local "rpmbuild" with that build root:
140
141
      ~ %  cd /tmp/libmeegotouch
142
      /tmp/libmeegotouch % rpmbuild -ba --buildroot /work/tmp/build-root
143
144
145
146
libmeegotouch Subpackage strategy
147
=================================
148
149
The one source tarball (libmeegotouch-x.y.tar.bz2) creates a number of RPM
150
packages:
151
152
153
- libmeegotouch: This is the main package, but it only contains one single file
154
  (LICENSE.LGPL) to satisfy packaging conventions (as enforced in MeeGo by the
155
  "rpmlint" tool). The main idea behind this main package is to serve as a
156
  collection for the real library packages:
157
158
  - libmeegotouchcore0
159
  - libmeegotouchextensions0
160
  - libmeegotouchsettings0
161
  - libmeegotouchviews0
162
163
  They each contain one of the libmeegotouch libraries. The main package
164
  "libmeegotouch" has "requires" dependencies set up on all of them so it is
165
  sufficient to install libmeegotouch.rpm to get all the modularized libs.
166
167
- libmeegotouchqtstyle": The "plain Qt style", the Qt plug-in that adds the
168
  Meego Touch look and feel for "plain Qt" applications (applications that
169
  don't link against libmeegotouch).
170
171
- libmeegotouch-bin: Some binaries required by applications using libmeegotouch
172
  such as the theme daemon and the service mapper.
173
174
- libmeegotouch-devel: Files needed for developing libmeegotouch-based
175
  applications: Header files, qmake specs etc.; please notice that the RPM
176
  package naming convention for development subpackages is -devel, not -dev
177
  like in Debian-based distributions.
178
179
- meegotouch-devel-tools: Tools needed for developing libmeegotouch-based
180
  applications like the libmeegotouch-specific "moc" preprocessor etc.
181
182
- libmeegotouch-doc: API documentation
183
184
- meegotouch-demos: Container for the demo subpackages:
185
186
  - meegotouch-demos-widgetsgallery: Widget gallery demo
187
  - meegotouch-demos-widgetsgallery-tests
188
  - meegotouch-demos-qtstyle
189
  - meegotouch-demos-animatedlayout
190
  - meegotouch-demos-appletinstallationsource
191
  - meegotouch-demos-applicationextension
192
193
- libmeegotouch-tests: Unit tests
194
195
- libmeegotouch-benchmarks: Benchmarks
196
197
198
- libmeegotouch-l10n- packages: Messages / translations for user-visible
199
  strings in the lib packages.
200
201
  - libmeegotouch-l10n-eng-en : "Engineering English"
202
  - libmeegotouch-l10n-en:      English
203
  - libmeegotouch-l10n-ar       Arabic
204
  - libmeegotouch-l10n-de       German
205
  - libmeegotouch-l10n-fi       Finnish
206
  - libmeegotouch-l10n-hu       Hungarian
207
  - libmeegotouch-l10n-ur       Urdu
208
  - libmeegotouch-l10n-zh-cn    Simplified Chinese
209
210
- meegotouch-demos-widgetsgallery-l10n- packages: Messages / translatiosn for
211
  user-visible strings in the "widgets gallery" demo. Please note that the
212
  "rpmlint" checking tool enforces a 64 character limit per file name component
213
  because of the Joliet file system that is commonly used on CDs / DVDs. Thus,
214
  -engineering-english had to be abbreviated to -eng-en.
215
216
  - meegotouch-demos-widgetsgallery-l10n-eng-en
217
  - meegotouch-demos-widgetsgallery-l10n-ar
218
  - meegotouch-demos-widgetsgallery-l10n-de
219
  - meegotouch-demos-widgetsgallery-l10n-en
220
  - meegotouch-demos-widgetsgallery-l10n-fi
221
  - meegotouch-demos-widgetsgallery-l10n-hu
222
  - meegotouch-demos-widgetsgallery-l10n-ur
223
  - meegotouch-demos-widgetsgallery-l10n-zh-cn
224
225
- meegotouch-demos-animatedlayout-l10n- packages: Messages / translations for
226
  user-visible strings in the "animated layout" demo.
227
228
  - meegotouch-demos-animatedlayout-l10n-eng-en
229
  - meegotouch-demos-animatedlayout-l10n-de
230
  - meegotouch-demos-animatedlayout-l10n-en
231
  - meegotouch-demos-animatedlayout-l10n-ja
232
233
234
RPM spec file cheat sheet
235
=========================
236
237
RPM Variables / Macros
238
----------------------
239
240
Variable definition:
241
242
    %define variable_name value
243
244
Variable reference:
245
246
    %variable_name
247
    %{variable_name}
248
249
250
Dependencies
251
-------------
252
253
    Requires: other_pkg
254
255
This package requires package other_pkg to run (not for building!).
256
257
    BuildRequires: other_pkg
258
259
This package requires package other_pkg for building (not at runtime!).
260
261
    Provides: some_capability
262
263
This package provides a capability named "some_capability" that other packages
264
might require. Note: A package always provides itself, so it's pointless to
265
write
266
267
    Provides: mypackage
268
269
in mypackage.spec.
270
271
A package also automatically provides all shared libs it has in its file list,
272
and a package built with a shared lib automatically requires that shared
273
lib. For example, package libqt4-x11 automatically provides libQtGui.so.4,
274
libQtSvg.so.4 etc.; likewise, it automatically requires libX11.so.6,
275
libXext.so.6 etc.
276
277
278
Package name and subpackages
279
----------------------------
280
281
The name of the main package is specified in
282
283
    Name: foo
284
285
it can have any number of subpackages. A subpackage is defined with
286
287
    %package subpkg-name1
288
or
289
290
    %package -n subpkg-name2
291
292
Without the -n, it will be prefixed with the main package name and a dash:
293
294
    foo-subpkg-name1
295
296
With the -n, there will be no prefix:
297
298
    subpkg-name2
299
300
301
File lists
302
----------
303
304
All files generated during the build process must be listed in the file
305
list(s). Wildcards may be used.
306
307
    %files
308
309
is the file list of the main package.
310
311
    %files -n subpkg-name
312
313
is the file list of subpackage "subpkg-name" (same rules as with %package:
314
Prefixed with the main package name if specified without -n).
315
316
    %defattr(-,root,root)
317
318
specifies the default file permission and ownership (user and group) for each
319
item in the file list.
320
321
    %dir /usr/share/somewhere
322
323
assigns directory ownership to this package.
324
325
    %config /etc/foo
326
327
indicates that /etc/foo should be packaged as a configuration file with special
328
rules what to do if it already exists when the package is installed so changes
329
by the system administrator don't simply get lost during package update.
330
331
    %doc /usr/share/doc/packages/foo/*
332
333
marks files as documentation.
334
335
336
Build section
337
-------------
338
339
    %prep
340
    %setup mysource-47.11.tar.bz2
341
342
This removes an existing build directory for that package, creates a new one
343
and unpacks the tarball there.
344
345
    %build
346
347
This executes the commands following %build inside the build directory.
348
The convention is to only build (compile and link) the project in that section,
349
not install any files there.
350
351
    %install
352
353
This is similar to %build, but the intention is to do "make install" and
354
whatever else is required to install files to the target system in this
355
section. IMPORTANT: Make sure to prefix all target paths with %{buildroot},
356
e.g. use
357
358
    %{buildroot}/usr/lib/whatever
359
360
and not just /usr/lib/whatever.
361
362
363
Misc
364
----
365
366
    Group: System Environment/Libraries
367
368
This specifies the RPM "group tag", a tree of categories where this package
369
belongs to. Different distributions may have different predefined such
370
categories.
371
372
-devel subpackages should go to a category below "Development/".
373
374
375
376
Further reading
377
===============
378
379
http://www.rpm.org/max-rpm-snapshot/
380
http://docs.fedoraproject.org/drafts/rpm-guide-en/