mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-23 04:25:14 +00:00
Merge pull request #226214 from leon-barrett/leon-make-disk-image-dir
nixos/make-disk-image: fix contents dir paths
This commit is contained in:
commit
6bf4cde63f
@ -423,6 +423,8 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||||||
|
|
||||||
- The `bind` module now allows the per-zone `allow-query` setting to be configured (previously it was hard-coded to `any`; it still defaults to `any` to retain compatibility).
|
- The `bind` module now allows the per-zone `allow-query` setting to be configured (previously it was hard-coded to `any`; it still defaults to `any` to retain compatibility).
|
||||||
|
|
||||||
|
- `make-disk-image` handles `contents` arguments that are directories better, fixing a bug where it used to put them in a subdirectory of the intended `target`.
|
||||||
|
|
||||||
## Detailed migration information {#sec-release-23.05-migration}
|
## Detailed migration information {#sec-release-23.05-migration}
|
||||||
|
|
||||||
### Pipewire configuration overrides {#sec-release-23.05-migration-pipewire}
|
### Pipewire configuration overrides {#sec-release-23.05-migration-pipewire}
|
||||||
|
@ -402,11 +402,16 @@ let format' = format; in let
|
|||||||
done
|
done
|
||||||
else
|
else
|
||||||
mkdir -p $root/$(dirname $target)
|
mkdir -p $root/$(dirname $target)
|
||||||
if ! [ -e $root/$target ]; then
|
if [ -e $root/$target ]; then
|
||||||
rsync $rsync_flags $source $root/$target
|
|
||||||
else
|
|
||||||
echo "duplicate entry $target -> $source"
|
echo "duplicate entry $target -> $source"
|
||||||
exit 1
|
exit 1
|
||||||
|
elif [ -d $source ]; then
|
||||||
|
# Append a slash to the end of source to get rsync to copy the
|
||||||
|
# directory _to_ the target instead of _inside_ the target.
|
||||||
|
# (See `man rsync`'s note on a trailing slash.)
|
||||||
|
rsync $rsync_flags $source/ $root/$target
|
||||||
|
else
|
||||||
|
rsync $rsync_flags $source $root/$target
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -17,6 +17,7 @@ with pkgs.lib;
|
|||||||
ln -s ${pkgs.writeText "sshPublicKey" sshPublicKey} $out/1.0/meta-data/public-keys/0/openssh-key
|
ln -s ${pkgs.writeText "sshPublicKey" sshPublicKey} $out/1.0/meta-data/public-keys/0/openssh-key
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
indentLines = str: concatLines (map (s: " " + s) (splitString "\n" str));
|
||||||
in makeTest {
|
in makeTest {
|
||||||
name = "ec2-" + name;
|
name = "ec2-" + name;
|
||||||
nodes = {};
|
nodes = {};
|
||||||
@ -36,6 +37,8 @@ with pkgs.lib;
|
|||||||
"create",
|
"create",
|
||||||
"-f",
|
"-f",
|
||||||
"qcow2",
|
"qcow2",
|
||||||
|
"-F",
|
||||||
|
"qcow2",
|
||||||
"-o",
|
"-o",
|
||||||
"backing_file=${image}",
|
"backing_file=${image}",
|
||||||
disk_image,
|
disk_image,
|
||||||
@ -59,7 +62,11 @@ with pkgs.lib;
|
|||||||
)
|
)
|
||||||
|
|
||||||
machine = create_machine({"startCommand": start_command})
|
machine = create_machine({"startCommand": start_command})
|
||||||
'' + script;
|
try:
|
||||||
|
'' + indentLines script + ''
|
||||||
|
finally:
|
||||||
|
machine.shutdown()
|
||||||
|
'';
|
||||||
|
|
||||||
inherit meta;
|
inherit meta;
|
||||||
};
|
};
|
||||||
|
@ -27,13 +27,19 @@ let
|
|||||||
inherit pkgs config;
|
inherit pkgs config;
|
||||||
lib = pkgs.lib;
|
lib = pkgs.lib;
|
||||||
format = "qcow2";
|
format = "qcow2";
|
||||||
contents = [{
|
contents = [
|
||||||
|
{
|
||||||
source = pkgs.writeText "testFile" "contents";
|
source = pkgs.writeText "testFile" "contents";
|
||||||
target = "/testFile";
|
target = "/testFile";
|
||||||
user = "1234";
|
user = "1234";
|
||||||
group = "5678";
|
group = "5678";
|
||||||
mode = "755";
|
mode = "755";
|
||||||
}];
|
}
|
||||||
|
{
|
||||||
|
source = ./.;
|
||||||
|
target = "/testDir";
|
||||||
|
}
|
||||||
|
];
|
||||||
}) + "/nixos.qcow2";
|
}) + "/nixos.qcow2";
|
||||||
|
|
||||||
in makeEc2Test {
|
in makeEc2Test {
|
||||||
@ -42,10 +48,15 @@ in makeEc2Test {
|
|||||||
userData = null;
|
userData = null;
|
||||||
script = ''
|
script = ''
|
||||||
machine.start()
|
machine.start()
|
||||||
|
# Test that if contents includes a file, it is copied to the target.
|
||||||
assert "content" in machine.succeed("cat /testFile")
|
assert "content" in machine.succeed("cat /testFile")
|
||||||
fileDetails = machine.succeed("ls -l /testFile")
|
fileDetails = machine.succeed("ls -l /testFile")
|
||||||
assert "1234" in fileDetails
|
assert "1234" in fileDetails
|
||||||
assert "5678" in fileDetails
|
assert "5678" in fileDetails
|
||||||
assert "rwxr-xr-x" in fileDetails
|
assert "rwxr-xr-x" in fileDetails
|
||||||
|
|
||||||
|
# Test that if contents includes a directory, it is copied to the target.
|
||||||
|
dirList = machine.succeed("ls /testDir")
|
||||||
|
assert "image-contents.nix" in dirList
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user