From ebb9d4f8e15672ea26acce011565bc36f37207cb Mon Sep 17 00:00:00 2001 From: Joshua Rich Date: Thu, 27 Jun 2024 11:01:51 +1000 Subject: [PATCH] build(go): :bug: ensure build scripts are committed --- .gitignore | 2 +- .../com.github.joshuar.go-hass-agent.yml | 16 ++++++++++ build/scripts/install-build-deps | 29 +++++++++++++++++++ build/scripts/install-run-deps | 28 ++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 build/package/com.github.joshuar.go-hass-agent.yml create mode 100755 build/scripts/install-build-deps create mode 100755 build/scripts/install-run-deps diff --git a/.gitignore b/.gitignore index cf79aa114..7d41bc1b3 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ !/*.yml !/*.json !/*.toml -!build/* +!build/**/* !/assets/**/* !/internal/agent/ui/assets/* diff --git a/build/package/com.github.joshuar.go-hass-agent.yml b/build/package/com.github.joshuar.go-hass-agent.yml new file mode 100644 index 000000000..61998d4cd --- /dev/null +++ b/build/package/com.github.joshuar.go-hass-agent.yml @@ -0,0 +1,16 @@ +id: com.github.joshuar.go-hass-agent +runtime: org.freedesktop.Platform +runtime-version: '23.08' +sdk: org.freedesktop.Sdk +command: go-hass-agent +modules: + - name: go-hass-agent + buildsystem: simple + env: + CGO_ENABLED: 1 + build-commands: + - go generate ./... + - go build + sources: + - type: dir + path: ./ \ No newline at end of file diff --git a/build/scripts/install-build-deps b/build/scripts/install-build-deps new file mode 100755 index 000000000..b869cb064 --- /dev/null +++ b/build/scripts/install-build-deps @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# Copyright (c) 2024 Joshua Rich +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +set -e + +# set ccpkg and arch as appropriate +case $1 in + linux/amd64) ccpkg=(gcc) arch=(amd64) ;; + linux/arm/*) ccpkg=(gcc gcc-arm-linux-gnueabihf) arch=(armhf) ;; + arm64) ccpkg=(gcc gcc-aarch64-linux-gnu) arch=(arm64) ;; + all) ccpkg=(gcc gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu) arch=(armhf arm64 amd64) ;; + *) echo "No arch specified" && exit -1 ;; +esac + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get -y install desktop-file-utils pkg-config git ${ccpkg[@]:0} +for arch in "$@"; do + apt-get -y install \ + libgl1-mesa-dev:${arch} xserver-xorg-dev:${arch} \ + libxcursor-dev:${arch} libxrandr-dev:${arch} \ + libxinerama-dev:${arch} libxi-dev:${arch} \ + libgl1-mesa-dev:${arch} libxxf86vm-dev:${arch} +done diff --git a/build/scripts/install-run-deps b/build/scripts/install-run-deps new file mode 100755 index 000000000..f4d959952 --- /dev/null +++ b/build/scripts/install-run-deps @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright (c) 2024 Joshua Rich +# +# This software is released under the MIT License. +# https://opensource.org/licenses/MIT + +set -e + +# set arch as appropriate +case $1 in + linux/amd64) arch=(amd64) ;; + linux/arm/*) arch=(armhf) ;; + arm64) arch=(arm64) ;; + all) arch=(armhf arm64 amd64) ;; + *) echo "No arch specified" && exit -1 ;; +esac + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +for arch in "$@"; do + apt-get -y install \ + libgl1:${arch} libx11-6:${arch} libglx0:${arch} \ + libglvnd0:${arch} libxcb1:${arch} libxau6:${arch} \ + libxdmcp6:${arch} dbus-x11:${arch} +done +rm -rf /var/lib/apt/lists/* /var/cache/apt/*