Quick and dirty build with podman on MacOS.

This commit is contained in:
Doncho Gunchev 2024-07-14 17:17:48 +03:00
parent 58223f0e8a
commit b3f0f66356
No known key found for this signature in database
GPG key ID: D3FF0619433A66E2
3 changed files with 65 additions and 0 deletions

14
Dockerfile-build Normal file
View file

@ -0,0 +1,14 @@
FROM rockylinux:9 as build
WORKDIR /root/profile.d
COPY ./ .
RUN \
dnf -y update && \
dnf -y install rpmdevtools make
# dnf -y install dnf-plugins-core epel-release && \
# /usr/bin/crb enable && \
RUN ./build.sh

View file

@ -47,3 +47,14 @@ changelog:
.PHONY: clean
clean:
rm -rf dist
.PHONY: podman_rpm
podman_rpm:
podman buildx build -t podman_rpm_build -f Dockerfile-build . # --platform linux/amd64
# Extract the RPMs from the container to ./dist/ locally.
if ! test -d dist; then mkdir dist; fi
podman run --rm -d --name=build localhost/podman_rpm_build /usr/bin/bash -c "trap : TERM INT; sleep infinity & wait"
podman cp build:/tmp/RPMS/. ./dist/
podman stop build
podman image rm localhost/podman_rpm_build

40
build.sh Executable file
View file

@ -0,0 +1,40 @@
#!/usr/bin/env bash
set -euo pipefail
shopt -s nullglob dotglob
if [ "$(uname -s)" != "Linux" ]; then echo "This script only works on Linux!" >&2; exit 254; fi
set -x # debug
. /etc/os-release
ARCH="${ARCH:-$(uname -m)}" #
VER="${VER:-${VERSION_ID%%\.*}}" # 8
DIST_PRE="${PLATFORM_ID##*:}" # el8
DIST="${DIST:-${DIST_PRE%%[0-9]*}}" # el
OUT_DIR="/tmp/RPMS"
export LANG='en_US.UTF-8'
export LANGUAGE="${LANG}"
export LC_ALL="${LANG}"
export LC_MEASUREMENT="${LANG}"
export LC_MONETARY="${LANG}"
export LC_NUMERIC="${LANG}"
export LC_TIME="${LANG}"
rm -rf "$OUT_DIR"
mkdir "$OUT_DIR"
#spectool -g ./*.spec
#
#if [ "$UID" == "0" ]; then
# dnf builddep -y --refresh ./*.spec
#fi
# make rpmsrc
rpmbuild -ta ./dist/*.tar.xz \
--define "_sourcedir $PWD/dist" \
--define "_srcrpmdir $OUT_DIR" \
--define "_rpmdir $OUT_DIR" \
mv "$OUT_DIR"/*/*.rpm "$OUT_DIR/"
rmdir "$OUT_DIR"/* 2>/dev/null || true