From 90f104ce6418565267ea8765a1b4c07560eb38de Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 31 Jul 2013 17:28:14 +0200 Subject: [PATCH] mocksetup: Update for recent Fedoras. --- bin/mocksetup | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 82 insertions(+), 12 deletions(-) diff --git a/bin/mocksetup b/bin/mocksetup index e811d20..da4800c 100755 --- a/bin/mocksetup +++ b/bin/mocksetup @@ -37,7 +37,10 @@ for r in $l;do fi echo >&2 -n "Locking $rpath/MOCK.mocksetup-lock ..." - lockfile -l 10 $rpath/MOCK.mocksetup-lock + if ! lockfile -1 -r 1 -s 1 $rpath/MOCK.mocksetup-lock;then + rm -f $rpath/MOCK.mocksetup-lock + lockfile -1 -r 1 -s 1 $rpath/MOCK.mocksetup-lock + fi echo >&2 " done" if $soft && [ -f $rpath/MOCK ];then @@ -79,33 +82,100 @@ for r in $l;do echo $c; $c fi + cp -p /etc/resolv.conf $rpath/etc/resolv.conf + dir="/dev/pts" c="umount $rpath$dir" - while $c 2>&1|grep -v ': not mounted$';do + if $c 2>&1|grep -v ': not \(mounted\|found\)$';then echo $c - done + fi - for dir in /home /usr/local/bin /dev /proc /sys /root;do + dir="/dev/shm" + c="umount $rpath$dir" + if $c 2>&1|grep -v ': not \(mounted\|found\)$';then + echo $c + fi + + test -e $rpath/dev/pts && rmdir $rpath/dev/pts + if ! $u;then + mkdir -p $rpath/dev/pts + fi + test -e $rpath/dev/shm && rmdir $rpath/dev/shm + if ! $u;then + mkdir -p $rpath/dev/shm + fi + rm -f $rpath/dev/null + if ! $u;then + mknod -m 666 $rpath/dev/null c 1 3 + fi + rm -f $rpath/dev/full + if ! $u;then + mknod -m 666 $rpath/dev/full c 1 7 + fi + rm -f $rpath/dev/zero + if ! $u;then + mknod -m 666 $rpath/dev/zero c 1 5 + fi + rm -f $rpath/dev/random + if ! $u;then + mknod -m 666 $rpath/dev/random c 1 8 + fi + rm -f $rpath/dev/urandom + if ! $u;then + mknod -m 444 $rpath/dev/urandom c 1 9 + fi + rm -f $rpath/dev/tty + if ! $u;then + mknod -m 666 $rpath/dev/tty c 5 0 + fi + rm -f $rpath/dev/console + if ! $u;then + mknod -m 600 $rpath/dev/console c 5 1 + fi + rm -f $rpath/dev/ptmx + if ! $u;then + mknod -m 666 $rpath/dev/ptmx c 5 2 + fi + rm -f $rpath/dev/stdin + if ! $u;then + ln -s /proc/self/fd/0 $rpath/dev/stdin + fi + rm -f $rpath/dev/stdout + if ! $u;then + ln -s /proc/self/fd/1 $rpath/dev/stdout + fi + rm -f $rpath/dev/stderr + if ! $u;then + ln -s /proc/self/fd/2 $rpath/dev/stderr + fi + rm -f $rpath/dev/fd + if ! $u;then + ln -s /proc/self/fd $rpath/dev/fd + fi + + mkdir -p $rpath/unsafe + for dir in /home /usr/local/bin /proc /sys /root /unsafe;do c="umount $rpath$dir" - while $c 2>&1|grep -v ': not mounted$';do + if $c 2>&1|grep -v ': not mounted$';then echo $c - done + fi if ! $u;then c="mount --bind $dir $rpath$dir" echo $c; $c fi done - dir="/dev/pts" if ! $u;then - c="mount --bind $dir $rpath$dir" + c="mount -t tmpfs mock_shmfs $rpath/dev/shm" + echo $c; $c + c="mount -t devpts -o mode=620,gid=5 mock_devpts $rpath/dev/pts" echo $c; $c fi c="umount $rpath/var/cache/yum" - while $c 2>&1|grep -v ': not mounted$';do + if $c 2>&1|grep -v ': not mounted$';then echo $c - done + fi if ! $u;then if [ -d /var/cache/mock/$r/yum_cache ];then cr=$r @@ -135,8 +205,8 @@ for r in $l;do # Old systems incl. RHEL-6 do not feature it. if [ -d $rpath/etc/sudoers.d ];then rm -f $rpath/etc/sudoers.d/inteltest - if ! $u;then - ln /etc/sudoers.d/inteltest $rpath/etc/sudoers.d/inteltest + if ! $u;then : +# ln /etc/sudoers.d/inteltest $rpath/etc/sudoers.d/inteltest fi fi -- 1.8.3.1