mocksetup: /unsafe+/hdd -> /quad
[nethome.git] / bin / mocksetup
index 3850ca9..4db3250 100755 (executable)
@@ -37,7 +37,10 @@ for r in $l;do
   fi
 
   echo >&2 -n "Locking $rpath/MOCK.mocksetup-lock ..."
   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
   echo >&2 " done"
 
   if $soft && [ -f $rpath/MOCK ];then
@@ -70,7 +73,7 @@ for r in $l;do
   # mock -q -r $r chroot true echo "$rpath lock check"
 
   for n in passwd group;do
   # mock -q -r $r chroot true echo "$rpath lock check"
 
   for n in passwd group;do
-    cat /etc/$n $rpath/etc/$n|perl -ne 'print if /^(?:[^:]*:){2}(5\d\d):/'|sort|uniq -u|tee -a $rpath/etc/$n
+    cat /etc/$n $rpath/etc/$n|perl -ne 'print if /^(?:[^:]*:){2}(10\d\d):/'|sort|uniq -u|tee -a $rpath/etc/$n
   done
   if [ ! -f $rpath/etc/mtab-orig ];then
     c="mv -f $rpath/etc/mtab $rpath/etc/mtab-orig"
   done
   if [ ! -f $rpath/etc/mtab-orig ];then
     c="mv -f $rpath/etc/mtab $rpath/etc/mtab-orig"
@@ -79,33 +82,83 @@ for r in $l;do
     echo $c; $c
   fi
 
     echo $c; $c
   fi
 
+  cmp -s   /etc/resolv.conf $rpath/etc/resolv.conf \
+  || cp -p /etc/resolv.conf $rpath/etc/resolv.conf
+
   dir="/dev/pts"
   c="umount $rpath$dir"
   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
     echo $c
-  done
+  fi
 
 
-  for dir in /home /usr/local/bin /dev /proc /sys /root;do
-    c="umount $rpath$dir"
-    while $c 2>&1|grep -v ': not mounted$';do
-      echo $c
-    done
-    if ! $u;then
-      c="mount --bind $dir $rpath$dir"
-      echo $c; $c
-    fi
-  done
+  dir="/dev/shm"
+  c="umount $rpath$dir"
+  if $c 2>&1|grep -v ': not \(mounted\|found\)$';then
+    echo $c
+  fi
 
 
-  dir="/dev/pts"
+  test -e $rpath/dev/pts && (rmdir $rpath/dev/pts || :)
   if ! $u;then
   if ! $u;then
-    c="mount --bind $dir $rpath$dir"
-    echo $c; $c
+    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
 
   fi
 
+  # Must be before umount of /quad
   c="umount $rpath/var/cache/yum"
   c="umount $rpath/var/cache/yum"
-  while $c 2>&1|grep -v ': not mounted$';do
+  if $c 2>&1|grep -v ': not \(mounted\|found\)$';then
     echo $c
     echo $c
-  done
+  fi
   if ! $u;then
     if [ -d /var/cache/mock/$r/yum_cache ];then
       cr=$r
   if ! $u;then
     if [ -d /var/cache/mock/$r/yum_cache ];then
       cr=$r
@@ -116,6 +169,25 @@ for r in $l;do
     echo $c; $c
   fi
 
     echo $c; $c
   fi
 
+  mkdir -p $rpath/quad
+  for dir in /home /usr/local/bin /proc /sys /root /quad;do
+    c="umount $rpath$dir"
+    if $c 2>&1|grep -v ': not \(mounted\|found\)$';then
+      echo $c
+    fi
+    if ! $u;then
+      c="mount --bind $dir $rpath$dir"
+      echo $c; $c
+    fi
+  done
+
+  if ! $u;then
+    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
+
   rm -f $rpath/usr/local/lib/debug
   if ! $u;then
     ln -s ../../lib/debug $rpath/usr/local/lib/debug
   rm -f $rpath/usr/local/lib/debug
   if ! $u;then
     ln -s ../../lib/debug $rpath/usr/local/lib/debug
@@ -129,14 +201,14 @@ for r in $l;do
   rm -f $rpath/usr/local/share/gdb
   if ! $u;then
     mkdir -p $rpath/usr/local/share
   rm -f $rpath/usr/local/share/gdb
   if ! $u;then
     mkdir -p $rpath/usr/local/share
-    ln -s ../../../share/gdb $rpath/usr/local/share/gdb
+    ln -s ../../share/gdb $rpath/usr/local/share/gdb
   fi
 
   # Old systems incl. RHEL-6 do not feature it.
   if [ -d $rpath/etc/sudoers.d ];then
     rm -f $rpath/etc/sudoers.d/inteltest
   fi
 
   # 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
 
     fi
   fi