Skip to content

Commit

Permalink
Toolkit: provide mechanism to auto-install build deps (microsoft#11081)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcilvaney authored Feb 12, 2025
1 parent 8cb3ed2 commit 1a4d090
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 53 deletions.
34 changes: 4 additions & 30 deletions toolkit/docs/building/prerequisites-mariner.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,10 @@ This page lists host machine requirements for building with the Azure Linux tool

```bash
# Install required dependencies.
# Recommended but not required: `pigz` for faster compression operations.
sudo tdnf -y install \
acl \
binutils \
cdrkit \
curl \
diffutils \
dosfstools \
gawk \
glibc-devel \
genisoimage \
git \
golang \
jq \
kernel-headers \
make \
moby-cli \
moby-engine \
openssl \
parted \
pigz \
qemu-img \
rpm \
rpm-build \
sudo \
systemd \
tar \
wget \
xfsprogs \
zstd
sudo ./toolkit/docs/building/prerequisites-mariner.sh

# Also supported is:
# make -C toolkit install-prereqs

# Enable Docker daemon at boot
sudo systemctl enable --now docker.service
Expand Down
45 changes: 45 additions & 0 deletions toolkit/docs/building/prerequisites-mariner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

set -e

tdnf -y install \
acl \
binutils \
cdrkit \
curl \
diffutils \
dosfstools \
gawk \
genisoimage \
git \
glibc-devel \
golang \
jq \
kernel-headers \
make \
moby-cli \
moby-engine \
openssl \
parted \
pigz \
qemu-img \
rpm \
rpm-build \
sudo \
systemd \
tar \
wget \
xfsprogs \
zstd

script_file=$(readlink -f "$0")
# md file is the same name as the script file, but with a .md extension
md_file="${script_file%.*}.md"

echo ""
echo "Install complete..."
echo ""
echo "**** Refer to ${md_file} for additional steps to complete the setup. ****"
echo ""
27 changes: 4 additions & 23 deletions toolkit/docs/building/prerequisites-ubuntu.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,11 @@
This page lists host machine requirements for building with the Azure Linux toolkit. They cover building the toolchain, packages, and images on an Ubuntu 22.04 host.

```bash
sudo apt-get update

# Install required dependencies.
# Recommended but not required: `pigz` for faster compression operations.
sudo apt -y install \
acl \
curl \
diffutils \
gawk \
genisoimage \
git \
golang-1.21-go \
jq \
make \
parted \
pigz \
openssl \
systemd \
qemu-utils \
rpm \
tar \
wget \
xfsprogs \
zstd
sudo ./toolkit/docs/building/prerequisites-ubuntu.sh

# Also supported is:
# make -C toolkit install-prereqs

# Fix go 1.21 link
sudo ln -vsf /usr/lib/go-1.21/bin/go /usr/bin/go
Expand Down
35 changes: 35 additions & 0 deletions toolkit/docs/building/prerequisites-ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

set -e

apt update
apt install -y \
acl \
curl \
diffutils \
gawk \
genisoimage \
git \
golang-1.21-go \
jq \
make \
openssl \
parted \
pigz \
qemu-utils \
rpm \
systemd \
tar \
wget \
xfsprogs \
zstd

script_file=$(readlink -f "$0")
# md file is the same name as the script file, but with a .md extension
md_file="${script_file%.*}.md"

echo ""
echo "**** Refer to ${md_file} for additional steps to complete the setup. ****"
echo ""
15 changes: 15 additions & 0 deletions toolkit/scripts/toolkit.mk
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,18 @@ $(valid_arch_spec_names): $(go-specarchchecker) $(chroot_worker) $(local_specs)
--log-level=$(LOG_LEVEL) \
--log-file="$(valid_arch_spec_names_logs_path)" \
--log-color="$(LOG_COLOR)"

##help:target:install-prereqs=Install build prerequisites automatically.
install-prereqs:
echo "Installing build prerequisites for AzureLinux..." && \
current_os=$$(grep '^ID=' /etc/os-release | cut -d'=' -f2-) && \
echo "Current OS: $$current_os" && \
if [ "$$current_os" = "mariner" ] || [ "$$current_os" = "azurelinux" ]; then \
scriptfile="$(toolkit_root)/docs/building/prerequisites-mariner.sh" ; \
elif [ "$$current_os" = "ubuntu" ]; then \
scriptfile="$(toolkit_root)/docs/building/prerequisites-ubuntu.sh" ; \
else \
$(call print_error,"Unsupported OS: $$current_os") ; \
fi && \
"$$scriptfile" || \
$(call print_error,Install failed)

0 comments on commit 1a4d090

Please sign in to comment.