---
name: "obs-build"
section: "1"
platform: "linux"
package: "obs-build"
version: "20210120-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/obs-build"
---

# obs-build(1)

build SUSE Linux RPMs in a chroot environment

## NAME

build - build SUSE Linux RPMs in a chroot environment

## SYNOPSIS

**build** \[**--clean**\|**--no-init\]** \[**--repo** *dir\_or\_url*\] \[**--repo**...\] \[**--root** *buildroot*\] \[**recipefile**\]\
 **build** **--help**\
 **build** **--verify**

## DESCRIPTION

**build** is a tool to build binary packages in a safe and reproducible way. The default is to build in a chroot sandbox, but **build** also supports building in a virtual machine for better security.

If a recipe file is specified on the command line, **build** will use this file and all other files in the directory for building the package. If no recipe argument is provided, build will search the current directory for a file.

The **build** tool understands the following recipe file types:

- **spec**

  A specfile used to generate rpms.

- **src.rpm**

  A source rpm, which will be unpacked for the build.

- **kiwi**

  A kiwi config file used to generate a kiwi image.

- **dsc**

  A dsc file used to generate Debian binary packages.

- **PKGBUILD**

  A file used to generate Arch Linux binary packages.

- **build.collax**

  A shell script used to generate a Collax binary package.

## OPTIONS

- **--clean**

  Remove the build system and reinitialize it from scratch.

- **--no-init**

  Skip the build system initialization and start with build immediately.

- **--repo** *dir\_or\_url*

  Either a directory containing binary packages (optionally with repository metadata), or a url pointing to some remote repository. Multiple **--repo** options can be used so create a specific repository layering. Note that packages are searched in the specified repository order, i.e. the first repository containing a package with a specific name wins regardless of the version. As a special form, 'zypp://reponame' can be used to specify a system repository. 'zypp://' selects all enabled system repositories. This is also the default if BUILD\_RPMS is not set and no **--rpms** or **--repo** option is used.

- **--dist** *distribution*

  Set the distribution. If this option is not given, build tries to guess the distribution by looking at the available packages. The specified distribution can either be a string like "11.2" or "sles9", "debian7", or the pathname of the build configuration to use.

- **--root** *buildroot*

  Specifies where the build system is set up. Overrides the BUILD\_ROOT enviroment variable.

- **--help**

  Print a short help text.

- **--norootforbuild**

  Force building with user abuild. Otherwise, **build** searches the recipe file for a "needsrootforbuild" hint to decide what user to use.

- **--list-state**

  list packages that would be used to create a fresh build root. Does not create the build root or perform a build.

- **--rpms** *path1***:***path2***:***path3...*

  Where build can find the packages needed to create the build system. This option overrides the BUILD\_RPMS environment variable. This option is deprecated, use **--repo** instead.

- **--arch** *arch1***:***arch2***:***arch3...*

  What architectures to select from the RPMs. **build** automatically sets this to a sensible value for your host if you do not specify this option so you should almost never need it.

## RPM BUILD SPECIFIC OPTIONS

- **--useusedforbuild**

  Tell build not to do dependency expansion, but to extract the list of packages to install from "# usedforbuild" lines or, if none are found, from all "BuildRequires" lines.  This option is useful if you want to re-build a package from a srcrpm with exactly the same packages used for the srcrpm build.

- **--stage**

  Pass a stage option to rpmbuild. The default is **-ba**.

- **--target**

  Call rpmbuild with a target option. This can be used for cross building.

- **--verify**

  Verify the files in an existing build system.

## VIRTUAL MACHINE SPECIFIC OPTIONS

- **--xen --kvm --uml --qemu --emulator --zvm --lxc**

  Sets a specific vm type.

- **--vm-type** *type*

  As above.

- **--vm-disk** *file*

  Specifies the location of the disk image to use. If this option is not given, *buildroot***.img** is used (e.g. /var/tmp/build-root.img).

- **--vm-disk-size** *size\_in\_mb*

  Specify the size of the disk image to create.

- **--vm-disk-filesystem** *type*

  Sets the filesystem type to use when creating the disk image. The default is to use the ext3 filesystem.

- **--vm-swap** *file*

  Specifies the location of the swap file to use. If this option is not given, *buildroot***.swap** is used (e.g. /var/tmp/build-root.swap).

- **--vm-swap-size** *size\_in\_mb*

  Specify the size of the swap file to create.

- **--vm-memory** *size\_in\_mb*

  Sets the desired memory size of the virtual machine.

- **--vm-kernel** *kernel\_file*

  Set a specific kernel to boot in the virtual machine.

- **--vm-initrd** *initrd\_file*

  Set a specific kernel to boot in the virtual machine.

- **--vm-disk-clean**

  Force the recreation of the disk image.

- **--vm-telnet PORT**

  Is forwarding PORT to a telnet session inside of the VM. Specify also needed extra packages via -x parameter, usually: *--vm-telnet 1234 -x telnet-server -x net-tools*\
      And connect from the host via: *telnet localhost 1234*\
      NOTE: The telnet server gets started after all packages got installed.

## RECIPE FILE OPTIONS

The **build** command interprets some special control comments in the recipe file:

- **# norootforbuild**

  - **# needsrootforbuild**

  **build** uses either user *root* or user *abuild* in the build system to do the build.  For non-SUSE distros as well as since SUSE 10.2, the default build user is *abuild.* For 10.2 and before, the default build user is *root.* These two flags in the spec file allow to deviate from the defaults and force-set the build user to *abuild* and *root* (for *# norootforbuild* and *# needsrootforbuild* respectively.

- **# needsbinariesforbuild**

  provide the binary rpms that have been used to set up the build root in */.build.binaries* within the build root.

## ENVIRONMENT

- **BUILD\_ROOT**

  The directory where build should install the chrooted build system. "/var/tmp/build-root" is used by default. See the **--root** option.

- **BUILD\_RPMS**

  This can be used instead of the **--rpms** option. Deprecated.

- **BUILD\_RPM\_BUILD\_STAGE**

  The rpm build stage (-ba, -bb, ...).  This is just passed through to rpm, check the rpm manpage for a complete list and descriptions. "-ba" is the default. You should probably use the **--stage** option instead.

## SEE ALSO

[**rpm**(8)](/rpm/8.md),[**dpkg**(8)](/dpkg/8.md),[**pacman**(8)](/pacman/8.md),[**kiwi**(8)](/kiwi/8.md)

- **Maximum RPM**:

  *http://www.rpm.org/max-rpm/*

- **cross distribution packaging**:

  *http://en.opensuse.org/openSUSE:Build\_Service\_cross\_distribution\_howto*

- **openSUSE packaging standards and guidelines**:

  *http://en.opensuse.org/Portal:Packaging*
