openSUSE:Build Service Concept SourceService
Examples for this are:
- Download service - downloads a file (e.g. tarball) from given URL and stores it.
- Checkout service - checks out from SVC system (svn, git, ...) and creates a tarball.
- Validate service - validates a file with a given checksum (md5sum, gpg key).
- Code generator - analyses a tarball and creates proper rpm and debian build descriptions (based on cmake, automake/conf, qmake or alike files).
- Run pre_checkin.sh scripts via a service
Tool aspects
- All of the given examples will need tools which are not 100% trustworthy, that means that they should run in a secure environment.
- The tools should allow to run on server and client side.
- The tools may be highly specific, e.g. a code generator which is based on cmake files. This code should not be part of the Build Service itself, but it should be inside a package which can be easily maintained. This allows contributors to fix, extend or add services via usual packaging methods.
- The tools should be maintained in a project, building for all distributions to allow the executions on the developer workstations. However only one instance is needed on the server side.
- As much as possible should be done within the packages to have a thin as possible layer for this within OBS code.
- Tools can share functionality via common packages.
Workflow aspects
A meta file (_service file) as part of the package sources should trigger the services. It might run multiple of them in a given order. A change in this meta file should not direct trigger a build, but wait for the generator result.
The result of the services should become part of the source package and the history. However it should not possible to change these files directly to avoid lost work, when the service is generating a new file.
Server side service instance
The server should have a permanently running service instance. This is basically a usual build instance, but running all the time, except when new service tools get deployed (or build). This instance needs internet connection for its services, but we need to protect against random connections to our internal interfaces.
The same instance should keep running and not restarted/rebuild for each call, but it needs to get updated when new service packages appear.
Needed implementations
Tools
- A set of tools which create files.
- Store all of these tools in a project
Source server
- On source commit, containing a _service file the server needs to trigger an event for updating the sources in package.
Dispatcher
- Validate that a service instance is running, if not start one according to specification.
- Send service event to service instance, if it is free (basically the _service file together with project and package information).
Scheduler
- Needs to block a package, if a service event is waiting
- Do not remove calculated buildinfo for service instance to keep it running. However it needs to get updated if service tool packages are changing and running instance need to get stopped as usual.
Build script and bs_worker
The build script needs a service mode which needs to
- build up a system according to a configured service repo and package list (TBD where to specify this, maybe just BSConfig.pm for now.)
- endless loop to process _service files, for each file
- run XEN/kvm with network enabled
- rename all _service:*:$name files to $name
- process all <service items by calling the specified tool in /opt/obs/lib/service/$name
- XEN/kvm session ends
- copy generate files with prefix to source server (_service:$tool:$filename)
- check if service instance got a kill event and die, otherwise loop back
Possible extensions
This framework might get extended later, to allow to create/remove complete new packages. This would allow us to use it for the productconverter and also for stuff like cpan2OBS generators.
This would also obsolete the oscupstream need.
Examples
Example 1: Input file commit
This is a real life example, stored as _service in the package sources.
<services> <service name="download_url"> <param name="protocol">http</param> <param name="host">download.kde.org</param> <param name="path">pub/kde/stuff/krabber-1.0.tar.gz</param> </service> <service name="verify_file"> <param name="file">_service:download_url:krabber-1.0.tar.gz</param> <param name="verifier">sha256</param> <param name="checksum">7f535a96a834b31ba2201a90c4d365990785dead92be02d4cf846713be938b78</param> </service> <!-- <service name="generate_automake_kde" /> --> </services>
This would download krabber-1.0.tar.gz and stores it as _service:download_url:krabber-1.0.tar.gz, validates it via a given sha256 checksum, and (commented out) generates a spec file using the generate_automake_kde tool.
This _service file is e.g. created by
osc add http://download.kde.org/pub/kde/stuff/krabber-1.0.tar.gz
The required packages (recent osc, obs-service-download_url, build) are available from openSUSE:Tools.
Example 2: GIT integration
Using OBS source services, you can create a package of the latest source code from a Git repository. We suppose that you know how to create/checkout/commit a package to an OBS project.
Requirements
You will need 4 additional packages on your OBS server:
- obs-service-tar_scm: create an archive from a source code repository
- obs-service-extract_file: extract files from an archive
- obs-service-recompress: compress/recompress an archive
- obs-service-set_version: update package version in spec/dsc files
You can check with service are available with the osc client:
osc api /service
Step by step
- Create an empty package, either using the web interface or the commandline
- In that package, create a file named _service with root tag
<services> </services>
- Insert a first service definition to create an archive from git: (FIXME tar_scm is discouraged in favor of obs_scm)
<service name="tar_scm"> <param name="scm">git</param> <param name="url">the URL of your Git repository (something like "git://gitorious.org/your-project.git")</param> <param name="subdir">the subdirectory of your repository you want to create an archive from</param> <param name="filename">the name of the file you want to create, without version</param> <param name="versionprefix">the first part of the version string (e.g. "0.4.git")</param> <param name="revision">optional: the commit hash, tag or branch you want to get</param> </service>
This will create a file called <filename>-<versionprefix>.<commit_timestamp>.tar, with <commit_timestamp> being the number of seconds between Jan 1st 1970 and the commit from which the archive is created.
- Insert a second service definition to extract .spec/.dsc files from the archive. If you prefer manually adding these files in your OBS package, just skip this section.
<service name="extract_file"> <param name="archive">*.tar</param> <param name="files">the files you want to extract from the previously created archive, separated by space (notice that there is a top directory with a name that you don't know, so file names should start with "*/"</param> </service>
- Insert a third service definition to compress the archive (Debian builds expect .tar.gz and it saves space on server)
<service name="recompress"> <param name="file">a pattern matching the archive name (e.g. "*git*.tar")</param> <param name="compression">the format in which you want to compress the archive: "gz", "bz2", "xz", "none"</param> </service>
- Insert a fourth service definition to update package version in spec and dsc files, with the one of the generated archive
<service name="set_version"/>
- Now upload/commit the _service file on OBS
- Each time a new commit is available in your Git repository, trigger a service run, either with the web UI or with osc service run
Complete _service example
FIXME tar_scm is discouraged in favor of obs_scm
<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>
All OBS services available
Note: You can check the parameters for the services with the osc client:
osc api /service
Or you can view the output form https://paste.opensuse.org/45284231
cpanspec
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-cpanspec
- GitHub:
- Description: A wrapper around cpanspec script.
cargo
- Package: https://build.opensuse.org/package/show/devel:languages:rust/obs-service-cargo
- GitHub: https://github.com/openSUSE-Rust/obs-service-cargo
- Description: This service helps vendoring rust dependencies when packaging rust programs.
go_modules
- Package: https://build.opensuse.org/package/show/devel:languages:go/obs-service-go_modules
- GitHub: https://github.com/openSUSE/obs-service-go_modules
- Description: This service helps vendoring go dependencies when packaging go programs.
download_files
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-download_files
- GitHub: https://github.com/openSUSE/obs-service-download_files
- Description: This service is parsing all spec files and downloads all Source files which are specified via a http, https or ftp url.
download_src_package
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-download_src_package
- GitHub:
- Description: It supports downloading src.rpms and extracting.
download_url
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-download_url
- GitHub: https://github.com/openSUSE/obs-service-download_url
- Description: It supports downloading files from given URLs via curl.
extract_file
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-extract_file
- GitHub: https://github.com/openSUSE/obs-service-extract_file
- Description: It supports to extract a file from an archive, for example a spec file from a tar.
format_spec_file
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-format_spec_file
- GitHub: https://github.com/openSUSE/obs-service-format_spec_file
- Description: This source service is formating the spec file to SUSE standard. The rational behind is to make it easier to review spec files from unknown packagers. This should be used in "trylocal" mode, so that osc is adapting the existing spec file instead of creating a new one.
generator_driver_update_disk
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-generator_driver_update_disk
- GitHub:
- Description: Creates kiwiw files to create driver update disks used to deliver updated hardware drivers to install older suse versions on newer hardware.
generator_pom
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-generator_pom
- GitHub:
- Description: Is supports downloading a java source from Maven Central and creates the build description for it.
git_tarballs
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-git_tarballs
- GitHub: https://github.com/openSUSE/obs-service-git_tarballs
- Description: It downloads tarballs from upstream and updates the spec file version and changes file.
github_tarballs
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-github_tarballs
- GitHub: https://github.com/openSUSE/obs-service-github_tarballs
- Description: It downloads tarballs from upstream and updates the spec file version and changes file using information from a github repository.
kiwi_import
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-kiwi_import
- GitHub: https://github.com/openSUSE/obs-service-kiwi_import
- Description: It supports the import of a generic kiwi archive.
node_modules
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-node_modules
- GitHub: https://github.com/openSUSE/obs-service-node_modules
- Description: It supports parsing package-lock.json, then preparing all externally downloaded sources for npm during packaging
part2pkg
- Package:
- GitHub: https://github.com/openSUSE/obs-service-part2pkg
- Description: snapcraft part repackage service for OBS
python_requires
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-python_requires
- GitHub: https://github.com/openSUSE/obs-service-python_requires
- Description: It refreshes Python Requires from the pypi source tarball
product_converter
- Package:
- GitHub: https://github.com/openSUSE/obs-service-product_converter
- Description: New product converter as OBS source service instead of OBS built-in
python_sdist
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-python_sdist
- GitHub: https://github.com/openSUSE/obs-service-python_sdist
- Description: It generates Python source distribution (sdist) tarballs
rearchive
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-rearchive
- GitHub:
- Description: It unpacks non-tar-archives to a temporary directory and generates a compressed tar archive (tar.gz). Supported formats: .zip
recompress
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-recompress
- GitHub: https://github.com/openSUSE/obs-service-recompress
- Description: It supports to compress, uncompress or recompress files from or to
- none : No Compression
- gz : Gzip Compression
- bz2 : Bzip2 Compression
- xz : XZ Compression
- zstd : Zstd Compression
refresh_patches
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-refresh_patches
- GitHub: https://github.com/openSUSE/obs-service-refresh_patches
- Description: It refreshes locals patches by using quilt.
regex_replace
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-regex_replace
- GitHub:
- Description: Very simply script to change the content of a file using regular expressions
renderspec
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-renderspec
- GitHub: https://github.com/openSUSE/obs-service-renderspec
- Description: It supports rendering .spec.j2 templates via renderspec.
set_version
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-set_version
- GitHub: https://github.com/openSUSE/obs-service-set_version
- Description: Very simply script to update the version in .spec or .dsc files according to a given version or to the existing files.
set_version.sle_11
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-set_version.sle_11
- GitHub:
- Description: Very simply script to update the version in .spec or .dsc files according to a given version or to the existing files.
source_validator
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-source_validator
- GitHub: https://github.com/openSUSE/obs-service-source_validator
- Description: This service runs all checks as required by openSUSE:Factory project. This can be used to guarantee that all checks succeed also on the service side. This plugin can be used via project wide defined services.
tar_scm
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-tar_scm
- GitHub: https://github.com/openSUSE/obs-service-tar_scm
- Description: It supports downloading from svn, git, hg and bzr repositories.
verify_file
- Package: https://build.opensuse.org/package/show/openSUSE:Tools/obs-service-verify_file
- GitHub:
- Description: This is a source service for openSUSE Build Service. It allows to verify a file with a given sha256sum