From a1a960183ab1e7775c435efd67a27fe35ac8df31 Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Mon, 9 Dec 2024 11:57:25 -0300 Subject: [PATCH 1/3] feat: add justfile + containerfile for local build testing --- .gitignore | 1 + Containerfile | 18 ++++++++++++++++++ Justfile | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .gitignore create mode 100644 Containerfile create mode 100644 Justfile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea1472e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +output/ diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..69a20a1 --- /dev/null +++ b/Containerfile @@ -0,0 +1,18 @@ +FROM registry.fedoraproject.org/fedora:latest AS builder +ARG TARGET_SPEC="${TARGET_SPEC:-staging/devpod/devpod.spec}" + +COPY . /app + +RUN dnf update -y && dnf upgrade -y && dnf install rpkg spectool -y && dnf clean all + +WORKDIR /app +RUN rpkg --path $(dirname $TARGET_SPEC) spec --outdir /tmp --spec $(basename $TARGET_SPEC) +WORKDIR /tmp +RUN export SPEC=$(basename $TARGET_SPEC) && \ + dnf -y builddep $SPEC && \ + spectool -ag $SPEC -C /tmp && \ + rpkg local --spec $SPEC + +FROM scratch AS artifacts + +COPY --from=builder /tmp/rpkg/*/*/*.rpm / diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..becf489 --- /dev/null +++ b/Justfile @@ -0,0 +1,37 @@ +# Run renovate locally to test modules +renovate dry-run="lookup" log-level="debug": + #!/usr/bin/env bash + if ! command -v "renovate" &> /dev/null ; then + echo "You need to install renovate first" + echo "It should be available on brew and on npm." + exit 1 + fi + if [ "$GITHUB_COM_TOKEN" == "" ] ; then + echo "Warning: No Github token found, renovate will nag at you for this." + echo "Set it with GITHUB_COM_TOKEN=(your token)" + fi + LOG_LEVEL=${LOG_LEVEL:-debug} renovate --platform=local --dry-run={{dry-run}} + echo "Updates can be found in a section of the logs called \"packageFiles with updates\"" + +build package="staging/devpod/devpod.spec": + #!/usr/bin/env bash + PKGNAME={{package}} + PKGNAME="${PKGNAME##*/}" + PKGNAME="${PKGNAME%.*}" + buildah bud -f Containerfile -t localhost/${PKGNAME}:latest --build-arg TARGET_SPEC={{package}} . + +extract package="staging/devpod/devpod.spec" extract_rpm="0": + #!/usr/bin/env bash + PKGNAME={{package}} + PKGNAME="${PKGNAME##*/}" + PKGNAME="${PKGNAME%.*}" + mkdir -p output + podman export $(podman create localhost/${PKGNAME}:latest) | tar xf - -C output + if [ {{extract_rpm}} -ne 1 ] ; then + exit 0 + fi + pushd output + for rpm_file in $(find . -iname "*.rpm"); do + rpm2cpio "$rpm_file" | cpio -idmv + done + popd From f5687696e7e436a08366da52e456b2f344eeec8d Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Mon, 9 Dec 2024 12:25:43 -0300 Subject: [PATCH 2/3] fix(just, containerfile): properly get build files --- Containerfile | 9 ++++++--- Justfile | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Containerfile b/Containerfile index 69a20a1..d533007 100644 --- a/Containerfile +++ b/Containerfile @@ -6,13 +6,16 @@ COPY . /app RUN dnf update -y && dnf upgrade -y && dnf install rpkg spectool -y && dnf clean all WORKDIR /app -RUN rpkg --path $(dirname $TARGET_SPEC) spec --outdir /tmp --spec $(basename $TARGET_SPEC) +RUN cp -rf $(dirname $TARGET_SPEC)/* /tmp && \ + rpkg --path $(dirname $TARGET_SPEC) spec --outdir /tmp --spec $(basename $TARGET_SPEC) + WORKDIR /tmp RUN export SPEC=$(basename $TARGET_SPEC) && \ dnf -y builddep $SPEC && \ spectool -ag $SPEC -C /tmp && \ - rpkg local --spec $SPEC + rpkg local --spec $SPEC --outdir /tmp && \ + find /tmp FROM scratch AS artifacts -COPY --from=builder /tmp/rpkg/*/*/*.rpm / +COPY --from=builder /tmp/*/*.rpm / diff --git a/Justfile b/Justfile index becf489..40e837d 100644 --- a/Justfile +++ b/Justfile @@ -25,6 +25,7 @@ extract package="staging/devpod/devpod.spec" extract_rpm="0": PKGNAME={{package}} PKGNAME="${PKGNAME##*/}" PKGNAME="${PKGNAME%.*}" + rm -rf output mkdir -p output podman export $(podman create localhost/${PKGNAME}:latest) | tar xf - -C output if [ {{extract_rpm}} -ne 1 ] ; then From 888e140101679464cb707d03a38c3e1486eb52f0 Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Mon, 9 Dec 2024 12:33:42 -0300 Subject: [PATCH 3/3] feat(just): clean target --- Justfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Justfile b/Justfile index 40e837d..e3dc955 100644 --- a/Justfile +++ b/Justfile @@ -36,3 +36,6 @@ extract package="staging/devpod/devpod.spec" extract_rpm="0": rpm2cpio "$rpm_file" | cpio -idmv done popd + +clean: + rm -rf output