Why do we do this?
The OpenSUSE Build Service (OBS) is a fantastic system to build RPM packages for OpenSUSE and other distributions. I always use it for building the RPMs whenever my favourite game Simutrans releases a new version.
Up until now, I always worked with the on-line web-interface. That works well enough, but it is sometimes difficult to see what is going on when it fails, because you can not access the files during the build.
So, I knew there is an other way, i.e. building locally by using osc
, the command-line command for OBS!
Documentation OBS and RPM
- openSUSE Build Service Tutorial
- openSUSE OSC Documentation
- OBS Simutrans
- openSUSE Packaging Conventions RPM Macros
- RPM documentation
- Maximum RPM
Local installation
It all starts by installing osc
on my openSUSE Leap 15.6 laptop:
zypper in osc build rpm-build quilt
To be able to run osc as normal user, not as root, the documentation at openSUSE:Build Service Tutorial says that you have to run the following command:
sudo /usr/sbin/visudo
Add the following 2 lines and replace the placeholder michiel with your login name:
michiel ALL = NOPASSWD: /usr/bin/build
michiel ALL = NOPASSWD: /usr/bin/osc
My OBS project is to be created in this folder:
cd /home/michiel/development/osc
Online preparation
Online, at https://build.opensuse.org/
, I logged in and branched my package simutrans, which is now located at https://build.opensuse.org/project/show/home:m_vanderwulp:branches:games
.
The project is: home:m_vanderwulp:branches:games
The package is: simutrans
Initial check-out
So, we can check out the contents of this project as follows:
michiel@Delphinus:~/development/osc> osc checkout home:m_vanderwulp:branches:games
You will be asked for your OBS username and password, and the way you want to store the password on your system.
The authentication settings are stored in: ~/.config/osc/oscrc
, after you ran osc
for the first time.
If you typed the wrong password, or the wrong storage method, you have to correct or erase this file.
If everything goes well, the result is:
michiel@Delphinus:~/development/osc> tree
.
├── home:m_vanderwulp
└── home:m_vanderwulp:branches:games
└── simutrans
├── config.default
├── returnNull.patch
├── simutrans.changes
├── simutrans-fhs-home-directory.patch
├── simutrans-makefile.patch
├── simutrans.spec
├── simutrans-square.svg
└── simutrans-src-124-3-1.zip
3 directories, 8 files
michiel@Delphinus:~/development/osc>
michiel@Delphinus:~/development/osc> cd home\:m_vanderwulp\:branches\:games/
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games> cd simutrans/
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games/simutrans>
About the backslashes for the cd
command: you do not need these to execute the cd
, but pressing
the TAB-key to complete the path name only works if you do enter “:” instead of “:”.
Update to latest online version
From here we can always update to the latest version online as follows.
We did not update anything yet, so:
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games/simutrans> osc up
...
Updating simutrans
At revision 7848cf700004b6d25c22b8f7b9791ab7.
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games>
Perform the local build
The openSUSE documentation says to use this:
osc build <platform> <arch> <specfile> [--clean|--noinit]
And they give this example:
osc build openSUSE_Leap_42.1 x86_64 my-package.spec
So, let’s try for platform 15.6 and architecture x86_64:
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games/simutrans> osc build 15.6 x86_64
...
Building simutrans.spec for 15.6/x86_64
Running source_service 'format_spec_file' ...
Running source_service 'source_validator' ...
Running source_service 'format_spec_file' ...
Running source_service 'source_validator' ...
Using local file: simutrans.spec
Getting buildconfig from server and store to /home/michiel/development/osc/home:m_vanderwulp:branches:games/simutrans/.osc/_buildconfig-15.6-x86_64
Getting buildinfo from server and store to /home/michiel/development/osc/home:m_vanderwulp:branches:games/simutrans/.osc/_buildinfo-15.6-x86_64.xml
Updating cache of required packages
The build root needs packages from project 'SUSE:SLE-15-SP3:Update'.
Note that malicious packages can compromise the build result or even your system.
Would you like to ...
0 - quit (default)
1 - always trust packages from 'SUSE:SLE-15-SP3:Update'
2 - trust packages just this time
?
1
etc… many more to trust - and finally:
Delphinus finished "build simutrans.spec" at Thu Apr 10 05:59:10 UTC 2025.
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/SRPMS/simutrans-124.3.1-0.src.rpm
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/simutrans-124.3.1-0.x86_64.rpm
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/simutrans-debugsource-124.3.1-0.x86_64.rpm
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/simutrans-makeobj-124.3.1-0.x86_64.rpm
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/simutrans-debuginfo-124.3.1-0.x86_64.rpm
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/simutrans-makeobj-debuginfo-124.3.1-0.x86_64.rpm
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games/simutrans>
The result is thus in:
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games/simutrans> tree /var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/
/var/tmp/build-root/15.6-x86_64/home/abuild/rpmbuild/RPMS/x86_64/
├── simutrans-124.3.1-0.x86_64.rpm
├── simutrans-debuginfo-124.3.1-0.x86_64.rpm
├── simutrans-debugsource-124.3.1-0.x86_64.rpm
├── simutrans-makeobj-124.3.1-0.x86_64.rpm
└── simutrans-makeobj-debuginfo-124.3.1-0.x86_64.rpm
0 directories, 5 files
michiel@Delphinus:~/development/osc/home:m_vanderwulp:branches:games/simutrans>
Conclusion
I am looking forward to the next release of Simutrans, and hope to use osc
to get the build working.
If the build would fail, I can inspect the files that exist at that moment, and figure out a solution more easily.