Skip to content

Commit 1e848f4

Browse files
committed
fixes ubuntu certificate
1 parent 48ae27e commit 1e848f4

2 files changed

Lines changed: 81 additions & 51 deletions

File tree

ci/distros_tags.sh

Lines changed: 76 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,89 @@
11
#!/usr/bin/env bash
2-
# -e — Exit on error
3-
# -u — Treat unset variables as an error
4-
# -o pipefail — Prevent errors in a pipeline from being masked
52
set -euo pipefail
63

7-
get_ubuntu_lts() { echo "24.04"; }
8-
get_fedora_latest() { echo "40"; }
9-
get_arch_latest() { echo "latest"; }
4+
get_ubuntu_lts() { echo "24.04"; }
5+
get_fedora_latest() { echo "40"; }
6+
get_arch_latest() { echo "latest"; }
107
get_almalinux_latest() { echo "9.4"; }
11-
get_debian_latest() { echo "13"; }
12-
get_rhel_latest() { echo "9.4"; }
13-
get_geant4_tag() { echo "11.3.2"; }
14-
15-
#!/usr/bin/env bash
16-
set -euo pipefail
17-
18-
# ... your get_* functions stay the same ...
8+
get_debian_latest() { echo "13"; }
9+
get_rhel_latest() { echo "9.4"; }
10+
get_geant4_tag() { echo "11.3.2"; }
1911

12+
# Pretty-print with jq if available, otherwise emit compact JSON
2013
build_matrix() {
21-
local geant4_tag
22-
geant4_tag="$(get_geant4_tag)"
23-
cat <<EOF
24-
{
25-
"include": [
26-
{ "distro": "ubuntu", "docker_from": "ubuntu:$(get_ubuntu_lts)", "geant4_tag": "${geant4_tag}" },
27-
{ "distro": "fedora", "docker_from": "fedora:$(get_fedora_latest)", "geant4_tag": "${geant4_tag}" },
28-
{ "distro": "arch", "docker_from": "archlinux:$(get_arch_latest)", "geant4_tag": "${geant4_tag}" },
29-
{ "distro": "almalinux", "docker_from": "almalinux:$(get_almalinux_latest)", "geant4_tag": "${geant4_tag}" },
30-
{ "distro": "debian", "docker_from": "debian:$(get_debian_latest)", "geant4_tag": "${geant4_tag}" },
31-
{ "distro": "rhel", "docker_from": "redhat/ubi9:$(get_rhel_latest)","geant4_tag": "${geant4_tag}" }
32-
]
33-
}
14+
local json
15+
json=$(
16+
cat <<EOF
17+
{"include":[
18+
{"distro":"ubuntu","docker_from":"ubuntu:$(get_ubuntu_lts)","geant4_tag":"$(get_geant4_tag)"},
19+
{"distro":"fedora","docker_from":"fedora:$(get_fedora_latest)","geant4_tag":"$(get_geant4_tag)"},
20+
{"distro":"arch","docker_from":"archlinux:$(get_arch_latest)","geant4_tag":"$(get_geant4_tag)"},
21+
{"distro":"almalinux","docker_from":"almalinux:$(get_almalinux_latest)","geant4_tag":"$(get_geant4_tag)"},
22+
{"distro":"debian","docker_from":"debian:$(get_debian_latest)","geant4_tag":"$(get_geant4_tag)"},
23+
{"distro":"rhel","docker_from":"redhat/ubi9:$(get_rhel_latest)","geant4_tag":"$(get_geant4_tag)"}
24+
]}
3425
EOF
26+
)
27+
if command -v jq >/dev/null 2>&1; then
28+
printf '%s' "$json" | jq .
29+
else
30+
printf '%s' "$json"
31+
fi
32+
}
33+
34+
# portable lowercasing (works on old bash, dash, zsh)
35+
lc() { printf '%s' "$1" | tr '[:upper:]' '[:lower:]'; }
36+
37+
# Build a clean GHCR image ref: ghcr.io/<owner>/<repo>
38+
build_image_ref() {
39+
# Owner from env (Actions sets this). Fallback for local runs.
40+
local owner="${GITHUB_REPOSITORY_OWNER:-JeffersonLab}"
41+
42+
# Repo name = LAST segment of GITHUB_REPOSITORY (strip any "owner/" prefix).
43+
# Fallback to a default if env is missing during local runs.
44+
local repo_full="${GITHUB_REPOSITORY:-jeffersonlab/geant4-docker}"
45+
local repo="${repo_full##*/}"
46+
47+
# Lowercase both parts (GHCR requires lowercase)
48+
printf 'ghcr.io/%s/%s' "$(lc "$owner")" "$(lc "$repo")"
3549
}
3650

