Skip to content

Commit ca3407e

Browse files
author
Willy Zhang
committed
Fix setup.sh for newer Ubuntu versions by falling back to libncursesw6/libtinfo6
1 parent 2def6e6 commit ca3407e

3 files changed

Lines changed: 24 additions & 57 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,18 @@ jobs:
108108
integration_tests_nix:
109109
runs-on: ot-provisioning-nix-runner
110110
timeout-minutes: 60
111-
env:
112-
OT_PROV_ORCHESTRATOR_PATH: /home/ci/orchestrator/latest/orchestrator.zip
113-
OT_PROV_ORCHESTRATOR_UNPACK: /home/ci/orchestrator/latest/copy_files.sh
114111
steps:
115112
- uses: actions/checkout@v4
116113
with:
117114
lfs: true
118115
- name: Initialize LFS objects
119116
run: git lfs pull
120117
- name: Run provisioning appliance load test (Nix)
121-
run: OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev nix develop --command ./tests/run_pa_loadtest.sh --prod
118+
run: nix develop --command env OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev ./tests/run_pa_loadtest.sh
122119
- name: Run provisioning appliance load test (PQ) (Nix)
123-
run: OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev-pq nix develop --command ./tests/run_pa_loadtest.sh --pq
120+
run: nix develop --command env OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev-pq ./tests/run_pa_loadtest.sh --pq
124121
- name: Run TLS test (Nix)
125-
run: OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev nix develop --command ./tests/run_tls_test.sh --prod
122+
run: nix develop --command env OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev ./tests/run_tls_test.sh
126123
- name: Run integration tests (SoftHSM2) (Nix)
127-
run: OT_PROV_ORCHESTRATOR_PATH="${OT_PROV_ORCHESTRATOR_PATH}" OT_PROV_ORCHESTRATOR_UNPACK="${OT_PROV_ORCHESTRATOR_UNPACK}" OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev nix develop --command ./tests/run_ate_test.sh
128-
- name: Run integration tests (Thales HSM) (Nix)
129-
run: OT_PROV_ORCHESTRATOR_PATH="${OT_PROV_ORCHESTRATOR_PATH}" OT_PROV_ORCHESTRATOR_UNPACK="${OT_PROV_ORCHESTRATOR_UNPACK}" OPENTITAN_VAR_DIR=$(pwd)/.otvar-prod nix develop --command ./tests/run_ate_test.sh --prod
124+
run: nix develop --command env OPENTITAN_VAR_DIR=$(pwd)/.otvar-dev ./tests/run_ate_test.sh
125+

flake.nix

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ outputs = { self, nixpkgs, ... }:
2424
unzip
2525

2626
# Build tools
27+
bazelisk
2728
go
2829
python3
2930
python3Packages.pip
@@ -36,54 +37,12 @@ outputs = { self, nixpkgs, ... }:
3637
libusb1
3738
libftdi1
3839
openssl
40+
libp11
3941
ncurses5
4042
udev
4143
stdenv.cc.cc.lib
4244
];
4345

