+ -
当前位置:首页 → 问答吧 → 指定软件包安装到/opt 来代替包管理的几个问题

指定软件包安装到/opt 来代替包管理的几个问题

时间:2010-05-04

来源:互联网

我一般的做法是安装在独立目录,如 /opt/xxx 或 /usr/local/xxx 然后建立链接,卸载的时候直接删目录就是了,想了解都装了什么包 ls 就是了
我也是装在opt下建链接,更新软件时先在/opt/tmp下建个目录装下,然后跟原来的比较一下,如果链接文件名一样就直接把/opt下的软件删掉然后用新的装一下,如果有不同的那就调整一下/usr下建的链接就行,永远不用在烦包管理的那种依赖...
------------------------------------
以上是从论坛里摘录出来的
这个实用性强吗?
我想先在LFS里试试
第6章构建系统时有configure的 可以用--prefix=/opt/xxx/1.54来安装软件xxx1.54
只有make install的怎么加参数安装到=/opt/xxx/1.54呢?

另外安装到/opt/xxx/1.54后
我得去根目录下建相应的link 好让系统找到库、命令吧
那得手工一条条的去建立链接吗?
比如/bin /sbin /usr/bin /usr/local/bin都要逐条建命令链接 lib下逐条建立库的链接
。。。这个有没有方便点的方法。。

作者: heuyck   发布时间: 2010-05-04

./configure --prefix=/usr
make
make DESTDIR=/usr/pkg/libfoo/1.1 install

LFS介绍的这种方法是不是不用自己建链接了?
还是只修复了库链接的功能

作者: heuyck   发布时间: 2010-05-04

用BLFS的脚本来解决 自己mark一下

# Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <[email protected]>
# modifications by Dagmar d'Surreal <[email protected]>

# System wide environment variables and startup programs.

# System wide aliases and functions should go in /etc/bashrc. Personal
# environment variables and startup programs should go into
# ~/.bash_profile. Personal aliases and functions should go into
# ~/.bashrc.

# Functions to help us manage paths. Second argument is the name of the
# path variable to be modified (default: PATH)
pathremove () {
local IFS=':'
local NEWPATH
local DIR
local PATHVARIABLE=${2:-PATH}
for DIR in ${!PATHVARIABLE} ; do
if [ "$DIR" != "$1" ] ; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR
fi
done
export $PATHVARIABLE="$NEWPATH"
}

pathprepend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}

pathappend () {
pathremove $1 $2
local PATHVARIABLE=${2:-PATH}
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}

if [ $EUID -eq 0 ] ; then
unset HISTFILE
fi

# Setup some environment variables.
export HISTSIZE=1000
export HISTIGNORE="&:[bf]g:exit"
#export PS1="[\u@\h \w]\\$ "
export PS1='\u@\h:\w\$ '

for script in /etc/profile.d/*.sh ; do
if [ -x $script ] ; then
. $script
fi
done

# Now to clean up after ourselves
unset pathremove pathprepend pathappend

# End /etc/profile








# Begin ~/.bash_profile
# Written for Beyond Linux From Scratch
# by James Robertson <[email protected]>
# updated by Bruce Dubbs <[email protected]>

# Personal environment variables and startup programs.

# Personal aliases and functions should go in ~/.bashrc. System wide
# environment variables and startup programs are in /etc/profile.
# System wide aliases and functions are in /etc/bashrc.

append () {
# First remove the directory
local IFS=':'
local NEWPATH
for DIR in $PATH; do
if [ "$DIR" != "$1" ]; then
NEWPATH = ${NEWPATH:+$NEWPATH:}$DIR
fi
done

# Then append the directory
export PATH=$NEWPATH:$1
}

if [ -f "$HOME/.bashrc" ] ; then
source $HOME/.bashrc
fi

if [ -d "$HOME/bin" ] ; then
append $HOME/bin
fi

unset append

# End ~/.bash_profile





cat > /etc/profile.d/extrapaths.sh << "EOF"
if [ -d /usr/local/lib/pkgconfig ] ; then
pathappend /usr/local/lib/pkgconfig PKG_CONFIG_PATH
fi
if [ -d /usr/local/bin ]; then
pathprepend /usr/local/bin
fi
if [ -d /usr/local/sbin -a $EUID -eq 0 ]; then
pathprepend /usr/local/sbin
fi
for directory in $(find /opt/*/lib/pkgconfig -type d 2>/dev/null); do
pathappend $directory PKG_CONFIG_PATH
done
for directory in $(find /opt/*/bin -type d 2>/dev/null); do
pathappend $directory
done
if [ -d ~/bin ]; then
pathprepend ~/bin
fi
#if [ $EUID -gt 99 ]; then
# pathappend .
#fi
EOF

作者: heuyck   发布时间: 2010-05-12

链接法确实可以省掉包管理器,更轻量化。
不过这种方法就是链接超多,使用链接有些许潜在的性能浪费

作者: swordhui   发布时间: 2010-05-12

热门下载

更多