how to build rpms as an ordinary user?

Hi!

I’d like to build rpms as an ordinary user. I understand there is the nasty tradition
that rpms are built as root. Coming from a Debian background I don’t have this tradition and now in year 2010 I don’t want to get used to it anymore;)

Searching the web there are many old tutorials doing it just as root. Some newer pages actually state that one should never do it, but I was not able to find a good tutorial how to accomplish that.

As opposed to most tutorials, I’d like to learn the building part first and looking at writing spec files later.

So here is what I did (using the typical wget example)

sudo zypper  source-install wget
cd /usr/src/packages
cp -r * /home/user/try/wget
cd  /home/user/try/wget

(Sounds a bit weird that I have to get the source as root and then copy it, so a better way would also be welcome)

Now I think I could run rpmbuild, but I obviously need to change the default locations because I don’t have access to /usr/source and I don’t want it. Some sources mention ~/.rpmacros or /etc/rpm/macros to do that.
Are those used in OpenSUSE or are they Fedora things?

I looked at rpmbuild --showrc, but I found that a bit intimidating for the new user.

P.S. I also saw the build command mentioned. Is that what OBS uses? I understand it uses a chroot environment to achieve isolation from the running system. While that probably gives best guarantees for a clean environment and real reproducible builds it looks like a bit of overkill to me just to build a single package for my private testing purposes, so I hope there is an easier way.

If you can lay your hands on the src rpm, then you can rebuild the rpm. Say the src rpm is called: kde4-kdenlive-0.7.8-1.pm.1.1.src.rpm

Then you could try:

rpmbuild --rebuild kde4-kdenlive-0.7.8-1.pm.1.1.src.rpm

… it should immediately fail and tell you what dependencies you are missing. So you then need to go, find and install the missing dependencies, and try again. With the exception of installing the missing dependencies (which need be done as user root) this rpm building can be done with regular user permissions.

Other than that rebuild method, and other than the rather ‘crude’ checkinstall method (requiring root permissions), I can not provide you the proper way to build an rpm from a tarball, as I have never taken the time to learn.

Hi
For just the one you can build as your user fine down
in /usr/src/packages/SPECS


rpmbuild -ba wget.spec

Else have a look at this thread (bit of a tutorial going on in it)
http://forums.opensuse.org/english/news/tech-news/449037-libdvdcss-packman.html


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.23-0.3-default
up 2 days 1:48, 2 users, load average: 0.06, 0.10, 0.28
GPU GeForce 8600 GTS Silent - Driver Version: 260.19.12

Also If you want to use OBS (I use this method and osc with chroot),
then have a look here;
http://en.opensuse.org/Portal:Development/Topics


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.23-0.3-default
up 2 days 1:51, 2 users, load average: 0.01, 0.06, 0.23
GPU GeForce 8600 GTS Silent - Driver Version: 260.19.12

> sudo zypper source-install wget

“ordinary user” (as in your thread subject) usually don’t need to
build an RPM, or compile from source, etc…

if you want to install wget why not just install it, as root:


zypper in wget

or pop open YaST and install it from there and you don’t even have to
see a command line…which is the way for most ordinary users…


DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]

Hi DD
The OP is wanting to learn how to build rpms… wget is what the user
downloaded to use an example for how an rpm builds :wink:


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.32.23-0.3-default
up 2 days 2:01, 2 users, load average: 0.02, 0.05, 0.14
GPU GeForce 8600 GTS Silent - Driver Version: 260.19.12

I don’t know anything of that “nasty” tradition, in fact I never had to build RPMs as root.

If you refer to the need for su/sudo when using build/lbuild, this is only needed for setting up a temporary and standardized chroot environment (in order to get redistributable builds as that chroot will always be “fresh” and only contain the required packages instead of using your running system), the build is executed by a special user (called build).

For local rebuilds with “rpmbuild” I always run that as a non-privileged user.

Here’s a method (if you don’t use OBS). You do everything as user. Indeed you don’t have to build rpms as root.

  • install the pattern devel_rpm_build
    zypper in -t pattern devel_rpm_build
  • copy the following directory to your user home directory
    cp -r /usr/src/packages/ ~/rpmbuild
  • create file ~/.rpmmacros, similar to the example below:
%_topdir        /home/geuder/rpmbuild
%_tmppath       /home/geuder/rpmbuild/tmp
%packager       pitfall <geuder@opensuse.org> 
%distribution   openSUSE
%vendor         openSUSE
%distsuffix     openSUSE

  • get a src.rpm package (if not for openSUSE, for another distro) and install it
    rpm -ivh someprogram.src.rpm
  • change to the directory ~/rpmbuild/SPECS
    cd ~/rpmbuild/SPECS
  • Edit the file someprogram.spec
    there.
  • compile and build the package:
    rpmbuild -ba someprogram.spec
  • If it worked, you’ll find the package in the ~/rpmbuild/RPMS subdirectory for your architecture (or noarch)

Of course the ordinary user as in “not interested in software development” does not need to do that. What I was referring to as a ordinary user, was a “non-root user” who wants to work in his home directory without being able able to screw up his installation while testing and playing around.

Not even necessary, because it was installed by default :wink:

.

True. I’m am the non-ordinary user who prefers the command line for most things, but I prefer to do it using an ordinary user account (no root access) whenever possible. Of course installation is not possible, but software building should be.

Thanks, that looks like the prefect answer to my question.

Of course few things related to SW are perfect without testing;) But first I need some sleep. I’ll let you know later how it goes.

geuder wrote:

> What I was referring to as a ordinary user, was a “non-root user”

argh! i tricked myself into believing you meant what you wrote… :wink:


DenverD
CAVEAT: http://is.gd/bpoMD [posted via NNTP w/openSUSE 10.3]

Thanks, worked indeed perfectly.

The main trick was installing the devel_rpm_buid pattern. I was still lacking some tools, although I had already installed some of them.

Setting _topdir is not even necessary. I had overlooked that the directories under /usr/share/packages are world-writable. But yes I think it’s cleaner to have my building exercises under my home directory instead of in the root file system.

As a matter of fact just building even works without the whole .rpmmacros file. But I agree it makes sense to use nice values.

I also had previously misunderstood that the source rpm is an output of building and not an input