44-
# Create a wrapped bazelisk that handles all the environment and sandbox issues
45-
bazelisk-wrapped = let
46-
# GCC specific library paths (both shared and static)
47-
gccLibPath = "${pkgs.stdenv.cc.cc.lib}/lib";
48-
in pkgs.writeShellScriptBin "bazelisk" ''
49-
export NIX_LIBS="${pkgs.lib.makeLibraryPath sharedTools}:$gccLibPath"
50-
export NIX_INTERPRETER="${pkgs.stdenv.cc.libc}/lib/ld-linux-x86-64.so.2"
51-
52-
# Final Force: Create a local directory in the workspace and COPY the libraries
53-
# This ensures the sandbox MUST see them.
54-
mkdir -p .nix-libs
55-
cp -f $gccLibPath/libgcc_s.so* .nix-libs/ 2>/dev/null
56-
57-
# Find libgcc.a in multiple locations and copy it
58-
# 1. From Nix GCC
59-
find ${pkgs.stdenv.cc.cc} -name "libgcc.a" -exec cp -f {} .nix-libs/ \; 2>/dev/null
60-
# 2. From Host GCC (Ubuntu 24.04)
61-
find /usr/lib/gcc -name "libgcc.a" -exec cp -f {} .nix-libs/ \; 2>/dev/null
62-
63-
# Create a local bazelrc for nix-specific settings
64-
cat > .bazelrc-nix <<EOF
65-
# Point to our local physically injected libraries
66-
build --linkopt=-L\$PWD/.nix-libs
67-
build --action_env=RUSTFLAGS="-L\$PWD/.nix-libs"
68-
69-
# Environment variables for actions
70-
build --action_env=LD_LIBRARY_PATH="$NIX_LIBS"
71-
build --host_action_env=LD_LIBRARY_PATH="$NIX_LIBS"
72-
build --action_env=LIBRARY_PATH="$NIX_LIBS"
73-
build --host_action_env=LIBRARY_PATH="$NIX_LIBS"
74-
75-
# Sandbox mounts
76-
build --sandbox_add_mount_pair=/nix:/nix
77-
build --sandbox_add_mount_pair=/usr/lib:/usr/lib
78-
build --sandbox_add_mount_pair=/lib:/lib
79-
build --sandbox_add_mount_pair=/lib64:/lib64
80-
EOF
81-
82-
export LD_LIBRARY_PATH="$NIX_LIBS:$LD_LIBRARY_PATH"
83-
export LIBRARY_PATH="$NIX_LIBS:$LIBRARY_PATH"
84-
85-
exec ${pkgs.bazelisk}/bin/bazelisk --bazelrc=.bazelrc-nix "$@"
86-
'';
8746
in
8847
{
8948
# 1. For bare-metal deployment (future)
@@ -96,18 +55,22 @@ EOF
9655

9756
# 2. For developers and Hybrid CI (current)
9857
devShells.${system}.default = pkgs.mkShell {
99-
buildInputs = sharedTools ++ [ bazelisk-wrapped ];
58+
buildInputs = sharedTools;
10059

10160
shellHook = ''
10261
echo "OpenTitan Provisioning Development Environment"
10362
export OT_PROV_SHELL=1
10463
105-
# Set defaults for other tools (like go or python)
64+
# Configure OpenSSL to find the pkcs11 engine provided by libp11
65+
export OPENSSL_ENGINES="${pkgs.libp11}/lib/engines"
66+
67+
# Basic LD paths to ensure tools run correctly in the shell
10668
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath sharedTools}:$LD_LIBRARY_PATH"
10769
export NIX_LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath sharedTools}"
10870
export NIX_LD="${pkgs.stdenv.cc.libc}/lib/ld-linux-x86-64.so.2"
10971
'';
11072
};
11173

74+
11275
};
11376
}

setup.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@ readonly REPO_TOP="$(dirname "$0")"
99
readonly OPENTITAN_VAR_DIR="/var/lib/opentitan"
1010

1111
sudo apt update
12-
sed -e '/^$/d' -e '/^#/d' -e 's/#.*//' \
13-
< "$REPO_TOP/apt-requirements.txt" \
14-
| sudo xargs apt install -y
12+
PACKAGES=$(sed -e '/^$/d' -e '/^#/d' -e 's/#.*//' < "$REPO_TOP/apt-requirements.txt")
13+
14+
# Fallback to newer ncurses/tinfo versions if older ones are missing (e.g. Ubuntu 24.04+)
15+
if ! apt-cache pkgnames "^libncursesw5$" | grep -q "libncursesw5"; then
16+
PACKAGES=$(echo "$PACKAGES" | sed 's/libncursesw5/libncursesw6/g')
17+
fi
18+
if ! apt-cache pkgnames "^libtinfo5$" | grep -q "libtinfo5"; then
19+
PACKAGES=$(echo "$PACKAGES" | sed 's/libtinfo5/libtinfo6/g')
20+
fi
21+
22+
echo "$PACKAGES" | sudo xargs apt install -y
1523
sudo apt clean
1624

1725
go install github.com/bazelbuild/bazelisk@v1.27.0

0 commit comments

Comments
 (0)