使用Exodus在不同linux之间迁移程序
source link: https://www.lujun9972.win/blog/2018/03/10/%E4%BD%BF%E7%94%A8exodus%E5%9C%A8%E4%B8%8D%E5%90%8Clinux%E4%B9%8B%E9%97%B4%E8%BF%81%E7%A7%BB%E7%A8%8B%E5%BA%8F/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
使用Exodus在不同linux之间迁移程序
Exodus能将Linux ELF二进制文件及其依赖打包在一起,从而保证程序在不同Linux之前迁移后依然能正常使用。
注意:由于Exodus并不会改变ELF文件的内容,因此请不要尝试在不同的硬件平台之间做迁移,比如将X86上的应用迁移到ARM中,那是不可能的
安装Exodus
我们需要使用 pip
来安装 exodus
。
sudo pip install exodus-bundler
根据 exodus
主页上的说明,还最好安装好 gcc
以及 musl
或 dietlibc
库
sudo pacman -S gcc musl dietlibc
使用Exodus把程序迁移到其他Linux中
使用Exodus迁移程序的方法很简单,只需要执行
exodus 程序|ssh user@remote
Exodus就会将程序打包好,然后放到remote下user用户的 $HOME/.exodus/bin
下
[lujun9972@T520 lctt-scripts]$ exodus vi |ssh lujun9972@orangepipc2 Pseudo-terminal will not be allocated because stdin is not a terminal. WARNING: Installing either the musl or diet C libraries will result in more efficient launchers (currently using bash fallbacks instead). ___ ____ _ ____ ____ ____ / _ \ _ __ __ _ _ __ __ _ ___ | _ \(_) | _ \ / ___|___ \ | | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | |_) | | __) | | |_| | | | (_| | | | | (_| | __/ | __/| | | __/| |___ / __/ \___/|_| \__,_|_| |_|\__, |\___| |_| |_| |_| \____|_____| |___/ Welcome to ARMBIAN 5.40 stable Ubuntu 16.04.4 LTS 4.14.18-sunxi64 System load: 0.39 0.21 0.19 Up time: 9 days Local users: 2 Memory usage: 17 % of 994MB Swap usage: 13 % of 497Mb IP: 192.168.1.9 CPU temp: 35°C Usage of /: 17% of 29G storage/: 86% of 466G Installing executable bundle in "/home/lujun9972/.exodus"... tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/bin/vi: time stamp 2018-03-10 22:07:15 is 158.261128965 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/bin/linker-dfd5de2638cea087685b67786050dcdc33aac7b67f5f8c2753b7da538517880a: time stamp 2018-03-10 22:07:15 is 158.256992469 s in the future tar: data/83d187def3d3ed02de70ec8b3059e3665b2d0c31b25431486262878be245c469: time stamp 2018-03-10 22:07:15 is 158.246799933 s in the future tar: data/39027ea769af1413aaac9ef7fafb8865b6bd83148539532523931d96bfd48f04: time stamp 2018-03-10 22:07:15 is 158.230871884 s in the future tar: data/6d0e1d459072c805cf1cee1a9d394998f477dbc5d947894cb04962d0e06288b1: time stamp 2018-03-10 22:07:15 is 158.162682666 s in the future tar: data/dfd5de2638cea087685b67786050dcdc33aac7b67f5f8c2753b7da538517880a: time stamp 2018-03-10 22:07:15 is 158.157154228 s in the future tar: data: time stamp 2018-03-10 22:07:15 is 158.156088023 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/lib64/ld-linux-x86-64.so.2: time stamp 2018-03-10 22:07:15 is 158.155651207 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/lib/libc.so.6: time stamp 2018-03-10 22:07:15 is 158.155441508 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/lib/libncursesw.so.6: time stamp 2018-03-10 22:07:15 is 158.155205809 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/bin/vi-x: time stamp 2018-03-10 22:07:15 is 158.155030941 s in the future tar: bin/vi: time stamp 2018-03-10 22:07:15 is 158.154871823 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/lib64: time stamp 2018-03-10 22:07:15 is 158.154811617 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/lib: time stamp 2018-03-10 22:07:15 is 158.154743787 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr/bin: time stamp 2018-03-10 22:07:15 is 158.154681539 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5/usr: time stamp 2018-03-10 22:07:15 is 158.154619792 s in the future tar: bundles/1d0a475efc744b690bfc00c4841507e2263c50efab8b6d6e0483c08a3b6851d5: time stamp 2018-03-10 22:07:15 is 158.154560128 s in the future tar: bundles: time stamp 2018-03-10 22:07:15 is 158.154503297 s in the future tar: bin: time stamp 2018-03-10 22:07:15 is 158.154448757 s in the future Successfully installed, be sure to add /home/lujun9972/.exodus/bin to your $PATH.
然后登陆user@remote,将 ~/.exodus/bin
加入 PATH 中,就可以运行程序了。
export PATH="~/.exodus/bin:${PATH}"
Exodus还提供了很多选项,比如可以通过 -r
来为程序改名等等,要查看更多选项的说明可以运行
(env) [lujun9972@T520 lctt-scripts]$ exodus -h usage: exodus [-h] [-c CHROOT_PATH] [-a DEPENDENCY] [-d] [--no-symlink FILE] [-o OUTPUT_FILE] [-q] [-r [NEW_NAME]] [--shell-launchers] [-t] [-v] EXECUTABLE [EXECUTABLE ...] Bundle ELF binary executables with all of their runtime dependencies so that they can be relocated to other systems with incompatible system libraries. positional arguments: EXECUTABLE One or more ELF executables to include in the exodus bundle. optional arguments: -h, --help show this help message and exit -c CHROOT_PATH, --chroot CHROOT_PATH A directory that will be treated as the root during linking. Useful for testing and bundling extracted packages that won run without a chroot. (default: None) -a DEPENDENCY, --add DEPENDENCY, --additional-file DEPENDENCY Specifies an additional file to include in the bundle, useful for adding programatically loaded libraries and other non-library dependencies. The argument can be used more than once to include multiple files, and directories will be included recursively. (default: []) -d, --detect Attempt to autodetect direct dependencies using the system package manager. Operating system support is limited. (default: False) --no-symlink FILE Signifies that a file must not be symlinked to the deduplicated data directory. This is useful if a file looks for other resources based on paths relative its own location. This is enabled by default for executables. (default: []) -o OUTPUT_FILE, --output OUTPUT_FILE The file where the bundle will be written out to. The extension depends on the output type. The "{{executables}}" and "{{extension}}" template strings can be used in the provided filename. If omitted, the output will go to stdout when it is being piped, or to "./exodus-{{executables}}-bundle.{{extension}}" otherwise. (default: None) -q, --quiet Suppress warning messages. (default: False) -r [NEW_NAME], --rename [NEW_NAME] Renames the binary executable(s) before packaging. The order of rename tags must match the order of positional executable arguments. (default: []) --shell-launchers Force the use of shell launchers instead of attempting to compile statically linked ones. (default: False) -t, --tarball Creates a tarball for manual extraction instead of an installation script. Note that this will change the output extension from ".sh" to ".tgz". (default: False) -v, --verbose Output additional informational messages. (default: False)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK