Skip to content

Commit

Permalink
wip: add support for xx-dnf
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Panek <[email protected]>
  • Loading branch information
panekj committed Jun 17, 2024
1 parent e6b34ab commit deb6cb8
Show file tree
Hide file tree
Showing 13 changed files with 669 additions and 60 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,11 @@ jobs:
uses: docker/setup-buildx-action@v3
-
name: Test
if: ${{ matrix.typ != 'rhel' }}
uses: docker/bake-action@v4
with:
targets: test
set: |
test-${{ matrix.typ }}.args.TEST_BASE_IMAGE=${{ matrix.image }}
-
name: Test (info)
if: ${{ matrix.typ == 'rhel' }}
uses: docker/bake-action@v4
with:
targets: test-info
set: |
test-${{ matrix.typ }}.args.TEST_BASE_IMAGE=${{ matrix.image }}
build:
runs-on: ubuntu-latest
Expand Down
12 changes: 9 additions & 3 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ variable "TEST_BASE_TYPE" {
}

variable "TEST_BASE_IMAGE" {
default = TEST_BASE_TYPE == "alpine" ? "alpine:3.19" : TEST_BASE_TYPE == "debian" ? "debian:bookworm" : null
default = TEST_BASE_TYPE == "alpine" ? "alpine:3.19" : TEST_BASE_TYPE == "debian" ? "debian:bookworm" : TEST_BASE_TYPE == "rhel" ? "fedora:39" : null
}

variable "DEV_SDK_PLATFORM" {
Expand Down Expand Up @@ -41,7 +41,7 @@ target "test-rhel" {
inherits = ["test-src"]
args = {
TEST_BASE_TYPE = "rhel"
TEST_BASE_IMAGE = "fedora:35"
TEST_BASE_IMAGE = "fedora:40"
}
}

Expand All @@ -55,6 +55,7 @@ group "test" {
"test-info",
"test-apk",
"test-apt",
"test-dnf",
"test-verify",
"test-clang",
"test-go",
Expand All @@ -77,6 +78,11 @@ target "test-apt" {
target = "test-apt"
}

target "test-dnf" {
inherits = ["test-base"]
target = "test-dnf"
}

target "test-verify" {
inherits = ["test-base"]
target = "test-verify"
Expand Down Expand Up @@ -356,4 +362,4 @@ target "sigtool" {
"linux/arm64",
"linux/arm/v7",
]
}
}
82 changes: 68 additions & 14 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ COPY xx-* /out/
RUN ln -s xx-cc /out/xx-clang && \
ln -s xx-cc /out/xx-clang++ && \
ln -s xx-cc /out/xx-c++ && \
ln -s xx-apt /out/xx-apt-get
ln -s xx-apt /out/xx-apt-get && \
ln -s xx-dnf /out/xx-yum && \
ln -s xx-dnf /out/xx-microdnf && \
ln -s xx-dnf /out/xx-dnf5 && \
ln -s xx-dnf /out/xx-dnf4 && \
ln -s xx-dnf /out/xx-dnf-3

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

FROM ${TEST_BASE_IMAGE} AS test-base-rhel
RUN <<EOT
RUN --mount=type=cache,target=/pkg-cache <<EOT
set -ex
if ! yum install -y epel-release; then

if test -e /etc/os-release; then
. /etc/os-release
fi

if test -d /var/cache/yum; then
rm -rf /var/cache/yum
ln -s /pkg-cache /var/cache/yum
fi

if test -d /var/cache/dnf; then
rm -rf /var/cache/dnf
ln -s /pkg-cache /var/cache/dnf
fi

case "${ID}" in
centos)
sed 's/keepcache=0/keepcache=1/g' /etc/yum.conf
;;
*)
echo 'keepcache=True' >> /etc/dnf/dnf.conf
;;
esac

cmd_exists() {
command -v $1 >/dev/null 2>/dev/null
}

get_dnf() {
if cmd_exists dnf; then
echo dnf
elif cmd_exists yum; then
echo yum
elif cmd_exists dnf5; then
echo dnf5
elif cmd_exists dnf4; then
echo dnf4
elif cmd_exists dnf-3; then
echo dnf-3
elif cmd_exists microdnf; then
echo microdnf
else
echo "No supported package manager found"
exit 1
fi
}

arg0="$(get_dnf)"

$arg0 makecache || true

if ! $arg0 install -y epel-release; then
if . /etc/os-release 2>/dev/null; then
case "$ID" in
fedora) ;;
rocky)
dnf install -y epel-release
;;
fedora|rocky) ;;
*)
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${VERSION:0:1}.noarch.rpm
yum update -y
$arg0 install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${VERSION:0:1}.noarch.rpm
$arg0 update -y
;;
esac
fi
fi
if command -v dnf >/dev/null 2>/dev/null; then
dnf install -y bats vim
else
yum install -y bats vim
fi

$arg0 install -y bats vim
EOT
WORKDIR /work

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

FROM test-base AS test-dnf
COPY test-dnf.bats .
RUN --mount=type=cache,target=/pkg-cache,sharing=locked [ ! -f /etc/system-release ] || ./test-dnf.bats

FROM test-base AS test-verify
COPY test-verify.bats .
RUN --mount=type=cache,target=/pkg-cache,sharing=locked ./test-verify.bats
Expand Down
3 changes: 3 additions & 0 deletions src/test-cargo.bats
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ testHelloCargoRustup() {
debian | ubuntu)
add cargo
;;
fedora)
add cargo
;;
esac
}

Expand Down
Loading

0 comments on commit deb6cb8

Please sign in to comment.