Add PowerShell script to run Docker (#815)
authorMatthew Klein <mklein994@gmail.com>
Sat, 4 Mar 2017 21:20:43 +0000 (15:20 -0600)
committerFredrik Fornwall <fredrik@fornwall.net>
Sat, 4 Mar 2017 21:20:43 +0000 (22:20 +0100)
* Add .gitattributes file

* Add PowerShell script to run Docker

.gitattributes [new file with mode: 0644]
scripts/run-docker.ps1 [new file with mode: 0644]

diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..b818329
--- /dev/null
@@ -0,0 +1,4 @@
+*       text=auto
+
+*.sh    text eol=lf
+*.ps1   text eol=crlf
diff --git a/scripts/run-docker.ps1 b/scripts/run-docker.ps1
new file mode 100644 (file)
index 0000000..891c978
--- /dev/null
@@ -0,0 +1,28 @@
+# PowerShell script to build Termux packages with Docker.
+#
+# Usage example:
+#
+# .\scripts\run-docker.ps1 ./build-package.sh -a arm libandroid-support
+
+Set-Variable -Name IMAGE_NAME -Value "termux/package-builder"
+Set-Variable -Name CONTAINER_NAME -Value "termux-package-builder"
+
+Write-Output "Running container ${CONTAINER_NAME} from image ${IMAGE_NAME}..."
+
+docker start $CONTAINER_NAME 2>&1 | Out-Null
+
+if (-Not $?) {
+    Write-Output "Creating new container..."
+    docker run `
+        --detach `
+        --name $CONTAINER_NAME `
+        --volume "${PWD}:/home/builder/termux-packages" `
+        --tty `
+        "$IMAGE_NAME"
+}
+
+if ($args.Count -eq 0) {
+    docker exec --interactive --tty --user builder $CONTAINER_NAME bash
+} else {
+    docker exec --interactive --tty --user builder $CONTAINER_NAME $args
+}