keepcalculator

06 Numbers and Powers

Open Build Service: What It Is & How to Use It

Card No. 06·41916 · Updated · Standard formula, shown below

The Open Build Service (OBS) is a free, open-source platform for building and distributing software packages for multiple operating systems, architectures, and package formats from a single source. You upload source code and a build recipe, and OBS compiles it in clean, isolated environments, producing ready-to-install packages for distributions like Fedora, Debian, Ubuntu, SUSE, Arch, and others. This article explains how OBS works, its core components, and how to get started using it.

Background: Why OBS Was Created

Before OBS, developers who wanted to distribute software to multiple Linux distributions had to maintain separate build machines for each distro, each with its own toolchain, library versions, and packaging rules. Releasing a new version meant manually rebuilding and testing on every target, a time-consuming and error-prone process.

OBS emerged from the openSUSE project around 2006 to solve this problem. It provides a centralized service where a single source package can be automatically rebuilt for many distributions and architectures. It also introduced the concept of project repositories—collections of packages that are built and published together, ensuring dependency consistency. Today, OBS is used by thousands of projects, including openSUSE itself, and it powers the build infrastructure for many Linux distributions and independent software vendors.

How OBS Works: The Core Workflow

At its heart, OBS follows a straightforward pipeline: source → build → publish. Here’s how each stage works:

  1. Source package: You create a directory containing your source code and a .spec file (for RPM-based distros) or debian/ files (for DEB-based distros). This is your source package.
  2. Upload to OBS: Using the osc command-line tool or the web interface, you push your source package to a project on an OBS server.
  3. Build: OBS schedules builds on worker machines. Each build runs in an isolated chroot/environment (using tools like build and mock) with only the declared build dependencies installed. This ensures reproducibility—the build doesn’t accidentally depend on something installed on your personal machine.
  4. Publish: Once built, the resulting binary packages are moved to a download repository, where users can install them with their package manager (e.g., zypper, dnf, apt).

OBS also handles dependency resolution: if your package requires a library that is itself built in OBS, it will build that library first and use it as a build dependency. This allows you to build complex stacks with many interdependent packages.

Key Features and Components

OBS is more than just a build tool. It includes several components that make it a complete distribution management system:

  • Project structure: OBS organizes packages into projects (e.g., home:username for personal projects, devel:languages:python for language-specific efforts). Projects can inherit from other projects via project links, enabling reuse of build configurations.
  • Repositories: Each project can have multiple repositories, each targeting a specific distribution (e.g., openSUSE Tumbleweed, Ubuntu 22.04) and architecture (x86_64, aarch64).
  • Build recipes: OBS uses standard packaging files—.spec for RPM, debian/control and debian/rules for DEB, and also supports Arch PKGBUILD and other formats. You can maintain multiple recipes in one source package.
  • Web interface and API: The web UI lets you browse projects, view build logs, and trigger rebuilds. The API (and the osc client) allows full automation.
  • Build result status: Each package shows a status (succeeded, failed, unresolvable, etc.) for every repository/architecture. You can click to see the full build log.

How to Choose: OBS vs. Alternatives

OBS is not the only multi-distro build service. Here’s how it compares to common alternatives:

  • GitHub Actions / GitLab CI: These are general CI/CD platforms. You can use them to build packages, but you must set up the build environments yourself. OBS provides pre-built environments for many distros and handles repository publishing natively.
  • Copr (Fedora): Copr is a build service specifically for Fedora and EPEL. It’s simpler but limited to RPM-based distributions. OBS supports both RPM and DEB, plus more.
  • Launchpad PPA: Ubuntu’s PPA system is for Ubuntu only. OBS can build for Ubuntu as well as many others.
  • Travis CI / AppVeyor: These can build packages but require more manual configuration and don’t provide the same level of distribution-specific integration.

Choose OBS if you need to target multiple distributions with minimal duplicated effort, or if you want a self-hosted solution (OBS is open source and can be installed on your own servers). If you only need Fedora or Ubuntu, a simpler service might suffice.

Getting Started: A Simple Example

