at master 4.1 kB view raw
1--- a/tests/libtest.sh 2+++ b/tests/libtest.sh 3@@ -301,7 +301,7 @@ 4 } 5 6 skip_without_python2 () { 7- if ! test -f /usr/bin/python2 || ! /usr/bin/python2 -c "import sys; sys.exit(0 if sys.version_info >= (2, 7) else 1)" ; then 8+ if true ; then 9 echo "1..0 # SKIP this test requires /usr/bin/python2 (2.7) support" 10 exit 0 11 fi 12--- a/tests/make-test-runtime.sh 13+++ b/tests/make-test-runtime.sh 14@@ -26,6 +26,7 @@ 15 PATH="$PATH:/usr/sbin:/sbin" 16 17 # Add bash and dependencies 18+mkdir -p ${DIR}/nix/store 19 mkdir -p ${DIR}/usr/bin 20 mkdir -p ${DIR}/usr/lib 21 ln -s ../lib ${DIR}/usr/lib64 22@@ -35,73 +36,28 @@ 23 else 24 cp `which ldconfig` ${DIR}/usr/bin 25 fi 26-LIBS=`mktemp` 27-BINS=`mktemp` 28- 29-add_bin() { 30- local f=$1 31- shift 32- 33- if grep -qFe "${f}" $BINS; then 34- # Already handled 35- return 0 36- fi 37- 38- echo $f >> $BINS 39- 40- # Add library dependencies 41- (ldd "${f}" | sed "s/.* => //" | awk '{ print $1}' | grep ^/ | sort -u -o $LIBS $LIBS -) || true 42- 43- local shebang=$(sed -n '1s/^#!\([^ ]*\).*/\1/p' "${f}") 44- if [ x$shebang != x ]; then 45- add_bin "$shebang" 46- fi 47-} 48 49 for i in $@; do 50- I=`which $i` 51- add_bin $I 52- if test $i == python2; then 53- mkdir -p ${DIR}/usr/lib/python2.7/lib-dynload 54- # This is a hardcoded minimal set of modules we need in the current tests. 55- # Pretty hacky stuff. Add modules as needed. 56- PYDIR=/usr/lib/python2.7 57- if test -d /usr/lib64/python2.7; then PYDIR=/usr/lib64/python2.7; fi 58- for py in site os stat posixpath genericpath warnings \ 59- linecache types UserDict abc _abcoll \ 60- _weakrefset copy_reg traceback sysconfig \ 61- re sre_compile sre_parse sre_constants \ 62- _sysconfigdata ; do 63- cp ${PYDIR}/$py.py ${DIR}/usr/lib/python2.7 64- done 65- # These might not exist, depending how Python was configured; and the 66- # part after ${so} might be "module" or ".x86_64-linux-gnu" or 67- # something else 68- for so in _locale strop ; do 69- cp ${PYDIR}/lib-dynload/${so}*.so ${DIR}/usr/lib/python2.7/lib-dynload || : 70- done 71- for plat in $( cd ${PYDIR} && echo plat-* ); do 72- test -e ${PYDIR}/${plat} || continue 73- mkdir -p ${DIR}/usr/lib/python2.7/${plat} 74- cp ${PYDIR}/${plat}/*.py ${DIR}/usr/lib/python2.7/${plat}/ 75- done 76- fi 77-done 78-for i in `cat $BINS`; do 79- echo Adding binary $i 1>&2 80- cp "$i" ${DIR}/usr/bin/ 81-done 82-for i in `cat $LIBS`; do 83- echo Adding library $i 1>&2 84- cp "$i" ${DIR}/usr/lib/ 85+ I=$(readlink -f $(which $i)) 86+ requisites=$(nix-store --query --requisites "$I") 87+ for r in $requisites; do 88+ # a single store item can be needed by multiple paths, no need to copy it again 89+ if [ ! -e ${DIR}/$r ]; then 90+ cp -r $r ${DIR}/$r 91+ fi 92+ done 93+ ln -s $I ${DIR}/usr/bin/$i 94 done 95 ln -s bash ${DIR}/usr/bin/sh 96 97-# We copy the C.UTF8 locale and call it en_US. Its a bit of a lie, but 98-# the real en_US locale is often not available, because its in the 99-# local archive. 100+mv ${DIR}/nix/store ${DIR}/usr/store # files outside /usr are not permitted, we will have to replace /nix/store with /usr/store 101+chmod -R u+w ${DIR} # nix store has read-only directories which would cause problems during clean-up, files need to be writable for sed 102+find ${DIR} -type f -print0 | xargs -0 sed -i 's~/nix/store/~/usr/store/~g' # replace hardcoded paths 103+find ${DIR} -type l | xargs -I '{}' sh -c 'tg="$(readlink "$1")"; newtg="${tg#/nix/store/}"; if [ "$tg" != "$newtg" ]; then ln -fs "/usr/store/$newtg" "$1"; fi' -- '{}' # replace symlink targets 104+ 105+# We copy the whole locale archive because we do not have C.UTF8 locale 106 mkdir -p ${DIR}/usr/lib/locale/ 107-cp -r /usr/lib/locale/C.* ${DIR}/usr/lib/locale/en_US 108+cp @glibcLocales@/lib/locale/locale-archive ${DIR}/usr/lib/locale/locale-archive 109 110 if [ x$COLLECTION_ID != x ]; then 111 collection_args=--collection-id=${COLLECTION_ID}