aboutsummaryrefslogtreecommitdiff
path: root/testing/docker
diff options
context:
space:
mode:
Diffstat (limited to 'testing/docker')
-rw-r--r--testing/docker/archlinux/Dockerfile13
-rw-r--r--testing/docker/centos6/Dockerfile11
-rw-r--r--testing/docker/centos7/Dockerfile11
-rwxr-xr-xtesting/docker/common-scripts/ctng-build-sample5
-rwxr-xr-xtesting/docker/common-scripts/ctng-install7
-rwxr-xr-xtesting/docker/common-scripts/ctng-test-all12
-rwxr-xr-xtesting/docker/common-scripts/ctng-test-basic7
-rwxr-xr-xtesting/docker/common-scripts/su-as-user16
-rwxr-xr-xtesting/docker/dmgr.sh104
-rwxr-xr-xtesting/docker/docker-remove-all.sh8
-rw-r--r--testing/docker/fedora28/Dockerfile11
-rw-r--r--testing/docker/gentoo-amd64/Dockerfile9
-rw-r--r--testing/docker/mint19-amd64/Dockerfile12
-rw-r--r--testing/docker/ubuntu16.04/Dockerfile14
-rw-r--r--testing/docker/ubuntu18.04/Dockerfile14
-rw-r--r--testing/docker/ubuntu18.10/Dockerfile14
16 files changed, 211 insertions, 57 deletions
diff --git a/testing/docker/archlinux/Dockerfile b/testing/docker/archlinux/Dockerfile
index eee2f47b..5f2b7170 100644
--- a/testing/docker/archlinux/Dockerfile
+++ b/testing/docker/archlinux/Dockerfile
@@ -1,3 +1,12 @@
-FROM hoverbear/archlinux
+FROM base/archlinux:latest
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
RUN pacman -Syu --noconfirm
-RUN pacman -S --noconfirm base-devel git help2man python
+RUN pacman -S --noconfirm base-devel git help2man python unzip wget
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+RUN echo 'export MENUCONFIG_COLOR=mono' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
diff --git a/testing/docker/centos6/Dockerfile b/testing/docker/centos6/Dockerfile
new file mode 100644
index 00000000..02a261fe
--- /dev/null
+++ b/testing/docker/centos6/Dockerfile
@@ -0,0 +1,11 @@
+FROM centos:6
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN yum install -y autoconf gperf bison flex texinfo help2man gcc-c++ libtool libtool-bin patch \
+ ncurses-devel python-devel perl-Thread-Queue bzip2 git wget xz unzip
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
diff --git a/testing/docker/centos7/Dockerfile b/testing/docker/centos7/Dockerfile
new file mode 100644
index 00000000..b0f928d6
--- /dev/null
+++ b/testing/docker/centos7/Dockerfile
@@ -0,0 +1,11 @@
+FROM centos:7
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN yum install -y autoconf gperf bison file flex texinfo help2man gcc-c++ libtool make patch \
+ ncurses-devel python-devel perl-Thread-Queue bzip2 git wget which xz unzip
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
diff --git a/testing/docker/common-scripts/ctng-build-sample b/testing/docker/common-scripts/ctng-build-sample
new file mode 100755
index 00000000..ef823ee9
--- /dev/null
+++ b/testing/docker/common-scripts/ctng-build-sample
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+set -e
+cd work
+ct-ng build-all ${1+CT_SAMPLES="$*"}
diff --git a/testing/docker/common-scripts/ctng-install b/testing/docker/common-scripts/ctng-install
index f29093a9..6994fd5d 100755
--- a/testing/docker/common-scripts/ctng-install
+++ b/testing/docker/common-scripts/ctng-install
@@ -1,10 +1,7 @@
#!/bin/bash
set -e
-cd
-rm -rf bld-ctng
-mkdir bld-ctng
-cd bld-ctng
-/crosstool-ng/configure --prefix=$HOME/inst-ctng
+cd work
+/crosstool-ng/configure --prefix=/opt/ctng
make
make install
diff --git a/testing/docker/common-scripts/ctng-test-all b/testing/docker/common-scripts/ctng-test-all
deleted file mode 100755
index f0ba2663..00000000
--- a/testing/docker/common-scripts/ctng-test-all
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-
-set -e
-cd
-rm -rf bld-samples
-mkdir bld-samples
-cd bld-samples
-export PATH=$HOME/inst-ctng/bin:$PATH
-ct-ng help
-ct-ng list-samples
-ct-ng list-steps
-ct-ng build-all
diff --git a/testing/docker/common-scripts/ctng-test-basic b/testing/docker/common-scripts/ctng-test-basic
new file mode 100755
index 00000000..a811ec6c
--- /dev/null
+++ b/testing/docker/common-scripts/ctng-test-basic
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+cd
+ct-ng help
+ct-ng list-samples
+ct-ng list-steps
diff --git a/testing/docker/common-scripts/su-as-user b/testing/docker/common-scripts/su-as-user
deleted file mode 100755
index 99246f23..00000000
--- a/testing/docker/common-scripts/su-as-user
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/bash
-
-usr=$1
-uid=$2
-grp=$3
-gid=$4
-shift 4
-
-groupadd -g ${gid} ${grp}
-useradd -d /home/${usr} -m -g ${gid} -u ${uid} ${usr}
-ln -sf /src /home/${usr}/src
-if [ -z "$*" ]; then
- exec su -l ${usr}
-else
- exec su -l -c "/bin/bash -c '$*'" ${usr}
-fi
diff --git a/testing/docker/dmgr.sh b/testing/docker/dmgr.sh
index 5dbb8b22..1330867e 100755
--- a/testing/docker/dmgr.sh
+++ b/testing/docker/dmgr.sh
@@ -19,24 +19,42 @@ usage()
cat >&2 <<EOF
${1:+ERROR :: $1
-}Usage: $0 [action] [containters]
+}Usage: $0 [action] [containter] [args...]
Action is one of:
build Build or rebuild the specified containers.
-
-If containers are not specified, the action is applied to all available containers.
+ 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.
+ root Spawn a root shell in the specified container.
+ clean Clean up in the specified container.
+
+If a special container name 'all' is used, the action is performed
+on all the containers.
EOF
exit 1
}
+do_cleanup()
+{
+ local d
+
+ for d in "$@"; do
+ [ -d "$d" ] || continue
+ chmod -R a+w "$d"
+ rm -rf "$d"
+ done
+}
+
# Build a docker container, store its ID.
action_build()
{
local cntr=$1
msg "Building Docker container for ${cntr}"
- docker build -t "ctng-${cntr}" "${cntr}"
+set -x
+ docker build --no-cache -t "ctng-${cntr}" --build-arg CTNG_GID=`id -g` --build-arg CTNG_UID=`id -u` "${cntr}"
}
# Common backend for enter/test
@@ -44,37 +62,67 @@ _dckr()
{
local topdir=`cd ../.. && pwd`
local cntr=$1
+ local scmd prefix
shift
- mkdir -p build-${cntr}
- docker run --rm -i -t \
- -v `pwd`/common-scripts:/setup-scripts:ro \
+ mkdir -p ${cntr}/{build,install,xtools}
+ prefix="docker run --rm -i -t \
+ -v `pwd`/common-scripts:/common-scripts:ro \
-v ${topdir}:/crosstool-ng:ro \
- -v `pwd`/build-${cntr}:/home \
- -v $HOME/src:/src:ro \
- ctng-${cntr} \
- /setup-scripts/su-as-user `id -un` `id -u` `id -gn` `id -g` "$@"
+ -v `pwd`/${cntr}/build:/home/ctng/work \
+ -v `pwd`/${cntr}/install:/opt/ctng \
+ -v `pwd`/${cntr}/xtools:/home/ctng/x-tools \
+ -v $HOME/src:/home/ctng/src:ro \
+ ctng-${cntr}"
+ if [ -n "${AS_ROOT}" ]; then
+ $prefix "$@"
+ elif [ -n "$*" ]; then
+ $prefix su -l ctng -c "$*"
+ else
+ $prefix su -l ctng
+ fi
}
# Run the test
-action_test()
+action_install()
{
local cntr=$1
# The test assumes the top directory is bootstrapped, but clean.
msg "Setting up crosstool-NG in ${cntr}"
- _dckr "${cntr}" /setup-scripts/ctng-install
- msg "Running build-all in ${cntr}"
- _dckr "${cntr}" /setup-scripts/ctng-test-all
+ do_cleanup ${cntr}/build
+ _dckr "${cntr}" /common-scripts/ctng-install && \
+ _dckr "${cntr}" /common-scripts/ctng-test-basic
+}
+
+# Run the test
+action_sample()
+{
+ local cntr=$1
+ shift
+
+ msg "Building samples in ${cntr} [$@]"
+ do_cleanup ${cntr}/build
+ _dckr "${cntr}" /common-scripts/ctng-build-sample "$@"
}
# Enter the container using the same user account/environment as for testing.
action_enter()
{
local cntr=$1
+ shift
msg "Entering ${cntr}"
- _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"
+ AS_ROOT=y _dckr "${cntr}" /bin/bash
}
# Clean up after test suite run
@@ -83,18 +131,30 @@ action_clean()
local cntr=$1
msg "Cleaning up after ${cntr}"
- rm -rf build-${cntr}
+ do_cleanup ${cntr}/build
+}
+
+# Clean up after test suite run
+action_distclean()
+{
+ local cntr=$1
+
+ msg "Dist cleaning ${cntr}"
+ do_cleanup ${cntr}/{build,install,xtools}
}
-action=$1
-shift
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
- build|test|enter|clean)
+ build|install|sample|enter|root|clean|distclean)
for c in ${selected_containers}; do
- eval "action_${action} $c"
+ eval "action_${action} ${c} \"$@\""
done
;;
"")
diff --git a/testing/docker/docker-remove-all.sh b/testing/docker/docker-remove-all.sh
new file mode 100755
index 00000000..d73ba1e6
--- /dev/null
+++ b/testing/docker/docker-remove-all.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+for c in `docker ps -a -q`; do
+ docker rm $c
+done
+for i in `docker images -q`; do
+ docker rmi --force $i
+done
diff --git a/testing/docker/fedora28/Dockerfile b/testing/docker/fedora28/Dockerfile
new file mode 100644
index 00000000..20363c9c
--- /dev/null
+++ b/testing/docker/fedora28/Dockerfile
@@ -0,0 +1,11 @@
+FROM fedora:28
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN yum install -y autoconf gperf bison file flex texinfo help2man gcc-c++ libtool make patch \
+ ncurses-devel python-devel perl-Thread-Queue bzip2 git wget which xz unzip
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
diff --git a/testing/docker/gentoo-amd64/Dockerfile b/testing/docker/gentoo-amd64/Dockerfile
new file mode 100644
index 00000000..ec5c1312
--- /dev/null
+++ b/testing/docker/gentoo-amd64/Dockerfile
@@ -0,0 +1,9 @@
+FROM gentoo/stage3-amd64-hardened
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
diff --git a/testing/docker/mint19-amd64/Dockerfile b/testing/docker/mint19-amd64/Dockerfile
new file mode 100644
index 00000000..7a0e4ba6
--- /dev/null
+++ b/testing/docker/mint19-amd64/Dockerfile
@@ -0,0 +1,12 @@
+FROM linuxmintd/mint19-amd64
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN apt-get update
+RUN apt-get install -y gcc gperf bison flex texinfo help2man make libncurses5-dev \
+ python-dev autoconf automake libtool libtool-bin gawk wget
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
diff --git a/testing/docker/ubuntu16.04/Dockerfile b/testing/docker/ubuntu16.04/Dockerfile
new file mode 100644
index 00000000..7a76712f
--- /dev/null
+++ b/testing/docker/ubuntu16.04/Dockerfile
@@ -0,0 +1,14 @@
+FROM ubuntu:16.04
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN apt-get update
+RUN apt-get install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
+ python-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip \
+ patch libstdc++6
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
+
diff --git a/testing/docker/ubuntu18.04/Dockerfile b/testing/docker/ubuntu18.04/Dockerfile
new file mode 100644
index 00000000..9fe27b26
--- /dev/null
+++ b/testing/docker/ubuntu18.04/Dockerfile
@@ -0,0 +1,14 @@
+FROM ubuntu:18.04
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN apt-get update
+RUN apt-get install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
+ python-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip \
+ patch libstdc++6
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
+
diff --git a/testing/docker/ubuntu18.10/Dockerfile b/testing/docker/ubuntu18.10/Dockerfile
new file mode 100644
index 00000000..468175e5
--- /dev/null
+++ b/testing/docker/ubuntu18.10/Dockerfile
@@ -0,0 +1,14 @@
+FROM ubuntu:18.10
+ARG CTNG_UID
+ARG CTNG_GID
+RUN groupadd -g $CTNG_GID ctng
+RUN useradd -d /home/ctng -m -g $CTNG_GID -u $CTNG_UID -s /bin/bash ctng
+RUN apt-get update
+RUN apt-get install -y gcc g++ gperf bison flex texinfo help2man make libncurses5-dev \
+ python-dev autoconf automake libtool libtool-bin gawk wget bzip2 xz-utils unzip \
+ patch libstdc++6
+RUN wget -O /sbin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_amd64
+RUN chmod a+x /sbin/dumb-init
+RUN echo 'export PATH=/opt/ctng/bin:$PATH' >> /etc/profile
+ENTRYPOINT [ "/sbin/dumb-init", "--" ]
+