From 10c49b266b8c67e6376cd3f5c260f9bab3aa1611 Mon Sep 17 00:00:00 2001 From: bott Date: Sat, 5 Nov 2022 21:00:53 +0100 Subject: [PATCH 1/5] add build script for linux --- .gitignore | 5 +++++ linux-build/build-linux.dockerfile | 10 ++++++++++ linux-build/makefile | 27 +++++++++++++++++++++++++++ linux-build/nfpm.yaml | 25 +++++++++++++++++++++++++ linux-build/postinstall.sh | 6 ++++++ 5 files changed, 73 insertions(+) create mode 100644 linux-build/build-linux.dockerfile create mode 100644 linux-build/makefile create mode 100644 linux-build/nfpm.yaml create mode 100644 linux-build/postinstall.sh diff --git a/.gitignore b/.gitignore index ac3e94b..96cbaad 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,11 @@ CMakeFiles/ Makefile cmake_install.cmake build +linux-build/out + +#IDE +.idea/ +*.iml # Executables mcmap diff --git a/linux-build/build-linux.dockerfile b/linux-build/build-linux.dockerfile new file mode 100644 index 0000000..a88f74e --- /dev/null +++ b/linux-build/build-linux.dockerfile @@ -0,0 +1,10 @@ +FROM ubuntu:22.10 + +RUN apt-get update && apt-get install -y \ + git make g++ libpng-dev cmake libspdlog-dev sudo + +# install nfpm +RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list && \ + apt-get update && apt-get install -y nfpm + +COPY . /app diff --git a/linux-build/makefile b/linux-build/makefile new file mode 100644 index 0000000..6b02531 --- /dev/null +++ b/linux-build/makefile @@ -0,0 +1,27 @@ +COMMIT_SHA_SHORT ?= $(shell git rev-parse --short=12 HEAD) +PWD_DIR:= ${CURDIR} +SHELL := /bin/bash + +default: help; + +# ====================================================================================== +build-builder: ## build the builder image that contains the source code + @docker build -f build-linux.dockerfile -t mcmap-builder:latest ./.. + +build-linux: build-builder ## build for linux using docker + @mkdir -p out + @docker run -it -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "cd /app && \ + mkdir -p /app/build && cd /app/build && \ + cmake .. && \ + make -j && \ + chmod -R 777 /app/build/bin/* && \ + cp -R /app/build/bin/* /out" + +package-linux: build-linux ## package the just compiled binary + @docker run -it -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "cd /out && \ + pwd && ls -al && \ + nfpm pkg -f /app/linux-build/nfpm.yaml -p deb" + + +help: ## Show this help + @egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m·%-20s\033[0m %s\n", $$1, $$2}' \ No newline at end of file diff --git a/linux-build/nfpm.yaml b/linux-build/nfpm.yaml new file mode 100644 index 0000000..3b69d88 --- /dev/null +++ b/linux-build/nfpm.yaml @@ -0,0 +1,25 @@ +# nfpm example config file +# +# check https://nfpm.goreleaser.com/configuration for detailed usage +# +name: "mcmap" +arch: "amd64" +platform: "linux" +version: "3.0.2" +section: "default" +priority: "extra" +description: | + Mcmap is a tool allowing you to create isometric renders of your Minecraft save file. +maintainer: "Andres Bott " +homepage: "https://github.com/spoutn1k/mcmap" +license: " GPL-3.0 license" +contents: +- src: ./mcmap # this path is mounted into the container + dst: /usr/local/bin/mcmap +overrides: + rpm: + scripts: + postinstall: /app/linux-build/postinstall.sh # this path is copied into the container at build time + deb: + scripts: + postinstall: /app/linux-build/postinstall.sh diff --git a/linux-build/postinstall.sh b/linux-build/postinstall.sh new file mode 100644 index 0000000..cfe53bd --- /dev/null +++ b/linux-build/postinstall.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# postinstall script +# +chown root:root /usr/local/bin/mcmap +chmod 755 /usr/local/bin/mcmap + From 8654fcb13d01a28342571bc4740bf9607d4bfec8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Mon, 7 Nov 2022 10:01:11 -0800 Subject: [PATCH 2/5] Added mcmap-gui --- linux-build/{makefile => Makefile} | 16 +++++++--------- linux-build/build-linux.dockerfile | 8 +++++--- linux-build/nfpm.yaml | 6 +++--- linux-build/postinstall.sh | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) rename linux-build/{makefile => Makefile} (51%) diff --git a/linux-build/makefile b/linux-build/Makefile similarity index 51% rename from linux-build/makefile rename to linux-build/Makefile index 6b02531..f209973 100644 --- a/linux-build/makefile +++ b/linux-build/Makefile @@ -10,18 +10,16 @@ build-builder: ## build the builder image that contains the source code build-linux: build-builder ## build for linux using docker @mkdir -p out - @docker run -it -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "cd /app && \ - mkdir -p /app/build && cd /app/build && \ + @docker run -it --rm -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "mkdir -p /mcmap/build && \ + cd /mcmap/build && \ cmake .. && \ - make -j && \ - chmod -R 777 /app/build/bin/* && \ - cp -R /app/build/bin/* /out" + make -j mcmap mcmap-gui && \ + cp /mcmap/build/bin/* /out" package-linux: build-linux ## package the just compiled binary - @docker run -it -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "cd /out && \ - pwd && ls -al && \ - nfpm pkg -f /app/linux-build/nfpm.yaml -p deb" + @docker run -it --rm -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "cd /out && \ + nfpm pkg -f /mcmap/linux-build/nfpm.yaml -p deb" help: ## Show this help - @egrep '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m·%-20s\033[0m %s\n", $$1, $$2}' \ No newline at end of file + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m·%-20s\033[0m %s\n", $$1, $$2}' diff --git a/linux-build/build-linux.dockerfile b/linux-build/build-linux.dockerfile index a88f74e..5d0262b 100644 --- a/linux-build/build-linux.dockerfile +++ b/linux-build/build-linux.dockerfile @@ -1,10 +1,12 @@ FROM ubuntu:22.10 -RUN apt-get update && apt-get install -y \ - git make g++ libpng-dev cmake libspdlog-dev sudo +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=Etc/PDT +RUN apt-get update && apt-get install -y \ + git make g++ libpng-dev cmake libspdlog-dev qttools5-dev # install nfpm RUN echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | tee /etc/apt/sources.list.d/goreleaser.list && \ apt-get update && apt-get install -y nfpm -COPY . /app +COPY . /mcmap diff --git a/linux-build/nfpm.yaml b/linux-build/nfpm.yaml index 3b69d88..96bf204 100644 --- a/linux-build/nfpm.yaml +++ b/linux-build/nfpm.yaml @@ -12,14 +12,14 @@ description: | Mcmap is a tool allowing you to create isometric renders of your Minecraft save file. maintainer: "Andres Bott " homepage: "https://github.com/spoutn1k/mcmap" -license: " GPL-3.0 license" +license: "GPL-3.0 license" contents: - src: ./mcmap # this path is mounted into the container dst: /usr/local/bin/mcmap overrides: rpm: scripts: - postinstall: /app/linux-build/postinstall.sh # this path is copied into the container at build time + postinstall: /mcmap/linux-build/postinstall.sh # this path is copied into the container at build time deb: scripts: - postinstall: /app/linux-build/postinstall.sh + postinstall: /mcmap/linux-build/postinstall.sh diff --git a/linux-build/postinstall.sh b/linux-build/postinstall.sh index cfe53bd..0c3225a 100644 --- a/linux-build/postinstall.sh +++ b/linux-build/postinstall.sh @@ -1,6 +1,6 @@ #!/bin/sh # postinstall script -# + chown root:root /usr/local/bin/mcmap chmod 755 /usr/local/bin/mcmap From 3b95f84967f0d89ceb4206d1cb3dd46361419b45 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Mon, 7 Nov 2022 10:29:58 -0800 Subject: [PATCH 3/5] Added dependencies --- linux-build/nfpm.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/linux-build/nfpm.yaml b/linux-build/nfpm.yaml index 96bf204..7e0d49c 100644 --- a/linux-build/nfpm.yaml +++ b/linux-build/nfpm.yaml @@ -16,10 +16,13 @@ license: "GPL-3.0 license" contents: - src: ./mcmap # this path is mounted into the container dst: /usr/local/bin/mcmap +- src: ./mcmap-gui + dst: /usr/local/bin/mcmap-gui overrides: - rpm: - scripts: - postinstall: /mcmap/linux-build/postinstall.sh # this path is copied into the container at build time deb: + depends: + - libpng16-16 + - libgomp1 + - qtbase5-dev scripts: postinstall: /mcmap/linux-build/postinstall.sh From 7dd08578cb49b336d73a4593828ad2d83e67c98c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Mon, 7 Nov 2022 10:32:50 -0800 Subject: [PATCH 4/5] Remove script --- linux-build/nfpm.yaml | 17 +++++++++++------ linux-build/postinstall.sh | 6 ------ 2 files changed, 11 insertions(+), 12 deletions(-) delete mode 100644 linux-build/postinstall.sh diff --git a/linux-build/nfpm.yaml b/linux-build/nfpm.yaml index 7e0d49c..bd3be56 100644 --- a/linux-build/nfpm.yaml +++ b/linux-build/nfpm.yaml @@ -1,7 +1,6 @@ -# nfpm example config file -# -# check https://nfpm.goreleaser.com/configuration for detailed usage -# +# mcmap packaging config +# expects to be run from the `bin` directory + name: "mcmap" arch: "amd64" platform: "linux" @@ -16,13 +15,19 @@ license: "GPL-3.0 license" contents: - src: ./mcmap # this path is mounted into the container dst: /usr/local/bin/mcmap + file_info: + mode: 0755 + owner: root + group: root - src: ./mcmap-gui dst: /usr/local/bin/mcmap-gui + file_info: + mode: 0755 + owner: root + group: root overrides: deb: depends: - libpng16-16 - libgomp1 - qtbase5-dev - scripts: - postinstall: /mcmap/linux-build/postinstall.sh diff --git a/linux-build/postinstall.sh b/linux-build/postinstall.sh deleted file mode 100644 index 0c3225a..0000000 --- a/linux-build/postinstall.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# postinstall script - -chown root:root /usr/local/bin/mcmap -chmod 755 /usr/local/bin/mcmap - From b31122a039ae31bef23f6264e52e7861f2f44837 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Skutnik Date: Mon, 7 Nov 2022 10:40:41 -0800 Subject: [PATCH 5/5] Rename build to reflect architecture --- .gitignore | 2 +- linux-build/Makefile | 25 ------------------- package-debian/Makefile | 25 +++++++++++++++++++ .../build-debian.dockerfile | 0 {linux-build => package-debian}/nfpm.yaml | 0 5 files changed, 26 insertions(+), 26 deletions(-) delete mode 100644 linux-build/Makefile create mode 100644 package-debian/Makefile rename linux-build/build-linux.dockerfile => package-debian/build-debian.dockerfile (100%) rename {linux-build => package-debian}/nfpm.yaml (100%) diff --git a/.gitignore b/.gitignore index 96cbaad..4c9aa89 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ CMakeFiles/ Makefile cmake_install.cmake build -linux-build/out +package-debian/out #IDE .idea/ diff --git a/linux-build/Makefile b/linux-build/Makefile deleted file mode 100644 index f209973..0000000 --- a/linux-build/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -COMMIT_SHA_SHORT ?= $(shell git rev-parse --short=12 HEAD) -PWD_DIR:= ${CURDIR} -SHELL := /bin/bash - -default: help; - -# ====================================================================================== -build-builder: ## build the builder image that contains the source code - @docker build -f build-linux.dockerfile -t mcmap-builder:latest ./.. - -build-linux: build-builder ## build for linux using docker - @mkdir -p out - @docker run -it --rm -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "mkdir -p /mcmap/build && \ - cd /mcmap/build && \ - cmake .. && \ - make -j mcmap mcmap-gui && \ - cp /mcmap/build/bin/* /out" - -package-linux: build-linux ## package the just compiled binary - @docker run -it --rm -v ${PWD_DIR}/out:/out mcmap-builder:latest /bin/bash -c "cd /out && \ - nfpm pkg -f /mcmap/linux-build/nfpm.yaml -p deb" - - -help: ## Show this help - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m·%-20s\033[0m %s\n", $$1, $$2}' diff --git a/package-debian/Makefile b/package-debian/Makefile new file mode 100644 index 0000000..32350ba --- /dev/null +++ b/package-debian/Makefile @@ -0,0 +1,25 @@ +COMMIT_SHA_SHORT ?= $(shell git rev-parse --short=12 HEAD) +PWD_DIR:= ${CURDIR} +SHELL := /bin/bash + +default: help; + +# ====================================================================================== +build-builder-debian: ## build the builder image that contains the source code + @docker build -f build-debian.dockerfile -t mcmap-builder-debian:latest ./.. + +build-debian: build-builder-debian ## build for linux using docker + @mkdir -p out + @docker run -it --rm -v ${PWD_DIR}/out:/out mcmap-builder-debian:latest /bin/bash -c "mkdir -p /mcmap/build && \ + cd /mcmap/build && \ + cmake .. && \ + make -j mcmap mcmap-gui && \ + cp /mcmap/build/bin/* /out" + +package-debian: build-debian ## package the just compiled binary + @docker run -it --rm -v ${PWD_DIR}/out:/out mcmap-builder-debian:latest /bin/bash -c "cd /out && \ + nfpm pkg -f /mcmap/package-debian/nfpm.yaml -p deb" + + +help: ## Show this help + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m- %-20s\033[0m %s\n", $$1, $$2}' diff --git a/linux-build/build-linux.dockerfile b/package-debian/build-debian.dockerfile similarity index 100% rename from linux-build/build-linux.dockerfile rename to package-debian/build-debian.dockerfile diff --git a/linux-build/nfpm.yaml b/package-debian/nfpm.yaml similarity index 100% rename from linux-build/nfpm.yaml rename to package-debian/nfpm.yaml