Skip to content

Commit 5f94d0b

Browse files
authored
[CHERRYPICK] azurelinux-sysinfo: fasttrack/2.0 to main (#9117)
1 parent 35d5f54 commit 5f94d0b

9 files changed

Lines changed: 673 additions & 1 deletion

File tree

.github/workflows/validate-cg-manifest.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ignore_multiple_sources=" \
2323

2424
# List of ignored specs due to no source tarball to scan.
2525
ignore_no_source_tarball=" \
26+
azurelinux-sysinfo \
2627
ca-certificates \
2728
check-restart \
2829
core-packages \

SPECS/LICENSES-AND-NOTICES/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.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,7 @@
21522152
"azcopy",
21532153
"azure-iot-sdk-c",
21542154
"azure-storage-cpp",
2155+
"azurelinux-sysinfo",
21552156
"bazel",
21562157
"blobfuse",
21572158
"blobfuse2",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Azure Linux Sysinfo Service
3+
After=cloud-init.target multi-user.target
4+
5+
[Service]
6+
Environment=PYTHONUNBUFFERED=1
7+
Type=simple
8+
ExecStart=/usr/bin/python3 /usr/bin/collect-sysinfo
9+
StandardOutput=journal
10+
StandardError=journal
11+
12+
[Install]
13+
WantedBy=multi-user.target
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Signatures": {
3+
"collect-sysinfo": "b47df8a856c49e4bc02b36d1c3dd2825b75b9d8449b5dae8af401fc6818131c9",
4+
"sysinfo-schema-v1.json": "67b541239416bd5f9a77a0799881f21c2e5eea686dc7a3ccaffe6bd7219a4798",
5+
"azurelinux-sysinfo.service": "c719ab2238d0412b7ac6a793cd83e5be7879023161f86fb29d1c0ca18e70631c",
6+
"sysinfo-selinuxpolicies.cil": "1f0df94a09f4db09093743339b6162735b6f1c81108cd3b857a6dbc729630400"
7+
}
8+
}
9+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Summary: Package to deploy azurelinux-sysinfo service
2+
Name: azurelinux-sysinfo
3+
Version: 2.0
4+
Release: 1%{?dist}
5+
License: MIT
6+
Vendor: Microsoft Corporation
7+
Distribution: Azure Linux
8+
Group: System Environment/Base
9+
URL: https://aka.ms/azurelinux
10+
Source0: collect-sysinfo
11+
Source1: sysinfo-schema-v1.json
12+
Source2: azurelinux-sysinfo.service
13+
Source3: sysinfo-selinuxpolicies.cil
14+
Requires: systemd
15+
Requires: python3-psutil
16+
17+
%description
18+
Deploys a systemd service that gathers system information related to the device, operating system, cloud-init, boot
19+
time, resource utilization, installed packages, and SELinux mode. Collected information is written in JSON format to
20+
a log file on the user's system for easy access and analysis. The systemd service runs at boot time if installed during
21+
image creation.
22+
23+
%install
24+
# Copy collection python script to /usr/bin/
25+
mkdir -p %{buildroot}%{_bindir}/
26+
install -m 755 %{SOURCE0} %{buildroot}%{_bindir}/
27+
28+
# Copy data schema to /usr/share/azurelinux-sysinfo/
29+
mkdir -p %{buildroot}%{_datadir}/azurelinux-sysinfo/
30+
install -m 755 %{SOURCE1} %{buildroot}%{_datadir}/azurelinux-sysinfo/
31+
32+
# Copy service to /etc/systemd/system/
33+
mkdir -p %{buildroot}%{_sysconfdir}/systemd/system/
34+
install -m 755 %{SOURCE2} %{buildroot}%{_sysconfdir}/systemd/system/
35+
36+
# Copy the sysinfo-selinuxpolicies file to /usr/share/selinux/packages/
37+
mkdir -p %{buildroot}%{_datadir}/selinux/packages/
38+
install -m 755 %{SOURCE3} %{buildroot}%{_datadir}/selinux/packages/
39+
40+
%files
41+
%{_bindir}/collect-sysinfo
42+
%dir %{_datadir}/azurelinux-sysinfo/
43+
%{_datadir}/azurelinux-sysinfo/sysinfo-schema-v1.json
44+
%{_sysconfdir}/systemd/system/azurelinux-sysinfo.service
45+
%{_datadir}/selinux/packages/sysinfo-selinuxpolicies.cil
46+
47+
%post
48+
#!/bin/sh
49+
# Enable the systemd service
50+
systemctl enable azurelinux-sysinfo.service
51+
52+
# Apply required SElinux policies only if selinux-policy is present
53+
if rpm -q selinux-policy &> /dev/null; then
54+
semodule -i %{_datadir}/selinux/packages/sysinfo-selinuxpolicies.cil
55+
fi
56+
57+
%postun
58+
# If selinux-policy is present, remove the sysinfo-selinuxpolicies module
59+
if rpm -q selinux-policy &> /dev/null; then
60+
semodule -r sysinfo-selinuxpolicies
61+
fi
62+
63+
%changelog
64+
* Thu Apr 04 2024 Amrita Kohli <amritakohli@microsoft.com> - 2.0-1
65+
- License verified.
66+
- Implementation of package that deploys azurelinux-sysinfo service.
67+
- Original version for CBL-Mariner.
68+
69+

0 commit comments

Comments
 (0)