Skip to content

Commit

Permalink
Merge pull request #155 from crazy-max/rpm-builddep
Browse files Browse the repository at this point in the history
common: rpm-builddep
  • Loading branch information
crazy-max committed Aug 6, 2023
2 parents 36c65fe + 22d1e86 commit 600b92c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 112 deletions.
38 changes: 38 additions & 0 deletions common/scripts/rpm-builddep.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash

# Copyright 2023 Docker Packaging authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

arch=$1
specsDir=$2

if [[ -z "$arch" ]] || [[ -z "$specsDir" ]]; then
echo "usage: ./rpm-builddep <arch> <specs-dir>" >&2
exit 1
fi

set -e

builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $arch dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $arch"
else
echo "unable to detect package manager" >&2
exit 1
fi

set -x
$builddepCmd -y "$specsDir"/*.spec
16 changes: 2 additions & 14 deletions pkg/buildx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG BUILDX_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/compose/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG COMPOSE_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/containerd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG CONTAINERD_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/credential-helpers/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG CREDENTIAL_HELPERS_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/docker-cli/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG DOCKER_CLI_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/docker-engine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG DOCKER_ENGINE_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/sbom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG SBOM_REF
ARG NIGHTLY_BUILD
Expand Down
16 changes: 2 additions & 14 deletions pkg/scan/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,8 @@ RUN --mount=type=bind,from=common-scripts,source=rpm-init.sh,target=/usr/local/b
rpm-init $PKG_RELEASE
COPY rpm /root/rpmbuild/SPECS
ARG TARGETPLATFORM
RUN <<EOT
set -e
builddepCmd=""
if command -v dnf &> /dev/null; then
builddepCmd="setarch $(xx-info rhel-arch) dnf builddep --nobest"
elif command -v yum-builddep &> /dev/null; then
builddepCmd="yum-builddep --target $(xx-info rhel-arch)"
else
echo >&2 "unable to detect package manager"
exit 1
fi
set -x
$builddepCmd -y /root/rpmbuild/SPECS/*.spec
EOT
RUN --mount=type=bind,from=common-scripts,source=rpm-builddep.sh,target=/usr/local/bin/rpm-builddep \
rpm-builddep $(xx-info rhel-arch) /root/rpmbuild/SPECS
WORKDIR /root/rpmbuild
ARG SCAN_REF
ARG NIGHTLY_BUILD
Expand Down

0 comments on commit 600b92c

Please sign in to comment.