Creating your first RPM Package on ArcaOS

From EDM2
Jump to: navigation, search

By Martin Iturbide

On this quick article, I will explain how did I create my first RPM package under the ArcaOS platform. I was used to creating some WarpIn installers and I felt that it was interesting to use RPM since it provides a single repository where the users can select which software to install. But I found it is a complete different process from creating WarpIn installer.

Software Requirements

To create my first installer, I used the following software:

And the following RPM packages:

  • rpm-build
  • os2-rpm-build

You can install all at once with one command:

yum install rpm-build os2-rpm-build

Preparing your Environment

How you will set your environment will vary according to your personal taste. On this case, I got some help and ideas from Andy Willis, so he gave me his way to "organize" the environment.

It was to create a directory structure on my "Home" directory. So I created the one that looks as the next image:

FirstRPM-001.png

In general terms, the folder are going to be used by:

BUILD
You are going to put the files that you want to include on your RPM package here.
BUILDROOT
Is the folder where some temporary file structure will be created to be able to pack the RPM file.
SPECS
Is there the .spec files are going to be located. The .specs files are the logic of the RPM package.
RPMS
Is the folder where your RPM package is going to be located once it is ready.

I'm not going to cover the rest of the folders, but Rpm HowTo Packagers article explains the rest.

Locating the Files

My first installer was as easy as possible, so it was only two files of a little open source game called RollBall.

So I located RollBall.exe and RollBall.txt on the "BUILD" directory.

FirstRPM-002.png

Working with the .SPEC File

This is where the fun begins. The SPEC file is the file that contains the logic for the RPM installer. Andy Willis provided me with some easy samples to follow.

On this case, I'm sharing with you my sample on how my "RollBall RPM" end up.

Name:           RollBall
Version:        1.00
Release:        1%{?dist}
Summary:        A Simple Action game.
Group:          Games/Action
License:        GNU GPL V3
URL:            https://www.os2world.com/games/index.php/native-games/action-2/50-roll-ball

Vendor:         OS2World

Obsoletes:	RollBall < %{version}-%{release}
Provides:	RollBall = %{version}-%{release}
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch:	i686

%description
RollBall is a little game with the goal to earn points with a rolling ball while preventing it from falling into holes.

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/@unixroot/usr/bin
mkdir -p $RPM_BUILD_ROOT/@unixroot/usr/share/doc/%{name}-%{version}
cp -p *.exe $RPM_BUILD_ROOT/@unixroot/usr/bin
cp -p *.txt $RPM_BUILD_ROOT/@unixroot/usr/share/doc/%{name}-%{version}

%files
%{_bindir}/*.exe
%doc RollBall.txt

%post
if [ "$1" -ge 1 ]; then # (upon update)
    %wps_object_delete_all
fi
%wps_object_create_begin
ROLLBALL_EXE:WPProgram|RollBall|<WP_DESKTOP>|EXENAME=((%{_bindir}/RollBall.exe))
%wps_object_create_end

%postun
if [ "$1" -eq 0 ]; then # (upon removal)
    %wps_object_delete_all
fi

The file is not long and the first part is almost self-explanatory with the general information about the installer. The interesting part is on %install and %files.

Important Note
Remember that a lot of things here are "case-sensitive". %{_bindir}/*.exe it is not the same as %{_bindir}/*.EXE. You may get errors that the .exe files are not found if you don't check the cases. It is also important to remember that we must use the "/" (slash) and not backslashes on the paths, since this came from the Unix world. The backslash is used for line continuations, so it can be a source of confusion for OS/2 users.
 %install 
Marks the part of the script that is going to be responsible to create the structure on how the files are going to be located inside your @unixroot directory (Usually starting from the drive root in a default installed ArcaOS)
So when you build the package, it will create the directory structure inside "BUILDROOT". After that, it will copy the respective files to those directories.
 %files 
From this part you will tell which files should the RPM package grab to include. For what I learned "%{_bindir}" is for the binaries, %{_libdir} for the DLLs, %doc for the text files, and also I had seen something like "/@unixroot/usr/share/os2/help/*.hlp" for the hlp file. I hope to get more experience on this area while I create some other RPM packages.
%post 
Are the instructions to run after the RPM package installs the files. On this case, it will be a good idea to create some icons on the Workplace Shell desktop. To create this, you can use some "wps_object_*" scripts that have been created for this task. There is more information on the Rpm HowTo Packagers article.
This is an area when more research is needed to understand more about this. I can only say that in my sample, it works creating a desktop icon and removes it when you uninstall the package.

Building the Package

Once your environment and your SPEC file is ready, it is time to see if the RPM package builds.

I also tried this the most easy way I could find. So I just used the OS/2 console from the "rpmbuild" directory.

FirstRPM-003.png

And this is where I got good advice from Dave Yeo, since you may have issues it is good to have a log of all the messages that shows up on the build process. To have this log stored on a text file, run first this command:

cmd 2>&1 | tee cmd.log

Now we are ready to build the RPM package. Just run from the "rpmbuild" directory:

rpmbuild -bb specs\RollBall.spec

It will start all the process and give you a lot of information.

FirstRPM-004.png

At the end you can see if got the .rpm file generated or if you got some error. On this case, the .rpm file was generated and stored on the "RPMS/i686" directory.

FirstRPM-005.png

If the .rpm file is not generated, and you get an error, it is a good time to check the "cmd.log" created on the same "rpmbuild" directory and try to figure it out which can be the issue.

Testing the Package

At first, I was not sure how to test the package or if I needed an RPM server to test it. Another tip from Dave Yeo told that it was as easy to test as to install any RPM package.

From the "i686" directory, where your generated .rpm package is located, just run:

yum install RollBall-1.00-1.oc00.i686.rpm

It will start the normal yum installer procedure.

FirstRPM-006.png

Just press "Y" and check where the files get installed in your /usr directory.

FirstRPM-007.png

You can also check the package with AN Package Manager and see the respective information:

FirstRPM-008.png

And you can deinstall your package with AN Package Manager or with a yum command like:

yum remove RollBall

Resources

You can download the package of the RPMBUILD structure with some files from this link.

Conclusions

The general conclusion is that I was able to create an RPM package that works. This is a very basic sample and easy to follow, but the idea was to get a basic and initial conception of the process of creating an RPM package/installer on ArcaOS. Over time and with different needs, more complexity will need to be added, but that was out of the scope of this first basic tutorial.

Links

To learn more about RPM, I recommend:

OS/2-ArcaOS Specifics
Linux Specific