Package Details: mindustry-server 146-1

Git Clone URL: https://aur.archlinux.org/mindustry.git (read-only, click to copy)
Package Base: mindustry
Description: A sandbox tower defense game - server
Upstream URL: https://github.com/Anuken/Mindustry
Licenses: GPL-3.0-only
Submitter: dmitmel
Maintainer: xiota
Last Packager: xiota
Votes: 33
Popularity: 0.158725
First Submitted: 2019-10-10 21:43 (UTC)
Last Updated: 2025-01-17 16:08 (UTC)

Dependencies (6)

Required by (0)

Sources (2)

Latest Comments

1 2 3 4 5 6 Next › Last »

xiota commented on 2025-01-18 16:41 (UTC)

@Pavlov. Please let that be your last comment on this non-issue. Edit your last comment if you need to revise your alternate PKGBUILD.

Pavlov commented on 2025-01-18 15:36 (UTC) (edited on 2025-01-18 15:39 (UTC) by Pavlov)

PKGBUILD

pkgbase="mindustry"
pkgname=("mindustry" "mindustry-server" "mindustry-icons")
pkgver="146"
pkgrel=1
pkgdesc="A sandbox tower defense game"
url="https://github.com/Anuken/Mindustry"
license=('GPL-3.0-only')
arch=('any')

depends=('hicolor-icon-theme' 'java-runtime')
makedepends=(
  'alsa-lib'
  'archlinux-java-run'
  'java-environment=17'
  'libicns'
  'gradle'
)

_pkgsrc="Mindustry-$pkgver"
_pkgsrc_arc="Arc-$pkgver"
source=(
  "${pkgbase}-${pkgver}.tar.gz"::"https://github.com/Anuken/Mindustry/archive/v${pkgver}.tar.gz"
  "${pkgbase}-arc-${pkgver}.tar.gz"::"https://github.com/Anuken/Arc/archive/refs/tags/v${pkgver}.tar.gz"
  "mindustry.sh.template"
  "mindustry.desktop.template"
)
b2sums=('9b299e478439fa9db6dc3ca46723e66393513101e236e62ed8bea8c3ec844de1eecf498fb0de2bef3f89ab3b4a2ba416f48abc677e505089c71ee2bb6e6e38a0'
        '01da117c758b861eb5d755ea3aef094905db7901c56dd5f53314d5420671b4da32c91db82d142f601340f500f86b859dc51cb067b9bdad3594108bb9458899ba'
        '86ceb4b207b9651b51f0201f76f2ee365e16e2fa29c2394570a19a36ecfaca63b566b074f7a16b4d1fcbce2b8c64f60a92b4519c7f8c6d99440a7ec91d0588fc'
        '36062279c09468b2de3d978812738113dc9ad50797b96f0ba24d61fe0eb0f7c708bc1b3cbef70a51c89a1bd9a6d80ba6fd2a5769968d02722f8eb198714f2272')

prepare() {
  ln -sf "$_pkgsrc_arc" "${srcdir}/Arc"
  cd "$_pkgsrc"
  gawk -i inplace -v MYVER="$pkgver" '{sub(/^archash=.*$/,"archash=v"MYVER); print $0}' gradle.properties
}

build() {
  mkdir -p "${srcdir}/$_pkgsrc/gradle_user_home"
  export GRADLE_USER_HOME="${srcdir}/$_pkgsrc/gradle_user_home"
  cd "$_pkgsrc"

  # skip android subproject; see settings.gradle
  unset ANDROID_HOME JITPACK

  JAVA_HOME=$(archlinux-java-run --min 17 --max 17 --feature jdk --java-home) gradle --info --no-daemon -Pbuildversion="${pkgver}" dist desktop:dist server:dist

  cd core/assets/icons
  icns2png --extract icon.icns
}

