Posts tagged with commit

easy packaging with openSUSE's build service

Distros tend to have their own unique package management system, though some share a common base (Debian and ubuntu for example), but non can do what openSUSE's online build service does, which is build for most architectures and practically all distributions. Being able to edit a couple of files, upload them, and let the remote computer to the work is a dream come true. No longer do upstream maintainers have to build packages individually for every distro they want to support, not to mention architectures. They can follow a set of simple instructions that practically anyone can follow and have their software available on most major platforms and architectures. This document should show you how its done. It is assumed you are using openSUSE as your base distro. Special thanks go out to Jigish Gohil/cyberorg, for helping me understand these steps


The first step is to create an account with https://build.opensuse.org/ or if you already have one, log into it. Also, we need to add a little script that tracks changes by pasting the following into /usr/bin/changelog and editting your time zone and email address:


#!/bin/bash
EDITOR=vi
FILE=$1
COMMENT_FILE=$(basename $FILE .spec).changes
tmpfile=$(mktemp changelog-XXXXXX)
timestamp=$(LC_ALL=POSIX TZ=Asia/Kolkata date)
email=my@emailaddress.org
separator="-------------------------------------------------------------------"
{
    echo "$separator"
    echo "$timestamp - $email"
    echo
    echo "- "
    echo
    if [ -n "$COMMENT_FILE" ]; then
      if [ -f "$COMMENT_FILE" ]; then
        cat $COMMENT_FILE
      fi
    fi
} >> $tmpfile || exit 1
if [ -z "$COMMENT_FILE" ]; then
    lines=1
    CHKSUM_BEFORE=$(md5sum $tmpfile | awk '{print $1}')
else
    lines=$(wc -l $COMMENT_FILE | awk '{print $1}')
    CHKSUM_BEFORE=has_changed
fi
$EDITOR +$((4+lines)) $tmpfile
if [ "$CHKSUM_BEFORE" = "$(md5sum $tmpfile | awk '{print $1}')" ]; then
    exit 1
fi
cat $tmpfile > $COMMENT_FILE
rm $tmpfile

and changing the permissions of the file by doing:


 


sudo chmod u+x /usr/bin/changelog

 


Meanwhile, search the net for a package you are interested in building. It is suggested to start off with something easy, that already has the source available in rpms format, that is to say, is a package that contains the source tarball and a .spec file at least. Usually these packages look like this: package-name-version-distro-1.2345.src.rpm. Next you want to download that file to the desktop and extract it by right clicking and choosing extract here.


You can now open the .spec file which will contain the description required to build the package on rpm based systems, as well as the name and description of the package. In the opensuse build service (oBS) web page, choose create a project or subproject, and then add a package. Here you need to fill out the Name, Title and description. The name and title are usually the same and are normally just the name of the package without version number or platform. (For example, sugar-maze) Then in the description copy and paste the description you got from the .spec file.


Now its time to go to the terminal and do:


osc co home:username:subproject packagename
cd home:username:subproject/packagename
mv ~/Desktop/package-name.version.distro.src/* ./

 


Now we want to edit the .spec file and replace the line that looks something like this:


Release: 1.20090216%{?dist}

with these lines:


%if 0%{?suse_version}
Release: 1
%else
Release: 1.20090216%{?dist}
%endif

 


We will also need to add any missing requires and buildrequires. These are usually visible inside the oSB tool, when the build has been committed. That means one may need to go back and edit the .spec file, and then recommit the changes. Now we need to add an entry to the changelog, which tracks what you are doing to the package:


changelog package-name

The command interface here is vi based, so its i for insert, and :qw to write and quit. Next you will want to edit the metadata (this only requires doing the first time you build a package!):


osc meta prj -e home:username:subproject

You should change the content so it looks something like this


Finally we add the spec, changes and source tarball to the oBS:


osc add *.spec *.changes *.gz

and we commit it:


osc ci -m "uploaded new package"

Thats all it takes to have your package now building or queued to be building. If you want to create a package directly from a tarball, that is also possible, and it is suggested you use the spec file you created as the base that you will need to edit accordingly. While it is not in the scope of this document to explain how that is done, it is easy enough to duplicate a project, and use that as the base:


osc copypac home:username:subproject youroldpac home:username:subproject newpac

And then you can rename the .spec file, changes, and add the source tarball of the package you want to build. Then you can follow the same instructions above for uploading to oBS.


Rate It! (Average 0, 0 votes)