From a8df2214212233d8fd2b07b84755daa87c2fe0c1 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Wed, 18 Sep 2019 12:07:05 -0400 Subject: [PATCH 1/2] BuildSourceImage: fail early if mkdir fails Signed-off-by: Vincent Batts --- BuildSourceImage.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/BuildSourceImage.sh b/BuildSourceImage.sh index 84b0248..4296dbd 100755 --- a/BuildSourceImage.sh +++ b/BuildSourceImage.sh @@ -976,6 +976,10 @@ main() { _rm_rf "${TMPDIR}" fi _mkdir_p "${TMPDIR}" + ret=$? + if [ ${ret} -ne 0 ] ; then + _error "failed to mkdir ${TMP}" + fi # setup rootfs to be inspected (if any) rootfs="" From a8636525053b8339a73e1caa1cc9e84a7adc9bd0 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Thu, 19 Sep 2019 05:23:40 -0400 Subject: [PATCH 2/2] *: default the container to /tmp basedir for non-root and adding an example to the README showing to run as non-root inside the container as well. Signed-off-by: Vincent Batts --- Dockerfile | 2 +- README.md | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d6a4727..a50044c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ RUN mkdir -p /output ENV OUTPUT_DIR=/output VOLUME /output -ENTRYPOINT ["/usr/local/bin/BuildSourceImage.sh"] +ENTRYPOINT ["/usr/local/bin/BuildSourceImage.sh", "-b", "/tmp/"] diff --git a/README.md b/README.md index b566eae..b3b7b7c 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,12 @@ Usage: BuildSourceImage.sh [-D] [-b ] [-c ] [-e ] [-r ] ``` -It also nicely usable inside a container +Nicely usable inside a container: + ```bash -$> buildah build-using-dockerfile -t containers/buildsourceimage . +$> podman build -t containers/buildsourceimage . +$> mkdir ./output/ +$> podman run -it -v $(pwd)/output/:/output/ -v $(pwd)/SRCRPMS/:/data/ -u $(id -u) containers/buildsourceimage -s /data/ ``` ## Examples @@ -45,4 +48,3 @@ $> buildah build-using-dockerfile -t containers/buildsourceimage . * Build a source code image from a collection of known `.src.rpm`'s * Include additional build context into the source image * Include extra sources use -