Add custom sysroot for arm

This commit is contained in:
Alexey Nagaev
2025-07-08 18:34:40 +03:00
parent 67c454b469
commit d1481021a7
4 changed files with 123 additions and 2 deletions

View File

@ -0,0 +1,54 @@
#!/usr/bin/env python
import sys
sys.path.append('../../../scripts')
import base
import os
import shutil
def bash_chroot(command, sysroot):
base.cmd2('sudo -S chroot', [sysroot, '/bin/bash -c', '\"' + command + ' \"'])
def download_sysroot():
curr_dir = base.get_script_dir(__file__)
tmp_sysroot_ubuntu_dir = curr_dir + '/sysroot_ubuntu_1604'
dst_sysroot_ubuntu_dir = curr_dir + '/../../../../sysroot_ubuntu_1604'
if os.path.isdir(tmp_sysroot_ubuntu_dir):
shutil.rmtree(tmp_sysroot_ubuntu_dir)
# debootstrap for downloading sysroot
base.cmd2('sudo -S apt-get', ['install', 'debootstrap'])
archive_ubuntu_url = 'http://archive.ubuntu.com/ubuntu/'
base.cmd2('sudo -S debootstrap', ['--arch=amd64', 'xenial', tmp_sysroot_ubuntu_dir, archive_ubuntu_url])
# setup a new sources
base.cmd2('sudo -S cp', [curr_dir + '/sources.list', tmp_sysroot_ubuntu_dir + '/etc/apt/sources.list'])
bash_chroot('apt update -y', tmp_sysroot_ubuntu_dir)
bash_chroot('apt upgrade -y', tmp_sysroot_ubuntu_dir)
bash_chroot('apt install -y build-essential curl libpthread-stubs0-dev zlib1g-dev', tmp_sysroot_ubuntu_dir)
# fix link to a libdl
bash_chroot('rm /usr/lib/x86_64-linux-gnu/libdl.so', tmp_sysroot_ubuntu_dir)
bash_chroot('ln -s /lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/x86_64-linux-gnu/libdl.so', tmp_sysroot_ubuntu_dir)
# # downloading arm toolchain
arm_toolchain_url = 'https://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/aarch64-linux-gnu/'
arm_toolchain_tar_filename = 'gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu.tar.xz'
arm_toolchain_output_dir = 'gcc-linaro-5.3.1-2016.05-x86_64_aarch64-linux-gnu'
base.cmd2('wget', [arm_toolchain_url + arm_toolchain_tar_filename])
base.cmd2('tar', ['-xf', arm_toolchain_tar_filename])
base.cmd2('sudo -S rsync', ['-avh', '--progress', curr_dir + '/' + arm_toolchain_output_dir + '/', tmp_sysroot_ubuntu_dir + '/usr/'])
shutil.rmtree(arm_toolchain_output_dir)
os.remove(arm_toolchain_tar_filename)
base.cmd2('sudo -S mv', [tmp_sysroot_ubuntu_dir + '/', dst_sysroot_ubuntu_dir + '/'])
base.cmd2('sudo -S chmod', ['-R', 'u+rwx', dst_sysroot_ubuntu_dir])
return
if __name__ == '__main__':
download_sysroot()

View File

@ -0,0 +1,51 @@
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu xenial partner
# deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse