如何基于ubuntu base制作一个可用于交叉编译的sysroot

1. 下载一个指定版本的ubuntu base文件

Index of /ubuntu-base/releases

tar -xvf  ubuntu-base-20.04.1-base-amd64.tar.xz -C .
cd ubuntu-base-20.04.1-base-amd64

2. 添加域名解析的IP

编辑 etc/resolv.conf
加入 nameserver 8.8.8.8

3. 绑定/dev 到 base文件里的dev

sudo mount --bind /dev dev

4. 修改sysroot路径为sysroot路径

sudo chroot $PWD

5. 安装开发库

apt update
apt-get install libc6-dev

6. 将sysroot里的库软链接地址从绝对路径改成相对路径

apt install symlinks
symlinks -cr /

7. 退出当前用户

exit

8. unmount dev

sudo umount  dev

9. 常见报错:

Reading package lists... Done                                                                                          
W: GPG error: http://security.ubuntu.com/ubuntu focal-security InRelease: Couldn't create temporary file /tmp/apt.conf.Q3Rffp for passing config to apt-key
E: The repository 'http://security.ubuntu.com/ubuntu focal-security InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

解决办法是:
chmod 1777 /tmp # 给/tmp赋予正确权限
apt clean 清理apt缓存

Error: Archives directory /var/cache/apt/archives/partial is missing. - Acquire (2: No such file or directory)

解决办法是:
mkdir -p /var/cache/apt/archives/partial
apt autoclean

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。