|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +%global crate openshell |
| 5 | + |
| 6 | +# Cargo/Rust builds with vendored deps do not produce debugsource listings |
| 7 | +# in the format redhat-rpm-config expects (especially on EPEL). |
| 8 | +%global debug_package %{nil} |
| 9 | + |
| 10 | +Name: openshell |
| 11 | +Version: 0.0.20 |
| 12 | +Release: 1%{?dist} |
| 13 | +Summary: Safe, sandboxed runtimes for autonomous AI agents |
| 14 | + |
| 15 | +License: Apache-2.0 |
| 16 | +URL: https://github.com/LobsterTrap/OpenShell |
| 17 | +Source0: %{name}-%{version}.tar.gz |
| 18 | +Source1: %{name}-%{version}-vendor.tar.xz |
| 19 | + |
| 20 | +ExclusiveArch: x86_64 aarch64 |
| 21 | + |
| 22 | +# Rust build dependencies |
| 23 | +# NOTE: MSRV is 1.88 (Rust edition 2024). As of mid-2025, this requires |
| 24 | +# Fedora Rawhide or newer. Stable Fedora and EPEL-10 may ship older Rust; |
| 25 | +# adjust targets in .packit.yaml accordingly or provide a supplementary |
| 26 | +# Rust toolchain via additional_repos in the COPR build config. |
| 27 | +BuildRequires: rust >= 1.88 |
| 28 | +BuildRequires: cargo |
| 29 | +BuildRequires: gcc |
| 30 | +BuildRequires: gcc-c++ |
| 31 | +BuildRequires: make |
| 32 | +BuildRequires: cmake |
| 33 | +BuildRequires: pkg-config |
| 34 | + |
| 35 | +# Python sub-package build dependencies |
| 36 | +BuildRequires: python3-devel |
| 37 | + |
| 38 | +%description |
| 39 | +OpenShell provides safe, sandboxed runtimes for autonomous AI agents. |
| 40 | +It offers a CLI for managing gateways, sandboxes, and providers with |
| 41 | +policy-enforced egress routing, credential proxying, and privacy-aware |
| 42 | +LLM inference routing. |
| 43 | + |
| 44 | +# --- Python SDK sub-package --- |
| 45 | +%package -n python3-%{name} |
| 46 | +Summary: OpenShell Python SDK for agent execution and management |
| 47 | +Requires: python3-cloudpickle >= 3.0 |
| 48 | +Requires: python3-grpcio >= 1.60 |
| 49 | +Requires: python3-protobuf >= 4.25 |
| 50 | +Recommends: %{name} |
| 51 | + |
| 52 | +%description -n python3-%{name} |
| 53 | +Python SDK for OpenShell providing programmatic access to sandbox |
| 54 | +management, agent execution, and inference routing via gRPC. |
| 55 | + |
| 56 | +%prep |
| 57 | +%autosetup -n %{name}-%{version} |
| 58 | + |
| 59 | +# Extract vendored Cargo dependencies |
| 60 | +tar xf %{SOURCE1} |
| 61 | + |
| 62 | +# Configure Cargo to use vendored dependencies for offline build |
| 63 | +mkdir -p .cargo |
| 64 | +cat > .cargo/config.toml << 'EOF' |
| 65 | +[source.crates-io] |
| 66 | +replace-with = "vendored-sources" |
| 67 | + |
| 68 | +[source.vendored-sources] |
| 69 | +directory = "vendor" |
| 70 | +EOF |
| 71 | + |
| 72 | +# Patch workspace version from placeholder to actual version |
| 73 | +sed -i 's/^version = "0.0.0"/version = "%{version}"/' Cargo.toml |
| 74 | +grep -q 'version = "%{version}"' Cargo.toml || (echo "ERROR: Cargo.toml version patch failed" && exit 1) |
| 75 | + |
| 76 | +%build |
| 77 | +# Build only the CLI binary |
| 78 | +export CARGO_BUILD_JOBS=%{_smp_build_ncpus} |
| 79 | +cargo build --release --bin openshell |
| 80 | + |
| 81 | +%install |
| 82 | +# Install CLI binary |
| 83 | +install -Dpm 0755 target/release/%{name} %{buildroot}%{_bindir}/%{name} |
| 84 | + |
| 85 | +# Install Python SDK modules (test files are intentionally excluded) |
| 86 | +install -d %{buildroot}%{python3_sitelib}/%{name} |
| 87 | +install -d %{buildroot}%{python3_sitelib}/%{name}/_proto |
| 88 | + |
| 89 | +install -pm 0644 python/%{name}/__init__.py %{buildroot}%{python3_sitelib}/%{name}/ |
| 90 | +install -pm 0644 python/%{name}/sandbox.py %{buildroot}%{python3_sitelib}/%{name}/ |
| 91 | +install -pm 0644 python/%{name}/_proto/__init__.py %{buildroot}%{python3_sitelib}/%{name}/_proto/ |
| 92 | +install -pm 0644 python/%{name}/_proto/*.py %{buildroot}%{python3_sitelib}/%{name}/_proto/ |
| 93 | + |
| 94 | +# Create dist-info so importlib.metadata can resolve the package version |
| 95 | +install -d %{buildroot}%{python3_sitelib}/%{name}-%{version}.dist-info |
| 96 | +cat > %{buildroot}%{python3_sitelib}/%{name}-%{version}.dist-info/METADATA << EOF |
| 97 | +Metadata-Version: 2.1 |
| 98 | +Name: %{name} |
| 99 | +Version: %{version} |
| 100 | +Summary: OpenShell Python SDK for agent execution and management |
| 101 | +License: Apache-2.0 |
| 102 | +Requires-Python: >=3.12 |
| 103 | +Requires-Dist: cloudpickle>=3.0 |
| 104 | +Requires-Dist: grpcio>=1.60 |
| 105 | +Requires-Dist: protobuf>=4.25 |
| 106 | +EOF |
| 107 | + |
| 108 | +# INSTALLER marker per PEP 376 |
| 109 | +echo "rpm" > %{buildroot}%{python3_sitelib}/%{name}-%{version}.dist-info/INSTALLER |
| 110 | + |
| 111 | +# RECORD can be empty for RPM-managed installs |
| 112 | +touch %{buildroot}%{python3_sitelib}/%{name}-%{version}.dist-info/RECORD |
| 113 | + |
| 114 | +%check |
| 115 | +# Smoke-test the CLI binary |
| 116 | +%{buildroot}%{_bindir}/%{name} --version |
| 117 | + |
| 118 | +# Smoke-test the Python SDK version metadata via importlib.metadata. |
| 119 | +# We query the dist-info directly rather than importing the package because |
| 120 | +# the full import pulls in grpcio and other runtime deps not present in the |
| 121 | +# build environment. |
| 122 | +PYTHONPATH=%{buildroot}%{python3_sitelib} %{python3} -c "from importlib.metadata import version; v = version('openshell'); print(v); assert v == '%{version}', f'expected %{version}, got {v}'" |
| 123 | + |
| 124 | +%files |
| 125 | +%license LICENSE |
| 126 | +%doc README.md |
| 127 | +%{_bindir}/%{name} |
| 128 | + |
| 129 | +%files -n python3-%{name} |
| 130 | +%license LICENSE |
| 131 | +%{python3_sitelib}/%{name}/ |
| 132 | +%{python3_sitelib}/%{name}-%{version}.dist-info/ |
| 133 | + |
| 134 | +%changelog |
| 135 | +%autochangelog |
0 commit comments