]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: install empty directories with NO_BUILD=1
authorFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 14 Dec 2023 14:06:12 +0000 (15:06 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 14 Dec 2023 22:11:12 +0000 (23:11 +0100)
Resolves: #30478

test/test-functions

index 4606745f105988f99b62322d564a576ec6a6c2dc..6a6f624d4cdfc06851caf8e61721419b2d2baea7 100644 (file)
@@ -1310,19 +1310,35 @@ install_compiled_systemd() {
     fi
 }
 
+install_package_file() {
+    local file="${1:?}"
+
+    # Skip missing files (like /etc/machine-info)
+    [[ ! -e "$file" ]] && return 0
+    # Skip python unit tests, since the image_install machinery will try to pull
+    # in the whole python stack in a very questionable state, making the tests fail.
+    # And given we're trying to transition to mkosi-based images anyway I'm not even
+    # going to bother
+    [[ "$file" =~ /tests/unit-tests/.*.py$ ]] && return 0
+    # If the current file is a directory, create it with the original
+    # mode; if it's a symlink to a directory, copy it as-is
+    if [[ -d "$file" ]]; then
+        inst_dir "$file"
+    else
+        inst "$file"
+    fi
+}
+
 install_debian_systemd() {
     dinfo "Install debian systemd"
 
-    local files
+    local deb file
 
     while read -r deb; do
-        files="$(dpkg-query -L "$deb" 2>/dev/null)" || continue
         ddebug "Install debian files from package $deb"
-        for file in $files; do
-            [ -e "$file" ] || continue
-            [ ! -L "$file" ] && [ -d "$file" ] && continue
-            inst "$file"
-        done
+        while read -r file; do
+            install_package_file "$file"
+        done < <(dpkg-query -L "$deb" 2>/dev/null)
     done < <(grep -E '^Package:' "${SOURCE_DIR}/debian/control" | cut -d ':' -f 2)
 }
 
@@ -1337,17 +1353,7 @@ install_rpm() {
 
     dinfo "Installing contents of RPM $rpm"
     while read -r file; do
-        # Skip missing files (like /etc/machine-info)
-        [[ ! -e "$file" ]] && continue
-        # Skip directories unless they are a symlink (both -L and -d pass in this case)
-        [[ -d "$file" && ! -L "$file" ]] && continue
-        # Skip python unit tests, since the image_install machinery will try to pull
-        # in the whole python stack in a very questionable state, making the tests fail.
-        # And given we're trying to transition to mkosi-based images anyway I'm not even
-        # going to bother
-        [[ "$file" =~ /tests/unit-tests/.*.py$ ]] && continue
-
-        image_install "$file"
+        install_package_file "$file"
     done < <(rpm -ql "$rpm")
 }