3751
main() {
38-
# Compute image ref (lowercase) for GHCR
39-
local owner repo owner_lc repo_lc image
40-
owner="${GITHUB_REPOSITORY_OWNER:-JeffersonLab}"
41-
repo="${GITHUB_REPOSITORY##*/:-geant4}"
42-
owner_lc="$(echo "$owner" | tr '[:upper:]' '[:lower:]')"
43-
repo_lc="$(echo "$repo" | tr '[:upper:]' '[:lower:]')"
44-
image="ghcr.io/${owner_lc}/${repo_lc}"
45-
46-
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
47-
# Running in GitHub Actions: write multi-line outputs
48-
local DELIM="MATRIX_$(date +%s%N)"
49-
{
50-
echo "matrix<<$DELIM"
51-
build_matrix
52-
echo "$DELIM"
53-
echo "image=$image"
54-
} >> "$GITHUB_OUTPUT"
55-
else
56-
# Local run: print JSON to stdout for inspection
57-
build_matrix
58-
echo "# image=$image" >&2
59-
fi
52+
# Resolve owner/repo and force lowercase (portable)
53+
local owner repo owner_lc repo_lc image
54+
owner="${GITHUB_REPOSITORY_OWNER:-JeffersonLab}"
55+
repo="${GITHUB_REPOSITORY##*/}"
56+
: "${repo:=geant4}"
57+
58+
owner_lc="$(printf '%s' "$owner" | tr '[:upper:]' '[:lower:]')"
59+
repo_lc="$(printf '%s' "$repo" | tr '[:upper:]' '[:lower:]')"
60+
image="$(build_image_ref)"
61+
62+
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
63+
DELIM="MATRIX_$(date +%s%N)"
64+
{
65+
echo "matrix<<$DELIM"
66+
build_matrix
67+
echo "$DELIM"
68+
echo "image=$image"
69+
} >>"$GITHUB_OUTPUT"
70+
else
71+
build_matrix
72+
echo "# image=$image" >&2
73+
fi
74+
75+
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
76+
local DELIM="MATRIX_$(date +%s%N)"
77+
{
78+
echo "matrix<<$DELIM"
79+
build_matrix
80+
echo "$DELIM"
81+
echo "image=$image"
82+
} >>"$GITHUB_OUTPUT"
83+
else
84+
build_matrix
85+
echo "# image=$image" >&2
86+
fi
6087
}
6188

6289
main "$@"

ci/g4pkglist.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ def packages_install_commands(image: str) -> str:
168168
)
169169
commands += f"RUN dnf install -y --allowerasing {packages}{cleanup}"
170170
elif distro == "ubuntu":
171+
commands += "RUN apt update\n\n"
172+
commands += "# Install ca-certificates tools\n"
173+
commands += "RUN apt-get install -y ca-certificates\n"
171174
commands += "RUN update-ca-certificates\n\n"
172175
commands += (
173176
"RUN ln -fs /usr/share/zoneinfo/America/New_York /etc/localtime \\\n"
@@ -195,7 +198,7 @@ def install_root_from_ubuntu_tarball(local_setup_file):
195198
commands += '# root installation using tarball\n'
196199
commands += f'RUN cd {root_install_dir} \\\n'
197200
commands += f' && {curl_command({root_remote_file})} \\\n'
198-
commands += f' && tar -xzvf {root_file} \\\n'
201+
commands += f' && tar -xzf {root_file} \\\n'
199202
commands += f' && rm {root_file} \\\n'
200203
commands += f' && echo "cd {root_install_dir}/root/bin ; source thisroot.sh ; cd -" >> {local_setup_file}\n'
201204
return commands
@@ -211,7 +214,7 @@ def install_meson():
211214
commands += '# meson installation using tarball\n'
212215
commands += f'RUN cd {meson_install_dir} \\\n'
213216
commands += f' && {curl_command({meson_remote_file})} \\\n'
214-
commands += f' && tar -xzvf {meson_file} \\\n'
217+
commands += f' && tar -xzf {meson_file} \\\n'
215218
commands += f' && rm {meson_file} \\\n'
216219
commands += f' && ln -s {meson_install_dir}/meson-{meson_version}/meson.py /usr/bin/meson\n'
217220
return commands

0 commit comments

Comments
 (0)