4

How do I install a package in my ~/bin directory using zypper? I first downloaded the package as root, and then tried to install it as non root, but that way it runs into dependency issues.

# zypper in --download-only wireshark
...
$ zypper -R /home/ec2-user/bin in /var/cache/zypp/packages/SMT-http_smt-ec2_susecloud_net:SLE11-SDK-SP3-Updates/rpm/x86_64/wireshark-1.10.11-0.2.1.x86_64.rpm
Loading repository data...
Reading installed packages...
Resolving package dependencies...

Problem: nothing provides libadns.so.1()(64bit) needed by wireshark-1.10.11-0.2.1.x86_64
 Solution 1: do not install wireshark-1.10.11-0.2.1.x86_64
 Solution 2: break wireshark-1.10.11-0.2.1.x86_64 by ignoring some of its dependencies

Is there some zypper option similar to --prefix? BTW I only want the analysis function of tshark. Thanks.

SailorCire
  • 2,423
  • 1
  • 15
  • 23
Dinesh
  • 1,241
  • 4
  • 14
  • 18

3 Answers3

3

Short answer is you don't. I haven't found a way after reading the man pages, help section, or website.

What you can do, is download the rpm and then install that into a different directory.

You should be able to do this with the following:

zypper in --download-only wireshark
rpm --prefix=/home/ec2-user/ -ivh /var/cache/zypp/packages/SMT-http_smt-ec2_susecloud_net:SLE11-SDK-SP3-Updates/rpm/x86_64/wireshark-1.10.11-0.2.1.x86_64.rpm

Don't ask me why, I think this has something to do with zypper's own internal database and dealing with distro-upgades.

SailorCire
  • 2,423
  • 1
  • 15
  • 23
  • With this I get an error "error: package wireshark is not relocatable". Is there a way to differentiate / download relocatable packages, or is this determined by pacakge writer? – Dinesh Apr 12 '16 at 18:26
3

Referring to the manual, zypper has a --root option:

-R, --root 
       Operates  on  a different root directory. This option influences
       the location of the repos.d directory  and  the  metadata  cache
       directory  and  also causes rpm to be run with the --root option
       to do the actual installation or removal of packages. Note  that
       the  ZYpp  lock is still created in the original system, as well
       as temporary files. See also the FILES section.

which it implements using the --root option of rpm. According to that manual page:

--root DIRECTORY

    Use the system rooted at DIRECTORY for all operations. Note that
    this means the database will be read or modified under DIRECTORY
    and any %pre or %post scriptlet(s) are run after a chroot(2) to
    DIRECTORY. 

In other words, --root changes the location of the RPM database, but has no effect on where the package would be installed.

Since zypper has no documented support for relocating a package, consider downloading it. Back to its manual:

-d, --download-only
       Only download the packages for later installation.

and

/var/cache/zypp/packages
       If  keeppackages property is set for a repository (see the modi-
       fyrepo command), all the RPM file downloaded during installation
       will be kept here. See also the clean command for cleaning these
       cache directories.

Some packages honor a --prefix option, making them relocatable. These are more of an exception than a rule. Most packages are not relocatable. If this is one of those, you can use rpm2cpio to unpack the files to a directory of your choosing.

Further reading:

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
0

zypper has the option --root <dir> which corresponds to --prefix as was asked by you. Nevertheless also consider SailorCire's answer

okurz
  • 361
  • 2
  • 3