在不同位置安装包

在不同位置安装包

通常,当我运行dpkgapt-get安装包时,它会将一些文件复制到特定位置。例如,mpv 文件被复制到这些位置(通过尝试获得 dpkg --listfiles mpv):

/.
/etc
/etc/mpv
/etc/mpv/encoding-profiles.conf
/etc/mpv/mpv.conf
/usr
/usr/bin
/usr/bin/mpv
/usr/share
/usr/share/applications
/usr/share/applications/mpv.desktop
/usr/share/doc
/usr/share/doc/mpv
/usr/share/doc/mpv/README.md.gz
/usr/share/doc/mpv/changelog.Debian.gz
/usr/share/doc/mpv/copyright
/usr/share/doc/mpv/edl-mpv.rst.gz
/usr/share/doc/mpv/encoding.rst.gz
/usr/share/doc/mpv/examples
/usr/share/doc/mpv/examples/lua
/usr/share/doc/mpv/examples/lua/README.md
/usr/share/doc/mpv/examples/lua/acompressor.lua.gz
/usr/share/doc/mpv/examples/lua/ao-null-reload.lua
/usr/share/doc/mpv/examples/lua/audio-hotplug-test.lua
/usr/share/doc/mpv/examples/lua/autocrop.lua
/usr/share/doc/mpv/examples/lua/autodeint.lua.gz
/usr/share/doc/mpv/examples/lua/autoload.lua.gz
/usr/share/doc/mpv/examples/lua/cycle-deinterlace-pullup.lua
/usr/share/doc/mpv/examples/lua/observe-all.lua
/usr/share/doc/mpv/examples/lua/ontop-playback.lua
/usr/share/doc/mpv/examples/lua/pause-when-minimize.lua
/usr/share/doc/mpv/examples/lua/status-line.lua
/usr/share/doc/mpv/input.conf.gz
/usr/share/doc/mpv/mplayer-input.conf
/usr/share/doc/mpv/mpv.conf.gz
/usr/share/doc/mpv/restore-old-bindings.conf
/usr/share/doc/mpv/tech-overview.txt.gz
/usr/share/doc/mpv/waf-buildsystem.rst.gz
/usr/share/icons
/usr/share/icons/hicolor
/usr/share/icons/hicolor/16x16
/usr/share/icons/hicolor/16x16/apps
/usr/share/icons/hicolor/16x16/apps/mpv.png
/usr/share/icons/hicolor/32x32
/usr/share/icons/hicolor/32x32/apps
/usr/share/icons/hicolor/32x32/apps/mpv.png
/usr/share/icons/hicolor/64x64
/usr/share/icons/hicolor/64x64/apps
/usr/share/icons/hicolor/64x64/apps/mpv.png
/usr/share/icons/hicolor/scalable
/usr/share/icons/hicolor/scalable/apps
/usr/share/icons/hicolor/scalable/apps/mpv.svg
/usr/share/icons/hicolor/symbolic
/usr/share/icons/hicolor/symbolic/apps
/usr/share/icons/hicolor/symbolic/apps/mpv-symbolic.svg
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/mpv.1.gz
/usr/share/zsh
/usr/share/zsh/vendor-completions
/usr/share/zsh/vendor-completions/_mpv

现在我想安装一个pkgxyz_1.23.deb到自定义位置比如~/xyz.是否可以将操作需要的所有文件xyz都存储在这个位置?

答案1

可以使用dpkgextract 命令(参见man dpkg):

-x--extract档案目录
提取包中包含的文件。

对于你的情况:

dpkg -x xyz_1.23.deb ~/xyz

但您需要安装所需的依赖项并手动调整一些环境变量,例如:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/xyz/usr/lib
export PATH=$PATH:$HOME/xyz/usr/bin

要删除此类“已安装”的包,您需要删除其文件夹:

rm -rf $HOME/xyz

然后将环境变量改正回来。


请注意,此解决方案并不通用。
它可能适用于简单的应用程序,但可能不适用于综合包(具有许多依赖项)。

例如它可以与简单的GNU你好应用:

cd ~/Downloads
apt-get download hello
dpkg -x hello*.deb ~/hello
export PATH=$PATH:$HOME/hello/usr/bin

测试结果如下:

$hello --version
hello (GNU Hello) 2.10
$ which hello
/home/user/hello/usr/bin/hello

相关内容