Skip to content

Commit deb6cb8

Browse files
committed
wip: add support for xx-dnf
Signed-off-by: Jakub Panek <[email protected]>
1 parent e6b34ab commit deb6cb8

File tree

13 files changed

+669
-60
lines changed

13 files changed

+669
-60
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,11 @@ jobs:
149149
uses: docker/setup-buildx-action@v3
150150
-
151151
name: Test
152-
if: ${{ matrix.typ != 'rhel' }}
153152
uses: docker/bake-action@v4
154153
with:
155154
targets: test
156155
set: |
157156
test-${{ matrix.typ }}.args.TEST_BASE_IMAGE=${{ matrix.image }}
158-
-
159-
name: Test (info)
160-
if: ${{ matrix.typ == 'rhel' }}
161-
uses: docker/bake-action@v4
162-
with:
163-
targets: test-info
164-
set: |
165-
test-${{ matrix.typ }}.args.TEST_BASE_IMAGE=${{ matrix.image }}
166157
167158
build:
168159
runs-on: ubuntu-latest

docker-bake.hcl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ variable "TEST_BASE_TYPE" {
77
}
88

99
variable "TEST_BASE_IMAGE" {
10-
default = TEST_BASE_TYPE == "alpine" ? "alpine:3.19" : TEST_BASE_TYPE == "debian" ? "debian:bookworm" : null
10+
default = TEST_BASE_TYPE == "alpine" ? "alpine:3.19" : TEST_BASE_TYPE == "debian" ? "debian:bookworm" : TEST_BASE_TYPE == "rhel" ? "fedora:39" : null
1111
}
1212

1313
variable "DEV_SDK_PLATFORM" {
@@ -41,7 +41,7 @@ target "test-rhel" {
4141
inherits = ["test-src"]
4242
args = {
4343
TEST_BASE_TYPE = "rhel"
44-
TEST_BASE_IMAGE = "fedora:35"
44+
TEST_BASE_IMAGE = "fedora:40"
4545
}
4646
}
4747

@@ -55,6 +55,7 @@ group "test" {
5555
"test-info",
5656
"test-apk",
5757
"test-apt",
58+
"test-dnf",
5859
"test-verify",
5960
"test-clang",
6061
"test-go",
@@ -77,6 +78,11 @@ target "test-apt" {
7778
target = "test-apt"
7879
}
7980

81+
target "test-dnf" {
82+
inherits = ["test-base"]
83+
target = "test-dnf"
84+
}
85+
8086
target "test-verify" {
8187
inherits = ["test-base"]
8288
target = "test-verify"
@@ -356,4 +362,4 @@ target "sigtool" {
356362
"linux/arm64",
357363
"linux/arm/v7",
358364
]
359-
}
365+
}

src/Dockerfile

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ COPY xx-* /out/
1010
RUN ln -s xx-cc /out/xx-clang && \
1111
ln -s xx-cc /out/xx-clang++ && \
1212
ln -s xx-cc /out/xx-c++ && \
13-
ln -s xx-apt /out/xx-apt-get
13+
ln -s xx-apt /out/xx-apt-get && \
14+
ln -s xx-dnf /out/xx-yum && \
15+
ln -s xx-dnf /out/xx-microdnf && \
16+
ln -s xx-dnf /out/xx-dnf5 && \
17+
ln -s xx-dnf /out/xx-dnf4 && \
18+
ln -s xx-dnf /out/xx-dnf-3
1419

1520
# xx builds the xx image
1621
FROM scratch AS xx
@@ -34,27 +39,72 @@ RUN --mount=type=cache,target=/pkg-cache \
3439
WORKDIR /work
3540

3641
FROM ${TEST_BASE_IMAGE} AS test-base-rhel
37-
RUN <<EOT
42+
RUN --mount=type=cache,target=/pkg-cache <<EOT
3843
set -ex
39-
if ! yum install -y epel-release; then
44+
45+
if test -e /etc/os-release; then
46+
. /etc/os-release
47+
fi
48+
49+
if test -d /var/cache/yum; then
50+
rm -rf /var/cache/yum
51+
ln -s /pkg-cache /var/cache/yum
52+
fi
53+
54+
if test -d /var/cache/dnf; then
55+
rm -rf /var/cache/dnf
56+
ln -s /pkg-cache /var/cache/dnf
57+
fi
58+
59+
case "${ID}" in
60+
centos)
61+
sed 's/keepcache=0/keepcache=1/g' /etc/yum.conf
62+
;;
63+
*)
64+
echo 'keepcache=True' >> /etc/dnf/dnf.conf
65+
;;
66+
esac
67+
68+
cmd_exists() {
69+
command -v $1 >/dev/null 2>/dev/null
70+
}
71+
72+
get_dnf() {
73+
if cmd_exists dnf; then
74+
echo dnf
75+
elif cmd_exists yum; then
76+
echo yum
77+
elif cmd_exists dnf5; then
78+
echo dnf5
79+
elif cmd_exists dnf4; then
80+
echo dnf4
81+
elif cmd_exists dnf-3; then
82+
echo dnf-3
83+
elif cmd_exists microdnf; then
84+
echo microdnf
85+
else
86+
echo "No supported package manager found"
87+
exit 1
88+
fi
89+
}
90+
91+
arg0="$(get_dnf)"
92+
93+
$arg0 makecache || true
94+
95+
if ! $arg0 install -y epel-release; then
4096
if . /etc/os-release 2>/dev/null; then
4197
case "$ID" in
42-
fedora) ;;
43-
rocky)
44-
dnf install -y epel-release
45-
;;
98+
fedora|rocky) ;;
4699
*)
47-
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${VERSION:0:1}.noarch.rpm
48-
yum update -y
100+
$arg0 install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${VERSION:0:1}.noarch.rpm
101+
$arg0 update -y
49102
;;
50103
esac
51104
fi
52105
fi
53-
if command -v dnf >/dev/null 2>/dev/null; then
54-
dnf install -y bats vim
55-
else
56-
yum install -y bats vim
57-
fi
106+
107+
$arg0 install -y bats vim
58108
EOT
59109
WORKDIR /work
60110

@@ -83,6 +133,10 @@ FROM test-base AS test-apk
83133
COPY test-apk.bats .
84134
RUN --mount=type=cache,target=/pkg-cache,sharing=locked [ ! -f /etc/alpine-release ] || ./test-apk.bats
85135

136+
FROM test-base AS test-dnf
137+
COPY test-dnf.bats .
138+
RUN --mount=type=cache,target=/pkg-cache,sharing=locked [ ! -f /etc/system-release ] || ./test-dnf.bats
139+
86140
FROM test-base AS test-verify
87141
COPY test-verify.bats .
88142
RUN --mount=type=cache,target=/pkg-cache,sharing=locked ./test-verify.bats

src/test-cargo.bats

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ testHelloCargoRustup() {
111111
debian | ubuntu)
112112
add cargo
113113
;;
114+
fedora)
115+
add cargo
116+
;;
114117
esac
115118
}
116119

0 commit comments

Comments
 (0)