To illustrate, let’s walk through building a trivial “hello world� RPM package for openSUSE Tumbleweed using OBS. You’ll need an account on build.opensuse.org (the public OBS instance) and the osc tool installed.

  1. Create a local directory and a simple spec file:
    hello.spec:
    Name:           hello
    Version:        1.0
    Release:        0
    Summary:        A test package
    License:        MIT
    Source:         hello-1.0.tar.gz
    
    %description
    A simple test package.
    
    %prep
    %setup -q
    
    %build
    make
    
    %install
    make install DESTDIR=%{buildroot}
    
  2. Create a tarball with a Makefile and a hello.c file.
  3. Run osc checkout home:yourusername to get your home project locally.
  4. Copy the source files into the project directory and run osc add to mark them.
  5. Run osc commit to upload. OBS will automatically start a build for the default repositories (usually openSUSE Tumbleweed x86_64).
  6. Watch the build in the web UI. Once it succeeds, you can add more repositories (e.g., Fedora, Ubuntu) and OBS will rebuild for them.

This basic flow works for any package. Real-world packages have more complex spec files, but the principle is the same.

Common Problems and How to Solve Them

New users often hit a few predictable issues:

  • Build fails with “unresolvable� dependencies: This means a BuildRequires package isn’t found in the repository. Check the exact name (versions differ across distros) and ensure the dependency is available in the target repo. You may need to add a repository that provides it.
  • Build fails with “file not found� errors: Often a missing %install step or a wrong path in the spec. Check the build log to see what’s missing.
  • Package builds on one distro but not another: Different distros have different library versions and paths. Use conditional spec sections (e.g., %if 0%{?suse_version}) to handle differences.
  • Build succeeds but package won’t install: This usually indicates a missing runtime dependency or a conflict. Test the package locally with rpm -ivh or dpkg -i and check for missing dependencies.

Always read the full build log—OBS provides a link to it. The log shows the exact command that failed and the error message.

Costs and Hosting Options

OBS itself is free and open source. You have two main ways to use it:

  • Public instance (build.opensuse.org): Free for open-source projects. You get a home project and can create additional projects. There are resource limits (e.g., number of concurrent builds) but they are generous for personal use.
  • Self-hosted: You can install OBS on your own hardware or cloud VMs. This gives you full control, but requires maintenance. The OBS website provides installation instructions. For production use, you’ll need at least a few servers (frontend, backend, workers), though a single machine can run everything for small teams.

There is no licensing cost for OBS. The main costs are infrastructure (if self-hosting) and time to learn the system.

Safety and Best Practices

When using OBS, keep these points in mind:

  • Build in isolation: OBS builds in clean environments, so you don’t need to worry about polluting your local machine. But be aware that builds can execute arbitrary code from the spec file—only build packages you trust.
  • Keep your source package clean: Do not include generated files or binaries in your source package; OBS should build them from source. This ensures reproducibility.
  • Use project links carefully: If you link to another project’s package, changes there can affect your build. Review linked projects before relying on them.
  • Back up your OBS project: Use osc to keep a local copy of your source packages. The public instance is reliable, but you should have your own backups.

Frequently Asked Questions

Is OBS only for Linux? OBS primarily builds Linux packages, but it can also build for other Unix-like systems (e.g., FreeBSD) and Windows (via MinGW). The focus is on Linux distributions.

Can I build for my own custom distribution? Yes. You can add a custom repository with your own distribution’s configuration. OBS uses a “distribution� definition that specifies the base packages and layout. This requires some setup but is possible.

How do I get a build for a new architecture? OBS supports many architectures (x86_64, i586, aarch64, ppc64le, s390x, etc.). To enable a new architecture for your project, edit the repository settings in the web UI and add the architecture. The build workers must support it (the public instance does for most common ones).

What is the difference between a project and a repository? A project is a collection of packages and their build configurations. A repository is a specific target (distribution + architecture) within a project. A project can have multiple repositories.

Can I use OBS for private packages? Yes, you can set a project to “access protection� so only authorized users can see or download the packages. However, the public instance still stores the data on its servers; for sensitive code, consider self-hosting.

How do I update a package after a source change? Simply commit the new source to the same OBS project. OBS will automatically rebuild the affected packages. You can also trigger a rebuild manually via the web UI or osc rebuild.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →