starfive-tech / VisionFive2

445 stars 79 forks source link

trying to buildroot with fedora silverblue podman container with ubuntu 20.04 focal #21

Open omac777 opened 1 year ago

omac777 commented 1 year ago

Running within Fedora Silverblue 37, I attempted to build the VF2(visionfive 2) image from within a podman ubuntu 20.04(focal) container rather than from straight ubuntu focal. Unfortunately, I have not been able to successfully repeat the build to get all the described VF2 build binaries and images and such with the steps described below.

  1. fetch ubuntu 20.04 focal container

podman pull ubuntu:focal-20221130

  1. create a directory to share data between the container and the host fedora silverblue 37

mkdir -p /mnt/vf2share

  1. start ubuntu 20.04 focal container
podman run -v ~/vf2share:/mnt/vf2share --net host -i -t ubuntu:focal-20221130 /bin/bash
#Later we'll start it like this after it has been committed
podman run -v /var/home/davidm/vf2share:/mnt/vf2share:Z --net host -i -t ubuntu-vf2-buildr /bin/bash
  1. issues with group and owner in the build.
    tar: Makefile.in: Cannot change ownership to uid 71588, gid 10513: Invalid argument
    tar: README: Cannot change ownership to uid 71588, gid 10513: Invalid argument
    tar: Exiting with failure status due to previous errors

    Attempted to resolve them with this alias, but did nothing to help. There are a lot of instances of "am__untar" holding tar commands. I can't possibly ask for a change request for this many files just to run this in a container. Don't most CI systems use containers to build stuff? Are there other devs here experiencing such issues or you resort to running native os in order to do this kind of work always? The tar flag in question to resolve all this is "--no-same-owner" but it has to be applied everywhere consistently. alias tar='tar --no-same-owner'

Inside ubuntu 20.04 focal container

  1. create the vf2 prep directory
mkdir visionfive2prep
cd visionfive2prep/
  1. install required build packages
apt update
apt-get install curl
apt-get install git-lfs
apt-get install build-essential g++ git autoconf automake autotools-dev texinfo bison xxd curl flex gawk gdisk gperf libgmp-dev libmpfr-dev libmpc-dev libz-dev libssl-dev libncurses-dev libtool patchutils python screen texinfo unzip zlib1g-dev libyaml-dev wget cpio bc dosfstools mtools device-tree-compiler libglib2.0-dev libpixman-1-dev kpartx
apt-get install rsync
apt-get install kmod
apt-get install time
apt-get install emacs-nox
  1. finish configuring git-lfs
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh -o script.deb.sh
sudo bash ./script.deb.sh

 

  1. clone the vf2 repo

git clone https://github.com/starfive-tech/VisionFive2.git

  1. changed directory to within vf2

cd VisionFive2

  1. modify the .gitmodules file to point to https url.
cat .gitmodules 
[submodule "buildroot"]
    path = buildroot
    url = https://github.com/starfive-tech/buildroot.git
    branch = JH7110_VisionFive2_devel
[submodule "u-boot"]
    path = u-boot
    url = https://github.com/starfive-tech/u-boot.git
    branch = JH7110_VisionFive2_devel
[submodule "linux"]
    path = linux
    url = https://github.com/starfive-tech/linux.git
    branch = JH7110_VisionFive2_devel
[submodule "opensbi"]
    path = opensbi
    url = https://github.com/starfive-tech/opensbi.git
    branch = master
  1. modify conf/buildroot_initramfs_config and conf/buildroot_rootfs_config to have the same https url

BR2_KERNEL_HEADERS_CUSTOM_REPO_URL="https://github.com/starfive-tech/linux.git"  

  1. Now checkout and submodule update
cd VisionFive2
git checkout JH7110_VisionFive2_devel
git submodule update --init --recursive
  1. Ensure we checkout on the label JH7110_VisionFive2_devel for all except opensbi
cd buildroot && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
cd u-boot && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
cd linux && git checkout --track origin/JH7110_VisionFive2_devel && cd ..
cd opensbi && git checkout master && cd ..
cd soft_3rdpart && git checkout JH7110_VisionFive2_devel && cd ..

 

  1. I used an emacs shell with no color enabled to capture the build output for discussing with other developers. You can use whatever you want.
emacs -nw --color=no
#alt-x shell
  1. Now start the build of everything
time make -j$(nproc)
# or 
time make -j$(nproc) all

FINISHED ubuntu 20.04 focal container

  1. pause podman container

ctrl-p ctrl-q  

  1. list podman containers

podman ps

Output will contain: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 8c35f4187b36 docker.io/library/ubuntu:focal-20221130 /bin/bash 2 hours ago Up 2 hours ago admiring_wescoff

  1. save all our actions and name the container

podman commit 8c35f4187b36 ubuntu-vf2-buildr   attach back into the running session

podman attach ubuntu-vf2-buildr

exit the container

exit

kill any running containers

podman kill 8c35f4187b36   next time you want to use this container:

podman run -v /var/home/davidm/vf2share:/mnt/vf2share:Z --net host -i -t ubuntu-vf2-buildr /bin/bash

Thank you in advance for any help on these matters. Cheers.

akgnah commented 1 year ago

Please refer https://github.com/containers/podman/blob/main/docs/tutorials/rootless_tutorial.md#etcsubuid-and-etcsubgid-configuration to configure your subuid and subgid.