Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install packages in Linux (CentOS) without root user with automatic dependency handling?

Is it possible to use RPM or YUM or any other package manager in Linux, specifically CentOS, to install a package either already downloaded or from repo to a custom location without admin/root access?

I tried building from sources, using cmake, configure, make, make install etc, but, it ended up having so many dependencies one after other.

Or are there any better alternatives?

like image 647
user3330840 Avatar asked Apr 15 '16 15:04

user3330840


People also ask

Does yum install require root?

You still can't install them directly without being root, but RPM packages are actually fancy .

How manually install package CentOS?

To install RPM packages, you need to be logged in as a root or user with sudo privileges . Usually, you would use a web browser to search and download an RPM file. Once you locate the file, you can download it using your browser or using a commandoline tool like curl or wget .

Can I install RPM without root?

You can build RPM's without root access, just do so inside your homedirectory.

Which command is used to install packages in CentOS?

YUM stands for Yellowdog Updater, Modified. It is an updated package manager that allows you to install, remove, update, view, or search software packages. For more information on the yum command, use yum ––help .


2 Answers

TL;DR Use Miniconda, conda-forge is amazing.

curl "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" | sh

Or, alternatively:

curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda.sh
bash Miniconda.sh -b -p ~/conda
# -b is used to specify that this is done "in batch", so skip the EULA prompt
# -p lets you specify where you want conda installed

Commonly wanted packages:

  • gcc conda install gcc
  • zlib conda install zlib
  • make conda install make
  • cmake conda install cmake
  • git conda install git
  • fish conda install -c conda-forge fish
  • zsh conda install -c ActivisionGameScience zsh
  • tmux conda install -c conda-forge tmux
    • This tmux has a bug with the name of the ncurse library it uses. You can work around it by going to your da/lib folder and symlinking ln -sT libtinfow.so.6.1 libtinfo.so.6

For the rest, you can try https://anaconda.org/search?q=.


I've tried for a long time to get a package manager to work well on CentOS/RedHat but without success. The best I could do was to install a Gentoo Prefix at the correct location on another CentOS with root access, then scp a .tar.xz of the whole installation to the target server (only way to get a proper gcc for Gentoo Prefix). I could emerge (build & install) packages on the target server but kept hitting problems with locals and permissions.


I recently achieved a user installation of some interesting packages using conda. Here is how to install it from the command line:

curl "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh" | sh

If like me, your home folder is hosted on a remote drive (a network file system), you might not want to install it in your home folder, so you might want to use something like mkdir /var/tmp/lo then specify an installation folder like /var/tmp/lo/da during the installation.

You'll then be able to install quite a lot of packages, though maybe not all those you wanted. Most of the time, if it is not in the default channel, it will be in conda-forge. You can check for existing packages at https://anaconda.org/search?q=


Other package managers I've tried to use after conda:

Linuxbrew

I thought that with that it would be easy to install homebrew (linuxbrew) but their sources are messy and use hard-coded absolute path to ruby interpreter, which fails because it isn't the last version and so on and so on and I gave up.

Nix

Nix still requires you to use the /nix folder. They hard-coded it too and it's hard to sed it correctly from every download it has to do during the installation (let alone updates).

Gentoo Prefix

I expect Gentoo Prefix to be easier to install directly now that we gcc can be used on the target server. -- Ok, I tried but met permissions bugs during installation (2018-09-28):

portage.exception.OperationNotPermitted: chown(b'~/gentoo/tmp/var/tmp/portage/sys-apps/gentoo-functions-0.12/image/var', 2000, 2000)

PkgSrc

I'm going to try pkgsrc now. -- Use (older) version 64-bit EL 6.x if on CentOS 6 or if encountering (G)LibC version issues with the 7.x one. -- No luck, pkgsrc hard codes /usr/pkg/sbin and /usr/pkg/bin. So it can't be used as user, unless maybe setting up a fakechroot environment. But I've never done that and I expect usability issues.


Please comment/answer if you succeed in installing any other package manager.

like image 54
loxaxs Avatar answered Oct 23 '22 02:10

loxaxs


Download the packages, and indicate to include dependencies with the --resolve flag.

yumdownloader --resolve openslide-tools

Iterate over all downloaded rpm files.

for i in *.rpm; do rpm2cpio $i | cpio -idv; done

the output will be stored in your present working directory $PWD/usr/*

like image 3
0-_-0 Avatar answered Oct 23 '22 03:10

0-_-0