Skip to content

Commit 9c14c8e

Browse files
authored
Add non-portable RID for OpenBSD (#16564)
1 parent 12f2683 commit 9c14c8e

File tree

4 files changed

+48
-22
lines changed

4 files changed

+48
-22
lines changed

eng/common/cross/build-rootfs.sh

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ __FreeBSDPackages+=" krb5"
8686
__FreeBSDPackages+=" terminfo-db"
8787

8888
__OpenBSDVersion="7.8"
89+
__OpenBSDPackages="heimdal-libs"
8990
__OpenBSDPackages+=" icu4c"
9091
__OpenBSDPackages+=" inotify-tools"
9192
__OpenBSDPackages+=" openssl"
92-
__OpenBSDPackages+=" heimdal-libs"
9393

9494
__IllumosPackages="icu"
9595
__IllumosPackages+=" mit-krb5"
@@ -632,19 +632,40 @@ elif [[ "$__CodeName" == "openbsd" ]]; then
632632

633633
echo "Installing packages into sysroot..."
634634

635+
# Fetch package index once
636+
if [[ "$__hasWget" == 1 ]]; then
637+
PKG_INDEX=$(wget -qO- "$PKG_MIRROR/")
638+
else
639+
PKG_INDEX=$(curl -s "$PKG_MIRROR/")
640+
fi
641+
635642
for pkg in $__OpenBSDPackages; do
636-
echo "Resolving package filename for $pkg..."
643+
PKG_FILE=$(echo "$PKG_INDEX" | grep -Po ">\K${pkg}-[0-9][^\" ]*\.tgz" \
644+
| sort -V | tail -n1)
645+
646+
echo "Resolved package filename for $pkg: $PKG_FILE"
647+
648+
[[ -z "$PKG_FILE" ]] && { echo "ERROR: Package $pkg not found"; exit 1; }
637649

638650
if [[ "$__hasWget" == 1 ]]; then
639-
PKG_FILE=$(wget -qO- "$PKG_MIRROR/" | grep -Eo "${pkg}-[0-9][^\" ]*\.tgz" | head -n1)
640-
[[ -z "$PKG_FILE" ]] && { echo "ERROR: Package $pkg not found"; exit 1; }
641651
wget -O- "$PKG_MIRROR/$PKG_FILE" | tar -C "$__RootfsDir" -xzpf -
642652
else
643-
PKG_FILE=$(curl -s "$PKG_MIRROR/" | grep -Eo "${pkg}-[0-9][^\" ]*\.tgz" | head -n1)
644-
[[ -z "$PKG_FILE" ]] && { echo "ERROR: Package $pkg not found"; exit 1; }
645653
curl -SL "$PKG_MIRROR/$PKG_FILE" | tar -C "$__RootfsDir" -xzpf -
646654
fi
647655
done
656+
657+
echo "Creating versionless symlinks for shared libraries..."
658+
# Find all versioned .so files and create the base .so symlink
659+
for lib in "$__RootfsDir/usr/lib/libc++.so."* "$__RootfsDir/usr/lib/libc++abi.so."* "$__RootfsDir/usr/lib/libpthread.so."*; do
660+
if [ -f "$lib" ]; then
661+
# Extract the filename (e.g., libc++.so.12.0)
662+
VERSIONED_NAME=$(basename "$lib")
663+
# Remove the trailing version numbers (e.g., libc++.so)
664+
BASE_NAME=${VERSIONED_NAME%.so.*}.so
665+
# Create the symlink in the same directory
666+
ln -sf "$VERSIONED_NAME" "$__RootfsDir/usr/lib/$BASE_NAME"
667+
fi
668+
done
648669
elif [[ "$__CodeName" == "illumos" ]]; then
649670
mkdir "$__RootfsDir/tmp"
650671
pushd "$__RootfsDir/tmp"

eng/common/native/init-distro-rid.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ getNonPortableDistroRid()
3939
# $rootfsDir can be empty. freebsd-version is a shell script and should always work.
4040
__freebsd_major_version=$("$rootfsDir"/bin/freebsd-version | cut -d'.' -f1)
4141
nonPortableRid="freebsd.$__freebsd_major_version-${targetArch}"
42+
elif [ "$targetOs" = "openbsd" ]; then
43+
nonPortableRid="openbsd.$(uname -r)-${targetArch}"
4244
elif command -v getprop >/dev/null && getprop ro.product.system.model | grep -qi android; then
4345
__android_sdk_version=$(getprop ro.build.version.sdk)
4446
nonPortableRid="android.$__android_sdk_version-${targetArch}"

src/Microsoft.DotNet.XUnitExtensions.Shared/DiscovererHelpers.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public static bool TestPlatformApplies(TestPlatforms platforms) =>
2222
(platforms.HasFlag(TestPlatforms.FreeBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) ||
2323
(platforms.HasFlag(TestPlatforms.Linux) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) ||
2424
(platforms.HasFlag(TestPlatforms.NetBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("NETBSD"))) ||
25+
(platforms.HasFlag(TestPlatforms.OpenBSD) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("OPENBSD"))) ||
2526
(platforms.HasFlag(TestPlatforms.OSX) && RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) ||
2627
(platforms.HasFlag(TestPlatforms.illumos) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("ILLUMOS"))) ||
2728
(platforms.HasFlag(TestPlatforms.Solaris) && RuntimeInformation.IsOSPlatform(OSPlatform.Create("SOLARIS"))) ||

src/Microsoft.DotNet.XUnitExtensions.Shared/TestPlatforms.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@ namespace Xunit
88
[Flags]
99
public enum TestPlatforms
1010
{
11-
Windows = 1,
12-
Linux = 2,
13-
OSX = 4,
14-
FreeBSD = 8,
15-
NetBSD = 16,
16-
illumos = 32,
17-
Solaris = 64,
18-
iOS = 128,
19-
tvOS = 256,
20-
Android = 512,
21-
Browser = 1024,
22-
MacCatalyst = 2048,
23-
LinuxBionic = 4096,
24-
Wasi = 8192,
25-
Haiku = 16384,
26-
AnyUnix = FreeBSD | Linux | NetBSD | OSX | illumos | Solaris | iOS | tvOS | MacCatalyst | Android | Browser | LinuxBionic | Wasi | Haiku,
11+
Windows = 1 << 0,
12+
Linux = 1 << 1,
13+
OSX = 1 << 2,
14+
FreeBSD = 1 << 3,
15+
NetBSD = 1 << 4,
16+
illumos = 1 << 5,
17+
Solaris = 1 << 6,
18+
iOS = 1 << 7,
19+
tvOS = 1 << 8,
20+
Android = 1 << 9,
21+
Browser = 1 << 10,
22+
MacCatalyst = 1 << 11,
23+
LinuxBionic = 1 << 12,
24+
Wasi = 1 << 13,
25+
Haiku = 1 << 14,
26+
OpenBSD = 1 << 15,
27+
2728
AnyApple = OSX | iOS | tvOS | MacCatalyst,
29+
AnyUnix = AnyApple | Linux | FreeBSD | NetBSD | OpenBSD | illumos | Solaris | Android | Browser | LinuxBionic | Wasi | Haiku,
2830
Any = ~0
2931
}
3032
}

0 commit comments

Comments
 (0)