فهرست منبع

Windows: Build docker.exe manifested and with icon

Signed-off-by: John Howard <John.Howard@microsoft.com>
John Howard 10 سال پیش
والد
کامیت
fd935ee63d

+ 8 - 0
Dockerfile

@@ -176,6 +176,14 @@ COPY vendor /go/src/github.com/docker/docker/vendor
 RUN go install -v github.com/cpuguy83/go-md2man \
 	github.com/BurntSushi/toml/cmd/tomlv
 
+# Build/install the tool for embedding resources in Windows binaries
+ENV RSRC_COMMIT e48dbf1b7fc464a9e85fcec450dddf80816b76e0
+RUN set -x \
+    && git clone https://github.com/akavel/rsrc.git /go/src/github.com/akavel/rsrc \
+    && cd /go/src/github.com/akavel/rsrc \
+    && git checkout -q $RSRC_COMMIT \
+    && go install -v
+
 # Wrap all commands in the "docker-in-docker" script to allow nested containers
 ENTRYPOINT ["hack/dind"]
 

+ 5 - 0
docker/docker_windows.go

@@ -0,0 +1,5 @@
+package main
+
+import (
+	_ "github.com/docker/docker/autogen/winresources"
+)

+ 37 - 2
hack/make/.go-autogen

@@ -3,7 +3,7 @@
 rm -rf autogen
 
 mkdir -p autogen/dockerversion
-cat > autogen/dockerversion/dockerversion.go <<EOF
+cat > autogen/dockerversion/dockerversion.go <<DVEOF
 // AUTOGENERATED FILE; see $BASH_SOURCE
 package dockerversion
 
@@ -15,4 +15,39 @@ var (
 	INITSHA1  string = "$DOCKER_INITSHA1"
 	INITPATH  string = "$DOCKER_INITPATH"
 )
-EOF
+DVEOF
+
+# Compile the Windows resources into the sources
+mkdir -p autogen/winresources
+cat > autogen/winresources/resources.go <<WREOF
+// AUTOGENERATED FILE; see $BASH_SOURCE
+package winresources
+
+/*
+
+This package is for embedding a manifest file and an icon into docker.exe.
+The benefit of this is that a manifest file does not need to be alongside
+the .exe, and there is an icon when docker runs, or viewed through Windows
+explorer.
+
+When make binary is run, the Dockerfile prepares the build environment by:
+
+ - Cloning github.com/akavel/rsrc
+
+ - Go-installing the rsrc executable
+
+make.sh invokes hack/make/.go-autogen to:
+
+ - Run rsrc to create a binary file (autogen/winresources/rsrc.syso) that 
+   contains the manifest and icon. This file is automatically picked up by 
+   'go build', so no post-processing steps are required. The sources for 
+   rsrc.syso are under hack/make/.resources-windows.
+
+*/
+WREOF
+if [ "$(go env GOOS)" = 'windows' ]; then
+	rsrc \
+		-manifest hack/make/.resources-windows/docker.exe.manifest \
+		-ico      hack/make/.resources-windows/docker.ico \
+		-o        autogen/winresources/rsrc.syso > /dev/null
+fi

+ 18 - 0
hack/make/.resources-windows/docker.exe.manifest

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+    <description>Docker</description>
+    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
+        <application> 
+            <!-- Windows 10 -->
+            <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+            <!-- Windows 8.1 -->
+            <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+            <!-- Windows Vista -->
+            <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
+            <!-- Windows 7 -->
+            <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+            <!-- Windows 8 -->
+            <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+        </application> 
+    </compatibility>
+</assembly>

BIN
hack/make/.resources-windows/docker.ico


BIN
hack/make/.resources-windows/docker.png