microsoft / azurelinux

Linux OS for Azure 1P services and edge appliances
MIT License
4.13k stars 510 forks source link

Problem building CBL-Mariner on arch linux running on WSL-2 #6801

Open mwoodpatrick opened 9 months ago

mwoodpatrick commented 9 months ago

Describe the bug When Building Mariner on Debian or Arch Linux running on WSL-2

sudo make iso REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/full.json
/mnt/wsl/projects/git/CBL-Mariner/toolkit/tools/pkggen/worker/create_worker_chroot.sh /mnt/wsl/projects/git/CBL-Mariner/build/worker /mnt/wsl/projects/git/CBL-Mariner/toolkit/resources/manifests/package/pkggen_core_x86_64.txt /mnt/wsl/projects/git/CBL-Mariner/build/toolchain_rpms /mnt/wsl/projects/git/CBL-Mariner/build/logs
mkdir: created directory '/mnt/wsl/projects/git/CBL-Mariner/build/worker/worker_chroot/dev'
Adding RPM to worker chroot: filesystem-1.1-17.cm2.x86_64.rpm.
make: *** [/mnt/wsl/projects/git/CBL-Mariner/toolkit/scripts/chroot.mk:48: /mnt/wsl/projects/git/CBL-Mariner/build/worker/worker_chroot.tar.gz] Error 127

To Reproduce

  1. cd $GIT_ROOT/
  2. git clone https://github.com/mwoodpatrick/CBL-Mariner.git
  3. cd $GIT_ROOT/CBL-Mariner/toolkit
  4. sudo make iso REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/full.json

Expected behavior Build completes normally.

christopherco commented 9 months ago

Hi @mwoodpatrick we currently only have official support for building Mariner on Mariner 2.0 or Ubuntu 22.04 - https://github.com/microsoft/CBL-Mariner/blob/2.0/toolkit/docs/building/prerequisites.md

All other environments are currently YMMV at this time, but we are interested in expanding the starting development environments.

elsaco commented 9 months ago

@mwoodpatrick there are some differences in installing the prerequisites on Arch. rpm is part of rpm-tools package, genisoimage is part of cdrtools . mkdosfs package must be installed also. The WSL Arch instance was created from the rootfs provided by @yuk7 at https://github.com/yuk7/ArchWSL/releases/download/22.10.16.0/Arch.zip

However, the build fails with Bad Option '-e' (error -1 BADFLAG) as mkisofs provided by Arch has no -e flag option.

[tux@RIPPER toolkit]$ sudo make iso REBUILD_TOOLS=y REBUILD_PACKAGES=n CONFIG_FILE=./imageconfigs/full.json
/home/tux/CBL-Mariner/toolkit/out/tools/isomaker \
        --base-dir ./imageconfigs/ \
        --build-dir /home/tux/CBL-Mariner/build/imagegen/full/workspace \
        --initrd-path /home/tux/CBL-Mariner/out/images/iso_initrd/iso-initrd.img \
        --input ./imageconfigs/full.json \
        --release-version 2.0.20231123.1101 \
        --resources /home/tux/CBL-Mariner/toolkit/resources \
        --iso-repo /home/tux/CBL-Mariner/build/imagegen/full/package_repo \
        --log-level=info \
        --log-file=/home/tux/CBL-Mariner/build/logs/imggen/isomaker.log \
         \
        --output-dir /home/tux/CBL-Mariner/out/images/full \
        --image-tag=
INFO[0000][isomaker] Building ISO under '/home/tux/CBL-Mariner/build/imagegen/full/workspace'.
WARN[0000][isomaker] Unexpected: temporary ISO build path '/home/tux/CBL-Mariner/build/imagegen/full/workspace' exists. Removing.
INFO[0001][isomaker] Preparing ISO's bootloaders.
WARN[0001][isomaker] 3+0 records in
WARN[0001][isomaker] 3+0 records out
WARN[0001][isomaker] 3145728 bytes (3.1 MB, 3.0 MiB) copied, 0.00171763 s, 1.8 GB/s
INFO[0002][isomaker] Generating ISO image under '/home/tux/CBL-Mariner/out/images/full/full-2.0.20231123.1101.iso'.
WARN[0002][isomaker] Bad Option '-e' (error -1 BADFLAG).
WARN[0002][isomaker] Usage: mkisofs [options] [-find] file... [find expression]
WARN[0002][isomaker]
WARN[0002][isomaker] Use mkisofs -help
WARN[0002][isomaker] to get a list all of valid options.
WARN[0002][isomaker]
WARN[0002][isomaker] Use mkisofs -find -help
WARN[0002][isomaker] to get a list of all valid -find options.
WARN[0002][isomaker]
WARN[0002][isomaker] Most important Options:
WARN[0002][isomaker]    -posix-H                Follow sylinks encountered on command line
WARN[0002][isomaker]    -posix-L                Follow all symlinks
WARN[0002][isomaker]    -posix-P                Do not follow symlinks (default)
WARN[0002][isomaker]    -o FILE, -output FILE   Set output file name
WARN[0002][isomaker]    -R, -rock               Generate Rock Ridge directory information
WARN[0002][isomaker]    -r, -rational-rock      Generate rationalized Rock Ridge directory info
WARN[0002][isomaker]    -J, -joliet             Generate Joliet directory information
WARN[0002][isomaker]    -print-size             Print estimated filesystem size and exit
WARN[0002][isomaker]    -UDF                    Generate UDF file system
WARN[0002][isomaker]    -dvd-audio              Generate DVD-Audio compliant UDF file system
WARN[0002][isomaker]    -dvd-video              Generate DVD-Video compliant UDF file system
WARN[0002][isomaker]    -dvd-hybrid             Generate a hybrid (DVD-Audio/DVD-Video) compliant UDF file system
WARN[0002][isomaker]    -iso-level LEVEL        Set ISO9660 level (1..3) or 4 for ISO9660 v 2
WARN[0002][isomaker]    -V ID, -volid ID        Set Volume ID
WARN[0002][isomaker]    -graft-points           Allow to use graft points for filenames
WARN[0002][isomaker]    -M FILE, -prev-session FILE     Set path to previous session to merge
PANI[0002][isomaker] Command 'mkisofs' failed with error: exit status 255
panic: (*logrus.Entry) 0xc0000b90a0
elsaco commented 9 months ago

Changing the flag at https://github.com/microsoft/CBL-Mariner/blob/7f380c5cac930ca91d33e8a6874f6509fb69743d/toolkit/tools/isomaker/maker.go#L105 from -e to -b the build finishes w/out errors. The new ISO image boots okay under hyper-v:

tux@marinerTest [ ~ ]$ sudo dmesg | grep -i uefi
[    0.000000] DMI: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.0 11/01/2019
tux@marinerTest [ ~ ]$ sudo dmesg | grep -i secure
[    0.000416] Secure boot enabled
[    1.175976] Loaded X.509 cert 'Microsoft Corporation: Mariner Secure Boot(Production Signing): b42d6b9e2809b7b9097cff9e9b0194b86e80bf95'
tux@marinerTest [ ~ ]$ cat /etc/os-release
NAME="Common Base Linux Mariner"
VERSION="2.0.20231115"
ID=mariner
VERSION_ID="2.0"
PRETTY_NAME="CBL-Mariner/Linux"
ANSI_COLOR="1;34"
HOME_URL="https://aka.ms/cbl-mariner"
BUG_REPORT_URL="https://aka.ms/cbl-mariner"
SUPPORT_URL="https://aka.ms/cbl-mariner"

So, yes, CBL-Mariner ISO can be build on WSL ArchLinux,