forked from mirrors/nixpkgs
commit
ae03fb8121
|
@ -378,5 +378,10 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
|||
docker.succeed(
|
||||
"docker run --rm ${examples.layeredImageWithFakeRootCommands.imageName} sh -c 'stat -c '%u' /home/jane | grep -E ^1000$'"
|
||||
)
|
||||
|
||||
with subtest("exportImage produces a valid tarball"):
|
||||
docker.succeed(
|
||||
"tar -tf ${examples.exportBash} | grep '\./bin/bash' > /dev/null"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
|
|
@ -191,13 +191,13 @@ rec {
|
|||
, postMount ? ""
|
||||
, postUmount ? ""
|
||||
}:
|
||||
let
|
||||
result = vmTools.runInLinuxVM (
|
||||
vmTools.runInLinuxVM (
|
||||
runCommand name
|
||||
{
|
||||
preVM = vmTools.createEmptyImage {
|
||||
size = diskSize;
|
||||
fullName = "docker-run-disk";
|
||||
destination = "./image";
|
||||
};
|
||||
inherit fromImage fromImageName fromImageTag;
|
||||
|
||||
|
@ -278,12 +278,6 @@ rec {
|
|||
|
||||
${postUmount}
|
||||
'');
|
||||
in
|
||||
runCommand name { } ''
|
||||
mkdir -p $out
|
||||
cd ${result}
|
||||
cp layer.tar json VERSION $out
|
||||
'';
|
||||
|
||||
exportImage = { name ? fromImage.name, fromImage, fromImageName ? null, fromImageTag ? null, diskSize ? 1024 }:
|
||||
runWithOverlay {
|
||||
|
@ -291,7 +285,13 @@ rec {
|
|||
|
||||
postMount = ''
|
||||
echo "Packing raw image..."
|
||||
tar -C mnt --hard-dereference --sort=name --mtime="@$SOURCE_DATE_EPOCH" -cf $out .
|
||||
tar -C mnt --hard-dereference --sort=name --mtime="@$SOURCE_DATE_EPOCH" -cf $out/layer.tar .
|
||||
'';
|
||||
|
||||
postUmount = ''
|
||||
mv $out/layer.tar .
|
||||
rm -rf $out
|
||||
mv layer.tar $out
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
|
@ -541,4 +541,7 @@ rec {
|
|||
config.Cmd = [ "hello" ];
|
||||
includeStorePaths = false;
|
||||
};
|
||||
|
||||
# Example export of the bash image
|
||||
exportBash = pkgs.dockerTools.exportImage { fromImage = bash; };
|
||||
}
|
||||
|
|
|
@ -257,14 +257,23 @@ rec {
|
|||
eval "$postVM"
|
||||
'';
|
||||
|
||||
|
||||
createEmptyImage = {size, fullName}: ''
|
||||
mkdir $out
|
||||
diskImage=$out/disk-image.qcow2
|
||||
/*
|
||||
A bash script fragment that produces a disk image at `destination`.
|
||||
*/
|
||||
createEmptyImage = {
|
||||
# Disk image size in MiB
|
||||
size,
|
||||
# Name that will be written to ${destination}/nix-support/full-name
|
||||
fullName,
|
||||
# Where to write the image files, defaulting to $out
|
||||
destination ? "$out"
|
||||
}: ''
|
||||
mkdir -p ${destination}
|
||||
diskImage=${destination}/disk-image.qcow2
|
||||
${qemu}/bin/qemu-img create -f qcow2 $diskImage "${toString size}M"
|
||||
|
||||
mkdir $out/nix-support
|
||||
echo "${fullName}" > $out/nix-support/full-name
|
||||
mkdir ${destination}/nix-support
|
||||
echo "${fullName}" > ${destination}/nix-support/full-name
|
||||
'';
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue