summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0f669a1e87cc2cbe6c4ca28d07771d498f002c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Maintainer: aligator <aligator at-symbol aligator.dev>
pkgrel=1
_pkgname='jsettlers'
pkgname=${_pkgname}'-git'

pkgver=0.6.0.8.alpha.r0.g990134459
pkgver() {
  cd  ${_pkgname}
  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
_gradlever='7.4.2'

arch=('any')
pkgdesc='A Remake of "The Settlers III" for Windows, Linux, Mac and Android - forked by paulwedeck'
url='https://github.com/paulwedeck/settlers-remake'
license=('MIT')
provides=(${_pkgname})
depends=('java-runtime>=11' 'sh')
optdepends=('settlers3-demo-data')
makedepends=('jdk11-openjdk' 'unzip' 'git')
install=${pkgname}'.install'
source=("jsettlers::git+https://github.com/paulwedeck/settlers-remake.git"
        "https://services.gradle.org/distributions/gradle-${_gradlever}-all.zip"
        "jsettlers-mapcreator.desktop"
        "jsettlers.desktop")
noextract=("gradle-${_gradlever}-all.zip")
sha512sums=('SKIP'
            '2e1d05486baa9661d5c8ffead2df87874a66f6cfc958ee6840432b89d221d8b0af9e3cad3675766f5413d12aa61c5b5fb0dd82f4164e5da3022865eba9ceadbf'
            '67d61b580daeb1dd098f10af99dccf81986732d9c6720432ec78cdfc093681b8f1a537c13b7460520ab0ae7443c1dc8da765f49cc8e90c27d59d14e6ee260179'
            '0c875bb6eb384867d46048054679ca555ff0600cbf197d170f9afda2b4a6c5e7bb275a08dad903cbf499508e2a96906a0f0267b4122f7cde8b42ed668ec17cc0')

prepare() {
  # prepare gradle to use downloaded zip
  sed -i "/distributionUrl=/c\distributionUrl=gradle-${_gradlever}-all.zip" ${srcdir}/${_pkgname}/gradle/wrapper/gradle-wrapper.properties
  mv gradle-${_gradlever}-all.zip ${srcdir}/${_pkgname}/gradle/wrapper
}

build() {
    cd ${srcdir}/${_pkgname}
    
    # build game (without android)
    JAVA_HOME="/usr/lib/jvm/java-11-openjdk" ANDROID_HOME="" ./gradlew --gradle-user-home=. releaseJSettlers || return 1
    # build server
    JAVA_HOME="/usr/lib/jvm/java-11-openjdk" ANDROID_HOME="" ./gradlew --gradle-user-home=. releaseDedicatedServer || return 1
}

package() {
    _jarDest=${pkgdir}/usr/share/java/${_pkgname}
    _dataDest=${pkgdir}/usr/share/${_pkgname}
    _licenseDest=${pkgdir}/usr/share/licenses/${pkgname}
    bin=${pkgdir}/usr/bin
    
    _progName='JSettlers'
    
    _mapCreatorName='MapCreator'
    _mapCreatorScript=${_pkgname}'-'${_mapCreatorName,,}

    _serverJar='DedicatedJSettlersServer.jar'
    _serverName='Server'
    _serverScript=${_pkgname}'-'${_serverName,,}

    # create destination-dirs
    mkdir -p ${_jarDest} ${_dataDest} ${_licenseDest}
    
    # copy game-files
    cd ${srcdir}/${_pkgname}/release
    unzip -j ${_progName}'.zip' ${_progName}'/'${_progName}'.jar' -d ${_jarDest} 
    unzip -j ${_progName}'.zip' ${_progName}'/'${_mapCreatorName}'.jar' -d ${_jarDest}
    unzip -j ${_progName}'.zip' ${_progName}'/maps/*' -d ${_dataDest}'/maps'
    cp ${_serverJar} ${_jarDest}

    # copy license
    cd ${srcdir}   
    cp ${_pkgname}'/LICENSE.txt' ${_licenseDest}
    
    # create launch-scripts
    mkdir -p ${bin}
    echo '#!/bin/sh' > ${bin}/${_pkgname}
    echo 'mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/'${_pkgname}'"' >> ${bin}/${_pkgname}
    echo 'cd "${XDG_DATA_HOME:-$HOME/.local/share}/'${_pkgname}'"' >> ${bin}/${_pkgname}
    echo 'exec /usr/bin/java -jar /usr/share/java/'${_pkgname}'/'${_progName}'.jar --maps=/usr/share/'${_pkgname}'/maps "$@"' >> ${bin}/${_pkgname}
    chmod +x ${bin}/${_pkgname}

    echo '#!/bin/sh' > ${bin}/${_mapCreatorScript}
    echo 'mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/'${_pkgname}'"' >> ${bin}/${_mapCreatorScript}
    echo 'cd "${XDG_DATA_HOME:-$HOME/.local/share}/'${_pkgname}'"' >> ${bin}/${_mapCreatorScript}
    echo 'exec /usr/bin/java -jar /usr/share/java/'${_pkgname}'/'${_mapCreatorName}'.jar --maps=/usr/share/'${_pkgname}'/maps "$@"' >> ${bin}/${_mapCreatorScript}
    chmod +x ${bin}/${_mapCreatorScript}

    echo '#!/bin/sh' > ${bin}/${_serverScript}
    echo 'mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/'${_pkgname}'"' >> ${bin}/${_serverScript}
    echo 'cd "${XDG_DATA_HOME:-$HOME/.local/share}/'${_pkgname}'"' >> ${bin}/${_serverScript}
    echo 'exec /usr/bin/java -jar /usr/share/java/'${_pkgname}'/'${_serverJar}' "$@"' >> ${bin}/${_serverScript}
    chmod +x ${bin}/${_serverScript}

    install -Dm644 ../${_pkgname}.desktop "${pkgdir}/usr/share/applications/${_pkgname}.desktop"
    install -Dm644 ../${_mapCreatorScript}.desktop "${pkgdir}/usr/share/applications/${_mapCreatorScript}.desktop"
    install -Dm644 ${srcdir}/jsettlers/jsettlers.main.swing/src/main/resources/jsettlers/main/swing/icon.png "${pkgdir}/usr/share/pixmaps/${_pkgname}.png"
    install -Dm644 ${srcdir}/jsettlers/jsettlers.main.swing/src/main/resources/jsettlers/main/swing/icon.png "${pkgdir}/usr/share/pixmaps/${_mapCreatorScript}.png"
}