package_mindustry-icons() {
    pkgdesc="A sandbox tower defense game - icons"
    cd "$_pkgsrc"
    local icon_size
    for icon_size in 256 512 1024; do
      install -Dm644 "core/assets/icons/icon_${icon_size}x${icon_size}x32.png" "${pkgdir}/usr/share/icons/hicolor/${icon_size}x${icon_size}/apps/mindustry.png"
    done
}

package_mindustry() {
    depends+=('mindustry-icons')
    pkgdesc="A sandbox tower defense game"
    gawk '{gsub(/%JARNAME%/, "Mindustry"); print $0}' mindustry.sh.template > mindustry.sh
    gawk '{gsub(/%APPNAME%/, "Mindustry"); gsub(/%APPDESC%/, "A sandbox tower defense game"); gsub(/%APPPATH%/, "/usr/bin/mindustry.sh"); gsub(/%APPICON%/, "mindustry"); print $0}' mindustry.desktop.template > mindustry.desktop
    install -Dm755 mindustry.sh "$pkgdir/usr/bin/mindustry.sh"
    install -Dm644 mindustry.desktop "$pkgdir/usr/share/applications/mindustry.desktop"
    rm mindustry.sh
    rm mindustry.desktop
    cd "$_pkgsrc"
    install -Dm755 "desktop/build/libs/Mindustry.jar" "$pkgdir/usr/share/java/mindustry/Mindustry.jar"
}

package_mindustry-server() {
    depends+=('mindustry-icons')
    pkgdesc="A sandbox tower defense game - server"
    gawk '{gsub(/%JARNAME%/, "MindustryServer"); print $0}' mindustry.sh.template > mindustry-server.sh
    gawk '{gsub(/%APPNAME%/, "Mindustry Server"); gsub(/%APPDESC%/, "A sandbox tower defense game - server"); gsub(/%APPPATH%/, "/usr/bin/mindustry-server.sh"); gsub(/%APPICON%/, "mindustry"); print $0}' mindustry.desktop.template > mindustry-server.desktop
    install -Dm755 mindustry-server.sh "$pkgdir/usr/bin/mindustry-server.sh"
    install -Dm644 mindustry-server.desktop "$pkgdir/usr/share/applications/mindustry-server.desktop"
    rm mindustry-server.sh
    rm mindustry-server.desktop
    cd "$_pkgsrc"
    install -Dm755 "desktop/build/libs/server-release.jar" "$pkgdir/usr/share/java/mindustry/MindustryServer.jar"
}

mindustry.sh.template

#!/usr/bin/env sh
exec /usr/bin/java -jar /usr/share/java/mindustry/%JARNAME%.jar "\$@"

mindustry.desktop.template

[Desktop Entry]
Type=Application
Name=%APPNAME%
Comment=%APPDESC%
Exec=%APPPATH%
Icon=%APPICON%
Categories=Game;
Terminal=false

There are still some things to modify, but just as is is far way better than your own, and doesn't use any eval or dynamically generated bash code and generates correct .SRCINFO information. You can still improve it, for example removing java-runtime from mindustry-icons dependencies.

xiota commented on 2025-01-17 16:28 (UTC) (edited on 2025-01-17 16:34 (UTC) by xiota)

The per-package metadata changes, like depends, would be missing. Manually editing .SRCINFO is generally considered bad practice.

Maintainers have no "duty to prove" anything. It is user responsibility to review PKGBUILDs before building. Good job. Now, if you find an actual problem, I'll fix it. But if you just don't like how it's written, no one is forcing you to build it.

Pavlov commented on 2025-01-17 16:00 (UTC)

Can you explain how without eval an incorrect .SRCINFO would be generated, and why you can not provide you own .SRCINFO if the one automatically generated by makepkg doesn't satisfies your expectations?

Linux is a package provided in Arch official repository, therefore the Arch team guarantees that it is secure and follows the official guidelines. Your package is in AUR, where everyone can upload (almost) whatever they want without a previous authorization, therefore it is your duty to prove that your package is safe and your imaginative Bash artifacts don't help in that sense (moreover, some variables aren't even defined).

