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.
… 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.
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.
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
.
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.
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