README 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. # Spectacle Tutorial
  2. ## Introduction
  3. Spectacle is the toolset for packaging maintenance of MeeGo, including the tool
  4. to generate spec files from metadata file in YAML format, and tools to convert
  5. spec files or spec-builder's ini files to YAML format.
  6. For spectacle managed packages, all generic packaging information will be stored
  7. in the YAML file, and it also allows maintaining customizations in the spec file
  8. directly with special enclosure tags.
  9. Three separated tools will be installed:
  10. * specify: the tool to generate or to update spec file, based on YAML
  11. * ini2spectacle: the tool to convert spec-builder .ini to YAML and new spec file
  12. * spec2spectacle: the tool to convert original spec to YAML and new spec file
  13. ## Installation
  14. ### Instruction
  15. Several methods available for spectacle installation:
  16. * rpm/deb packages for several supported Linux distributions
  17. From [MeeGo Repos](http://repo.meego.com/tools/repo/), repo urls can be found for:
  18. * MeeGo
  19. * Fedora 10,11,12
  20. * openSUSE(s)
  21. * xUbuntu 8.10/9.04/9.10
  22. * Debian 5.0
  23. * Download the latest source package, and install it by ``make install``
  24. (Only running ``setup.py install`` is not enough!)
  25. The latest code in git tree can be accessed at:
  26. [git tree](git://gitorious.org/meego-developer-tools/spectacle.git)
  27. ### Requirements
  28. * python 2.x, above 2.5
  29. * PyYAML, the python module for YAML parsing
  30. * cheetah, one popular templating system for python<br>
  31. In many linux distributions, the package may be named as python-cheetah.
  32. ## Usage
  33. ### specify
  34. Usage: specify [options] [yaml-path]
  35. Options:
  36. --version show program's version number and exit
  37. -h, --help show this help message and exit
  38. -o OUTFILE_PATH, --output=OUTFILE_PATH
  39. Path of output spec file
  40. -s, --skip-scm Skip to check upstream SCM when specified in YAML
  41. -N, --not-download Do not try to download newer source files
  42. -n, --non-interactive
  43. Non interactive running, to use default answers
  44. ### ini2spectacle
  45. Usage: ini2spectacle [options] [ini-path]
  46. Options:
  47. --version show program's version number and exit
  48. -h, --help show this help message and exit
  49. -o OUTFILE_PATH, --output=OUTFILE_PATH
  50. Path of output yaml file
  51. -f, --include-files To store files list in YAML file
  52. ### spec2spectacle
  53. Usage: spec2spectacle [options] [spec-path]
  54. Options:
  55. --version show program's version number and exit
  56. -h, --help show this help message and exit
  57. -o OUTFILE_PATH, --output=OUTFILE_PATH
  58. Path of output yaml file
  59. -r, --replace-macros To replace self-defined macros in spec file
  60. --no-builder-parsing Do NOT try to parse build/install scripts
  61. -f, --include-files To store files list in YAML file
  62. ## Syntax of spectacle YAML
  63. The syntax of YAML can be refered here: <http://www.yaml.org/spec/>
  64. Two example spectacle YAML files are placed to examples/ directory in source
  65. code:
  66. * xfce4-session.yaml, a real world sample with most of the elements
  67. * general.yaml, a fake spectacle contains all the available elements,
  68. with comments
  69. All available directives for spectacle are listed as the following:
  70. * Name: **string**
  71. * Summary: **string**
  72. * Version: **string**, version string
  73. * Release: **string**
  74. * Epoch: **string**, *optional*
  75. * Group: **string**
  76. * License: **string**
  77. * URL: **string**, *optional*
  78. * BuildArch: **string**, *optional*
  79. * ExclusiveArch: **string**, *optional*
  80. * Prefix: **string**, *optional*
  81. * LocaleName: **string**, *optional*
  82. * LocaleOptions: **string**, *optional*
  83. * Description: **text**, *optional*
  84. * Sources: **list** of **string**
  85. * SourcePrefix: **string**, *optional*, specify the prefix path in source package
  86. * ExtraSources: **list** of **string**, *optional*
  87. * SetupOptions: **string**, *optional*, the options string for %setup
  88. * Patches: **list** of **string**, all patches need to be in 'p1' level
  89. * Requires: **list** of **string**
  90. * RequiresPre: **list** of **string**
  91. * RequiresPreUn: **list** of **string**
  92. * RequiresPost: **list** of **string**
  93. * RequiresPostUn: **list** of **string**
  94. * PkgBR: **list** of **string**, packages required in building, or BuildRequires
  95. * PkgConfigBR: **list** of **string**, pkg-config requires in building
  96. * Provides: **list** of **string**
  97. * Conflicts: **list** of **string**
  98. * Obsoletes: **list** of **string**
  99. * BuildConflicts: **list** of **string**
  100. * Configure: **string**, *optional*, valid values: **autogen**, **configure**,
  101. **reconfigure**, **none**<br>
  102. **If not specified, the default value "configure" will be used**
  103. * ConfigOptions: **list**, *optional*, extra options for ``Configure``
  104. * Builder: **string**, *optional*, valid values: **make**, **single-make**,
  105. **python**, **perl**, **qmake**, **none**<br>
  106. **If not specified, the deault value "make" will be used. If do not want a
  107. automatic builder, please use "none".**
  108. * QMakeOptions: **list**, *optional*, extra options for **qmake** ``Builder``
  109. * Files: **list** of **string**, *optional*, content of ``%files`` for small packages
  110. * FilesInput: **string**, *optional*, extra input source for %files
  111. * NoFiles: **boolean**, *optional*, if to be set as True, means no %files section for this package and it cause no rpm generated
  112. * RunFdupes: **string**, path under %buildroot to run ``%fdupes`` macro in %install
  113. * RpmLintIgnore: **list**, *optional*, list of skip items for ``rpmlint``
  114. * Check: **boolean**, whether need ``%check`` section in spec
  115. * SupportOtherDistros: **boolean**, whether need to check for other distros (besides MeeGo)
  116. * UseAsNeeded: **boolean**, whether export LD\_AS\_NEEDED=1 environ variable before building
  117. * NoAutoReq: **boolean**, whether add 'AutoReq: 0' to spec
  118. * NoAutoProv: **boolean**, whether add 'AutoProv: 0' to spec
  119. * NoSetup: **boolean**, whether to skip using ``%setup`` in ``%prep``
  120. * NoAutoLocale: **boolean**, whether to use ``%find_lang`` to search locale data when found 'intltool' in PkgBR
  121. * NoDesktop: **boolean**, whether to install the desktop files in package
  122. * UpdateDesktopDB: **boolean**, whether to run 'update-desktop-database' to flush cache when package (un)installation
  123. * AutoDepend: **boolean**, for subpackages only, whether to add Require to main package automatically
  124. * AsWholeName: **boolean**, for subpackages only, whether to use **Name** as the whole package name
  125. * AutoSubPackages: **list** of **string**, mainly for '-devel'
  126. * SubPackages: **list** of **dict**, the **dict** item is the lower level
  127. directives for sub packages:
  128. * Name
  129. * Summary
  130. * Description, *optional*
  131. * Group, *optional*
  132. * License, *optional*
  133. * Requires, *optional*
  134. * etc.
  135. **CAUTION**: The following cases of value string have special meaning in YAML syntax:
  136. * string with leading **``%``** charactor
  137. * string with leading **``*``** charactor
  138. * string contains **``:``** charactor and one or more spaces/tabs after **``:``**
  139. * string end with **``:``** charactor
  140. **Then these string values need to be quoted by ``'``(single-quote) or ``"``
  141. (double-quote), and the choice of quote char should not conflict with the value
  142. string self.**
  143. ## Namespace support for multi-architecture in several keywords
  144. For the following spectacle YAML keywords:
  145. * Requires
  146. * PkgBR
  147. * PkgConfigBR
  148. * Patches
  149. * ConfigOptions
  150. * QMakeOptions
  151. If one of the items need to be architecture specified, we can add arch prefix to
  152. it. The supported prefix and the corresponding architectures as the followings:
  153. * ``ix86:`` - x86 platform
  154. * ``arm:`` - arm platform
  155. Here's some samples:
  156. Requires:
  157. - arm:pkg-need-in-arm-image
  158. - ix86:pkg-need-in-x86-image
  159. - normal-pkg
  160. ConfigOptions:
  161. - arm:--arm-specific-opt
  162. - ix86:--ix86-specific-opt
  163. - --common-opt
  164. ## Customizations in spec
  165. Generated spec files by specify will have many placeholders for customizations,
  166. such as:
  167. # >> build pre
  168. # << build pre
  169. You can add any custom code between the markers, next time when you run
  170. ``specify``, the text between the markers will be kept as is, all other sections
  171. relying on the meta data from the YAML file will be changed depending on the
  172. values in the YAML file.
  173. The following placeholders in spec can be customized:
  174. * Private Macros, used in this package's spec
  175. With placeholder:
  176. # >> macros
  177. # << macros
  178. * Extra setup scripts in the last of ``%prep``
  179. With placeholder:
  180. # >> setup
  181. # << setup
  182. * Pre-Build, scripts before package building
  183. With placeholder:
  184. # >> build pre
  185. # << build pre
  186. * Post-Build, scripts after package building
  187. With placeholder:
  188. # >> build post
  189. # << build post
  190. * Pre-Install, scripts before package installation
  191. With placeholder:
  192. # >> install pre
  193. # << install pre
  194. * Post-Install, scripts after package installation
  195. With placeholder:
  196. # >> install post
  197. # << install post
  198. * Files, files list in packaged rpm
  199. With placeholder:
  200. # >> files [[-p] sub-package]
  201. # << files [[-p] sub-package]
  202. **NOTE**: "sub-packge" stands for the name of sub-package, and it is optional.
  203. If no sub-package name specified, it means the files of **main** package.
  204. **NOTE**: If the file list is simple enough, you can use YAML *Files* keyword
  205. instead to record it.
  206. * Scripts for %check section
  207. With placeholder:
  208. # >> check
  209. # << check
  210. **NOTE**: Only if YAML boolean *Check* is specifed as ``yes``, %check with
  211. placeholder lines will be generated in .spec.
  212. * Scriptlets for %pre section
  213. With placeholder:
  214. # >> pre
  215. # << pre
  216. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  217. you need customized %pre scripts, it need be added manually, and only once.
  218. * Scriptlets for %preun section
  219. With placeholder:
  220. # >> preun
  221. # << preun
  222. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  223. you need customized %preun scripts, it need be added manually, and only once.
  224. * Scriptlets for %post section
  225. With placeholder:
  226. # >> post
  227. # << post
  228. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  229. you need customized %post scripts, it need be added manually, and only once.
  230. * Scriptlets for %postun section
  231. With placeholder:
  232. # >> postun
  233. # << postun
  234. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  235. you need customized %postun scripts, it need be added manually, and only once.
  236. ## Internal Implementation
  237. Spectacle uses cheetah templates to generate the spec file, based the metadata
  238. from YAML file. But the end users need not tackle it.
  239. ## Tips
  240. * If to upgrade the pkg to a newer version, you can just edit the
  241. version string in spectacle YAML file, and when you run ``specify``, it
  242. will download the needed files for you automatically.
  243. * For packages with locale data, *LocaleName* is needed. If package
  244. maintainers cannot confirm whether there are locale files, they can just
  245. do not use *LocaleName* at first, and whenever "unpackaged files" rpm
  246. packaging errors encountered, it means *LocaleName* should be added. And
  247. please do not use it for packages without locale data to keep them clean,
  248. though it will not block the building and packaging.
  249. * When using spec2spectacle/ini2spectacle to generate spectacle, the following
  250. problems should be checked:
  251. * Remove duplicate Requires(include pre/post/preun/postun) which were
  252. added automatically based on the analysis of file list.
  253. * Review and clean up the reserved scripts in "build|install pre|post"
  254. sections in new generated spec file.
  255. * User can use "series.conf" file to specify multiple patches under package directory.
  256. The "series.conf" can be used by ``quilt`` and the content can be updated to spec
  257. automatically when running ``specify``.