mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] scripts: add container.sh as simple podman wrapper
@ 2023-06-12  6:56 Ahmad Fatoum
  2023-06-12  7:01 ` [PATCH] fixup! " Ahmad Fatoum
  2023-06-13  8:44 ` [PATCH] " Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-06-12  6:56 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

We have a Containerfile in tree now that is used for CI, but it's not
completely self evident, how to use it locally. Add a simple script
that mounts the current working directory into the container and calls
its arguments inside.

Example building MAKEALL (Some configs will expectedly fail due to size
or firmware constraints):

  ./scripts/container.sh ./MAKEALL

Example starting a shell:

  ./scripts/container.sh /bin/bash

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 scripts/container.sh | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100755 scripts/container.sh

diff --git a/scripts/container.sh b/scripts/container.sh
new file mode 100755
index 000000000000..4ddee7d0a90c
--- /dev/null
+++ b/scripts/container.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+CONTAINER=${CONTAINER:-ghcr.io/barebox/barebox/barebox-ci:latest}
+KCONFIG_ADD="$test/kconfig/disable_target_tools.kconf KCONFIG_ADD"
+
+while getopts "c:uh" opt; do
+	case "$opt" in
+	h)
+		echo "usage: $0 [-c CONTAINER] [command...]"
+		echo "This script mounts the working directory into a container"
+		echo "and runs the specified command inside or /bin/bash if no"
+		echo "command was specified."
+		echo "OPTIONS:"
+		echo "  -c <container>    container image to use (default: $CONTAINER)"
+		echo "  -u                pull container image updates"
+		echo "  -h                This help text"
+
+		exit 0
+		;;
+	u)
+		update=1
+		;;
+	c)
+		CONTAINER="$OPTARG"
+		;;
+	esac
+done
+
+shift $((OPTIND-1))
+
+[ -n "$update" ] && podman pull "$CONTAINER"
+
+pwd_real=$(realpath $PWD)
+
+exec podman run -it -v "$PWD:$PWD:z" -v "$pwd_real:$pwd_real:z" --rm \
+	-e TERM -e ARCH -e CONFIG -e JOBS -e LOGDIR -e REGEX \
+	-e KCONFIG_ADD -w "$PWD" --userns=keep-id \
+	-- "$CONTAINER" "${@:-/bin/bash}"
-- 
2.40.1




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] fixup! scripts: add container.sh as simple podman wrapper
  2023-06-12  6:56 [PATCH] scripts: add container.sh as simple podman wrapper Ahmad Fatoum
@ 2023-06-12  7:01 ` Ahmad Fatoum
  2023-06-13  8:44 ` [PATCH] " Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-06-12  7:01 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

fix typos. The toolchains in the container have no libc, so it's
probably easiest to just set test/kconfig/disable_target_tools.kconf
globally, so ./MAKEALL mostly works.

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
 scripts/container.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/container.sh b/scripts/container.sh
index 4ddee7d0a90c..eb1e87b59baa 100755
--- a/scripts/container.sh
+++ b/scripts/container.sh
@@ -2,7 +2,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 
 CONTAINER=${CONTAINER:-ghcr.io/barebox/barebox/barebox-ci:latest}
-KCONFIG_ADD="$test/kconfig/disable_target_tools.kconf KCONFIG_ADD"
+export KCONFIG_ADD="test/kconfig/disable_target_tools.kconf $KCONFIG_ADD"
 
 while getopts "c:uh" opt; do
 	case "$opt" in
-- 
2.40.1




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scripts: add container.sh as simple podman wrapper
  2023-06-12  6:56 [PATCH] scripts: add container.sh as simple podman wrapper Ahmad Fatoum
  2023-06-12  7:01 ` [PATCH] fixup! " Ahmad Fatoum
@ 2023-06-13  8:44 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2023-06-13  8:44 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jun 12, 2023 at 08:56:26AM +0200, Ahmad Fatoum wrote:
> We have a Containerfile in tree now that is used for CI, but it's not
> completely self evident, how to use it locally. Add a simple script
> that mounts the current working directory into the container and calls
> its arguments inside.
> 
> Example building MAKEALL (Some configs will expectedly fail due to size
> or firmware constraints):
> 
>   ./scripts/container.sh ./MAKEALL
> 
> Example starting a shell:
> 
>   ./scripts/container.sh /bin/bash
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
>  scripts/container.sh | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100755 scripts/container.sh

Applied, thanks

Sascha

> 
> diff --git a/scripts/container.sh b/scripts/container.sh
> new file mode 100755
> index 000000000000..4ddee7d0a90c
> --- /dev/null
> +++ b/scripts/container.sh
> @@ -0,0 +1,39 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-only
> +
> +CONTAINER=${CONTAINER:-ghcr.io/barebox/barebox/barebox-ci:latest}
> +KCONFIG_ADD="$test/kconfig/disable_target_tools.kconf KCONFIG_ADD"
> +
> +while getopts "c:uh" opt; do
> +	case "$opt" in
> +	h)
> +		echo "usage: $0 [-c CONTAINER] [command...]"
> +		echo "This script mounts the working directory into a container"
> +		echo "and runs the specified command inside or /bin/bash if no"
> +		echo "command was specified."
> +		echo "OPTIONS:"
> +		echo "  -c <container>    container image to use (default: $CONTAINER)"
> +		echo "  -u                pull container image updates"
> +		echo "  -h                This help text"
> +
> +		exit 0
> +		;;
> +	u)
> +		update=1
> +		;;
> +	c)
> +		CONTAINER="$OPTARG"
> +		;;
> +	esac
> +done
> +
> +shift $((OPTIND-1))
> +
> +[ -n "$update" ] && podman pull "$CONTAINER"
> +
> +pwd_real=$(realpath $PWD)
> +
> +exec podman run -it -v "$PWD:$PWD:z" -v "$pwd_real:$pwd_real:z" --rm \
> +	-e TERM -e ARCH -e CONFIG -e JOBS -e LOGDIR -e REGEX \
> +	-e KCONFIG_ADD -w "$PWD" --userns=keep-id \
> +	-- "$CONTAINER" "${@:-/bin/bash}"
> -- 
> 2.40.1
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-13  8:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12  6:56 [PATCH] scripts: add container.sh as simple podman wrapper Ahmad Fatoum
2023-06-12  7:01 ` [PATCH] fixup! " Ahmad Fatoum
2023-06-13  8:44 ` [PATCH] " Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox