dotnet-mediatr-12
LOW
maintainer ChrisTX
0 votes
scanned 2026-10-31 05:57:59.662655
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=dotnet-mediatr-12
6
pkgver=12.5.0
7
_contractsver=2.0.1
8
pkgrel=1
9
pkgdesc="Simple mediator implementation in .NET, MediatR 12 and MediatR.Contracts (NuGet packages)"
10
arch=('any')
11
url='https://github.com/jbogard/MediatR'
12
license=('Apache-2.0')
13
_dotnetsdkver="10.0"
14
makedepends=(
15
dotnet-sdk-"$_dotnetsdkver"
16
)
17
# MediatR 13 and later come under the Reciprocal Public License or a commercial license instead of
18
# Apache 2.0, so this packages the last release of MediatR 12.
19
# The commit it was published from (tag v12.5.0). MediatR.Contracts 2.0.1 was published from an
20
# earlier commit, only its project file changed since.
21
_commit="8a64581e2570e7410c5f44835d9ea112beccbe6b"
22
source=("MediatR-$_commit.tar.gz::$url/archive/$_commit.tar.gz")
23
sha512sums=('9923173eb9f1225c0535294cd4eff087440acdde2861c3a68182d9badc9e4c2312d69e0981404d31c97df652dc6cca1116f87cc5f8d8a6defe5ea1c116270809')
24
b2sums=('7b4b97f6bf51ab9d32c48b624be2a26f3a000b6a6ef49df83dd46e7ea31a591bd45afc88f5f3d32daeb8fed7175014035feec70afa35d5318a5633a805dd9420')
25
26
_dotnet_env() {
27
export NUGET_PACKAGES="$srcdir/nuget"
28
export DOTNET_CLI_HOME="$srcdir/dotnet-home"
29
export DOTNET_CLI_TELEMETRY_OPTOUT=1
30
export DOTNET_NOLOGO=1
31
32
# The repository information usually comes from git, which would find the repository this PKGBUILD
33
# is in instead. The runtime packages from the source-built artifacts are newer than the versions
34
# referenced (NU1603).
35
_build_arguments=(
36
--configuration Release
37
-p:SourceRevisionId="$_commit"
38
-p:EnableSourceControlManagerQueries=false
39
-p:RepositoryType=git
40
-p:RepositoryCommit="$_commit"
41
-p:RepositoryUrl="$url"
42
-p:IncludeSymbols=false
43
-p:WarningsNotAsErrors=NU1603
44
)
45
# MinVer computes the version of MediatR from the git tag
46
_mediatr_arguments=(
47
-p:MinVerSkip=true
48
-p:Version="$pkgver"
49
-p:AssemblyVersion="${pkgver%%.*}.0.0.0"
50
-p:FileVersion="$pkgver.0"
51
)
52
}
53
54
# .NET runtime packages MediatR is built against
55
_runtimepackages=(
56
Microsoft.Bcl.AsyncInterfaces
57
Microsoft.Extensions.DependencyInjection.Abstractions
58
)
59
60
# Writes NuGet.Config with the feed $1 (as key=url) for everything but MediatR.Contracts, which is
61
# built first, and the runtime packages, which are taken from the source-built artifacts if prepare()
62
# found them there and $2 isn't "tests"
63
_nuget_config() {
64
local _package
65
{
66
cat <<EOF
67
<?xml version="1.0" encoding="utf-8"?>
68
<configuration>
69
<packageSources>
70
<clear />
71
<add key="mediatr" value="$srcdir/nupkg" />
72
<add key="dotnet-source-built" value="$srcdir/nuget-local" />
73
<add key="${1%%=*}" value="${1#*=}" />
74
</packageSources>
75
<packageSourceMapping>
76
<clear />
77
<packageSource key="mediatr">
78
<package pattern="MediatR.Contracts" />
79
</packageSource>
80
EOF
81
if [[ -f "$srcdir/runtime-packages" && "${2-}" != tests ]]; then
82
echo ' <packageSource key="dotnet-source-built">'
83
for _package in "${_runtimepackages[@]}"; do
84
echo " <package pattern=\"$_package\" />"
85
done
86
echo ' </packageSource>'
87
fi
88
cat <<EOF
89
<packageSource key="${1%%=*}">
90
<package pattern="*" />
91
</packageSource>
92
</packageSourceMapping>
93
</configuration>
94
EOF
95
} >NuGet.Config
96
}
97
98
prepare() {
99
# The runtime packages are part of the source-built .NET of Arch Linux
100
# (dotnet-source-built-artifacts), which Arch Linux ARM doesn't have. It can't be a makedepends of
101
# an arch=any package, so it's used when it's installed, and they come from nuget.org otherwise.
102
mkdir -p nuget-local nupkg
103
local _artifacts
104
for _artifacts in /usr/share/dotnet/source-built-artifacts/Private.SourceBuilt.Artifacts.*.tar.gz; do
105
[[ -f "$_artifacts" ]] || continue
106
bsdtar -xf "$_artifacts" -C nuget-local "${_runtimepackages[@]/%/.*.nupkg}"
107
touch runtime-packages
108
done
109
110
cd "MediatR-$_commit" || exit
111
_nuget_config "nuget.org=https://api.nuget.org/v3/index.json"
112
}
113
114
build() {
115
_dotnet_env
116
cd "MediatR-$_commit" || exit
117
# The assemblies are signed with the key in the repository, giving them the same strong names as
118
# upstream's
119
dotnet pack src/MediatR.Contracts/MediatR.Contracts.csproj "${_build_arguments[@]}" --output "$srcdir/nupkg"
120
dotnet pack src/MediatR/MediatR.csproj "${_build_arguments[@]}" "${_mediatr_arguments[@]}" \
121
--output "$srcdir/nupkg"
122
}
123
124
check() {
125
_dotnet_env
126
cd "MediatR-$_commit" || exit
127
# Lamar, which the tests use, needs the runtime packages of .NET 8 from nuget.org, so MediatR is
128
# restored (NuGet doesn't notice the changed package source mapping) and built again against them
129
_nuget_config "nuget.org=https://api.nuget.org/v3/index.json" tests
130
dotnet build test/MediatR.Tests/MediatR.Tests.csproj "${_build_arguments[@]}" "${_mediatr_arguments[@]}" \
131
--force --no-incremental
132
# The test runner targets .NET 8
133
DOTNET_ROLL_FORWARD=Major dotnet test test/MediatR.Tests/MediatR.Tests.csproj "${_build_arguments[@]}" \
134
"${_mediatr_arguments[@]}" --no-build
135
}
136
137
# Fails if a binary in $pkgdir, also inside the .nupkg files there, is identical to one of the packages
138
# restored from a remote feed like nuget.org into $1, so no prebuilt binary slips in instead of one built
139
# from source
140
_check_prebuilt() {
141
local _extracted="$srcdir/check-prebuilt" _metadata _file _hash _found=0
142
local _binaries=(-type f '(' -name '*.dll' -o -name '*.exe' -o -name '*.so' -o -name '*.so.*' -o -name '*.dylib' ')')
143
local -A _prebuilt=()
144
while IFS= read -r -d '' _metadata; do
145
grep -qE '"source": *"https?://' "$_metadata" || continue
146
while IFS= read -r -d '' _file; do
147
_prebuilt[$(sha256sum <"$_file")]="${_file#"$1"/}"
148
done < <(find "${_metadata%/*}" "${_binaries[@]}" -print0)
149
done < <(find "$1" -name .nupkg.metadata -print0)
150
151
rm -rf "$_extracted"
152
mkdir -p "$_extracted"
153
while IFS= read -r -d '' _file; do
154
mkdir -p "$_extracted/${_file#"$pkgdir"/}"
155
bsdtar -xf "$_file" -C "$_extracted/${_file#"$pkgdir"/}"
156
done < <(find "$pkgdir" -type f -name '*.nupkg' -print0)
157
while IFS= read -r -d '' _file; do
158
_hash=$(sha256sum <"$_file")
159
if [[ -v "_prebuilt[$_hash]" ]]; then
160
echo "Prebuilt binary: ${_file#"$_extracted"/} is ${_prebuilt[$_hash]}" >&2
161
_found=1
162
fi
163
done < <(find "$pkgdir" "$_extracted" "${_binaries[@]}" -print0)
164
rm -rf "$_extracted"
165
return "$_found"
166
}
167
168
package() {
169
install -Dm644 "$srcdir/nupkg/MediatR.$pkgver.nupkg" "$srcdir/nupkg/MediatR.Contracts.$_contractsver.nupkg" \
170
-t "$pkgdir/usr/share/dotnet/nuget-packages/"
171
install -Dm644 "MediatR-$_commit/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
172
173
_check_prebuilt "$srcdir/nuget"
174
}
175
Scan history
| Scanned at (UTC) | Severity | Rules |
|---|---|---|
| 2026-10-31 05:57:59 | Low | 1 |