Debian Codegraph @

tools/testing/test_README_in_docker

raw
1 #!/bin/bash
2 #emacs: -*- mode: shell-script; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
3 #ex: set sts=4 ts=4 sw=4 noet:
4 # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
5 #
6 # See COPYING file distributed along with the datalad package for the
7 # copyright and license terms.
8 #
9 # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
10 #
11 # Helper to generate a Docker instance mapping user uder docker into your USER/UID/GID
12 # and allowing to run tox within that clean automatically generated according to
13 # README.md's apt-get lines environment
14 #
15 set -e
16 #set -x
17 set -u
18
19 DL_DIST=$1
20
21 topdir=$(realpath `dirname $0`)
22 dockerfile=$topdir/test_README_in_docker-Dockerfile
23 # echo "D: $DL_APT"
24 sed -e "s,DL_DIST,$DL_DIST,g" \
25 -e "s,DL_USER,$USER,g" \
26 -e "s,DL_UID,`id -u`,g" \
27 -e "s,DL_GID,`id -g`,g" \
28 -e "s,DL_GIT_USER_EMAIL,`git config --get user.email`,g" \
29 -e "s,DL_GIT_USER_NAME,`git config --get user.name`,g" \
30 $dockerfile.in >| $dockerfile
31
32 #DL_APT=$(grep '^\(apt-get\|pip\)' ./../../README.md)
33
34 grep '^apt-get ' ./../../README.md | sed -e 's|python-{|python{,3}-{|g' \
35 | while read aptline; do
36 sed -i -e "s|\(\(.*\)DL_APT\(.*\)\)|\2$aptline\3\n\1|g" $dockerfile
37 :
38 done
39 sed -e '/DL_APT/d' -i $dockerfile
40
41 tag=datalad:test_README_${USER}_$DL_DIST
42 echo "I: tag $tag"
43 if docker images | grep -q datalad.*test_README.*$DL_DIST; then
44 echo "I: tag already exists -- skipping rebuilding"
45 else
46 docker build -t $tag -f $dockerfile . #&& rm Dockerfile
47 #docker build --no-cache=True -t $tag -f $dockerfile . #&& rm Dockerfile
48 fi
49
50 topgitdir=`realpath ${topdir}/../..`
51 echo "I: top git dir $topgitdir"
52
53 tox="$topgitdir/.tox"
54 if [ -e "$tox" ]; then
55 echo "I: removing existing tox under $tox"
56 rm -r $tox
57 fi
58
59 echo "I: running tox within docker"
60 docker run -it --rm=true -v $topgitdir:/home/$USER/datalad $tag tox --sitepackages