powershell-mmi
LOW
maintainer ChrisTX
0 votes
scanned 2026-10-31 07:58:04.077835
Why flagged
Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.
Triggered rules
Low
Few votes, recently uploaded
zero_votes_recent
Uploaded within the last 14 days with 2 or fewer community votes — little peer review so far.
PKGBUILD
1
# Maintainer: Christian Pfeiffer <cpfeiffer at rev-crew dot info>
2
# shellcheck disable=SC2034,SC2154
3
# shellcheck shell=bash
4
5
pkgname=powershell-mmi
6
pkgver=2.0.0preview1
7
pkgrel=1
8
pkgdesc="Microsoft.Management.Infrastructure (MMI) for PowerShell, built from its open source code"
9
# The assembly is compiled to a ReadyToRun image for the architecture
10
arch=('x86_64' 'aarch64')
11
url='https://github.com/PowerShell/MMI'
12
license=('MIT')
13
_dotnetsdkver="10.0"
14
depends=(
15
powershell
16
)
17
makedepends=(
18
dotnet-sdk-"$_dotnetsdkver"
19
git
20
)
21
makedepends_x86_64=(
22
dotnet-source-built-artifacts-"$_dotnetsdkver"
23
)
24
checkdepends=(
25
powershell
26
)
27
provides=("$pkgname-bin")
28
conflicts=("$pkgname-bin")
29
# PowerShell is built without MMI. It's only needed by modules built against PowerShell with it, e.g.
30
# PSScriptAnalyzer from the PowerShell Gallery. The last commit of the archived repository, the managed
31
# part of MMI for Linux and macOS, whose API matches Microsoft's Runtime.Unix package
32
# (powershell-mmi-bin). The OMI client library (libmi) it calls isn't included, Microsoft's packages of
33
# PowerShell for Linux don't have it either, so CIM operations fail with or without this package.
34
# No .nvchecker.toml: the repository is archived, so it can't change anymore.
35
_commit="cf32fc695b32c2eae848b693395c09222fe1d2ae"
36
source=("git+$url.git#commit=$_commit"
37
"crossgen2-pack.targets"
38
"check-assembly.ps1")
39
sha512sums=('51abd78f1d72f8c12bc8ee39bd311fa5fc3f1696d45ba25c4ba654103359a986c01e487783059b64ec0f6bf48386077fb4c2dd60a22fca076330acf5e17cd8f5'
40
'340bfd8bcb4548a6b70954d1d17b5c402c47285979c3f2eae27ff8d3fd0547b54ddf934f41e4a777825a8cc9fc674589760b2f701db11a10c7e17f0af2cf3981'
41
'2fe10d7b7a687eb8d80280086b33953b12b377e66d0f937e18d0967692a95fb3463480a788d700765dce640f60e8564348184e120a4e0ed45a4dceb8c9e8a12b')
42
b2sums=('826bc5cd8b212060820ad4eb800de18986ee4fb776e693049cd7e11e88234bccb28e360006a026ac0239b26a13727cdeefedcf30c8201265cf735504330257d1'
43
'3493eecfb50819af971399abe1e62782ccf28500559d222822bddb91ddac6bf191d7e20abf01dfbcb99f7c51df9356061c8f1687a10700228e7d1f77308e873b'
44
'a25a1f97ac5fd6974bc6806430b65e98113ea1d752aa83c0e31502218fafbe64cb026e4a74436889ad6b33085f35afe7ae0b71a3be0c38b99fda811ee64ca23d')
45
46
_dotnet_env() {
47
export NUGET_PACKAGES="$srcdir/nuget"
48
export DOTNET_CLI_HOME="$srcdir/dotnet-home"
49
export DOTNET_CLI_TELEMETRY_OPTOUT=1
50
export DOTNET_NOLOGO=1
51
# RID of the .NET SDK: arch-x64 for the source-built .NET of Arch, linux-arm64 for Microsoft's build
52
_rid=$(dotnet --info | sed -n -E 's/^ *RID: *//p')
53
}
54
55
prepare() {
56
_dotnet_env
57
# The runtime and crossgen2 packs for ReadyToRun come from the source-built .NET where it's
58
# installed (see crossgen2-pack.targets), nuget.org otherwise
59
mkdir -p nuget-local
60
local _artifacts
61
for _artifacts in /usr/share/dotnet/source-built-artifacts/Private.SourceBuilt.Artifacts.*.tar.gz; do
62
[[ -f "$_artifacts" ]] || continue
63
bsdtar -xf "$_artifacts" -C nuget-local "Microsoft.NETCore.App.Crossgen2.$_rid.*.nupkg" \
64
"Microsoft.NETCore.App.Runtime.$_rid.*.nupkg"
65
done
66
67
cd MMI || exit
68
rm global.json
69
cat >nuget.config <<EOF
70
<?xml version="1.0" encoding="utf-8"?>
71
<configuration>
72
<packageSources>
73
<clear />
74
<add key="dotnet-source-built" value="$srcdir/nuget-local" />
75
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
76
</packageSources>
77
</configuration>
78
EOF
79
# Built for the .NET PowerShell runs on instead of .NET Standard 2.0, so the packages it compiled
80
# against (System.Security.SecureString and the like) are part of .NET. Unsigned like Microsoft's
81
# build in the Runtime.Unix package, with its key the build would only be delay signed. The constants
82
# of its Linux configuration apply to the Release one.
83
sed -i -E \
84
-e "s|<TargetFramework>netstandard2.0</TargetFramework>|<TargetFramework>net$_dotnetsdkver</TargetFramework>|" \
85
-e '/<PackageReference /d' \
86
-e '/<DelaySign>|<AssemblyOriginatorKeyFile>/d' \
87
-e "s|<PropertyGroup Condition=\"'\\\$\(Configuration\)' == 'Linux' \">|<PropertyGroup>|" \
88
src/Microsoft.Management.Infrastructure/Microsoft.Management.Infrastructure.csproj
89
}
90
91
build() {
92
_dotnet_env
93
cd MMI || exit
94
# The analyzers of newer .NET versions aren't errors
95
dotnet publish src/Microsoft.Management.Infrastructure --configuration Release \
96
--runtime "$_rid" --no-self-contained --output "$srcdir/publish" \
97
-p:TreatWarningsAsErrors=false -p:EnableNETAnalyzers=false \
98
-p:PublishReadyToRun=true -p:CustomAfterMicrosoftCommonTargets="$srcdir/crossgen2-pack.targets" \
99
-p:DisableTransitiveFrameworkReferenceDownloads=true \
100
-p:SourceRevisionId="$_commit" -p:EnableSourceControlManagerQueries=false
101
}
102
103
check() {
104
# The tests need the OMI server and client library (test.sh), so the assembly is only checked to
105
# load with the identity and API PowerShell and modules expect
106
HOME="$srcdir/home" pwsh -NoProfile -NonInteractive -File "$srcdir/check-assembly.ps1" \
107
-Path "$srcdir/publish/Microsoft.Management.Infrastructure.dll"
108
}
109
110
# Fails if a binary in $pkgdir, also inside the .nupkg files there, is identical to one of the packages
111
# restored from a remote feed like nuget.org into $1, so no prebuilt binary slips in instead of one built
112
# from source
113
_check_prebuilt() {
114
local _extracted="$srcdir/check-prebuilt" _metadata _file _hash _found=0
115
local _binaries=(-type f '(' -name '*.dll' -o -name '*.exe' -o -name '*.so' -o -name '*.so.*' -o -name '*.dylib' ')')
116
local -A _prebuilt=()
117
while IFS= read -r -d '' _metadata; do
118
grep -qE '"source": *"https?://' "$_metadata" || continue
119
while IFS= read -r -d '' _file; do
120
_prebuilt[$(sha256sum <"$_file")]="${_file#"$1"/}"
121
done < <(find "${_metadata%/*}" "${_binaries[@]}" -print0)
122
done < <(find "$1" -name .nupkg.metadata -print0)
123
124
rm -rf "$_extracted"
125
mkdir -p "$_extracted"
126
while IFS= read -r -d '' _file; do
127
mkdir -p "$_extracted/${_file#"$pkgdir"/}"
128
bsdtar -xf "$_file" -C "$_extracted/${_file#"$pkgdir"/}"
129
done < <(find "$pkgdir" -type f -name '*.nupkg' -print0)
130
while IFS= read -r -d '' _file; do
131
_hash=$(sha256sum <"$_file")
132
if [[ -v "_prebuilt[$_hash]" ]]; then
133
echo "Prebuilt binary: ${_file#"$_extracted"/} is ${_prebuilt[$_hash]}" >&2
134
_found=1
135
fi
136
done < <(find "$pkgdir" "$_extracted" "${_binaries[@]}" -print0)
137
rm -rf "$_extracted"
138
return "$_found"
139
}
140
141
package() {
142
local _pshome=/usr/lib/powershell-7
143
install -Dm644 "$srcdir/publish/Microsoft.Management.Infrastructure.dll" -t "$pkgdir$_pshome/"
144
# Added to pwsh.deps.json by the powershell-deps hook of powershell, the .NET host only loads the
145
# assemblies it lists
146
install -dm755 "$pkgdir/usr/share/powershell/deps.d"
147
cat >"$pkgdir/usr/share/powershell/deps.d/microsoft-management-infrastructure.json" <<EOF
148
{
149
"targets": {
150
".NETCoreApp,Version=v$_dotnetsdkver": {
151
"Microsoft.Management.Infrastructure/2.0.0": {
152
"runtime": {
153
"Microsoft.Management.Infrastructure.dll": {
154
"assemblyVersion": "2.0.0.0",
155
"fileVersion": "2.0.0.0"
156
}
157
}
158
}
159
}
160
},
161
"libraries": {
162
"Microsoft.Management.Infrastructure/2.0.0": {
163
"type": "project",
164
"serviceable": false,
165
"sha512": ""
166
}
167
}
168
}
169
EOF
170
install -Dm644 MMI/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
171
172
_check_prebuilt "$srcdir/nuget"
173
}
174
Scan history
| Scanned at (UTC) | Severity | Rules |
|---|---|---|
| 2026-10-31 07:58:04 | Low | 1 |