diff options
author | Oscar Morante | 2018-12-18 13:18:51 +0200 |
---|---|---|
committer | Oscar Morante | 2018-12-18 17:11:56 +0200 |
commit | 096422350f86d83219811be166def21e2214cda4 (patch) | |
tree | f9a7c9f5411c96f7e18d31c55cac7104fd40af5f | |
parent | b53f8e284fd71d0c88d2d5f26830522cc6916666 (diff) | |
download | aur-096422350f86d83219811be166def21e2214cda4.tar.gz |
add unityhub integration helpers
-rw-r--r-- | .SRCINFO | 7 | ||||
-rw-r--r-- | PKGBUILD | 23 | ||||
-rwxr-xr-x | unity-editor | 54 | ||||
-rw-r--r-- | unity-editor.install | 12 |
4 files changed, 86 insertions, 10 deletions
@@ -1,9 +1,10 @@ pkgbase = unity-editor pkgdesc = The world's most popular development platform for creating 2D and 3D multiplatform games and interactive experiences. pkgver = 2018.3.0f2 - pkgrel = 1 + pkgrel = 2 epoch = 1 url = https://unity3d.com/ + install = unity-editor.install arch = x86_64 license = custom depends = desktop-file-utils @@ -28,6 +29,8 @@ pkgbase = unity-editor optdepends = unity-editor-windows optdepends = unity-editor-facebook optdepends = visual-studio-code-bin + optdepends = unityhub + optdepends = jq: needed for UnityHub integration helpers --register/--deregister options = !strip source = 2018.3.0f2.tar.xz::https://download.unity3d.com/download_unity/6e9a27477296/LinuxEditorInstaller/Unity.tar.xz source = unity-editor @@ -35,7 +38,7 @@ pkgbase = unity-editor source = unity-editor-icon.png source = eula.txt md5sums = 50fc7ae8146a7f8e16e30778ce0be7e4 - md5sums = c5871a48d70e13e33138176c0490ac59 + md5sums = a8fe2e41f06489dd09f651b08ec87125 md5sums = ee60f0d4d3c3fa9e0a52da085b1f3be6 md5sums = 723f9e556821810682a6d1f4be540a74 md5sums = 24f6741eba3d591a0761f3c92e3cc1f7 @@ -4,7 +4,7 @@ _prefix=/opt/Unity pkgname=unity-editor pkgver=2018.3.0f2 -pkgrel=1 +pkgrel=2 epoch=1 pkgdesc="The world's most popular development platform for creating 2D and 3D multiplatform games and interactive experiences." arch=('x86_64') @@ -31,17 +31,20 @@ optdepends=("${pkgname}-doc" "${pkgname}-webgl" "${pkgname}-windows" "${pkgname}-facebook" - "visual-studio-code-bin") + "visual-studio-code-bin" + "unityhub" + "jq: needed for UnityHub integration helpers --register/--deregister") +install=${pkgname}.install source=("2018.3.0f2.tar.xz::https://download.unity3d.com/download_unity/6e9a27477296/LinuxEditorInstaller/Unity.tar.xz" "${pkgname}" "${pkgname}.desktop" "${pkgname}-icon.png" "eula.txt") -md5sums=("50fc7ae8146a7f8e16e30778ce0be7e4" - "c5871a48d70e13e33138176c0490ac59" - "ee60f0d4d3c3fa9e0a52da085b1f3be6" - "723f9e556821810682a6d1f4be540a74" - "24f6741eba3d591a0761f3c92e3cc1f7") +md5sums=('50fc7ae8146a7f8e16e30778ce0be7e4' + 'a8fe2e41f06489dd09f651b08ec87125' + 'ee60f0d4d3c3fa9e0a52da085b1f3be6' + '723f9e556821810682a6d1f4be540a74' + '24f6741eba3d591a0761f3c92e3cc1f7') options=(!strip) PKGEXT='.pkg.tar' # Prevent compressing of the final package @@ -56,7 +59,11 @@ package() { find "${pkgdir}${_prefix}/Editor/Data" -type d -exec chmod ga+rx {} \; # Add version to desktop file - sed -i "/^Version=/c\Version=${_version}${_build}" "${srcdir}/${pkgname}.desktop" + sed -i "/^Version=/c\Version=${pkgver}" "${srcdir}/${pkgname}.desktop" + + # Add version/name to launch script + sed -i "s/%PKGNAME%/${pkgname}/g" "${srcdir}/${pkgname}" + sed -i "s/%PKGVER%/${pkgver}/g" "${srcdir}/${pkgname}" install -Dm644 -t "${pkgdir}/usr/share/applications" "${srcdir}/${pkgname}.desktop" install -Dm644 -t "${pkgdir}/usr/share/icons/hicolor/256x256/apps" "${srcdir}/${pkgname}-icon.png" diff --git a/unity-editor b/unity-editor index 9623372060a9..d068ad203bf5 100755 --- a/unity-editor +++ b/unity-editor @@ -1,5 +1,59 @@ #!/bin/sh +unityhub_editors_path="$HOME/.config/UnityHub" +unityhub_editors_json="$unityhub_editors_path/editors.json" + +check_jq() { + hash jq 2> /dev/null + if [ $? -ne 0 ]; then + echo "ERROR: You need to install 'jq' to register/deregister %PKGNAME% with unithub" + exit 1 + fi +} + +check_unityhub() { + local unityhub_pids=$(pgrep unityhub) + if [ ! -z "$unityhub_pids" ]; then + echo "ERROR: Can't UnityHub config while it's running. Close all Unity/UnityHub processes and try again." + exit 1 + fi +} + +ensure_json() { + if [ ! -f "$unityhub_editors_json" ] || [ ! -s "$unityhub_editors_json" ]; then + mkdir -p "$unityhub_editors_path" + echo "{}" > "$unityhub_editors_json" + fi +} + +unityhub_remove() { + local oldentries=$(cat "$unityhub_editors_json" \ + | jq 'to_entries[] | select(.value.location == ["/usr/bin/%PKGNAME%"]) | [.key?]' \ + | jq -cs '.') + cat "$unityhub_editors_json" | jq -c "delpaths($oldentries)" > /tmp/editors.json + mv /tmp/editors.json "$unityhub_editors_json" +} + +unityhub_add() { + unityhub_remove + cat "$unityhub_editors_json" | jq -c ". + {\"%PKGVER%\":{version:\"%PKGVER%\",location:[\"/usr/bin/%PKGNAME%\"],manual:true}}" > /tmp/editors.json + mv /tmp/editors.json "$unityhub_editors_json" +} + +if [ "$1" == "--register" ]; then + check_jq + check_unityhub + ensure_json + unityhub_add + exit 0 +elif [ "$1" == "--deregister" ]; then + check_jq + check_unityhub + ensure_json + unityhub_remove + exit 0 +fi + # This prevents the editor from crashing when opening projects in some systems unset GTK_IM_MODULE diff --git a/unity-editor.install b/unity-editor.install new file mode 100644 index 000000000000..348b30df81c9 --- /dev/null +++ b/unity-editor.install @@ -0,0 +1,12 @@ +unityhub_msg() { + echo "To integrate with UnityHub you can run 'unity-editor --register' after every update." + echo "To remove the integration you can run 'unity-editor --deregister' or manually remove the entry in UnityHub's GUI." +} + +post_install() { + unityhub_msg +} + +post_upgrade() { + unityhub_msg +} |