非root用户安装rpm半自动安装脚本

非root用户安装rpm半自动安装脚本
手动实现:创建一个新目录,将rpm文件移动进去,rpm2cpio xxx.rpm |cpio -idvm解压出lib等文件夹,添加至.bashrc。
半自动脚本(更改权限为711,放在PATH下):
用法:rpm_installer.sh xxx.rpm
rpm_installer.sh:

new_soft=$1

folder=${new_soft/.rpm/}
mkdir $folder
mv $new_soft $folder
cd $folder
rpm2cpio $new_soft |cpio -idvm

bashrc_modifier.sh usr

bashrc_modifier.sh:


new_soft=$1
bin=${new_soft}/bin
lib=${new_soft}/lib
pkgconfig=${new_soft}/lib/pkgconfig/
include=${new_soft}/include
if [ -d $bin ]; then echo export PATH=\"`realpath $bin`:\$PATH\"; fi
if [ -d $lib ]; then echo export LD_LIBRARY_PATH=\"`realpath $lib`:\$LD_LIBRARY_PATH\"; fi
if [ -d ${lib}64 ]; then echo export LD_LIBRARY_PATH=\"`realpath ${lib}64`:\$LD_LIBRARY_PATH\"; fi
if [ -d $pkgconfig ]; then echo export PKG_CONFIG_PATH=\"`realpath $pkgconfig`:\$PKG_CONFIG_PATH\"; fi
if [ -d $include ]; then echo export CPLUS_INCLUDE_PATH=\"`realpath $include`:\$CPLUS_INCLUDE_PATH\"; fi

echo vim /home/`whoami`/.bashrc (手动输入该命令,将以上结果贴入该文件)

你可能感兴趣的:(Linux)