瀏覽代碼

Merge pull request #10230 from tianon/emptyfs

Update emptyfs support to work properly if scratch is already an image
Tibor Vass 10 年之前
父節點
當前提交
bb4025c4e2
共有 3 個文件被更改,包括 8 次插入6 次删除
  1. 1 1
      project/make/.ensure-busybox
  2. 6 5
      project/make/.ensure-emptyfs
  3. 1 0
      project/make/test-integration-cli

+ 1 - 1
project/make/.ensure-busybox

@@ -1,8 +1,8 @@
 #!/bin/bash
+set -e
 
 if ! docker inspect busybox &> /dev/null; then
 	if [ -d /docker-busybox ]; then
-		source "$(dirname "$BASH_SOURCE")/.ensure-scratch"
 		( set -x; docker build -t busybox /docker-busybox )
 	else
 		( set -x; docker pull busybox )

+ 6 - 5
project/make/.ensure-scratch → project/make/.ensure-emptyfs

@@ -1,12 +1,13 @@
 #!/bin/bash
+set -e
 
-if ! docker inspect scratch &> /dev/null; then
+if ! docker inspect emptyfs &> /dev/null; then
 	# let's build a "docker save" tarball for "emptyfs"
 	# see https://github.com/docker/docker/pull/5262
 	# and also https://github.com/docker/docker/issues/4242
-	mkdir -p /docker-scratch
+	dir="$(mktemp -d)"
 	(
-		cd /docker-scratch
+		cd "$dir"
 		echo '{"emptyfs":{"latest":"511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158"}}' > repositories
 		mkdir -p 511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158
 		(
@@ -16,6 +17,6 @@ if ! docker inspect scratch &> /dev/null; then
 			tar -cf layer.tar --files-from /dev/null
 		)
 	)
-	( set -x; tar -cf /docker-scratch.tar -C /docker-scratch . )
-	( set -x; docker load --input /docker-scratch.tar )
+	( set -x; tar -cC "$dir" . | docker load )
+	rm -rf "$dir"
 fi

+ 1 - 0
project/make/test-integration-cli

@@ -20,6 +20,7 @@ bundle_test_integration_cli() {
 		sleep 2
 
 		source "$(dirname "$BASH_SOURCE")/.ensure-busybox"
+		source "$(dirname "$BASH_SOURCE")/.ensure-emptyfs"
 
 		bundle_test_integration_cli
 	}; then