From b3f0f6635695dc91d42a2c49b92d38ae788a5097 Mon Sep 17 00:00:00 2001 From: Doncho Gunchev Date: Sun, 14 Jul 2024 17:17:48 +0300 Subject: [PATCH] Quick and dirty build with podman on MacOS. --- Dockerfile-build | 14 ++++++++++++++ Makefile | 11 +++++++++++ build.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 Dockerfile-build create mode 100755 build.sh diff --git a/Dockerfile-build b/Dockerfile-build new file mode 100644 index 0000000..c69d769 --- /dev/null +++ b/Dockerfile-build @@ -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 diff --git a/Makefile b/Makefile index f4a9348..5efc318 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..95379b3 --- /dev/null +++ b/build.sh @@ -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