Page MenuHomeFreeBSD

D54935.id.diff
No OneTemporary

D54935.id.diff

diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
--- a/usr.sbin/etcupdate/etcupdate.sh
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -242,10 +242,6 @@
(cd $1 && printf '%s\n' $autogenfiles >> $metatmp && \
rm -f $autogenfiles) || return 1
- # Remove empty files. These just clutter the output of 'diff'.
- (cd $1 && find . -type f -size 0 -delete -print >> $metatmp) || \
- return 1
-
# Trim empty directories.
(cd $1 && find . -depth -type d -empty -delete -print >> $metatmp) || \
return 1
diff --git a/usr.sbin/etcupdate/tests/Makefile b/usr.sbin/etcupdate/tests/Makefile
--- a/usr.sbin/etcupdate/tests/Makefile
+++ b/usr.sbin/etcupdate/tests/Makefile
@@ -1,6 +1,7 @@
PLAIN_TESTS_SH=
.for test in always_test \
conflicts_test \
+ empty_file_test \
fbsdid_test \
ignore_test \
preworld_test \
diff --git a/usr.sbin/etcupdate/tests/empty_file_test.sh b/usr.sbin/etcupdate/tests/empty_file_test.sh
new file mode 100755
--- /dev/null
+++ b/usr.sbin/etcupdate/tests/empty_file_test.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# Regression test for "etcupdate: Do not ignore empty files"
+
+FAILED=no
+WORKDIR=$(pwd)/work
+
+usage()
+{
+ echo "Usage: empty_file_test.sh [-s script] [-w workdir]"
+ exit 1
+}
+
+COMMAND=etcupdate
+while getopts "s:w:" option; do
+ case $option in
+ s)
+ COMMAND="sh $OPTARG"
+ ;;
+ w)
+ WORKDIR=$OPTARG
+ ;;
+ *)
+ echo
+ usage
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+if [ $# -ne 0 ]; then
+ usage
+fi
+
+SRC=$WORKDIR/src
+DEST=$WORKDIR/dest
+TEST=$WORKDIR/test
+
+# Clean up
+rm -rf $WORKDIR
+
+# Create a mock source tree
+mkdir -p $SRC
+touch $SRC/empty_file
+
+# Create a mock make script
+cat > $WORKDIR/mock_make.sh <<EOF
+#!/bin/sh
+
+# Scan all arguments for targets
+for arg in "\$@"; do
+ case \$arg in
+ *=*)
+ # Export variable assignments
+ export "\$arg"
+ ;;
+ distrib-dirs)
+ if [ -n "\$DESTDIR" ]; then
+ mkdir -p "\$DESTDIR/etc"
+ fi
+ ;;
+ distribution)
+ if [ -n "\$DESTDIR" ]; then
+ cp $SRC/empty_file "\$DESTDIR/etc/empty_file"
+ echo "./etc/empty_file type=file mode=0644 uname=root gname=wheel" > "\$DESTDIR/METALOG"
+ fi
+ ;;
+ esac
+done
+exit 0
+EOF
+chmod +x $WORKDIR/mock_make.sh
+
+# Run etcupdate
+# Use -B to skip build targets
+# Use -N to run without root privileges
+# Use 'extract' command to bypass root check in 'update' command
+$COMMAND extract -N -B -s $SRC -d $WORKDIR -m $WORKDIR/mock_make.sh > $WORKDIR/test.out 2>&1
+
+if [ -f $WORKDIR/current/etc/empty_file ]; then
+ echo "Empty file preserved."
+else
+ echo "Empty file missing from current tree."
+ FAILED=yes
+fi
+
+[ "${FAILED}" = no ]

File Metadata

Mime Type
text/plain
Expires
Thu, May 14, 7:28 PM (9 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33056322
Default Alt Text
D54935.id.diff (2 KB)

Event Timeline