|
7 | 7 |
|
8 | 8 | jobs: |
9 | 9 | build-linux: |
10 | | - runs-on: ubuntu-22.04 |
| 10 | + # Built inside a manylinux container rather than on the runner itself. A |
| 11 | + # binary's glibc floor is set by the glibc it was linked against, and |
| 12 | + # nothing in the source or the link line can lower it: an ubuntu-22.04 |
| 13 | + # build (glibc 2.35) picks up __libc_start_main@GLIBC_2.34 and |
| 14 | + # pow/log@GLIBC_2.29 purely as an artifact of the host, which makes the |
| 15 | + # asset unloadable in the manylinux containers where downstream projects |
| 16 | + # such as dcmqi run their dciodvfy conformance tests. See issue #19. |
| 17 | + # |
| 18 | + # Note this is not a `container:` job. A container job runs the JS actions |
| 19 | + # (checkout, upload-artifact) on the node binary the runner injects into |
| 20 | + # the image, and that needs glibc >= 2.28, which manylinux2014 does not |
| 21 | + # have. So the host runner does the checkout, packaging and upload, and |
| 22 | + # only Configure/imake/make run in the container. |
| 23 | + strategy: |
| 24 | + fail-fast: false |
| 25 | + matrix: |
| 26 | + include: |
| 27 | + # manylinux2014 is CentOS 7: glibc 2.17, which covers every consumer |
| 28 | + # at or above that, including dcmqi's dockcross/manylinux2014-x64 |
| 29 | + # test container. The image is frozen (CentOS 7 is EOL) but its yum |
| 30 | + # repositories still resolve against vault.centos.org. If it ever |
| 31 | + # goes away, manylinux_2_28_x86_64 is the fallback, at a 2.28 floor. |
| 32 | + - arch: x86_64 |
| 33 | + runner: ubuntu-24.04 |
| 34 | + image: quay.io/pypa/manylinux2014_x86_64 |
| 35 | + install: yum install -y imake |
| 36 | + glibc_floor: '2.17' |
| 37 | + # manylinux_2_28 is AlmaLinux 8: glibc 2.28, matching the floor of |
| 38 | + # dcmqi's own arm64 package. imake lives in the powertools repo |
| 39 | + # there, which ships disabled. Built on a native arm64 runner, free |
| 40 | + # for public repositories, so nothing is emulated. |
| 41 | + - arch: aarch64 |
| 42 | + runner: ubuntu-24.04-arm |
| 43 | + image: quay.io/pypa/manylinux_2_28_aarch64 |
| 44 | + install: dnf install -y --enablerepo=powertools imake |
| 45 | + glibc_floor: '2.28' |
| 46 | + |
| 47 | + runs-on: ${{ matrix.runner }} |
11 | 48 | permissions: |
12 | 49 | contents: write |
13 | | - |
| 50 | + |
14 | 51 | steps: |
15 | 52 | - name: Checkout repository |
16 | 53 | uses: actions/checkout@v7 |
17 | 54 |
|
18 | | - - name: Install build dependencies |
| 55 | + - name: Write container build script |
| 56 | + # Kept out of the workspace so it cannot end up in the archive. |
19 | 57 | run: | |
20 | | - sudo apt-get update |
21 | | - sudo apt-get install -y g++ xutils-dev libx11-dev libxext-dev |
| 58 | + cat > "$RUNNER_TEMP/build-in-container.sh" <<'SCRIPT' |
| 59 | + #!/bin/bash |
| 60 | + set -e |
22 | 61 |
|
23 | | - - name: Configure |
24 | | - run: ./Configure |
| 62 | + # The container runs as root while the workspace belongs to the |
| 63 | + # runner user, and the packaging step that follows runs as that user. |
| 64 | + # Hand ownership back however this script exits. |
| 65 | + trap 'chown -R "$HOST_UID:$HOST_GID" /work' EXIT |
25 | 66 |
|
26 | | - - name: Run imake |
27 | | - run: imake -I./config -DInstallInTopDir |
| 67 | + echo "::group::Container environment" |
| 68 | + cat /etc/redhat-release |
| 69 | + ldd --version | head -1 |
| 70 | + g++ --version | head -1 |
| 71 | + echo "::endgroup::" |
28 | 72 |
|
29 | | - - name: Build |
30 | | - # The awk scripts that generate the dconvert headers write their |
31 | | - # diagnostics to /dev/tty, which is fatal to gawk when there is no |
32 | | - # controlling terminal, and silently costs us the himr and ge9800 |
33 | | - # converters. script(1) supplies a pseudo terminal; -e passes the exit |
34 | | - # status of the command through. |
35 | | - run: script -qec "make World" /dev/null |
| 73 | + echo "::group::Install imake" |
| 74 | + # One package supplies imake, makedepend and mkdirhier. gawk, the X11 |
| 75 | + # headers and libX11/libXext are already in the manylinux images, so |
| 76 | + # this is the only thing that has to be fetched. |
| 77 | + eval "$INSTALL_CMD" |
| 78 | + echo "::endgroup::" |
36 | 79 |
|
37 | | - - name: Install |
38 | | - run: script -qec "make install" /dev/null |
| 80 | + # The awk scripts that generate the dconvert headers write their |
| 81 | + # diagnostics to /dev/tty, which is fatal to gawk when there is no |
| 82 | + # controlling terminal, and silently costs us the himr and ge9800 |
| 83 | + # converters. The macOS and Windows workflows use script(1) to supply |
| 84 | + # a pseudo terminal, but that cannot be used here: CentOS 7 ships |
| 85 | + # util-linux 2.23.2, whose script kills the child as soon as its own |
| 86 | + # stdin reaches EOF - which is how every Actions step runs it - and |
| 87 | + # whose -e never propagates the child's exit status. Under it, |
| 88 | + # `make World` produced a 15 byte log, built nothing, and reported |
| 89 | + # success. Python's pty.spawn gets both right on every image here. |
| 90 | + PYTHON=$(ls -d /opt/python/cp3*/bin/python3 | head -1) |
| 91 | + runpty() { |
| 92 | + "$PYTHON" -c 'import pty, sys, os; sys.exit(os.waitstatus_to_exitcode(pty.spawn(sys.argv[1:])))' "$@" |
| 93 | + } |
| 94 | +
|
| 95 | + echo "::group::Configure" |
| 96 | + ./Configure |
| 97 | + echo "::endgroup::" |
| 98 | +
|
| 99 | + echo "::group::imake" |
| 100 | + imake -I./config -DInstallInTopDir |
| 101 | + echo "::endgroup::" |
| 102 | +
|
| 103 | + echo "::group::make World" |
| 104 | + runpty make World |
| 105 | + echo "::endgroup::" |
| 106 | +
|
| 107 | + echo "::group::make install" |
| 108 | + runpty make install |
| 109 | + echo "::endgroup::" |
39 | 110 |
|
40 | | - - name: Test binary execution |
41 | | - run: | |
42 | | - echo "Testing binary execution to ensure they work correctly..." |
43 | | - |
44 | | - # Get the platform-specific directory name |
45 | 111 | PLATFORM_DIR=$(ls -1 bin | head -1) |
46 | 112 | echo "Platform directory: $PLATFORM_DIR" |
47 | | - |
48 | | - # Test a few key binaries |
49 | | - BINARIES="dciodvfy dcdump dcfile dcentvfy" |
50 | | - |
51 | | - for binary in $BINARIES; do |
52 | | - BINARY_PATH="bin/$PLATFORM_DIR/$binary" |
53 | | - if [ -f "$BINARY_PATH" ]; then |
54 | | - echo "Testing $binary..." |
55 | | - # Test that the binary can at least show usage without crashing |
56 | | - if $BINARY_PATH 2>&1 | head -5; then |
57 | | - echo "✓ $binary executed successfully" |
58 | | - else |
59 | | - echo "✗ $binary failed to execute" |
60 | | - exit 1 |
61 | | - fi |
| 113 | + echo "Programs built: $(ls -1 "bin/$PLATFORM_DIR" | wc -l)" |
| 114 | +
|
| 115 | + # `make World` returns 0 even when a subdirectory fails - a broken |
| 116 | + # dconvert build reports "Error 2" and the top level make still exits |
| 117 | + # 0 - so the exit status above guarantees nothing. These checks are |
| 118 | + # what actually gates the archive. himrtodc, himrdump, ge9800todc and |
| 119 | + # ge9800dump are the canaries for the /dev/tty problem described |
| 120 | + # above: they are exactly what goes missing when the awk header |
| 121 | + # generation runs without a terminal. (himrunid is not, despite the |
| 122 | + # name: it is an installed script, so it appears either way.) |
| 123 | + echo "Checking that the build is complete..." |
| 124 | + MISSING="" |
| 125 | + for program in dciodvfy dcdump dcfile dcentvfy dcdisp \ |
| 126 | + himrtodc himrdump ge9800todc ge9800dump; do |
| 127 | + [ -f "bin/$PLATFORM_DIR/$program" ] || MISSING="$MISSING $program" |
| 128 | + done |
| 129 | + if [ -n "$MISSING" ]; then |
| 130 | + echo "✗ incomplete build, missing:$MISSING" |
| 131 | + exit 1 |
| 132 | + fi |
| 133 | + echo "✓ all required programs present" |
| 134 | +
|
| 135 | + echo "Testing binary execution to ensure they work correctly..." |
| 136 | + for program in dciodvfy dcdump dcfile dcentvfy; do |
| 137 | + # stdin from /dev/null so a program that reads it cannot hang. |
| 138 | + # Captured through an if so that set -e does not fire on the |
| 139 | + # non-zero status a usage message legitimately exits with, and so |
| 140 | + # that the status is the program's own and not head's. |
| 141 | + if OUTPUT=$("bin/$PLATFORM_DIR/$program" </dev/null 2>&1); then |
| 142 | + STATUS=0 |
62 | 143 | else |
63 | | - echo "⚠ $binary not found at $BINARY_PATH" |
| 144 | + STATUS=$? |
| 145 | + fi |
| 146 | + printf '%s\n' "$OUTPUT" | head -5 |
| 147 | + if [ "$STATUS" -ge 128 ]; then |
| 148 | + echo "✗ $program died on signal $((STATUS - 128))" |
| 149 | + exit 1 |
64 | 150 | fi |
| 151 | + echo "✓ $program executed successfully" |
| 152 | + done |
| 153 | +
|
| 154 | + echo "::group::Dependencies of dciodvfy and dcdisp" |
| 155 | + # dcdisp is the one program that links X11; the archive ships no X11 |
| 156 | + # of its own, so it resolves against the user's libX11.so.6. |
| 157 | + for program in dciodvfy dcdisp; do |
| 158 | + echo "$program:" |
| 159 | + objdump -p "bin/$PLATFORM_DIR/$program" | grep NEEDED |
| 160 | + readelf -V "bin/$PLATFORM_DIR/$program" \ |
| 161 | + | grep -oE '(GLIBC|GLIBCXX|CXXABI|GCC)_[0-9.]+' | sort -u -V | tr '\n' ' ' |
| 162 | + echo |
65 | 163 | done |
66 | | - |
67 | | - echo "All binary execution tests passed!" |
| 164 | + echo "::endgroup::" |
68 | 165 |
|
69 | | - - name: Check binary dependencies |
| 166 | + # The regression guard for issue #19: the highest versioned glibc |
| 167 | + # symbol any shipped program references is its true floor, and it must |
| 168 | + # stay at or below the container's glibc. |
| 169 | + # |
| 170 | + # bin also holds shell scripts (dccmp, dcdiff), and they have to be |
| 171 | + # recognised by their ELF magic rather than by letting readelf reject |
| 172 | + # them: CentOS 7's readelf aborts on a non-ELF file instead of |
| 173 | + # failing cleanly, which works but fills the log with signal noise. |
| 174 | + is_elf() { |
| 175 | + [ "$(od -A n -t x1 -N 4 "$1" 2>/dev/null | tr -d ' ')" = "7f454c46" ] |
| 176 | + } |
| 177 | +
|
| 178 | + echo "Checking the glibc floor of every program..." |
| 179 | + HIGHEST=$( |
| 180 | + for f in "bin/$PLATFORM_DIR"/*; do |
| 181 | + is_elf "$f" || continue |
| 182 | + readelf -V "$f" | grep -oE 'GLIBC_[0-9]+\.[0-9]+(\.[0-9]+)?' |
| 183 | + done | sed 's/^GLIBC_//' | sort -u -V | tail -1 |
| 184 | + ) |
| 185 | + echo "Highest glibc symbol version referenced: ${HIGHEST:-none}" |
| 186 | + if [ -z "$HIGHEST" ]; then |
| 187 | + # Every program is dynamically linked against glibc, so finding |
| 188 | + # no versioned reference at all means the scan itself broke |
| 189 | + # rather than that the floor is low. |
| 190 | + echo "✗ found no glibc symbol versions to check" |
| 191 | + exit 1 |
| 192 | + fi |
| 193 | + if [ "$(printf '%s\n%s\n' "$HIGHEST" "$GLIBC_FLOOR" | sort -V | tail -1)" != "$GLIBC_FLOOR" ]; then |
| 194 | + echo "✗ requires glibc $HIGHEST, above the $GLIBC_FLOOR floor this package promises" |
| 195 | + exit 1 |
| 196 | + fi |
| 197 | + echo "✓ glibc floor is $GLIBC_FLOOR or lower" |
| 198 | + SCRIPT |
| 199 | +
|
| 200 | + - name: Build in ${{ matrix.image }} |
70 | 201 | run: | |
71 | | - echo "Checking binary dependencies..." |
72 | | - |
73 | | - # Get the platform-specific directory name |
74 | | - PLATFORM_DIR=$(ls -1 bin | head -1) |
75 | | - |
76 | | - # Check dependencies for a key binary |
77 | | - echo "Dependencies for dciodvfy:" |
78 | | - ldd bin/$PLATFORM_DIR/dciodvfy |
79 | | - |
80 | | - # Check GLIBC and GLIBCXX versions required |
81 | | - echo "" |
82 | | - echo "Required GLIBC versions:" |
83 | | - objdump -T bin/$PLATFORM_DIR/dciodvfy | grep GLIBC | awk '{print $5}' | grep GLIBC | sort -u |
84 | | - |
85 | | - echo "" |
86 | | - echo "Required GLIBCXX versions:" |
87 | | - objdump -T bin/$PLATFORM_DIR/dciodvfy | grep GLIBCXX | awk '{print $5}' | grep GLIBCXX | sort -u |
| 202 | + docker run --rm \ |
| 203 | + -v "$PWD":/work -w /work \ |
| 204 | + -v "$RUNNER_TEMP/build-in-container.sh":/build-in-container.sh:ro \ |
| 205 | + -e INSTALL_CMD="${{ matrix.install }}" \ |
| 206 | + -e GLIBC_FLOOR="${{ matrix.glibc_floor }}" \ |
| 207 | + -e HOST_UID="$(id -u)" -e HOST_GID="$(id -g)" \ |
| 208 | + "${{ matrix.image }}" bash /build-in-container.sh |
88 | 209 |
|
89 | 210 | - name: Package binaries |
90 | 211 | run: | |
91 | 212 | # Get the platform-specific directory name |
92 | 213 | PLATFORM_DIR=$(ls -1 bin | head -1) |
93 | 214 | echo "Platform directory: $PLATFORM_DIR" |
94 | | - |
95 | | - # Create a tar.gz archive of the binaries |
96 | | - cd bin/$PLATFORM_DIR |
97 | | - tar -czf ../../dicom3tools-linux-x86_64.tar.gz . |
| 215 | +
|
| 216 | + # Flat archive, tools at the root, matching the macOS and Windows |
| 217 | + # packages: consumers can put one directory on PATH. |
| 218 | + cd "bin/$PLATFORM_DIR" |
| 219 | + tar -czf "../../dicom3tools-linux-${{ matrix.arch }}.tar.gz" . |
98 | 220 | cd ../.. |
| 221 | + ls -lh "dicom3tools-linux-${{ matrix.arch }}.tar.gz" |
99 | 222 |
|
100 | 223 | - name: Upload artifact |
101 | 224 | uses: actions/upload-artifact@v7 |
102 | 225 | with: |
103 | | - name: dicom3tools-linux-x86_64 |
104 | | - path: dicom3tools-linux-x86_64.tar.gz |
| 226 | + name: dicom3tools-linux-${{ matrix.arch }} |
| 227 | + path: dicom3tools-linux-${{ matrix.arch }}.tar.gz |
105 | 228 | retention-days: 90 |
106 | 229 |
|
107 | 230 | - name: Attach to release |
108 | 231 | if: github.event_name == 'release' |
109 | 232 | uses: softprops/action-gh-release@v3 |
110 | 233 | with: |
111 | | - files: dicom3tools-linux-x86_64.tar.gz |
| 234 | + files: dicom3tools-linux-${{ matrix.arch }}.tar.gz |
112 | 235 | env: |
113 | 236 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments