README 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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. * NoIconCache: **boolean**, whether to run 'gtk-update-icon-cache' if icon files found in package
  124. * AutoDepend: **boolean**, for subpackages only, whether to add Require to main package automatically
  125. * AsWholeName: **boolean**, for subpackages only, whether to use **Name** as the whole package name
  126. * AutoSubPackages: **list** of **string**, mainly for '-devel'
  127. * SubPackages: **list** of **dict**, the **dict** item is the lower level
  128. directives for sub packages:
  129. * Name
  130. * Summary
  131. * Description, *optional*
  132. * Group, *optional*
  133. * License, *optional*
  134. * Requires, *optional*
  135. * etc.
  136. **CAUTION**: The following cases of value string have special meaning in YAML syntax:
  137. * string with leading **``%``** charactor
  138. * string with leading **``*``** charactor
  139. * string contains **``:``** charactor and one or more spaces/tabs after **``:``**
  140. * string end with **``:``** charactor
  141. **Then these string values need to be quoted by ``'``(single-quote) or ``"``
  142. (double-quote), and the choice of quote char should not conflict with the value
  143. string self.**
  144. ## Mandatory and valid keywords for all packages
  145. ### Mandatory keywords
  146. The following keywords are mandatory for main package:
  147. * Name
  148. * Summary
  149. * Description
  150. * Version
  151. * Group
  152. * License
  153. The following keywords are mandatory for sub-package:
  154. * Name
  155. * Summary
  156. * Description
  157. * Group
  158. ### Valid keywords for sub-packages
  159. For sub-packages, only a subset of keywords can be specified:
  160. * Name
  161. * Summary
  162. * Description
  163. * Group
  164. * License
  165. * Version
  166. * Release
  167. * Epoch
  168. * URL
  169. * BuildArch
  170. * Files
  171. * Prefix
  172. * Requires
  173. * RequiresPre
  174. * RequiresPreUn
  175. * RequiresPost
  176. * RequiresPostUn
  177. * Provides
  178. * Conflicts
  179. * Obsoletes
  180. * NoAutoReq
  181. * NoAutoProv
  182. * NoAutoReqProv
  183. * NoIconCache
  184. * FilesInput
  185. ### Keywords only for sub-packages
  186. The following keywords are only valid for sub-packages:
  187. * AsWholeName
  188. * AutoDepend
  189. ## Namespace support for multi-architecture in several keywords
  190. For the following spectacle YAML keywords:
  191. * Requires
  192. * PkgBR
  193. * PkgConfigBR
  194. * Patches
  195. * ConfigOptions
  196. * QMakeOptions
  197. If one of the items need to be architecture specified, we can add arch prefix to
  198. it. The supported prefix and the corresponding architectures as the followings:
  199. * ``ix86:`` - x86 platform
  200. * ``arm:`` - generic arm platform
  201. * ``armv5:`` - armv5 platform, will expand to "armv5el armv5tel armv5tejl"
  202. * ``armv7:`` - armv7 platform, will expand to "armv7el armv7tel armv7l armv7hl armv7nhl"
  203. Here's some samples:
  204. Requires:
  205. - arm:pkg-need-in-arm-image
  206. - ix86:pkg-need-in-x86-image
  207. - normal-pkg
  208. ConfigOptions:
  209. - arm:--arm-specific-opt
  210. - ix86:--ix86-specific-opt
  211. - --common-opt
  212. ## Customizations in spec
  213. Generated spec files by specify will have many placeholders for customizations,
  214. such as:
  215. # >> build pre
  216. # << build pre
  217. You can add any custom code between the markers, next time when you run
  218. ``specify``, the text between the markers will be kept as is, all other sections
  219. relying on the meta data from the YAML file will be changed depending on the
  220. values in the YAML file.
  221. The following placeholders in spec can be customized:
  222. * Private Macros, used in this package's spec
  223. With placeholder:
  224. # >> macros
  225. # << macros
  226. * Extra setup scripts in the last of ``%prep``
  227. With placeholder:
  228. # >> setup
  229. # << setup
  230. * Pre-Build, scripts before package building
  231. With placeholder:
  232. # >> build pre
  233. # << build pre
  234. * Post-Build, scripts after package building
  235. With placeholder:
  236. # >> build post
  237. # << build post
  238. * Pre-Install, scripts before package installation
  239. With placeholder:
  240. # >> install pre
  241. # << install pre
  242. * Post-Install, scripts after package installation
  243. With placeholder:
  244. # >> install post
  245. # << install post
  246. * Files, files list in packaged rpm
  247. With placeholder:
  248. # >> files [[-p] sub-package]
  249. # << files [[-p] sub-package]
  250. **NOTE**: "sub-packge" stands for the name of sub-package, and it is optional.
  251. If no sub-package name specified, it means the files of **main** package.
  252. **NOTE**: If the file list is simple enough, you can use YAML *Files* keyword
  253. instead to record it.
  254. * Scripts for %check section
  255. With placeholder:
  256. # >> check
  257. # << check
  258. **NOTE**: Only if YAML boolean *Check* is specifed as ``yes``, %check with
  259. placeholder lines will be generated in .spec.
  260. * Scriptlets for %pre section
  261. With placeholder:
  262. # >> pre
  263. # << pre
  264. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  265. you need customized %pre scripts, it need be added manually, and only once.
  266. * Scriptlets for %preun section
  267. With placeholder:
  268. # >> preun
  269. # << preun
  270. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  271. you need customized %preun scripts, it need be added manually, and only once.
  272. * Scriptlets for %post section
  273. With placeholder:
  274. # >> post
  275. # << post
  276. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  277. you need customized %post scripts, it need be added manually, and only once.
  278. * Scriptlets for %postun section
  279. With placeholder:
  280. # >> postun
  281. # << postun
  282. **NOTE**: The placeholder lines will NOT generated in spec by default. If
  283. you need customized %postun scripts, it need be added manually, and only once.
  284. ## Internal Implementation
  285. Spectacle uses cheetah templates to generate the spec file, based the metadata
  286. from YAML file. But the end users need not tackle it.
  287. ## Tips
  288. * If to upgrade the pkg to a newer version, you can just edit the
  289. version string in spectacle YAML file, and when you run ``specify``, it
  290. will download the needed files for you automatically.
  291. * For packages with locale data, *LocaleName* is needed. If package
  292. maintainers cannot confirm whether there are locale files, they can just
  293. do not use *LocaleName* at first, and whenever "unpackaged files" rpm
  294. packaging errors encountered, it means *LocaleName* should be added. And
  295. please do not use it for packages without locale data to keep them clean,
  296. though it will not block the building and packaging.
  297. * When using spec2spectacle/ini2spectacle to generate spectacle, the following
  298. problems should be checked:
  299. * Remove duplicate Requires(include pre/post/preun/postun) which were
  300. added automatically based on the analysis of file list.
  301. * Review and clean up the reserved scripts in "build|install pre|post"
  302. sections in new generated spec file.
  303. * User can use "series.conf" file to specify multiple patches under package directory.
  304. The "series.conf" can be used by ``quilt`` and the content can be updated to spec
  305. automatically when running ``specify``.