Skip to content

Commit bb7f723

Browse files
authored
Initial azure-linux-image-tools as a new rpm from SPEC. (microsoft#14360)
1 parent 8c3f159 commit bb7f723

File tree

9 files changed

+289
-1
lines changed

9 files changed

+289
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
ARG BASE_IMAGE
5+
ARG TARGETARCH
6+
ARG AZ_MON_CONN_STR
7+
8+
FROM $BASE_IMAGE
9+
10+
ENV AZURE_MONITOR_CONNECTION_STRING=${AZ_MON_CONN_STR}
11+
12+
@INCLUDE_MAIN_RUN_INSTRUCTION@
13+
14+
RUN tdnf update -y && \
15+
tdnf install -y azurelinux-repos-cloud-native && \
16+
tdnf update -y && \
17+
tdnf install -y oras && \
18+
if [ "$TARGETARCH" = "amd64" ]; then \
19+
echo "Installing AMD64-specific packages..."; \
20+
tdnf install -y grub2-pc systemd-ukify; \
21+
else \
22+
echo "Skipping AMD64-specific packages for $TARGETARCH"; \
23+
fi && \
24+
tdnf clean all
25+
26+
# Create virtual environment and install Python dependencies for telemetry
27+
RUN python3 -m venv /opt/telemetry-venv
28+
RUN /opt/telemetry-venv/bin/pip install --no-cache-dir -r /imagecustomizer-telemetry-requirements.txt
29+
30+
ENTRYPOINT ["/usr/local/bin/imagecustomizer-entrypoint.sh"]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
imagecustomizer
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
qemu-img
2+
rpm
3+
coreutils
4+
util-linux
5+
systemd
6+
openssl
7+
sed
8+
createrepo_c
9+
squashfs-tools
10+
cdrkit
11+
parted
12+
e2fsprogs
13+
dosfstools
14+
xfsprogs
15+
zstd
16+
veritysetup
17+
grub2
18+
binutils
19+
lsof
20+
python3
21+
python3-pip
22+
jq
23+
azurelinux-image-tools-imagecustomizer

LICENSES-AND-NOTICES/SPECS/LICENSES-MAP.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSES-AND-NOTICES/SPECS/data/licenses.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,7 @@
22442244
"azure-iot-sdk-c",
22452245
"azure-nvme-utils",
22462246
"azure-storage-cpp",
2247+
"azurelinux-image-tools",
22472248
"azurelinux-release",
22482249
"azurelinux-repos",
22492250
"azurelinux-rpm-macros",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"Signatures": {
3+
"azurelinux-image-tools-0.18.0.tar.gz": "dc0a167cbce8164f1a051abde165a575d411774cc65020bd39d6dfe0bb120064",
4+
"azurelinux-image-tools-0.18.0-vendor.tar.gz": "6fadff7d823a97658704183f028ecc94e9725fe3ffcba1e4eb48c2d291c184da"
5+
}
6+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
%define our_gopath %{_topdir}/.gopath
2+
3+
Summary: Azure Linux Image Tools
4+
Name: azurelinux-image-tools
5+
Version: 0.18.0
6+
Release: 1%{?dist}
7+
License: MIT
8+
URL: https://github.com/microsoft/azure-linux-image-tools/
9+
Group: Applications/System
10+
Vendor: Microsoft Corporation
11+
Distribution: Azure Linux
12+
Source0: https://github.com/microsoft/azure-linux-image-tools/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
13+
# Below is a manually created tarball, no download link.
14+
# We're using pre-populated Go modules from this tarball, since network is disabled during build time.
15+
# Use generate_source_tarball.sh script with the package version to build this tarball.
16+
#
17+
Source1: %{name}-%{version}-vendor.tar.gz
18+
BuildRequires: golang >= 1.24.1
19+
BuildRequires: systemd-udev
20+
Requires: %{name}-imagecustomizer = %{version}-%{release}
21+
22+
%description
23+
Azure Linux Image Tools. This package provides the Azure Linux Image Customizer tool
24+
and its dependencies for customizing Azure Linux images.
25+
26+
%package imagecustomizer
27+
Summary: Image Customizer
28+
Requires: qemu-img
29+
Requires: rpm
30+
Requires: coreutils
31+
Requires: util-linux
32+
Requires: systemd
33+
Requires: openssl
34+
Requires: sed
35+
Requires: createrepo_c
36+
Requires: squashfs-tools
37+
Requires: cdrkit
38+
Requires: parted
39+
Requires: e2fsprogs
40+
Requires: dosfstools
41+
Requires: xfsprogs
42+
Requires: zstd
43+
Requires: veritysetup
44+
Requires: grub2
45+
Requires: binutils
46+
Requires: lsof
47+
Requires: python3
48+
Requires: python3-pip
49+
Requires: jq
50+
%ifarch x86_64
51+
Requires: grub2-pc
52+
Requires: systemd-ukify
53+
%endif
54+
55+
%description imagecustomizer
56+
The Azure Linux Image Customizer is a tool that can take an
57+
existing generic Azure Linux image and modify it to be suited for a particular
58+
scenario. By providing an Azure Linux base image, users can also supply a config
59+
file specifying how they want the image to be customized. For example, this
60+
could include the installation of certain RPMs, updating the SELinux mode, and
61+
enabling DM-Verity.
62+
63+
%prep
64+
%autosetup -p1 -n azure-linux-image-tools-%{version}
65+
tar -xf %{SOURCE1} --no-same-owner -C toolkit/tools
66+
67+
%build
68+
export GOPATH=%{our_gopath}
69+
export GOFLAGS="-mod=vendor"
70+
make -C toolkit go-imagecustomizer REBUILD_TOOLS=y SKIP_LICENSE_SCAN=y
71+
72+
%install
73+
mkdir -p %{buildroot}%{_bindir}
74+
install -p -m 0755 toolkit/out/tools/imagecustomizer %{buildroot}%{_bindir}/imagecustomizer
75+
76+
# Install container support files for imagecustomizer subpackage
77+
# These files are used when building the imagecustomizer container
78+
mkdir -p %{buildroot}/usr/local/bin
79+
mkdir -p %{buildroot}/
80+
81+
# Copy container scripts from their source locations to container paths
82+
install -p -m 0755 toolkit/tools/imagecustomizer/container/entrypoint.sh %{buildroot}/usr/local/bin/imagecustomizer-entrypoint.sh
83+
install -p -m 0755 toolkit/tools/imagecustomizer/container/run.sh %{buildroot}/usr/local/bin/imagecustomizer-run.sh
84+
install -p -m 0755 toolkit/scripts/telemetry_hopper/telemetry_hopper.py %{buildroot}/usr/local/bin/telemetry_hopper.py
85+
install -p -m 0644 toolkit/scripts/telemetry_hopper/requirements.txt %{buildroot}/imagecustomizer-telemetry-requirements.txt
86+
87+
%check
88+
go test -C toolkit/tools ./...
89+
90+
%files
91+
92+
%files imagecustomizer
93+
%license LICENSE
94+
%{_bindir}/imagecustomizer
95+
# Container support files - placed in container filesystem paths with imagecustomizer- prefix
96+
/usr/local/bin/imagecustomizer-entrypoint.sh
97+
/usr/local/bin/imagecustomizer-run.sh
98+
/usr/local/bin/telemetry_hopper.py
99+
/imagecustomizer-telemetry-requirements.txt
100+
101+
%changelog
102+
* Wed Aug 20 2025 Lanze Liu <[email protected]> 0.18.0-1
103+
- Original version for Azure Linux (license: MIT).
104+
- License verified.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/bin/bash
2+
# Copyright (c) Microsoft Corporation.
3+
# Licensed under the MIT License.
4+
5+
# Quit on failure
6+
set -e
7+
8+
PKG_VERSION=""
9+
SRC_TARBALL=""
10+
OUT_FOLDER="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
11+
12+
# parameters:
13+
#
14+
# --srcTarball : src tarball file
15+
# this file contains the 'initial' source code of the component
16+
# and should be replaced with the new/modified src code
17+
# --outFolder : folder where to copy the new tarball(s)
18+
# --pkgVersion : package version
19+
#
20+
PARAMS=""
21+
while (( "$#" )); do
22+
case "$1" in
23+
--srcTarball)
24+
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
25+
SRC_TARBALL=$2
26+
shift 2
27+
else
28+
echo "Error: Argument for $1 is missing" >&2
29+
exit 1
30+
fi
31+
;;
32+
--outFolder)
33+
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
34+
OUT_FOLDER=$2
35+
shift 2
36+
else
37+
echo "Error: Argument for $1 is missing" >&2
38+
exit 1
39+
fi
40+
;;
41+
--pkgVersion)
42+
if [ -n "$2" ] && [ ${2:0:1} != "-" ]; then
43+
PKG_VERSION=$2
44+
shift 2
45+
else
46+
echo "Error: Argument for $1 is missing" >&2
47+
exit 1
48+
fi
49+
;;
50+
-*|--*=) # unsupported flags
51+
echo "Error: Unsupported flag $1" >&2
52+
exit 1
53+
;;
54+
*) # preserve positional arguments
55+
PARAMS="$PARAMS $1"
56+
shift
57+
;;
58+
esac
59+
done
60+
61+
echo "--srcTarball -> $SRC_TARBALL"
62+
echo "--outFolder -> $OUT_FOLDER"
63+
echo "--pkgVersion -> $PKG_VERSION"
64+
65+
if [ -z "$PKG_VERSION" ]; then
66+
echo "--pkgVersion parameter cannot be empty"
67+
exit 1
68+
fi
69+
70+
echo "-- create temp folder"
71+
tmpdir=$(mktemp -d)
72+
function cleanup {
73+
echo "+++ cleanup -> remove $tmpdir"
74+
rm -rf $tmpdir
75+
}
76+
trap cleanup EXIT
77+
78+
pushd $tmpdir > /dev/null
79+
80+
PKG_NAME="azure-linux-image-tools"
81+
NAME_VER="$PKG_NAME-$PKG_VERSION"
82+
VENDOR_PKG_NAME="azurelinux-image-tools"
83+
VENDOR_NAME_VER="$VENDOR_PKG_NAME-$PKG_VERSION"
84+
VENDOR_TARBALL="$OUT_FOLDER/$VENDOR_NAME_VER-vendor.tar.gz"
85+
86+
# If source tarball is provided, use it; otherwise download it
87+
if [ -n "$SRC_TARBALL" ]; then
88+
echo "Using provided source tarball: $SRC_TARBALL"
89+
cp "$SRC_TARBALL" .
90+
SOURCE_FILE=$(basename "$SRC_TARBALL")
91+
else
92+
echo "Downloading source tarball..."
93+
SOURCE_FILE="$NAME_VER.tar.gz"
94+
wget https://github.com/microsoft/azure-linux-image-tools/archive/refs/tags/v$PKG_VERSION.tar.gz -O "$SOURCE_FILE"
95+
fi
96+
97+
echo "Unpacking source tarball..."
98+
tar -xf "$SOURCE_FILE"
99+
cd "$NAME_VER/toolkit/tools"
100+
101+
echo "Generate vendored modules tarball"
102+
go mod tidy
103+
go mod vendor
104+
105+
echo "Tar vendored modules"
106+
tar --sort=name \
107+
--mtime="2025-07-18 00:00Z" \
108+
--owner=0 --group=0 --numeric-owner \
109+
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
110+
-cf "$VENDOR_TARBALL" vendor
111+
112+
popd > /dev/null
113+
echo "$VENDOR_PKG_NAME vendored modules are available at $VENDOR_TARBALL"

cgmanifest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,16 @@
900900
}
901901
}
902902
},
903+
{
904+
"component": {
905+
"type": "other",
906+
"other": {
907+
"name": "azurelinux-image-tools",
908+
"version": "0.18.0",
909+
"downloadUrl": "https://github.com/microsoft/azure-linux-image-tools/archive/refs/tags/v0.18.0.tar.gz"
910+
}
911+
}
912+
},
903913
{
904914
"component": {
905915
"type": "other",

0 commit comments

Comments
 (0)