Created
May 6, 2022 09:57
-
-
Save kidpixo/f95c5c80e32fc76d93f10489ba8f5896 to your computer and use it in GitHub Desktop.
rpm - yum install in user home for non-admins : unpack rpm and move executable, manpages etc to $USER home.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# see : rpm - yum install in user home for non-admins | |
# http://unix.stackexchange.com/questions/61283/yum-install-in-user-home-for-non-admins | |
# Usage: | |
# 0. check your architecture | |
# uname -a | |
# Linux laser.pe.ba.dlr.de 3.10.0-514.21.1.el7.x86_64 #1 SMP Sat Apr 22 02:41:35 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux | |
# | |
# 1. search a packet for your architecture. | |
# Example: gnu parallel for x86_64 architecture. | |
# http://fr2.rpmfind.net/linux/rpm2html/search.php?query=parallel&arch=x86_64 | |
# | |
# 2. download the right file, in this case fedora 25 rpm. | |
# $ wget ftp://fr2.rpmfind.net/linux/fedora/linux/releases/25/Everything/x86_64/os/Packages/p/parallel-20160722-2.fc25.noarch.rpm | |
# | |
# 3. call this script | |
# $ ./extract_rpm.sh parallel-20160722-2.fc25.noarch.rpm | |
# | |
# this extract and a directory tree with the binary, docs, man and all. | |
# | |
# $ tree parallel-20160722-2.fc25.noarch | |
# | |
# parallel-20160722-2.fc25.noarch | |
# ├── parallel-20160722-2.fc25.noarch.cpio | |
# └── usr | |
# ├── bin | |
# │ ├── niceload | |
# │ ├── parallel | |
# │ ├── sem | |
# │ └── sql | |
# └── share | |
# ├── doc | |
# │ └── parallel | |
# │ ├── NEWS | |
# │ └── README | |
# ├── licenses | |
# │ └── parallel | |
# │ └── COPYING | |
# └── man | |
# ├── man1 | |
# │ ├── niceload.1.gz | |
# │ ├── parallel.1.gz | |
# │ ├── sem.1.gz | |
# │ └── sql.1.gz | |
# └── man7 | |
# ├── parallel_design.7.gz | |
# └── parallel_tutorial.7.gz | |
# | |
# 10 directories, 14 files | |
# | |
# 4. Copy the file in yoour location under PATH for the binary, and MANPATH for the man. My structure looks like: | |
# My (MAN)PATH definiton in bashrc: | |
# PATH=$MANPATH:$HOME/.local/bin | |
# MANPATH=$MANPATH:$HOME/bin/usr/share/man | |
# | |
# $ tree -CdL 2 ~/.local/ | |
# | |
# /user/mars/MYUSER/.local/ | |
# ├── bin | |
# ├── lib | |
# │ └── python3.5 | |
# ├── man | |
# │ └── man1 | |
# ├── rpms | |
# │ └── parallel-20160722-2.fc25.noarch | |
# └── share | |
# ├── local-mail | |
# └── Trash | |
# | |
pro=$1 | |
proname=${pro%.*} | |
prodir=${proname} | |
RSYNC_OPT='-r --links --ignore-existing' | |
mkdir $prodir | |
rpm2cpio "${pro}" > "${prodir}/${proname}.cpio" | |
(cd "${prodir}" && cpio -idv < "${proname}.cpio") | |
echo "shows the unpacked data" | |
tree ${prodir} | |
echo "copy the binaries to the appropiate location:" | |
echo " > rsync $RSYNC_OPT ${prodir}/usr/bin/ ${HOME}/.local/bin" | |
rsync $RSYNC_OPT ${prodir}/usr/bin/ ${HOME}/.local/bin | |
# copy the man to the appropiate location | |
echo " > rsync -r ${prodir}/usr/share/man/ ${HOME}/.local/man" | |
rsync $RSYNC_OPT ${prodir}/usr/share/man/ ${HOME}/.local/man | |
# copy extra stuff whatever blabla are you really reading here? | |
echo " > rsync $RSYNC_OPT ${prodir}/usr/share/doc/ ${HOME}/.local/share/doc" | |
rsync $RSYNC_OPT ${prodir}/usr/share/doc/ ${HOME}/.local/share/doc | |
echo " > rsync $RSYNC_OPT ${prodir}/usr/lib/ ${HOME}/.local/lib" | |
rsync $RSYNC_OPT ${prodir}/usr/lib/ ${HOME}/.local/lib | |
echo " > rsync $RSYNC_OPT ${prodir}/usr/lib64/ ${HOME}/.local/lib64" | |
rsync $RSYNC_OPT ${prodir}/usr/lib64/ ${HOME}/.local/lib64 | |
# not feeling sure enough to uncomment this.... | |
#echo "delete the temporary directory" | |
#rm -rf ${prodir} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment