Non-root users Installing packages from a rpm file - linux

I'm a non-root user running centos Linux.....the problem is i have the desired rpm file i don't how to install them into my home directory being a non-root user.Any help would be appreciated.thanks in advance

This nice little script ( unPack_rpm.sh ) will unpack rpm packages to a folder with the package name ...
#!/bin/bash
# Purpose: Unpack RPM archives (author: #unSpawn)
# Args: /path/to/archive
# Deps: Bash, GNU utils, RPM
rpmDetails() { for Q in changelog provides requires scripts triggers triggerscripts; do
rpm -q -p --${Q} "${f}" 2>&1 | grep -v NOKEY > "${Q}.log"; done; }
rpmUnpack() { f=$(readlink -f "${f}"); file "${f}"|grep -q "RPM.v" && \
{ d=$(basename "${f}" .rpm); d="./${d:=ERROR_$$}"; mkdir -p "${d}" && \
{ cd "${d}" && rpm2cpio "${f}" | cpio -idmv && rpmDetails "${f}"; }; }; }
for f in $#; do rpmUnpack "${f}"; done
exit 0

I think this is somewhat a duplicate question, the same as the one here. In this thread, it is suggested to extract the rpm (using conversion to cpio) and then use the source files locally.
A link to an in-depth explenation for this is also supplied, you can see it here.

Related

OpenBSD 6.7 how to install xbase

I am updating our integration test environments to OpenBSD 6.7 (from 6.5)
We use ansible to install all the packages on the target system (openbsd 6.7, Vagrant image https://app.vagrantup.com/generic/boxes/openbsd6/versions/3.0.6 )
With the above image, I cannot install java openjdk 11.
obsd-31# pkg_add -r jdk%11
quirks-3.325 signed on 2020-05-27T12:56:02Z
jdk-11.0.7.10.2p0v0:lz4-1.9.2p0: ok
jdk-11.0.7.10.2p0v0:zstd-1.4.4p1: ok
jdk-11.0.7.10.2p0v0:jpeg-2.0.4p0v0: ok
jdk-11.0.7.10.2p0v0:tiff-4.1.0: ok
jdk-11.0.7.10.2p0v0:lcms2-2.9p0: ok
jdk-11.0.7.10.2p0v0:png-1.6.37: ok
jdk-11.0.7.10.2p0v0:giflib-5.1.6: ok
Can't install jdk-11.0.7.10.2p0v0 because of libraries
|library X11.17.0 not found
| not found anywhere
|library Xext.13.0 not found
| not found anywhere
|library Xi.12.1 not found
| not found anywhere
|library Xrender.6.0 not found
| not found anywhere
|library Xtst.11.0 not found
| not found anywhere
|library freetype.30.0 not found
| not found anywhere
Direct dependencies for jdk-11.0.7.10.2p0v0 resolve to png-1.6.37 libiconv-1.16p0 giflib-5.1.6 lcms2-2.9p0 jpeg-2.0.4p0v0
Full dependency tree is giflib-5.1.6 lz4-1.9.2p0 tiff-4.1.0 png-1.6.37 xz-5.2.5 jpeg-2.0.4p0v0 lcms2-2.9p0 zstd-1.4.4p1 libiconv-1.16p0
Couldn't install jdk-11.0.7.10.2p0v0
my guess is that xbase is not installed.
However, I cannot figure out how to install xbase without rebooting into a bootable installer (because I need to do it via a shell command running from ansible)
Is there a way?
The generic OpenBSD Vagrant image you're using was created as a command line environment, so the X windows files were were excluded during the install process.
There are lots of ways to add X windows to OpenBSD after installation, but the quickest method that comes to mind would be:
sudo su -l
curl -LO 'https://ftp.usa.openbsd.org/pub/OpenBSD/6.7/amd64/x{base,serv,font,share}67.tgz'
tar xzf xbase67.tgz -C /
tar xzf xserv67.tgz -C /
tar xzf xfont67.tgz -C /
tar xzf xshare67.tgz -C /
rm -f xbase67.tgz xfont67.tgz xserv67.tgz xshare67.tgz
ldconfig /usr/local/lib /usr/X11R6/lib
If you would like to test for the presence of X windows on OpenBSD, try using the following shell snippet:
if [ -d /usr/X11R6/bin/ ] && [ -f /usr/X11R6/bin/xinit ]; then
echo "X windows has been installed."
else
echo "This is a command line only system."
fi
The xbase file set can be extracted manually via the following commands:
cd /
curl -LO https://ftp.usa.openbsd.org/pub/OpenBSD/6.7/amd64/xbase67.tgz
tar xzvf xbase67.tgz
Note: this is the mirror used in the vagrant sources.
If you care about security enough to use OpenBSD, then you really shouldn't grab new package sets from the internet without also checking the hashes/signatures are valid. Try this script:
#!/bin/ksh
echo -n "Downloading ... "
curl --silent --fail --fail-early -O "https://ftp.usa.openbsd.org/pub/OpenBSD/7.0/amd64/SHA256.sig" -O "https://ftp.usa.openbsd.org/pub/OpenBSD/7.0/amd64/x{base,font,serv,share}70.tgz"
if [ $? != 0 ]; then
echo "X windows download failed. Terminating."
exit 1
fi
echo "complete."
signify -Cp /etc/signify/openbsd-70-base.pub -x SHA256.sig xbase70.tgz xfont70.tgz xserv70.tgz xshare70.tgz
if [ $? != 0 ]; then
echo "X windows signature verification failed. Terminating."
exit 1
fi
tar -z -x -C / -f xbase70.tgz && tar -z -x -C / -f xfont70.tgz && tar -z -x -C / -f xserv70.tgz && tar -z -x -C / -f xshare70.tgz
if [ $? != 0 ]; then
echo "X windows installation failed. Terminating."
exit 1
fi
echo "Installation complete. Happy hacking."
On the other hand if you just want a one liners:
# Install just x11 base set.
sudo ksh -c 'curl --silent https://ftp.usa.openbsd.org/pub/OpenBSD/7.0/amd64/xbase70.tgz | gzip -d -c | tar -x -C / -f - '
# Install all the x11 sets.
sudo ksh -c 'curl --silent https://ftp.usa.openbsd.org/pub/OpenBSD/7.0/amd64/xbase70.tgz | gzip -d -c | tar -x -C /-f - '
You can omit the sudo portion if you are already logged in as root. And for the vagrant folks, the lazy version looks:
# Install just x11 base set from the host, to a vagrant guest.
vagrant ssh -c "sudo ksh -c 'curl --silent https://ftp.usa.openbsd.org/pub/OpenBSD/7.0/amd64/xbase70.tgz | gzip -d -c | tar -x -C / -f - '"
# Install all the x11 sets from the host, to a vagrant guest.
vagrant ssh -c "sudo ksh -c 'curl --silent -O \"https://ftp.usa.openbsd.org/pub/OpenBSD/7.0/amd64/x{base,font,serv,share}70.tgz\" && tar -z -x -C / -f xbase70.tgz && tar -z -x -C / -f xfont70.tgz && tar -z -x -C / -f xserv70.tgz && tar -z -x -C / -f xshare70.tgz'"

can't translate my program via debian package but with autotools can

i use autotools as build system also i use gettext in my code for Translations.
I have few .po files (de.po, es.po and th.po ) and with autotools no problem to get them working. After:
./configure,
make
sudo make install
the program and the Translations .mo files get installed.
To testing that i open a terminal and change the locale e.g :
$ export LANG=de_DE.UTF-8
$ ./myprogram
and the translations works!.
I do with the same source code a debian deb package.
During the deb installation in a .posinst script i deploy the translations mo files to the locale destination (docklight is the program name):
#!/bin/bash
set -e
# check for locale dir (LIVE SYSTEMS don't have it)
if [ -d "/usr/local/share/locale" ]; then
podir="/usr/lib/docklight/docklight.data/po"
if [ -d ${podir} ]; then
cd ${podir}
PO_LINGUAS=$( if test -r LINGUAS; then grep -v "^\#" LINGUAS; fi)
linguas=$PO_LINGUAS
for lang in $linguas; do
dir=/usr/local/share/locale/$lang/LC_MESSAGES;
# check for locale dir (LIVE SYSTEMS don't have it)
if [ ! -d $dir ]; then
continue;
fi
# check for po file
if [ ! -f "$lang.po" ]; then
continue;
fi
file=`echo $lang | sed 's,.*/,,'`.gmo \
&& rm -f $file && /usr/local/bin/msgfmt -o $file "$lang.po"
/bin/bash install-sh -d $dir; \
if test -r $lang.gmo; then \
/usr/bin/install -c -m 644 $lang.gmo $dir/docklight.mo; \
echo "installing $lang.gmo as $dir/docklight.mo"; \
else \
/usr/bin/install -c -m 644 ./$lang.gmo $dir/docklight.mo; \
echo "installing ./$lang.gmo as" \
"$dir/docklight.mo"; \
fi
done
fi
fi
the generated Translations .mo files are correct and get installed on the locale folder for the language:
dir=/usr/local/share/locale/$lang/LC_MESSAGES;
exact the same like the build process with autotools.
After testing the languages:
$ export LANG=de_DE.UTF-8
$ ./myprogram
my program does not have any translation.
I don't know where the problem is. The deb installation works correct!
is something more that i need to care for the creation of a debian deb package?
As far as I understood, when you get myprogramm.mo files in place you should get the program translated.
Any ideas about that?
Thanks in advance for any help.
if find the solution:
I just need to set the PROGRAMNAME_LOCALEDIR path where the mo file are.
The gettext initialization can find the mo files and then everything gets translate. Works!
bindtextdomain(GETTEXT_PACKAGE, PROGRAMNAME_LOCALEDIR);
%s\n",domain,GETTEXT_PACKAGE,PROGRAMNAME_LOCALEDIR);
bind_textdomain_codeset - set encoding of message transā€lations
btdcodeset = bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
Thank you all.

Creating a docker Base Image

I have a private Linux distribution (based on redhat7).
I have an ISO file which holds the installation of that distribution, which can be used to install the OS on a clear system only.
I have some programs I would like to run as images on docker, each program on a different image.
Each program can only run on my Linux environment and so I am looking for a way to create the appropriate images, so they can be ran under docker.
I tried following Solomon instructions here:
mkdir rootfs
mount -o loop /path/to/iso rootfs
tar -C rootfs -c . | docker import - rich/mybase
But I don't know how to proceed. I can't run any command since the machine isn't running yet (no /bin/bash/ etc.)
How can I open the installation shell?
Is there a better way to run programs via docker on a private Linux distribution?
(Just to be clear, the programs can run only on that specific OS and that OS can only be installed on a clear machine. Not sure if I need a base image but I'd like to run these programs with Docker and that is possible only over this OS)
I ran into many questions like mine (like this) but I couldn't find answer that helped me.
Assumption
Server A where the ISO will be mount
Server R your private repositoy
Server N where container will be run
All server can connect to server R.
How to
build a base image as mentioned in your OP (named base/myimage)
Push the image to your private repository https://docs.docker.com/registry/deploying/
Create application images from your base base/myimage then push them to your private repo
From Server N, run the application image
docker run application/myapp
This script is from the official Docker contrib repo. It's used to create CentOS images from scratch. It should work with any Redhat/Centos based system and gives you plenty of control over the various steps. Anything beyond that you can then modify post-base-image through a Dockerfile.
The file is here
#!/usr/bin/env bash
#
# Create a base CentOS Docker image.
#
# This script is useful on systems with yum installed (e.g., building
# a CentOS image on CentOS). See contrib/mkimage-rinse.sh for a way
# to build CentOS images on other systems.
usage() {
cat <<EOOPTS
$(basename $0) [OPTIONS] <name>
OPTIONS:
-p "<packages>" The list of packages to install in the container.
The default is blank.
-g "<groups>" The groups of packages to install in the container.
The default is "Core".
-y <yumconf> The path to the yum config to install packages from. The
default is /etc/yum.conf for Centos/RHEL and /etc/dnf/dnf.conf for Fedora
EOOPTS
exit 1
}
# option defaults
yum_config=/etc/yum.conf
if [ -f /etc/dnf/dnf.conf ] && command -v dnf &> /dev/null; then
yum_config=/etc/dnf/dnf.conf
alias yum=dnf
fi
install_groups="Core"
while getopts ":y:p:g:h" opt; do
case $opt in
y)
yum_config=$OPTARG
;;
h)
usage
;;
p)
install_packages="$OPTARG"
;;
g)
install_groups="$OPTARG"
;;
\?)
echo "Invalid option: -$OPTARG"
usage
;;
esac
done
shift $((OPTIND - 1))
name=$1
if [[ -z $name ]]; then
usage
fi
target=$(mktemp -d --tmpdir $(basename $0).XXXXXX)
set -x
mkdir -m 755 "$target"/dev
mknod -m 600 "$target"/dev/console c 5 1
mknod -m 600 "$target"/dev/initctl p
mknod -m 666 "$target"/dev/full c 1 7
mknod -m 666 "$target"/dev/null c 1 3
mknod -m 666 "$target"/dev/ptmx c 5 2
mknod -m 666 "$target"/dev/random c 1 8
mknod -m 666 "$target"/dev/tty c 5 0
mknod -m 666 "$target"/dev/tty0 c 4 0
mknod -m 666 "$target"/dev/urandom c 1 9
mknod -m 666 "$target"/dev/zero c 1 5
# amazon linux yum will fail without vars set
if [ -d /etc/yum/vars ]; then
mkdir -p -m 755 "$target"/etc/yum
cp -a /etc/yum/vars "$target"/etc/yum/
fi
if [[ -n "$install_groups" ]];
then
yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \
--setopt=group_package_types=mandatory -y groupinstall $install_groups
fi
if [[ -n "$install_packages" ]];
then
yum -c "$yum_config" --installroot="$target" --releasever=/ --setopt=tsflags=nodocs \
--setopt=group_package_types=mandatory -y install $install_packages
fi
yum -c "$yum_config" --installroot="$target" -y clean all
cat > "$target"/etc/sysconfig/network <<EOF
NETWORKING=yes
HOSTNAME=localhost.localdomain
EOF
# effectively: febootstrap-minimize --keep-zoneinfo --keep-rpmdb --keep-services "$target".
# locales
rm -rf "$target"/usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive}
# docs and man pages
rm -rf "$target"/usr/share/{man,doc,info,gnome/help}
# cracklib
rm -rf "$target"/usr/share/cracklib
# i18n
rm -rf "$target"/usr/share/i18n
# yum cache
rm -rf "$target"/var/cache/yum
mkdir -p --mode=0755 "$target"/var/cache/yum
# sln
rm -rf "$target"/sbin/sln
# ldconfig
rm -rf "$target"/etc/ld.so.cache "$target"/var/cache/ldconfig
mkdir -p --mode=0755 "$target"/var/cache/ldconfig
version=
for file in "$target"/etc/{redhat,system}-release
do
if [ -r "$file" ]; then
version="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' "$file")"
break
fi
done
if [ -z "$version" ]; then
echo >&2 "warning: cannot autodetect OS version, using '$name' as tag"
version=$name
fi
tar --numeric-owner -c -C "$target" . | docker import - $name:$version
docker run -i -t --rm $name:$version /bin/bash -c 'echo success'
rm -rf "$target"

