Create A PCLinuxOS Packaging Environment In Phoenix

by Joble

Have you have ever been curious about what it takes to create packages for PCLinuxOS? The first and most important step is setting up your packaging environment. I don’t know if my method is the best way to do it, but it’s what I did, and it works. Since I am the maintainer of Phoenix, the PCLinuxOS Xfce remaster, I’ve chosen to set up my packaging environment in Phoenix for this article.

To get started, install these packages from Synaptic:

  • a-task-packager-minimal
  • pkgutils-thunar

For KDE fans you would need to install task-packaging-kde4, which will put context menus in dolphin for use in Minime.

Next, install any tools or reference materials you may want to use. I recommend these as a minimum:

You will need a PDF viewer for the PDF version. I recommend epdfview in Synaptic. It’s light, it’s fast, and it works well. But, there are no window controls for Xfce, so you have to resize the window by dragging the edges.

Next, you may want to read through the PCLinuxOS Packager’s Wiki. The information in the wiki will serve as a valuable reference as you learn the steps to creating your own PCLinuxOS packages.

Now, from the command line, run mkrepo --help. This will show you all the options that are available to set up your own local repository.

[joe@localhost /]$ mkrepo --help
Usage: mkrepo [OPTION]...
Create a local repository including folder structure,
.rpmrc and .rpmmacros files, modify sources.list, and
optionally install prerequisite build packages.
Mandatory arguments to long options are mandatory for short options too.
  -d, --distribution=DIST    Distribution [PCLinuxOS]
  -s, --distsuffix=SUFFIX    Distribution suffix [pclos]
  -r, --release=YYYY         Mandriva release [2010]
  -v, --vendor=VENDOR        Vendor
  -p, --packager=NAME        Packager info
  -b, --basedir=DIR          Base folder for src tree [/home/joe]
  -a, --addpkgs              Install packages needed to build rpms
  -n, --noupdate             No apt-get update if installing pkgs
  -u, --usage                Display typical usage and exit
  -h, --help                 Display this help and exit
Use a - as the argument to d,s,r,v,p to remove an existing macro.
[joe@localhost /]$
mkrepo -a -d PCLinuxOS -v PCLinuxOS -s <your PCLOS user name> -p <your PCLOS user name>

I will not use -a, because I've already install a-task-packager-minimal and I will change the -s to -s pclos as that is what most packagers use. I don’t know what Tex prefers but I haven’t seen any packager yet use -s username, so I use -s pclos.

[joe@localhost /]$ mkrepo -d PCLinuxOS -v PCLinuxOS -s pclos -p Joble

I will be using /home/joe as the base for the source tree, which is /home/joe/src . These lines will be written to ~/.rpmmacros:

And the result:

%_topdir    /home/joe/src/rpm
%_tmppath    /home/joe/src/tmp
%packager    Joble
%distribution    PCLinuxOS
%distsuffix    pclos
%vendor    PCLinuxOS
Continue? [Y/n] Y
Please enter root Password:
Old local repo line(s) found:
Can't find folder /media/disk/pclinuxos2010/RPMS.main for Section main in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.updates for Section updates in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.nonfree for Section nonfree in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.kde4 for Section kde4 in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/ for Section games in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS./home/joe/src/apt/ for Section /home/joe/src/apt/ in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.pclinuxos/2010 for Section pclinuxos/2010 in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.athlon for Section athlon in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.i586 for Section i586 in "/etc/apt/sources.list"
Can't find folder /media/disk/pclinuxos2010/RPMS.noarch for Section noarch in "/etc/apt/sources.list"
Check path "/media/disk/pclinuxos2010" for folders (or links) like "RPMS.section"
File sources.list backed up as sources.list.old
mkrepo is now finished. You can install source rpms
(*.src.rpm) as normal user by typing:
$ rpm -i program.src.rpm
Enjoy building rpms!
[joe@localhost /]$

Now a lot of really neat stuff just happened to your computer. I won’t explain it here, but if you were to do all this yourself, it would require a lot of work. For a more in-depth explanation of the process, check the wiki:

Notice that the sources.list was backed up to sources.list.old? If things don't look right in your sources.list, you might want to restore that.

[joe@localhost /]$ cat /etc/apt/sources.list
# Package repository URL's
# Signed repositories have a [] where  is the name of the key
# as it appears in vendors.list. If you remove it, no digital signature check
# will be made.

..Snipped a lot of stuff out to shorten this up...

rpm file:/media/disk/pclinuxos/ 2010 main updates nonfree kde4 games  
rpm file:/home/joe/src/apt/ pclinuxos/2010 athlon i586 noarch  (this one was added by the mkrepo command)
[joe@localhost /]$

Now you need to remove your Thunar configuration folder:

[joe@localhost .config]$ rm -rf ~/.config/Thunar

Once you have completed this, you will need to log out of Xfce and log back in. Now that the setup is finished, here’s how to use it!

First, right click on the *.src.rpm file, and select “SRPM Install for build” from the context menu in Thunar.


Below is the output of our previous step. Your output should look similar.


Those messages are normal, so do not worry. It just means Neal built the src.rpm and Neal is not a user on my computer. I’m not sure why it says using root when I’m not logged in as root, but it always says that.

Now a bit about the packaging environment. The mkrepo command created the directories needed, but it helps if you have some idea what they are so here we go. In /home/(your user name)/ there is now the following directories:

src/apt         - your local repo contains links to rpm/RPMS
src/tmp         - where the install goes before getting turned into an rpm.
src/rpm/BUILD   - where the sources are extracted to during the build.
src/rpm/RPMS    - where the rpm files end up when you’re finished.
src/rpm/SOURCES - where the source files go when you install a src.rpm
src/rpm/SPECS   - where the spec files go when you install a src.rpm
src/rpm/SRPMS   - where the src.rpm will be after a successful build

In Thunar, navigate to ~/src/rpm/SPECS and right click on the spec file.



If you are building a package for the distro, you have to put information in the %changelog section at the bottom of the spec file like so:

  • * date (hehe, stardate), YourPCLOSusername, <your email address>, version and release info
  • - what you did. First build, update, added a patch or whatever
  • * Mon May 24 2010 YourPCLOSUserName <email at> 0.1.0-1pclos2010
  • - first build

Install Dependencies:

The first you want to do after creating or editing a spec file is to install the dependencies. If you are missing one, that is the first error you will get when you try to build it.

Build All:

Build all will attempt to go through the entire build process. If all goes well, it will report that it has created an rpm and src.rpm when it is finished. The rpm file can be found in rpm/RPMS/i586 or athalon or noarch depending on the architecture it was built for. The rest of the options are incremental steps though the build process that can help with troubleshooting when things don’t go so well.

So, how does it work with the local repo? I’ve actually never run gbd before, so I opened synaptic and activated only the local repo created by the mkrepo script. (My other repo is also a local repo, and I wasn’t sure what might happen to it). Now open a terminal and type gbd.

[joe@localhost ~]$ gbd
rm -f /home/joe/src/apt/pclinuxos/2010/base/*
genbasedir --flat --bz2only --progress /home/joe/src/apt/pclinuxos/2010 athlon i586 noarch
Components: athlon i586 noarch
Processing pkglists... athlon i586 0002/0002 noarch [done]
Processing srclists... [done]
Updating component releases... athlon i586 noarch [done]
Creating global release file... [done]
Appending MD5Sum... athlon i586 noarch [done]
All your base are belong to us!!!
Update apt package list? [y/N] y
Please enter root Password:
Reading Package Lists... Done
Building Dependency Tree... Done
[joe@localhost ~]$

Now in Synaptic, reload and click the status button and section New in Repository if all went well, your package will be listed there and you can install it. If it’s not listed there, then go back an make sure your local repo is checked for use. mkrepo will activate it by default, and if you forget to run gbd, it will fail to install.

Personally I don’t like to bother with the local repo and gbd. I usually go right to rpm/RPMS/i586 (or other appropriate directory) and use apt-get install (name of rpm).

Now here’s an interesting little side project for practice. Wanna know what all those context menus in Thunar do? Each is linked to a command and can be executed from a terminal.


Install that and look at the spec file. Can you find the command line equivalent to the Thunar context menus in there? Still wanna be a packager? I know I do, but I’m glad I’m not trying to edit that spec file. The changelog shows MBantz, Neal and travisn000 worked on it last. You can find us all, in the packagers section of the forum.