Source: debianutils
Version: 5.2-2
Tags: patch

Hi Clint,

we've identified a number of smaller issues post merging the
update-shells stuff. This is a cumulative update of known issues.

Guillem Jover asked that update-shells.8 includes a FILES section.

Guillem Jover said that we should also sync containing directories.

Johannes Schauer found that for some reason /etc/shells was not reliably
created prior to running update-shells. We have no clue how this could
happen given that the postinst script always creates /etc/shells before
running update-shells, but it makes
https://salsa.debian.org/helmutg/dpkg-root-demo fail. We propose dealing
with this case and copying the template if needed.

The attached patch addresses all of the above.

Helmut
--- debianutils-5.2.orig/update-shells
+++ debianutils-5.2/update-shells
@@ -63,10 +63,15 @@ done
 
 PKG_DIR="$ROOT/usr/share/debianutils/shells.d"
 STATE_FILE="$ROOT/var/lib/shells.state"
-ETC_FILE="$ROOT/etc/shells"
-NEW_ETC_FILE="$ETC_FILE.tmp"
+TARGET_ETC_FILE="$ROOT/etc/shells"
+SOURCE_ETC_FILE="$TARGET_ETC_FILE"
+NEW_ETC_FILE="$TARGET_ETC_FILE.tmp"
 NEW_STATE_FILE="$STATE_FILE.tmp"
 
+if ! test -e "$SOURCE_ETC_FILE"; then
+       SOURCE_ETC_FILE="$ROOT/usr/share/debianutils/shells"
+fi
+
 PKG_SHELLS='#'
 LC_COLLATE=C.UTF-8  # glob in reproducible order
 for f in "$PKG_DIR/"*; do
@@ -106,7 +111,7 @@ while IFS= read -r line; do
        else
                log "removing shell $shell"
        fi
-done < "$ETC_FILE"
+done < "$SOURCE_ETC_FILE"
 
 : > "$NEW_STATE_FILE"
 saved_IFS=$IFS
@@ -133,12 +138,14 @@ if [ "$NOACT" = 0 ]; then
        else
                chmod 0644 "$NEW_STATE_FILE"
        fi
-       chmod --reference="$ETC_FILE" "$NEW_ETC_FILE"
-       chown --reference="$ETC_FILE" "$NEW_ETC_FILE"
+       chmod --reference="$SOURCE_ETC_FILE" "$NEW_ETC_FILE"
+       chown --reference="$SOURCE_ETC_FILE" "$NEW_ETC_FILE"
        sync --data "$NEW_ETC_FILE" "$NEW_STATE_FILE"
-       mv "$NEW_ETC_FILE" "$ETC_FILE"
-       sync "$ETC_FILE"
+       mv "$NEW_ETC_FILE" "$TARGET_ETC_FILE"
+       sync "$TARGET_ETC_FILE"
+       sync "$(dirname "$TARGET_ETC_FILE")"
        mv "$NEW_STATE_FILE" "$STATE_FILE"
        sync "$STATE_FILE"
+       sync "$(dirname "$STATE_FILE")"
        trap "" EXIT
 fi
--- debianutils-5.2.orig/update-shells.8
+++ debianutils-5.2/update-shells.8
@@ -27,5 +27,9 @@ Operate on a chroot at
 .TP
 .B \-\-verbose
 Print the shells that are being added or removed.
+.SH FILES
+.I /etc/shells
+.I /var/lib/shells.state
+.I /usr/share/debianutils/shells.d
 .SH SEE ALSO
 .BR shells (5)

Reply via email to