From fdd380dde2ec2cbcecbd20b91cf6b819ef3dc0db Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Thu, 14 Dec 2023 15:06:12 +0100 Subject: [PATCH] test: install empty directories with NO_BUILD=1 Resolves: #30478 --- test/test-functions | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/test/test-functions b/test/test-functions index 4606745f105..6a6f624d4cd 100644 --- a/test/test-functions +++ b/test/test-functions @@ -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") }