74

How can I install an RPM on a machine where I don't have root permissions? I want to install a package for my use only in a personal work directory. I'm running SuSe SLES10.

Please don't flame me with "This idea is so dumb, you shouldn't do it because all requests must go through the corporate root god, may he live forever."

I know I can request this of the root god, but I'll be shot down (for immaculate, impeccable reasons, I'm sure...). Besides, he'll never get around to installing it even if he does say he'll do it.

random
  • 14,638
  • 9
  • 54
  • 58
Ross Rogers
  • 4,427
  • 8
  • 32
  • 43
  • 8
    This isn't a duplicate at all. Overriding the path does not always allow a non-priviledged user to utilize rpm. – John T Nov 11 '10 at 19:08
  • Thanks HarryMC. I'll check that out. Also, adding link to the other ticket that people thought mine was a duplicate of. Maybe the breadcrumbs will help someone else : http://superuser.com/questions/160530/override-rpm-install-path – Ross Rogers Nov 11 '10 at 22:47
  • For a better future, look at https://appimage.org/ . – Ross Rogers Nov 14 '18 at 18:59

5 Answers5

83
cd my-dir;
rpm2cpio to-install.rpm | cpio -idv

See How To Extract an RPM Package Without Installing It (rpm extract command).

harrymc
  • 455,459
  • 31
  • 526
  • 924
  • 2
    I did this and cpio doesn't seem to do anything except print '1 block'. Did I do something wrong? – Nate Parsons Nov 16 '10 at 15:44
  • Thanks. Turns out I was able to install from source, so I don't need to bother with RPMs – Nate Parsons Nov 16 '10 at 16:11
  • 17
    That just unpacks the contents of the RPM and dumps it where you are. That doesn't mean the result works (its configuration isn't where it should be, ...) – vonbrand Jan 18 '13 at 17:07
  • 1
    Wish I could just give you some reputation reward of charity. Thank you! – macetw Jun 07 '17 at 14:14
  • I was able to get slack-desktop to install this way. Setup an alias for `alias slack="$HOME/.apps/usr/bin/slack > /dev/null &"` – PatS Jun 02 '21 at 13:37
5

How to extract rpm packages contents

export ins=foo-bar.rpm
rpm2cpio $ins | cpio -idv

How to extract tar.gz archive

gzip -dc foo-bar.tar.gz | tar xvf –
cd foo-bar-dir

How to extract tar.gz packages to the current directory

export file=foo-bar.tar.gz
# Note that `xovf` switch order *matters*
gzip -dc $file | tar -xovf -

How to build binaries as a non-root

./configure --prefix=$HOME && make && make install
Yordan Georgiev
  • 153
  • 1
  • 8
2

I think the "real" answer to "installing" an rpm without root privilege is, you can't. BUT assuming you could actually start the install process...

RPMs install using a list of instructions provided in a specification file (.spec) that usually follow the Filesystem Hierarchy. Most paths on that hierarchy are almost always operating system paths and not user paths. So unless your username has access to all of the paths an RPM installs to, then it would certainly fail. If you create an RPM that prefixes all of its paths with /home/me (or some other path you own), then it would work. This would require acquiring a src.rpm and extracting it as explained in other answers, then rebuilding it. By the time you do that, you might just consider getting root access or building the software from scratch (usually what you do if you do not plan on distributing the software across many machines).

There are clever tricks to help you in the manual build process. For example, you can utilize the dependencies already listed in an RPM to get all of your dependencies: https://stackoverflow.com/a/13877738/1236128.

Jonathan Komar
  • 472
  • 4
  • 14
2

Another option is to install from source, where you can usually change the install directory using the --prefix switch.

John T
  • 163,373
  • 27
  • 341
  • 348
0

You can try --prefix and --dbpath options. Not all RPMs will support --prefix, but if your rolling your own RPMs that won't be an issue, just make them relocatable.

I've been successful copying the systems rpm DB /tmp/lib/rpm to my own directory and specifying that via --dbpath. Then I can run rpm -i w/o root. Of course you now have a private copy of the DB and it will become out-of-date as your IT installs new packages - and other users won't know about your privately install packages. But hey, thats probably ok given the question you asked.

Unfortunately distributing your RPMs will still require other users to go thru IT or create their own DB as well, eg.

rpm -ivh --dpath ~/rpmdb --prefix ~/ mypkg-1.0-1.el8.x86_64.rpm

You could also ask your IT to make the system RPM DB writable.

Also answered here How to install packages on Linux without root-access?

brookbot
  • 111
  • 3