Skip to content

Toolkit: provide mechanism to auto-install build deps #11081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with there being a make target here too, but can we have an even simpler entry point that doesn't even count on make being installed? In other words, if we placed this logic (including the distro detection) in a simple install-prereqs.sh script in an easy-to-find place in the repo, then it would be runnable with only bash and the OS's native package manager. That's a bit closer to what I'm accustomed to seeing in other projects.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Loading