新的高通SDK需要较新的Ubuntu版本,但老的高通SDK却不兼容,因为Ubuntu 22.04的rootfs环境与16.04差异巨大,导致SDK中部分项目在编译时由于依赖不兼容导致编译出错。同时又因为服务器硬件升级导致安装旧版本的Ubuntu系统时,部分硬件由于驱动问题得不到支持,不得不将系统升级到新版本的Ubuntu上来。那又该如何去兼容老的高通SDK编译环境?使用Dockers和LXC容器,会带来文件权限问题,操作非常麻烦;使用PVE或Hyper-V等虚拟机方案也不错,但是硬件资源利用率又是一个问题。schroot就是可以兼容当前用户权限的虚拟化方案。
下面介绍如何安装schroot并部署Ubuntu 16.04 LTS(xenial)根文件系统。
# 安装ubuntu 16.04LTS Rootfs
sudo apt install debootstrap schroot
mkdir -p ~/chroot
cd ~/chroot
sudo debootstrap --arch=amd64 xenial ./ https://mirrors.tuna.tsinghua.edu.cn/ubuntu/
# 挂载基本目录,用于chroot(非schroot)时进入环境进行初始化部署,后续可以取消挂载并依靠schroot自动挂载相关目录sudo mount --bind /proc /home/pypyn/chroot/proc
sudo mount --bind /sys /home/pypyn/chroot/sys
sudo mount --bind /dev /home/pypyn/chroot/dev
sudo mount --bind /dev/pts /home/pypyn/chroot/dev/pts
# 配置文件:xenial.conf,放到/etc/schroot/chroot.d/,该配置使用/etc/schroot/default配置修改而来[xenial]
description=Ubuntu 16.04 LTS (build env)
type=directory
directory=/home/pypyn/chroot/
users=pypyn
groups=pypyn
root-groups=root
aliases=default
问题解决方案:
1、无法显示中文
首先用root(sudo schroot)用户重装字符集locale-gen zh_CN.UTF-8 en_US.UTF-8
然后修改/etc/default/locale# File generated by update-locale
LANG="zh_CN.UTF-8"
LANGUAGE="zh_CN:zh:en_US:en"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
2、初始化的环境执行apt update,报证书校验错误问题
在host系统中修改chroot系统的/ect/apt/sources.list,将https改为http
使用root进入chroot系统环境重装证书,执行
sudo schroot
apt --reinstall install ssl-cert ca-certificates
从ubuntu 16.04LTS机器上拷贝/etc/ssl文件夹到chroot对应目录
然后再更新源
apt update
3、修改挂载目录/etc/schroot/default/fstab
注意workspace和Qualcomm需要在chroot系统环境中提前创建好空文件夹
# <file system> <mount point> <type> <options> <dump> <pass>
/proc /proc none rw,bind 0 0
/sys /sys none rw,bind 0 0
/dev /dev none rw,bind 0 0
/dev/pts /dev/pts none rw,bind 0 0
/dev/shm /dev/shm none rw,bind 0 0
/home/pypyn/workspace /home/pypyn/workspace none rw,bind 0 0
/home/pypyn/Qualcomm /home/pypyn/Qualcomm none rw,bind 0 0
/tmp /tmp none rw,bind 0 0
/pkg /pkg none rw,bind 0 0
/prj /prj none rw,bind 0 0
4、安装CP编译环境
安装工具
apt install gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip libssl-dev libxml-simple-perl
安装make
wget http://ftp.gnu.org/pub/gnu/make/make-3.81.tar.bz2
tar xf make-3.81.tar.bz2
cd make-3.81
./configure
make
make install
mv /usr/bin/make /usr/bin/make-4.1
ln -sf /usr/local/bin/make /usr/bin/make
安装opensslwget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1f.tar.gz
tar xf openssl-1.0.1f.tar.gz
cd openssl-1.0.1f
./config --prefix=/usr/local --openssldir=/usr/local/openssl
make
mv /usr/bin/pod2man /usr/bin/pod2man_bak
make install
mv /usr/bin/pod2man_bak /usr/bin/pod2man
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/include/openssl /usr/include/openssl.old
ln -sf /usr/local/bin/openssl /usr/bin/openssl
ln -sf /usr/local/include/openssl/ /usr/include/openssl
openssl version -a
安装python2
apt install libsqlite3-dev
wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
./configure
make -16
make install
sudo apt install python2.7
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
修改脚本解释器rm /bin/sh
ln -s /bin/bash /bin/sh
配置user环境
cd ~
touch .bash_history
touch .bash_logout
这两个文件从源主机上拷贝
.profile
.bashrc
将以下环境变量添加到.bashrc# set PATH so it includes user's private bin directories
export PATH=~/.local/bin:$PATH
export ARMLMD_LICENSE_FILE=/pkg/qct/software/arm/RVDS/5.01bld94/license.dat
export HEXAGON_ROOT=$HOME/Qualcomm/HEXAGON_Tools
export LANG="zh_CN.UTF-8"
export LANGUAGE="zh_CN:zh:en_US:en"
export LC_NUMERIC="zh_CN.UTF-8"
export LC_TIME="zh_CN.UTF-8"
export LC_MONETARY="zh_CN.UTF-8"
export LC_PAPER="zh_CN.UTF-8"
export LC_IDENTIFICATION="zh_CN.UTF-8"
export LC_NAME="zh_CN.UTF-8"
export LC_ADDRESS="zh_CN.UTF-8"
export LC_TELEPHONE="zh_CN.UTF-8"
export LC_MEASUREMENT="zh_CN.UTF-8"
标签:bin,zh,CN,16.04,22.04,usr,Ubuntu,UTF,LC From: https://www.cnblogs.com/pypyn/p/18383981