mirror of
https://github.com/crosstool-ng/crosstool-ng.git
synced 2025-06-17 14:58:12 +00:00
Add the ability to run some but not all samples in docker
Also, build containers with --no-cache: distributions like ArchLinux retire their packages very quickly, need to always use up-to-date package databases. Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
@ -6,7 +6,4 @@ rm -rf bld-samples
|
|||||||
mkdir bld-samples
|
mkdir bld-samples
|
||||||
cd bld-samples
|
cd bld-samples
|
||||||
export PATH=$HOME/inst-ctng/bin:$PATH
|
export PATH=$HOME/inst-ctng/bin:$PATH
|
||||||
ct-ng help
|
ct-ng build-all ${1+CT_SAMPLES="$*"}
|
||||||
ct-ng list-samples
|
|
||||||
ct-ng list-steps
|
|
||||||
ct-ng build-all
|
|
8
testing/docker/common-scripts/ctng-test-basic
Executable file
8
testing/docker/common-scripts/ctng-test-basic
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
cd
|
||||||
|
export PATH=$HOME/inst-ctng/bin:$PATH
|
||||||
|
ct-ng help
|
||||||
|
ct-ng list-samples
|
||||||
|
ct-ng list-steps
|
@ -19,16 +19,19 @@ usage()
|
|||||||
cat >&2 <<EOF
|
cat >&2 <<EOF
|
||||||
${1:+ERROR :: $1
|
${1:+ERROR :: $1
|
||||||
|
|
||||||
}Usage: $0 [action] [containters]
|
}Usage: $0 [action] [containter] [args...]
|
||||||
|
|
||||||
Action is one of:
|
Action is one of:
|
||||||
|
|
||||||
build Build or rebuild the specified containers.
|
build Build or rebuild the specified containers.
|
||||||
test Run tests (build-all).
|
install Install crosstool-NG in specified containers.
|
||||||
|
sample Build a sample or if no sample name specified, all.
|
||||||
enter Spawn a shell in the specified container.
|
enter Spawn a shell in the specified container.
|
||||||
|
root Spawn a root shell in the specified container.
|
||||||
clean Clean up in the specified container.
|
clean Clean up in the specified container.
|
||||||
|
|
||||||
If containers are not specified, the action is applied to all available containers.
|
If a special container name 'all' is used, the action is performed
|
||||||
|
on all the containers.
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -39,7 +42,7 @@ action_build()
|
|||||||
local cntr=$1
|
local cntr=$1
|
||||||
|
|
||||||
msg "Building Docker container for ${cntr}"
|
msg "Building Docker container for ${cntr}"
|
||||||
docker build -t "ctng-${cntr}" "${cntr}"
|
docker build --no-cache -t "ctng-${cntr}" "${cntr}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Common backend for enter/test
|
# Common backend for enter/test
|
||||||
@ -56,19 +59,29 @@ _dckr()
|
|||||||
-v `pwd`/build-${cntr}:/home \
|
-v `pwd`/build-${cntr}:/home \
|
||||||
-v $HOME/src:/src:ro \
|
-v $HOME/src:/src:ro \
|
||||||
ctng-${cntr} \
|
ctng-${cntr} \
|
||||||
/setup-scripts/su-as-user `id -un` `id -u` `id -gn` `id -g` "$@"
|
${SETUPCMD:-/setup-scripts/su-as-user `id -un` `id -u` `id -gn` `id -g`} "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the test
|
# Run the test
|
||||||
action_test()
|
action_install()
|
||||||
{
|
{
|
||||||
local cntr=$1
|
local cntr=$1
|
||||||
|
|
||||||
# The test assumes the top directory is bootstrapped, but clean.
|
# The test assumes the top directory is bootstrapped, but clean.
|
||||||
msg "Setting up crosstool-NG in ${cntr}"
|
msg "Setting up crosstool-NG in ${cntr}"
|
||||||
_dckr "${cntr}" /setup-scripts/ctng-install
|
_dckr "${cntr}" /setup-scripts/ctng-install
|
||||||
msg "Running build-all in ${cntr}"
|
_dckr "${cntr}" /setup-scripts/ctng-test-basic
|
||||||
_dckr "${cntr}" /setup-scripts/ctng-test-all
|
}
|
||||||
|
|
||||||
|
# Run the test
|
||||||
|
action_sample()
|
||||||
|
{
|
||||||
|
local cntr=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
# The test assumes the top directory is bootstrapped, but clean.
|
||||||
|
msg "Building samples in ${cntr} [$@]"
|
||||||
|
_dckr "${cntr}" /setup-scripts/ctng-build-sample "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Enter the container using the same user account/environment as for testing.
|
# Enter the container using the same user account/environment as for testing.
|
||||||
@ -80,6 +93,15 @@ action_enter()
|
|||||||
_dckr "${cntr}"
|
_dckr "${cntr}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Enter the container using the same user account/environment as for testing.
|
||||||
|
action_root()
|
||||||
|
{
|
||||||
|
local cntr=$1
|
||||||
|
|
||||||
|
msg "Entering ${cntr} as root"
|
||||||
|
SETUPCMD=/bin/bash _dckr "${cntr}"
|
||||||
|
}
|
||||||
|
|
||||||
# Clean up after test suite run
|
# Clean up after test suite run
|
||||||
action_clean()
|
action_clean()
|
||||||
{
|
{
|
||||||
@ -92,15 +114,18 @@ action_clean()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
action=$1
|
|
||||||
shift
|
|
||||||
all_containers=`ls */Dockerfile | sed 's,/Dockerfile,,'`
|
all_containers=`ls */Dockerfile | sed 's,/Dockerfile,,'`
|
||||||
selected_containers="${*:-${all_containers}}"
|
action=$1
|
||||||
|
selected_containers=$2
|
||||||
|
shift 2
|
||||||
|
if [ "${selected_containers}" = "all" ]; then
|
||||||
|
selected_containers="${all_containers}"
|
||||||
|
fi
|
||||||
|
|
||||||
case "${action}" in
|
case "${action}" in
|
||||||
build|test|enter|clean)
|
build|install|sample|enter|root|clean)
|
||||||
for c in ${selected_containers}; do
|
for c in ${selected_containers}; do
|
||||||
eval "action_${action} ${c}"
|
eval "action_${action} ${c} \"$@\""
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
"")
|
"")
|
||||||
|
Reference in New Issue
Block a user