构建ubuntu-rootfs / ARM32上安装 Python的第三方软件包

1 Prepare the environment needed

On Another Linux system (such as Ubuntu , x86 or x64)

# apt-get install qemu-user-static
# wget http://cdimage.ubuntu.com/ubuntu-base/releases/16.04.1/release/ubuntu-base-16.04.1-base-armhf.tar.gz
# mkdir ubuntu-rootfs
# tar xvf ubuntu-base-16.04.1-base-armhf.tar.gz -C ubuntu-rootfs
# cp /usr/bin/qemu-arm-static ubuntu-rootfs/usr/bin
# cp /etc/resolv.conf ubuntu-rootfs/etc/resolv.conf
# touch ch-mount.sh
# chmod +x ch-mount.sh

Add Following content to ch-mount.sh

#!/bin/bash
function mnt() {
        echo "MOUNTING"
        sudo mount -t proc /proc ${2}/proc
        sudo mount -t sysfs /sys ${2}/sys
        sudo mount -o bind /dev ${2}/dev
        sudo mount -o bind /dev/pts ${2}/dev/pts
        sudo chroot ${2}
}
function umnt() {
        echo "UNMOUNTING"
        sudo umount ${2}/proc
        sudo umount ${2}/sys
        sudo umount ${2}/dev/pts
        sudo umount ${2}/dev
}

if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
        mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
        umnt $1 $2
else
        echo "Either 1'st, 2'nd or both parameters were missing"
        echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
        echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
        echo "For example: ch-mount -m /media/sdcard/"
        echo 1st parameter : ${1}
        echo 2nd parameter : ${2}
fi

2 setup python3.6.8 to ubuntu-rootfs

# tar xvf python3.6.8.tar.gz -C ubuntu-rootfs/home
# echo "export PATH=\$PATH:/home/python3.6.8/bin" >> ubuntu-rootfs/etc/profile
# echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/home/python3.6.8/lib" >> ubuntu-rootfs/etc/profile
# cp ubuntu-rootfs/home/python3.6.8/lib/libpython3*  ubuntu-rootfs/usr/lib/ -ad

3 chroot to armhf and install python packages

# ./ch-mount.sh -m ubuntu-rootfs/
# uname -a 
Linux advantech-machine 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 armv7l armv7l armv7l GNU/Linux

# apt-get update
# apt-get install vim gcc g++ build-essential libssl-dev

# source /etc/profile
# python3 /home/python3.6.8/share/get-pip.py


If failed, execute the following command:

# python3 /home/python3.6.8/share/get-pip.py -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com


# pip3 install sysv-ipc -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

4 copy the python package to gateway

# exit
# ./ch-mount.sh -u ubuntu-rootfs/

# cd ubuntu-rootfs/home
# tar zcvf python3.6.8.tar.gz python3.6.8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值