Setting up RPM Building for SME Server on rocky 8

From SME Server
Jump to navigationJump to search

Creating the build system

Build yourself a Rock8 system, probably minimal server, but any level will do.

https://rockylinux.org/download/

Then login to the new system as you username, which is administrator and is able to sudo.


sudo dnf install wget
sudo dnf install @development
wget https://src.koozali.org/staging/sme-release/raw/branch/master/RPM-GPG-KEY-sme11
sudo rpm --import RPM-GPG-KEY-sme11
sudo dnf install epel-release
sudo dnf install -y https://rpms.remirepo.net/enterprise/remi-release-8.rpm
dnf install -y http://repo.openfusion.net/centos8-x86_64/openfusion-release-0.8-2.of.el8.noarch.rpm
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-remi.el8
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-openfusion 
sudo dnf install mock git koji git-lfs lua glances make rpm-build rpm-sign xz policycoreutils-python-utils setools-console rsyslog setroubleshoot-server
sudo /usr/sbin/usermod -G mock $USER

get the temp yum/dnf settings to install sme specifics

echo "[smeos]
enabled=1
mirrorlist=http://mirrorlist.koozali.org/mirrorlist/smeos-11
name=SME Server - os
gpgcheck=1
enablegroups=1
includepkgs=smeserver-mock,smeserver-devtools,perl-Algorithm-Dependency,perl-File-Flat,perl-File-chmod,perl-JSON-PP,perl-Test-Inline" > /etc/yum.repos.d/smeserver11.repo

then this will pull most needed devtools and more importantly smeserver mock configs.

sudo dnf install smeserver-mock smeserver-devtools


Then:

#!/bin/sh
mkdir ~/rpmbuild
for i in BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
do
 mkdir ~/rpmbuild/$i
done

KOJI

you need to install configuration to access koji. see Koji_Usage


tar -xzf koji-<userid>-bundle.tgz
ls ~/.koji
client.crt  config  <userid>_browser_cert.p12  serverca.crt
koji moshimoshi

GIT

The git utilities currently developed live in the smedev/smeserver-gitutils repo.

Pull it over as follows:

git clone  https://src.koozali.org/smedev/smeserver-gitutils.git

Then copy the shell scripts to ~/bin or wherever.

mkdir ~/bin
cp smeserver-gitutils/git-*.sh  ~/bin/.
mkdir ~/.smegit
cp smeserver-gitutils/conf ~/.smegit/config

Then edit the ~/.smegit/conf for your own setup. Make sure that ~/bin is in the $PATH - you can use .bashrc to set this up if necessary.

The gitutils use the change-log and BogusDataBot.sh scripts which are normally installed from smeserver-mock. Until an EL8 rpm is built, then you need to copy these to ~/bin or /usr/bin from your EL7 or SMEServer system.

They also use the json utilities "jq", and "git-lfs" plugin and "lua" (needed for change-log) so you need:

sudo dnf install jq
sudo dnf install lua
sudo dnf install git-lfs


Git is quite sensitive to the local time, so make sure your timezone is correct (adapt to your timezone):

timedatectl 
timedatectl list_timezones | grep London
timedatectl set-timezone Europe/London

If you want to save your credentials to the gitea server, then do this:

git config --global credential.helper store

Then next time you need to access the repo to push and it asks for your credentials it will save them. This saves them apparently in plain to a restricted file called ".git-credentials" somewhere, however I've not found it yet!

Using the git utilities

Say you want to move a package from CVS to the GIT system. Here are the instructions:

  • git-cvs2git.sh packagename organisation #Bring it across from CVS, create an equivalent git repo
  • git-get-repo-and-build.sh packagename organisation #Prime it down from the gitr repo and "make mockbuild" on it.
  • git-make-release.sh packagename organisation tagname releasetype #Create the release as part of the repo and copy the rpms to it as attachments.

releasetypes are draft, prerelease or release. Note that a draft release is not visible unless you are logged in with write access to the repo.

Mockbuilding direct from the git repos

First create some sort of directory structure to hold the repo contents - this is what I use:

cd ~
mkdir -p GITFiles
cd GITFiles
mkdir -p {smedev,smecontribs,smeserver}

and add in the common directory which provides an environment for the mockbuild .

cd smecontribs
git clone https://src.koozali.org/smedev/common.git
cd smeserver
git clone https://src.koozali.org/smedev/common.git

we then can add in the repo we want to work on (you get the git clone link by browsing to https://src.koozali.org and then (e.g.) https://src.koozali.org/smecontribs/smeserver-mailstats, or you can "guess" the URL!

cd ~/GITFiles/smecontribs
git clone https://src.koozali.org/smecontribs/smeserver-mailstats

Then to mockbuild it locally you can:

cd ~/smecontribs/smeserver-mailstats
make mockbuild

after a lot of on screen messages you should finally see a positive outcome message. If you want to pull down a complete set of repos for (e.g.) the core system, then by using one of the git-utils you can do this:

cd ~/GITFiles/smeserver
git-list-all-org-repos.sh smeserver | xargs -I % sh -c 'git clone https://src.koozali.org/smeserver/%'

Submitting jobs to the build system

cd ~/GITFiles/smecontribs
git clone https://src.koozali.org/smecontribs/common
git clone https://src.koozali.org/smecontribs/smeserver-mailstats
cd smeserver-mailstats

do your changes, then up the release and edit the changelog in spec file

change-log
vim smeserver-mailstats.spec

check the files that were changed, and add modified files for the ongoing commit

git status
git add smeserver-mailstats

check you can mockbuild

make mockbuild

if you are ok with result, then commit / push

make commit

And then tag and build (tag in git and send to koji for building)

make tag
make build
#or one liner
make tagbuild


If you wat to get some changes from another users before starting your changes

cd ~/GITFiles/smecontribs/smeserver-mailstats
git pull