Fvennetier (Talk | contribs) (→Create an archive from your source code repository) |
(→set_version - Update package version in .spec and .dsc files) |
||
| (8 intermediate revisions not shown) | |||
| Line 1: | Line 1: | ||
| - | + | OBS provides '''source services''' which can download/compress/extract/verify files before actually building a package. There is only small documentation [http://doc.opensuse.org/products/draft/OBS/obs-reference-guide_draft/cha.obs.source_service.html here]. You can find two interesting blog posts [http://informatiq.org/content/obs-source-service-git-master-build here] and [http://saigkill.homelinux.net/entry/2011/07/15/how-to-use-three-open-build-service-source-services-to-simplify-the-packaging there]. | |
| - | OBS provides '''source services''' which can download/compress/extract/verify files before actually building a package. There is only small documentation [http://doc.opensuse.org/products/draft/OBS/obs-reference-guide_draft/cha.obs.source_service.html here]. | + | |
| - | + | To use source services in your project, simply create a file with name '''<tt>_service</tt>''', and insert service definitions in it surrounded by a global '''<code><services>...</services></code>''' tag. | |
| - | == Create an archive from your source code repository == | + | Notice that all sources services are not installed on all OBS servers (''pub.meego.com'' OBS seems to have only 2 while ''opensuse.org'' OBS has 14 services). |
| + | |||
| + | = Available services = | ||
| + | == ''tar_scm'' - Create an archive from your source code repository == | ||
A service called '''tar_scm''' is available to create a ''.tar'' archive from Subversion, Git, Mercurial and Bazaar source code management systems. | A service called '''tar_scm''' is available to create a ''.tar'' archive from Subversion, Git, Mercurial and Bazaar source code management systems. | ||
Here is a configuration example: | Here is a configuration example: | ||
| Line 26: | Line 28: | ||
* '''revision''' (''optional''): the revision number (Subversion, Mercurial, Bazaar), the commit hash, tag or branch (Git) to checkout. | * '''revision''' (''optional''): the revision number (Subversion, Mercurial, Bazaar), the commit hash, tag or branch (Git) to checkout. | ||
| - | == Extract files from an archive == | + | == ''extract_file'' - Extract files from an archive == |
After having created an archive with the '''tar_scm''' service, you may want to extract some files, for example the spec file of your package. The '''extract_file''' service is what you need. | After having created an archive with the '''tar_scm''' service, you may want to extract some files, for example the spec file of your package. The '''extract_file''' service is what you need. | ||
Here is an example: | Here is an example: | ||
| Line 35: | Line 37: | ||
</service> | </service> | ||
</code> | </code> | ||
| - | Tag | + | Tag meaning: |
* '''archive''' (''required''): name of the archive to extract files from. Bash regular expressions authorized. | * '''archive''' (''required''): name of the archive to extract files from. Bash regular expressions authorized. | ||
* '''files''' (''required''): name(s) of file(s) to be extracted. | * '''files''' (''required''): name(s) of file(s) to be extracted. | ||
* '''outfilename''' (''optional''): name the extracted file will be renamed to. To be used only if you extract a single file. | * '''outfilename''' (''optional''): name the extracted file will be renamed to. To be used only if you extract a single file. | ||
| - | == Change archive compression == | + | Notice that there is a top directory with a name that you don't know, so file names should start with "*/" |
| + | |||
| + | == ''recompress'' - Change archive compression == | ||
The '''recompress''' service allows you to compress or recompress an archive. Two reasons to use it: save space, and make an archive compatible with your spec file (which probably expects ''.tar.gz'' or ''.tar.bz2''). Here is an example: | The '''recompress''' service allows you to compress or recompress an archive. Two reasons to use it: save space, and make an archive compatible with your spec file (which probably expects ''.tar.gz'' or ''.tar.bz2''). Here is an example: | ||
<code> | <code> | ||
| Line 52: | Line 56: | ||
* '''file''' (''required''): the name of the file to be recompressed. Bash regular expressions authorized. | * '''file''' (''required''): the name of the file to be recompressed. Bash regular expressions authorized. | ||
| - | == Update package version in ''.spec'' and ''.dsc'' files == | + | == ''set_version'' - Update package version in ''.spec'' and ''.dsc'' files == |
You have just configured the '''tar_scm''' service, but the archive name is different from the one in your spec file, because the version part of the name has been incremented. | You have just configured the '''tar_scm''' service, but the archive name is different from the one in your spec file, because the version part of the name has been incremented. | ||
The '''set_version''' service allows you to update your ''.spec'' and ''.dsc'' files with the new version of your archive. | The '''set_version''' service allows you to update your ''.spec'' and ''.dsc'' files with the new version of your archive. | ||
| Line 59: | Line 63: | ||
<service name="set_version"/> | <service name="set_version"/> | ||
</code> | </code> | ||
| - | The version will be automatically guessed from ''*.tar.*'', ''*.tgz'', ''*.tbz2'' or ''*.zip'' files. | + | The version will be automatically guessed from ''*.tar.*'', ''*.tgz'', ''*.tbz2'' or ''*.zip'' files. Note, however that the associated script is picky on what version fields it accepts. In particular, the version string must begin with a numeric value as can be seen in the [https://build.opensuse.org/package/view_file?file=set_version&package=obs-service-set_version&project=openSUSE%3ATools&rev=c5cb320228dfabee71e6a4df48798830 script source itself]. Failure to comply with this scheme will lead to an 'ERROR: no version is given and can't get detected automatically' error. |
| + | |||
| + | Provided your spec 'Source' tag contains the %{version} string, it will pick up the updated string as well. Also note that although the OBS server web UI presents the generated tarball with a leading prefix corresponding to the source services applied, the actual archive on which the spec works has its name unchanged. | ||
However there are optional parameters (syntax <code>''<param name="'''parameter_name'''">'''value'''</param>''</code>): | However there are optional parameters (syntax <code>''<param name="'''parameter_name'''">'''value'''</param>''</code>): | ||
| Line 65: | Line 71: | ||
* '''basename''': the prefix of files to use for version auto-detection. | * '''basename''': the prefix of files to use for version auto-detection. | ||
* '''file''': the name of the file to update. If not specified, all ''*.spec'' and ''*.dsc'' files will be updated. | * '''file''': the name of the file to update. If not specified, all ''*.spec'' and ''*.dsc'' files will be updated. | ||
| + | |||
| + | == many others == | ||
| + | ''To be continued...'' | ||
| + | |||
| + | = Complete example = | ||
| + | <code> | ||
| + | <services> | ||
| + | <!-- Make an archive from our git repository --> | ||
| + | <service name="tar_scm"> | ||
| + | <param name="scm">git</param> | ||
| + | <param name="subdir">src</param> | ||
| + | <param name="url">git://gitorious.org/meego-developer-tools/obs-light.git</param> | ||
| + | <param name="versionprefix">0.4.git</param> | ||
| + | <param name="filename">obslight</param> | ||
| + | </service> | ||
| + | <!-- Extract build control files from the archive --> | ||
| + | <service name="extract_file"> | ||
| + | <param name="archive">*.tar</param> | ||
| + | <param name="files">*/deb/* */rpm/obslight.changes */rpm/obslight.spec */rpm/obslight.yaml</param> | ||
| + | </service> | ||
| + | <!-- Compress the archive to save space --> | ||
| + | <service name="recompress"> | ||
| + | <param name="file">*git*.tar</param> | ||
| + | <param name="compression">gz</param> | ||
| + | </service> | ||
| + | <!-- Update spec and dsc files with generated version string --> | ||
| + | <service name="set_version"/> | ||
| + | </services> | ||
| + | </code> | ||
OBS provides source services which can download/compress/extract/verify files before actually building a package. There is only small documentation here. You can find two interesting blog posts here and there.
To use source services in your project, simply create a file with name _service, and insert service definitions in it surrounded by a global <services>...</services> tag.
Notice that all sources services are not installed on all OBS servers (pub.meego.com OBS seems to have only 2 while opensuse.org OBS has 14 services).
Contents |
A service called tar_scm is available to create a .tar archive from Subversion, Git, Mercurial and Bazaar source code management systems.
Here is a configuration example:
<service name="tar_scm"> <param name="scm">git</param> <param name="url">git://gitorious.org/meego-developer-tools/obs-light.git</param> <param name="subdir">src</param> <param name="filename">obslight</param> <param name="versionprefix">0.4.git</param> </service>
Tag significations:
After having created an archive with the tar_scm service, you may want to extract some files, for example the spec file of your package. The extract_file service is what you need.
Here is an example:
<service name="extract_file"> <param name="archive">*.tar</param> <param name="files">*/deb/* */rpm/obslight.changes */rpm/obslight.spec */rpm/obslight.yaml</param> </service>
Tag meaning:
Notice that there is a top directory with a name that you don't know, so file names should start with "*/"
The recompress service allows you to compress or recompress an archive. Two reasons to use it: save space, and make an archive compatible with your spec file (which probably expects .tar.gz or .tar.bz2). Here is an example:
<service name="recompress"> <param name="compression">gz</param> <param name="file">*git*.tar</param> </service>
Tag significations:
You have just configured the tar_scm service, but the archive name is different from the one in your spec file, because the version part of the name has been incremented.
The set_version service allows you to update your .spec and .dsc files with the new version of your archive.
Here is a simple example:
<service name="set_version"/>
The version will be automatically guessed from *.tar.*, *.tgz, *.tbz2 or *.zip files. Note, however that the associated script is picky on what version fields it accepts. In particular, the version string must begin with a numeric value as can be seen in the script source itself. Failure to comply with this scheme will lead to an 'ERROR: no version is given and can't get detected automatically' error.
Provided your spec 'Source' tag contains the %{version} string, it will pick up the updated string as well. Also note that although the OBS server web UI presents the generated tarball with a leading prefix corresponding to the source services applied, the actual archive on which the spec works has its name unchanged.
However there are optional parameters (syntax <param name="parameter_name">value</param>):
To be continued...
<services>
<service name="tar_scm">
<param name="scm">git</param>
<param name="subdir">src</param>
<param name="url">git://gitorious.org/meego-developer-tools/obs-light.git</param>
<param name="versionprefix">0.4.git</param>
<param name="filename">obslight</param>
</service>
<service name="extract_file">
<param name="archive">*.tar</param>
<param name="files">*/deb/* */rpm/obslight.changes */rpm/obslight.spec */rpm/obslight.yaml</param>
</service>
<service name="recompress">
<param name="file">*git*.tar</param>
<param name="compression">gz</param>
</service>
<service name="set_version"/>
</services>