Tar 将相对符号链接更改为绝对符号链接 [英] Tar changes relative symlinks to absolute symlinks

查看:61
本文介绍了Tar 将相对符号链接更改为绝对符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了简化交叉编译的 sysroot 生成,我生成了一个带有相对符号链接的 tar 文件.

To simplify the sysroot generation for cross compiling, I generate a tar file with relative symbolic links.

如果我用

tar tvf sysroot-libc6-dev.tar

然后我得到正确的结果:

then I get the correct result:

lrw-r--r-- jens/jens         1 2018-03-30 23:42 usr/lib/x86_64-linux-gnu/libBrokenLocale.so -> ../../../lib/x86_64-linux-gnu/libBrokenLocale.so.1
lrw-r--r-- jens/jens         1 2018-03-30 23:42 usr/lib/x86_64-linux-gnu/libanl.so -> ../../../lib/x86_64-linux-gnu/libanl.so.1
lrw-r--r-- jens/jens         1 2018-03-30 23:42 usr/lib/x86_64-linux-gnu/libcidn.so -> ../../../lib/x86_64-linux-gnu/libcidn.so.1

如果我用

tar xvf sysroot-libc6-dev.tar

那么符号链接是绝对的,这是一团糟,因为这样sysroot目录指向我的主机,交叉编译将不起作用.

then the symlinks are absolute, this is a mess, because then the sysroot directory points to my host machine and cross compile will not work.

ls -al

lrwxrwxrwx 1 jens jens      33 Jan 14 11:39 libanl.so -> /lib/x86_64-linux-gnu/libanl.so.1
lrwxrwxrwx 1 jens jens      42 Jan 14 11:39 libBrokenLocale.so -> /lib/x86_64-linux-gnu/libBrokenLocale.so.1
lrwxrwxrwx 1 jens jens      34 Jan 14 11:39 libcidn.so -> /lib/x86_64-linux-gnu/libcidn.so.1

脚本的目的是保持一切相对,链接器脚本也是如此,例如libc.so 将被修补到相关链接.

The purpose of the script is to keep everything relative, also the linker scripts, e.g. libc.so will be patched to relative links.

提前致谢

延斯·里博尔德

推荐答案

我发现我的帖子有问题.仅当符号链接的目的地也在 tar 存档中时,tar 才会设置相对链接.

I found the problem of my post. The tar will set relative links only if the destination of the symbolic link is also in the tar archive.

raspberry pi 交叉编译的问题是库的绝对符号链接和 ld 脚本中的绝对路径.(SO 文件).

The problem with cross compiling for the raspberry pi are the absolute symbolic links to the libraries and the absolute paths in the ld scripts. (SO Files).

如果您将树莓派中的预构建库复制到您的交叉编译项目中,那么您必须修复它.在处理我的项目时,我花了一些时间来理解奇怪的链接器问题.

If you copy prebuild libraries from the raspberry pi into your cross compile project, then you have to fix that. It took me some time to understand the strange linker issues while working on my project.

该项目的工作原理如下:

The project works as follows:

sync_package.pl <debian package name>

输出是一个 tar 文件,其中包含 ld 脚本中的相对链接和相对路径.

The output is a tar file with relative links and relative pathes in the ld scripts.

示例:

sync_package.pl libmodbus-dev

输出:

sysroot-libmodbus-dev.tar

这篇关于Tar 将相对符号链接更改为绝对符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