Hello!

This should solve the "debootstrapped with merged usr" case (see
#810301) and Marco has already implemented the upgrade case in
usrmerge 11.

Please review attached patch.

Regards,
Andreas Henriksson
>From 12794e2c3c8d04677f8f0a3395a48e3674560484 Mon Sep 17 00:00:00 2001
From: Andreas Henriksson <andr...@fatal.se>
Date: Thu, 24 Mar 2016 12:17:42 +0100
Subject: [PATCH] add/remove-shell: also add/remove shells real path

In the case of usr merged systems we want the shells to also
be listed with their real paths, eg. /usr/bin/bash, in addition
to their specified path in /etc/shells

(While at it also fix mixed tab/spaces indentation of help texts
and trailing whitespace.)

The mixture of dirname/realpath/basename is to avoid expanding
the filename, only the directory part of the path.
This is to avoid /bin/sh being expanded to /usr/bin/dash
rather than /usr/bin/sh. Maybe we want to add both in
such a case?

Closes: #817168
---
 add-shell    | 16 ++++++++++------
 remove-shell | 14 +++++++++-----
 2 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/add-shell b/add-shell
index 4c91015..2fc54bf 100755
--- a/add-shell
+++ b/add-shell
@@ -2,8 +2,8 @@
 
 if test $# -eq 0
 then
-	echo usage: $0 shellname [shellname ...]
-	exit 1
+        echo usage: $0 shellname [shellname ...]
+        exit 1
 fi
 
 file=/etc/shells
@@ -25,10 +25,14 @@ fi
 
 for i
 do
-        if ! grep -q "^${i}$" $tmpfile
-        then
-                echo $i >> $tmpfile
-        fi
+        REALDIR="$(dirname $(realpath -m $i))/$(basename $i)"
+        for j in "$i" "$REALDIR"
+        do
+                if ! grep -q "^${j}$" $tmpfile
+                then
+                        echo $j >> $tmpfile
+                fi
+        done
 done
 
 chmod --reference=$file $tmpfile
diff --git a/remove-shell b/remove-shell
index 1e6b739..15eca39 100755
--- a/remove-shell
+++ b/remove-shell
@@ -2,8 +2,8 @@
 
 if test $# -eq 0
 then
-	echo usage: $0 shellname '[shellname ...]' 1>&2
-	exit 1
+        echo usage: $0 shellname '[shellname ...]' 1>&2
+        exit 1
 fi
 
 file=/etc/shells
@@ -14,7 +14,7 @@ otmpfile=${file}.tmp2
 set -o noclobber
 
 trap "rm -f $tmpfile $otmpfile" EXIT
-        
+
 if ! cat $file > $tmpfile
 then
         cat 1>&2 <<EOF
@@ -27,8 +27,12 @@ fi
 # this is supposed to be reliable, not pretty
 for i
 do
-	grep -v "^${i}$" $tmpfile > $otmpfile || true
-	mv $otmpfile $tmpfile
+        REALDIR="$(dirname $(realpath -m $i))/$(basename $i)"
+        for j in "$i" "$REALDIR"
+        do
+                grep -v "^${j}$" $tmpfile > $otmpfile || true
+                mv $otmpfile $tmpfile
+        done
 done
 
 chmod --reference=$file $tmpfile
-- 
2.7.0

Reply via email to