Since there are only two packages associated to this pkgbase it doesn't seem too expensive writing them both.

xiota commented on 2025-01-17 15:07 (UTC)

Without eval, incorrect .SRCINFO would be generated. Consider using a different distro if it bothers you. See "voluntary obfuscation" in extra/linux and extra/linux-lts.

Sourcing arbitrary external files makes the package "difficult to analyze or even unreadable, which can be interpreted as voluntary obfuscation."

Pavlov commented on 2025-01-17 13:06 (UTC) (edited on 2025-01-17 13:08 (UTC) by Pavlov)

for _p in "${pkgname[@]}"; do
  eval "package_$_p() {
    $(declare -f "_package_common" | tail -n +2)
    $(declare -f "_package_${_p#$_pkgtype}" | tail -n +2)
  }"
done

You should avoid to use eval since it makes the PKGBUILD difficult to analyze or even unreadable, which can be interpreted as voluntary obfuscation.

install -Dm755 /dev/stdin "$pkgdir/usr/share/applications ${pkgname#$_pkgtype}.desktop" << END
[Desktop Entry]
Type=Application
Name=$(sed -E -e "s/-/ /g;s/\b(.)/\u\1/g" <<< "${pkgname#$_pkgtype}")
Comment=$pkgdesc
Exec=${pkgname#$_pkgtype}
Icon=${pkgname#$_pkgtype}
Categories=Game;
Terminal=false
END

  install -Dm755 /dev/stdin "$pkgdir/usr/bin/${pkgname#$_pkgtype}" << END
#!/usr/bin/env sh
exec /usr/bin/java -jar /usr/share/java/$_pkgname/${pkgname#$_pkgtype}.jar "\$@"
END

You should put them in a different file sourced in source field and use sed to replace the relevant parts instead of putting everything in the PKGBUILD`.

Pavlov commented on 2024-05-23 21:57 (UTC)

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'Mindustry-146'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find com.github.Anuken.Arc:packer:152e49944a.
     Searched in the following locations:
       - file:/home/loara/.m2/repository/com/github/Anuken/Arc/packer/152e49944a/packer-152e49944a.pom
       - https://repo.maven.apache.org/maven2/com/github/Anuken/Arc/packer/152e49944a/packer-152e49944a.pom
       - https://dl.google.com/dl/android/maven2/com/github/Anuken/Arc/packer/152e49944a/packer-152e49944a.pom
       - https://oss.sonatype.org/content/repositories/snapshots/com/github/Anuken/Arc/packer/152e49944a/packer-152e49944a.pom
       - https://jitpack.io/com/github/Anuken/Arc/packer/152e49944a/packer-152e49944a.pom
       - https://plugins.gradle.org/m2/com/github/Anuken/Arc/packer/152e49944a/packer-152e49944a.pom
     Required by:
         project :
   > Could not find com.github.Anuken.Arc:arc-core:152e49944a.
     Searched in the following locations:
       - file:/home/loara/.m2/repository/com/github/Anuken/Arc/arc-core/152e49944a/arc-core-152e49944a.pom
       - https://repo.maven.apache.org/maven2/com/github/Anuken/Arc/arc-core/152e49944a/arc-core-152e49944a.pom
       - https://dl.google.com/dl/android/maven2/com/github/Anuken/Arc/arc-core/152e49944a/arc-core-152e49944a.pom
       - https://oss.sonatype.org/content/repositories/snapshots/com/github/Anuken/Arc/arc-core/152e49944a/arc-core-152e49944a.pom
       - https://jitpack.io/com/github/Anuken/Arc/arc-core/152e49944a/arc-core-152e49944a.pom
       - https://plugins.gradle.org/m2/com/github/Anuken/Arc/arc-core/152e49944a/arc-core-152e49944a.pom
     Required by:
         project :

Arc should be added as dependency. Moreover, Mindustry doesn't support Java >= 18 so you should replace

archlinux-java-run --min 16 --feature jdk --java-home

with

archlinux-java-run --min 16 --max 17 --feature jdk --java-home

dmitmel commented on 2024-02-28 10:17 (UTC)

Uh, I suppose Java versions that are too new are not supported by the Gradle version Mindustry is using, try compiling with an older JDK

hrehfeld commented on 2024-02-28 09:48 (UTC) (edited on 2024-02-28 09:52 (UTC) by hrehfeld)

:shrug:

$ which gradle
gradle not found
$ rm -rf /home/hrehfeld/.cache/pikaur/build/mindustry/src
hrehfeld@heinrich ~
$ archlinux-java status                             
Available Java environments:
  java-11-openjdk
  java-21-openjdk (default)
hrehfeld@heinrich ~
$ pikaur -S --aur mindustry --noconfirm                  
Reading local package database...
Resolving AUR dependencies...
Reading repository package databases...
looking for conflicting AUR packages...
Not showing diff for mindustry package (--noconfirm)
:: Skipping review of PKGBUILD for mindustry package (--noconfirm)
Reading local package database...
:: Installing repository dependencies for mindustry:
resolving dependencies...
looking for conflicting packages...

Packages (1) libicns-0.8.1-10

Total Installed Size:  0.12 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                          [########################################] 100%
(1/1) checking package integrity                                        [########################################] 100%
(1/1) loading package files                                             [########################################] 100%
(1/1) checking for file conflicts                                       [########################################] 100%
(1/1) checking available disk space                                     [########################################] 100%
:: Processing package changes...
(1/1) installing libicns                                                [########################################] 100%
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Commit /etc/.git
++ cat -
++ xargs
+ packages=libicns
+ sh -c 'date --iso-8601=seconds >> /root/pacman-hook.log'
+ echo libicns
+ G='/usr/bin/git --git-dir=/etc/.git --work-tree=/etc'
+ /usr/bin/git --git-dir=/etc/.git --work-tree=/etc add --all /etc/
++ date --iso-8601=seconds
+ /usr/bin/git --git-dir=/etc/.git --work-tree=/etc commit -m '2024-02-28T10:47:29+01:00: libicns'
[master 5df5239] 2024-02-28T10:47:29+01:00: libicns
 1 file changed, 0 insertions(+), 0 deletions(-)
+ true
Reading local package database...

:: Starting the build:
==> Making package: mindustry 1:7.0_146-2 (2024-02-28T10:47:31 CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found mindustry-146.tar.gz
  -> Found mindustry.desktop
  -> Found mindustry.sh
  -> Found mindustry-server.desktop
  -> Found mindustry-server.sh
==> Validating source files with sha256sums...
    mindustry-146.tar.gz ... Passed
    mindustry.desktop ... Passed
    mindustry.sh ... Passed
    mindustry-server.desktop ... Passed
    mindustry-server.sh ... Passed
==> Extracting sources...
  -> Extracting mindustry-146.tar.gz with bsdtar
==> Removing existing $pkgdir/ directory...
==> Starting build()...
To honour the JVM settings for this build a single-use Daemon process will be forked. See https://docs.gradle.org/7.5.1/userguide/gradle_daemon.html#sec:disabling_the_daemon.
Daemon will be stopped at the end of the build 
No Android SDK found. Skipping Android module.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'Mindustry-146'.
> Could not open cp_proj generic class cache for build file '/home/hrehfeld/.cache/pikaur/build/mindustry/src/Mindustry-146/build.gradle' (/home/hrehfeld/.gradle/caches/7.5.1/scripts/ac4nskr41bfrj85568wxvt9pj).
   > BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 65

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
==> ERROR: A failure occurred in build().
    Aborting...

Installing gradle doesn't help.