LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 815|回复: 3

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

[复制链接]
发表于 2010-5-4 15:35:58 | 显示全部楼层 |阅读模式
我一般的做法是安装在独立目录,如 /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下逐条建立库的链接
。。。这个有没有方便点的方法。。
 楼主| 发表于 2010-5-4 15:41:09 | 显示全部楼层
./configure --prefix=/usr
make
make DESTDIR=/usr/pkg/libfoo/1.1 install

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

使用道具 举报

 楼主| 发表于 2010-5-12 08:34:29 | 显示全部楼层
用BLFS的脚本来解决 自己mark一下

# Begin /etc/profile
# Written for Beyond Linux From Scratch
# by James Robertson <jameswrobertson@earthlink.net>
# modifications by Dagmar d'Surreal <rivyqntzne@pbzpnfg.arg>

# 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 <jameswrobertson@earthlink.net>
# updated by Bruce Dubbs <bdubbs@linuxfromscratch.org>

# 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=$NEWPATH1
}

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
回复 支持 反对

使用道具 举报

发表于 2010-5-12 09:02:33 | 显示全部楼层
链接法确实可以省掉包管理器,更轻量化。
不过这种方法就是链接超多,使用链接有些许潜在的性能浪费
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表