]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Copy files with git only in true git repository
authorMichal Koutný <mkoutny@suse.com>
Wed, 1 Mar 2023 21:54:06 +0000 (22:54 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 2 Mar 2023 15:04:40 +0000 (15:04 +0000)
When mkosi is run from git-worktree(1), the .git is not a repository
directory but a textfile pointing to the real git dir
(e.g. /home/user/systemd/.git/worktrees/systemd-worktree). This git dir
is not bind mounted into build environment and it fails with:

> fatal: not a git repository: /home/user/systemd/.git/worktrees/systemd-worktree
> test/meson.build:190:16: ERROR: Command `/usr/bin/env -u GIT_WORK_TREE /usr/bin/git --git-dir=/root/src/.git ls-files ':/test/dmidecode-dumps/*.bin'` failed with status 128.

There is already a fallback to use shell globbing instead of ls-files,
use it with git worktrees as well.

meson.build
test/fuzz/meson.build
test/meson.build

index 0476d972d009007bfa4ca24e56dd791e6a77c456..25761535367c578cb2cc18a3d0e443d063c3a2f9 100644 (file)
@@ -815,7 +815,7 @@ endif
 time_epoch = get_option('time-epoch')
 if time_epoch <= 0
         time_epoch = run_command(sh, '-c', 'echo "$SOURCE_DATE_EPOCH"', check : true).stdout().strip()
-        if time_epoch == '' and git.found() and fs.exists('.git')
+        if time_epoch == '' and git.found() and fs.is_dir('.git')
                 # If we're in a git repository, use the creation time of the latest git tag.
                 latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags',
                                          check : false)
index f7f0a6111c201a6210305c894c97a147d982914e..a8fb71c566d12d83a0e335584c437e35c496e5e5 100644 (file)
@@ -50,7 +50,7 @@ sanitize_address_undefined = custom_target(
 fuzz_sanitizers = [['address,undefined', sanitize_address_undefined]]
 fuzz_testsdir = 'test/fuzz'
 
-if git.found() and fs.exists(project_source_root / '.git')
+if git.found() and fs.is_dir(project_source_root / '.git')
         out = run_command(env, '-u', 'GIT_WORK_TREE',
                           git, '--git-dir=@0@/.git'.format(project_source_root),
                           'ls-files', ':/@0@/*/*'.format(fuzz_testsdir),
index 93f0e679fe3afba0ad186631193c3004e549d9f6..a051f77a5220222e6030669ce1c2af3fb08cceb7 100644 (file)
@@ -187,7 +187,7 @@ endif
 if want_tests != 'false' and dmi_arches.contains(host_machine.cpu_family())
         udev_dmi_memory_id_test = find_program('udev-dmi-memory-id-test.sh')
 
-        if git.found() and fs.exists(project_source_root / '.git')
+        if git.found() and fs.is_dir(project_source_root / '.git')
                 out = run_command(
                         env, '-u', 'GIT_WORK_TREE',
                         git, '--git-dir=@0@/.git'.format(project_source_root),