# SYE setup in Ansible playbook # SYSTEM PACKAGES INSTALLATION - name: Install all DNF dependencies on Fedora tags: s3,sye become: true when: ansible_facts['os_family'] == "RedHat" ansible.builtin.dnf: name: - pkg-config - bridge-utils - elfutils - uboot-tools - dtc - libfdisk - ncurses-devel - arm-none-eabi-gcc-cs - bison - flex - qemu-system-arm - qemu-system-aarch64 - cmake - gcc # for user space programs in SO3 ? - ncurses-compat-libs.x86_64 # for debug - tar # for python 2.7 installation - xz # for python 2.7 installation - net-tools # for scripts/qemu-ifup.sh - dnsmasq # for scripts/qemu-ifup.sh - iptables # for scripts/qemu-ifup.sh - dosfstools # mkfs.vfat: command not found - e2fsprogs # mkfs.ext4: command not found - bc # for sr.fish - wget # for code bridge on WSL - mtools # mcopy: command not found - file # for python compilation - gdb # for debugging in 2025 setup as a replacement for gdb-multiarch - name: Enable i386 architecture on Ubuntu tags: s3,sye become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.command: dpkg --add-architecture i386 - name: Install all APT dependencies on Ubuntu tags: s3,sye become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.apt: update_cache: true # run apt update before name: - libc6:i386 - libstdc++6:i386 - lib32z1-dev - zlib1g:i386 - pkg-config - libgtk2.0-dev - bridge-utils - mtools - unzip - bc - elfutils - u-boot-tools - device-tree-compiler - fdisk - libncurses-dev - bison - flex - gcc-arm-none-eabi - qemu-system - qemu-system-arm - build-essential - cmake - net-tools - dnsmasq - wget - iptables - dosfstools - gdb-multiarch # as the way to debug in 2025 - python3-debian # necessary for next task # Not available anymore in Ubuntu 24.04 # libncurses5 # taked from old focal-security registry # libpython2.7 # compiled from source # Note: libncurses5 is not available anymore, this may be a temporary solution # echo "deb http://security.ubuntu.com/ubuntu focal-security main universe" | sudo tee /etc/apt/sources.list.d/ubuntu-focal-sources.list - name: Add debian repo for focal-security to get the old package libncurses5 become: true tags: s3,sye when: ansible_facts['os_family'] == "Debian" deb822_repository: name: ubuntu-focal-sources uris: http://security.ubuntu.com/ubuntu suites: focal-security components: - main - universe - name: Install the old version of libncurses5 on Ubuntu tags: s3,sye become: true when: ansible_facts['os_family'] == "Debian" ansible.builtin.apt: update_cache: true # run apt update before name: libncurses5 # COMPILEDB installation - name: Install compiledb via pipx to generate compile_commands.json for kernel folder tags: s3,sye community.general.pipx: name: compiledb # SR.fish installation - name: Install sr.fish via lxup tags: s3,sye ansible.builtin.command: fish -c 'lxup get sr' # Do not make it idempotent to augment the probability people have the latest version # TODO: enable this later when lxup update exists # args: # creates: "~/.config/fish/functions/sr.fish" # # # OLD toolchain and Python 2.7 installation that is completely useless # It's possible that this was actually never necessary in pre-2025 versions and that gdb on Fedora works fine but that Ubuntu requires the gdb-multiarch... # I automated this installation because this is what I found in the VM and didn't know that gdb-multiarch would work on Ubuntu # I have a vague memory that "gdb" was working on Fedora and I couldn't understand why... # # INSTALL DEBUG TOOLCHAIN # - name: Download and setup debug toolchain via sye.debug.sh script # tags: s3,sye # become: true # because some commands are touching /opt/toolchains # ansible.builtin.command: bash ./s3/sye.debug.sh # args: # creates: /opt/toolchains/arm-linux-gnueabihf_6.4.1 # # # TODO: only if python 2.7 not already installed !! # - name: Download and compile Python 2.7 to support debug # tags: s3,sye # ansible.builtin.shell: # cmd: | # cd /tmp # PYTHON_VERSION=2.7.18 # DEST=/opt/python/2.7 # curl -LO "https://www.python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tgz" # tar xzf Python-$PYTHON_VERSION.tgz # cd Python-$PYTHON_VERSION # # Note: this CFLAGS="-std=gnu99" is necessary because some C++23 have defined true and false keywords, which is failing the build # # This answer was suggested by GPT4.1 # env CFLAGS="-std=gnu99" ./configure --prefix=$DEST --enable-shared --enable-unicode=ucs4 # make -j 10 PROFILE_TASK="" CFLAGS="-std=gnu99" # args: # creates: /opt/python/2.7/lib/libpython2.7.so.1.0 # # - name: Install Python 2.7 under /opt/python/2.7 to support debug # tags: s3,sye # become: true # because we are touching /opt/ # ansible.builtin.shell: # cmd: | # PYTHON_VERSION=2.7.18 # cd /tmp/Python-$PYTHON_VERSION # make altinstall # args: # creates: /opt/python/2.7/lib/libpython2.7.so.1.0 # # # NOTE: make sure this is your shell config # # Bash # # export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/python/2.7/lib # # Fish # # set -gax LD_LIBRARY_PATH /opt/python/2.7/lib # # # SO3 EXECUTION VERIFICATION - name: Make sure SO3 can be compiled with sye_student repository and can run "ls" inside SO3 via sr tags: s3,sye ansible.builtin.shell: cmd: | rm -rf /tmp/sye_student &> /dev/null cd /tmp # TODO: change the repository here each year ?? git clone --depth 1 https://reds-gitlab.heig-vd.ch/reds-public/sye25 && cd sye25 make init # the new 2025 version needs this ! make | grep "Compilation done" # search for this message to validate the compilation works, make's exit code are not reliable # the lab03 branch don't exist at the start of the semester, only master does if git checkout lab03 &>/dev/null; then fish -c 'sr "echo hey there" "ls"' > out grep cat.elf out && echo -e "\n\nSO3 is working !!" else # otherwise, we need to check if the panic can be seen, it means SO3 is actually starting (with a kernal panic as the expected state of the lab1) fish -c 'sr "echo hey there" "ls"' &> out grep "kernel_panic: entering infinite loop" out &> /dev/null && echo "SO3 is working in Qemu !" fi echo Testing the export of compile_commands.json ~/.local/bin/compiledb make &> /dev/null test -f compile_commands.json cd usr && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -B build && cd .. test -f usr/build/compile_commands.json echo "Seems to be all good !!" args: creates: "/tmp/sye_student/so3/so3.bin" # This will run too much times if we rebooted in the meantime and we lost the /tmp content...