Install npm package without dependencies

I am looking for best solution how to install npm package without it's dependencies described in it's package.json file.
The goal is to change dependencies versions before install package. I can do it manually for one package by downloading source, but if you have many nested dependencies it becomes a problem.
Here's a shell script that seems to get you the extracted files you need.
#!/bin/bash
package="$1"
version=$(npm show ${package} version)
archive="${package}-${version}.tgz"
curl --silent --remote-name \
"https://registry.npmjs.org/${package}/-/${archive}"
mkdir "${package}"
tar xzf "${archive}" --strip-components 1 -C "${package}"
rm "${archive}"
Save it as npm_download.sh and run it with the name of the package you want:
./npm_download.sh pathval
Please check simialr quesition on stackexchange: https://unix.stackexchange.com/questions/168034/is-there-an-option-to-install-an-npm-package-without-dependencies
My solution was to rename package.json to package.bak before the install, then reverting rename afterwards:
RENAME package.json package.bak
npm install <package_name> --no-save
RENAME package.bak package.json
I supplemented the above script to allow the specification of multiple packages, avoid the temporary downloaded file and to install the packages straight to node_modules:
#!/bin/sh
# filename suggestion: `npm-i-no-deps`
while [ $# -gt 0 ]
do
package="$1"
version=$(npm show ${package} version)
mkdir -p "node_modules/${package}"
echo "Installing ${package}-${version}"
curl --silent "https://registry.npmjs.org/${package}/-/${package}-${version}.tgz" | tar xz --strip-components 1 -C "node_modules/${package}"
shift
done
I found this script useful for situations where dependencies are too strict with their dependency requirements, you can install deps you know work ok without adding them to your package.json until the upstream dependency is updated.
I adapted the script from mxcl to handle scoped packages (#user/package)
#!/bin/sh
# filename suggestion: `npm-i-no-deps`
while [ $# -gt 0 ]
do
package="$1"
version=$(npm show ${package} version)
mkdir -p "node_modules/${package}"
echo "Installing ${package}-${version}"
packagename=$(echo $package | sed 's/#.*\///g')
curl --silent "https://registry.npmjs.org/${package}/-/${packagename}-${version}.tgz" | tar xz --strip-components 1 -C "node_modules/${package}"
shift
done
Warning: mac has a weird version of sed, it should work but I can't guarantee.

GNU Make removes downloaded zip files for no apparent reason

I have this makefile tha sthould download and build openssh (along with other things):
ROOT_DIR=$(PWD)
DATA_DIR=$(ROOT_DIR)/data
SOURCES_DIR=$(ROOT_DIR)/sources
RESOURCES_DIR=$(ROOT_DIR)/resources
DRAFTS_DIR=$(ROOT_DIR)/drafts
$(SOURCES_DIR):
mkdir $(SOURCES_DIR)
$(RESOURCES_DIR):
mkdir $(RESOURCES_DIR)
$(DRAFTS_DIR):
mkdir $(DRAFTS_DIR)
openssh-tar-url="ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/OpenSSH/portable/openssh-6.2p2.tar.gz"
TAR_PROJECTS += openssh
openssh:
echo "Building $#"
openssh-clean: openssh-archive-clean
.SECONDEXPANSION :
$(TAR_PROJECTS) : $(SOURCES_DIR) $(SOURCES_DIR)/$$#-archive
$(DRAFTS_DIR)/%.tar.gz: $(DRAFTS_DIR)
echo "Pulling $*."
wget $($*-tar-url) -O $(DRAFTS_DIR)/$*.tar.gz
.SECONDEXPANSION :
$(SOURCES_DIR)/%-archive : | $(DRAFTS_DIR)/$$*.tar.gz
mkdir $#
cd $# && tar xvzf $(DRAFTS_DIR)/$*.tar.gz
%-archive-clean:
rm -rf $(SOURCES_DIR)/$*-archive $(DRAFTS_DIR)/$*.tar.gz
When i run make openssh it runs correctly but at the end it removes the archive it downloaded. This is very strange to me:
$ make openssh --just-print
echo "Pulling openssh."
wget "ftp://ftp.cc.uoc.gr/mirrors/OpenBSD/OpenSSH/portable/openssh-6.2p2.tar.gz" -O /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
mkdir /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/sources/openssh-archive
cd /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/sources/openssh-archive && tar xvzf /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
echo "Building openssh"
rm /home/fakedrake/Projects/ThinkSilicon/xilinx-zynq-bootstrap/drafts/openssh.tar.gz
Pretty sure you can list targets (and intermediates) as .PRECIOUS to avoid them being deleted for you. I'm afraid you'll need to RTFM for more details - I'm in visual studio rather than make these days, so my make skills are a bit rusty...

Resources