📜 ⬆️ ⬇️

Open Build Service - we create our own repositories

image
Open Build Service is open source software distributed under the GPL license, which makes it much easier to organize your own repositories for popular Linux distributions and build binary packages.

In the article I will give a way to quickly install the server part on openSUSE 12.1, the environment settings for the user and give a list of useful commands for working from the console. Of course, you can use ready-made images of Open Build Server, which can be downloaded from the developer’s website. But, for example, on VirtualBox, installation from these images does not go. In any case, when you yourself go through the installation path, it is always easier to figure out how the system works. So let's get started.

First of all, you need to make sure that you have connected the Oss repository (this is the main openSUSE repository, but for some reason it is not included immediately in new versions). It is needed to install packages such as Apache2, MySQL-server, etc.
#zypper addrepo download.opensuse.org/distribution/12.1/repo/oss/ openSUSE-12.1-Oss 

Add a repository to install, in fact, the very Open Build Server.
 #sudo zypper addrepo zypper addrepo download.opensuse.org/repositories/openSUSE:/Tools:/Unstable/openSUSE_12.1/openSUSE:Tools:Unstable.repo #sudo zypper refresh 

Now you can start the installation.
 #sudo zypper in obs-server obs-api 

The installation will pull a pack of necessary packages, such as apache, mysql-server, rubygems, etc. Total about 90MB.
When the installation is complete, make a couple of changes to the configuration file. To do this, open / etc / sysconfig / obs-server , find and bring them to the following line type:
 OBS_SRC_SERVER=«localhost:5352» OBS_REPO_SERVERS=«localhost:5252» 

We start services:
 rcobsrepserver start rcobssrcserver start rcobsscheduler start rcobsdispatcher start rcobspublisher start 

We proceed to the creation of databases and their content:
 mysql> create database api_production; mysql> create database webui_production; mysql> create user 'obs'@'%' identified by 'obspassword'; mysql> create user 'obs'@'localhost' identified by 'obspassword'; mysql> GRANT all privileges ON api_production.* TO 'obs'@'%', 'obs'@'localhost'; mysql> GRANT all privileges ON webui_production.* TO 'obs'@'%', 'obs'@'localhost'; mysql> FLUSH PRIVILEGES; 

Configure the connection to the mysql API and WebUI. To do this, in any convenient editor open the files /srv/www/obs/api/config/database.yml and
/srv/www/obs/webui/config/database.yml , find and edit the following block:
 production: adapter: mysql2 database: api_production username: obs password: obspassword 

Fill in the database and set the necessary rights to the tmp and log folders
 cd /srv/www/obs/api/ sudo RAILS_ENV=«production» rake db:setup sudo chown -R wwwrun.www log tmp cd /srv/www/obs/webui/ sudo RAILS_ENV=«production» rake db:setup sudo chown -R wwwrun.www log tmp 

Configure Apache. Install the apache2-mod_xforward module. For this we will connect another repository.
 zypper addrepo download.opensuse.org/repositories/openSUSE:/Tools/SLE_11/ Tools-SLE zypper refresh zypper in apache2-mod_xforward 

We connect the necessary modules in / etc / sysconfig / apache2 .
 APACHE_MODULES="… passenger rewrite proxy proxy_http xforward headers" 

Enable SSL support and generate certificates. Open / etc / sysconfig / apache2 again and find the line:
 APACHE_SERVER_FLAGS="-DSSL" 

 mkdir /srv/obs/certs openssl genrsa -out /srv/obs/certs/server.key 1024 openssl req -new -key /srv/obs/certs/server.key -out /srv/obs/certs/server.csr openssl x509 -req -days 365 -in /srv/obs/certs/server.csr -signkey /srv/obs/certs/server.key -out /srv/obs/certs/server.crt cat /srv/obs/certs/server.key /srv/obs/certs/server.crt > /srv/obs/certs/server.pem 

Set use_xforward: true to /srv/www/obs/webui/config/options.yml and /srv/www/obs/api/config/options.yml

Now one very important nuance. Open the file / srv / www / obs / webui / config / environments / production.rb , look for the line CONFIG ['frontend_host'] = "localhost" and instead of localhost we write the name of the server that we specified when generating the certificate.
If you do not do this, then when you try to open the WebUI or API, you will receive the error “hostname does not match the server certificate”.
')
Perform a restart.
 rcapache2 restart rcobsapidelayed restart 

We check the performance.
After restarting, the Apache API should be accessible at servername:444.
WebUI will be available at servername servername .
Username and default password Admin / opensuse.
I will not dwell on using WebUI. The interface is intuitive and easy to use.

Better to pay more attention to using OSC (openSUSE Build Service Commander). This package is available for almost all Linux distributions. With it, we can create projects, packages, download source files.
I use Ubuntu, so for installation I use:
 apt-get install osc 

The next step is to create a configuration file that is required for working with our server. You can create it automatically using any of the osc commands, for example, osc ls. But it is easier to create in the root of your home directory an .oscrc file with the following content:
.oscrc
 [general]
 apiurl = https: // servername: 444
 use_keyring = 0

 [https: // servername: 444]
 user = admin
 pass = opensuse
 keyring = 0


Instead servername write the name of your server. Again, the name must match the one specified during certificate creation, otherwise you will get the error "Certificate Verification Error: Peer certificate commonName does not match host"
We check the connection by executing the osc ls command (list the projects).
Accept the certificate.
 The server certificate failed verification Would you like to 0 — quit (default) 1 — continue anyways 2 — trust the server certificate permanently 9 — review the server certificate Enter choice [0129]: 2 

Let's try to create a new project.
 osc meta prj -e MyProject 

where MyProject is the name of your project.
After that, the xml-file of the new project configuration will open, where you will need at least to specify the Title and Description. Here you can uncomment the lines in which it is indicated under which system packages will be assembled in this project.
Example xml configuration for the project:
project.xml
 <project name = "MyProject">
   <title> MyProject </ title>
   <description> MyTestProject </ description>
   <person role = "maintainer" userid = "Admin" />
   <person role = "bugowner" userid = "Admin" />
   <publish>
     <disable />
   </ publish>
   <build>
     <enable />
   </ build>
   <debuginfo>
     <disable />
   </ debuginfo>
   <repository name = "openSUSE_Factory">
     <path project = "openSUSE: Factory" repository = "standard" />
     <arch> x86_64 </ arch>
     <arch> i586 </ arch>
   </ repository>
   <repository name = "openSUSE_11.2">
     <path project = "openSUSE: 11.2" repository = "standard" />
     <arch> x86_64 </ arch>
     <arch> i586 </ arch>
   </ repository>
   <repository name = "openSUSE_11.1">
     <path project = "openSUSE: 11.1" repository = "standard" />
     <arch> x86_64 </ arch>
     <arch> i586 </ arch>
   </ repository>
   <repository name = "Fedora_12">
     <path project = "Fedora: 12" repository = "standard" />
     <arch> x86_64 </ arch>
     <arch> i586 </ arch>
   </ repository>
   <repository name = "SLE_11">
     <path project = "SUSE: SLE-11" repository = "standard" />
     <arch> x86_64 </ arch>
     <arch> i586 </ arch>
   </ repository>
 </ project>


The package is created in the same way.
 osc meta pkg -e MyProject MyPackage 

where MyProject is the name of your project, MyPackage is your new package.
Now that the project and the package have been created, we need to send the source files from the server from which the binary packages will be built.
First, create a local copy of the project on your work machine.
 osc co MyProject 

After that, you should have a hierarchy of MyProject / MyPackage directories. We place our source files in the MyPackage directory, and then add them to version control using the command:
 osc add MyProject/MyPackage/MyFiles 

and upload to server
 osc ci MyProject/MyPackage -m «Your comment» –skip-validation 

After the sources come to the server, the system automatically begins to build binary packages.
The result of the assembly team look
 osc results MyProject/MyPackage 

Now we’ll get a link to the project’s .repo file. To do this, go to the project directory and execute the command:
 osc repourls 

That's it, now we can connect our repositories to Linux machines and install our packages.

Now, as promised, I will give a brief list of commands for working with projects and packages from the console separately.
 #  . osc ls # . osc meta prj -e ProjectName # . osc meta pkg -e ProjectName PackageName #   . osc rdelete ProjectName/PackageName #   . osc co ProjectName #     . osc add ProjectName/PackageName/YourFiles #  . osc rremove ProjectName PackageName SourceName osc update ProjectName #   . osc ci ProjectName -m «Your comment» --skip-validation #   . osc ci Project Name/Package Name -m «Your comment» #   osc results Project Name/Package Name #   (   ). osc buildlog Platform Arch (osc buildlog xUbuntu_12.04 i586) # URLs .repo  (   ) osc repourls 

Source: https://habr.com/ru/post/160609/


All Articles