Bug 275606 - games/minecraft-server: Update to 1.20.4
Summary: games/minecraft-server: Update to 1.20.4
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Vladimir Druzenko
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-07 12:54 UTC by Alexandre Labarre
Modified: 2024-03-24 18:45 UTC (History)
4 users (show)

See Also:
freebsd: maintainer-feedback+


Attachments
Update from 1.20.2 to 1.20.3 and improvements for cleaning during uninstall (5.28 KB, text/plain)
2023-12-07 12:54 UTC, Alexandre Labarre
no flags Details
Update from 1.20.2 to 1.20.4 and improvements for cleaning during uninstall (5.28 KB, text/plain)
2023-12-08 09:03 UTC, Alexandre Labarre
no flags Details
Update from 1.20.2 to 1.20.4 and improvements for cleaning during uninstall (5.47 KB, text/plain)
2023-12-27 12:35 UTC, Alexandre Labarre
no flags Details
Patch to 1.20.4 - maintaining existing strategy for cleaning on uninstall. See comments (4.44 KB, patch)
2024-02-25 15:41 UTC, Jonathan Price
freebsd: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexandre Labarre 2023-12-07 12:54:30 UTC
Created attachment 246870 [details]
Update from 1.20.2 to 1.20.3 and improvements for cleaning during uninstall

Update from 1.20.2 to 1.20.3

This patch updates games/minecraft-server to 1.20.3

Master URL found on official website https://www.minecraft.net/en-us/download/server
Full changelog available on official website https://www.minecraft.net/en-us/article/minecraft-java-edition-1-20-3

As discussed for previous version with vvd@ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=274534 I made improvements for files deletion directly downloaded by the app itself.
/usr/local/minecraft-server is removed when port is uninstalled. I added "@postunexec rm -rf %D/minecraft-server" and removed each "@rmtry" in pkg-plist and I also removed folders deletion (minecraft-server/libraries and minecraft-server/versions) in pkg-deinstall.in
This way only one command in one file replace many commands in two files. 
This is a proposal and I can keep the previous way if you are disagree with it.
Comment 1 Alexandre Labarre 2023-12-08 09:03:08 UTC
Created attachment 246899 [details]
Update from 1.20.2 to 1.20.4 and improvements for cleaning during uninstall

Mojang Studio released a new version of Minecraft Server since 1.20.3 update proposal.

I kept the same approach than the one suggested yesterday for 1.20.3.

Minecraft 1.20.4 is a hotfix release for Java Edition which fixes a critical bug that could cause items to vanish after being stored in a Decorated Pot.

Minecraft Java Edition 1.20.4 changelog is available on the official website https://www.minecraft.net/en-us/article/minecraft-java-edition-1-20-4
Comment 2 Eugene M. Kim 2023-12-17 02:39:32 UTC
(In reply to Alexandre Labarre from comment #1)

Nuking /usr/local/minecraft-server directory altogether is dangerous, when the port never made it clear that the directory is ephemeral and anything added there could be gone at uninstall time.  I can imagine people storing mods and other files that should persist across upgrades, in that directory.
Comment 3 Vladimir Druzenko freebsd_committer freebsd_triage 2023-12-25 22:29:41 UTC
What about:
@postunexec rm -rf %D/minecraft-server/libraries %D/minecraft-server/versions
?
Comment 4 Alexandre Labarre 2023-12-27 12:35:50 UTC
Created attachment 247289 [details]
Update from 1.20.2 to 1.20.4 and improvements for cleaning during uninstall

Thank you Eugene for your reply. I hope the following correction will match what you expect.

As proposed by vvd@ I modified pkg-plist with these lines (I removed previous @postunexec rm -rf %D/minecraft-server)

+@postunexec rm -rf %D/minecraft-server/libraries
+@postunexec rm -rf %D/minecraft-server/versions
Comment 5 Vladimir Druzenko freebsd_committer freebsd_triage 2023-12-27 14:45:55 UTC
(In reply to Eugene M. Kim from comment #2)
> storing mods
What is exact path for storing mods?
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2023-12-27 14:49:23 UTC
(In reply to Alexandre Labarre from comment #4)
LGFM, but:
1) waiting maintainer approval;
2) I want to test on my installation before commit.
Comment 8 Alexandre Labarre 2023-12-27 17:20:28 UTC
(In reply to Vladimir Druzenko from comment #7)
On official website https://www.minecraft.net/en-us/download/server this is the URL returned when I click on the link to download JAR file. 
Do you get the same mirror server on you side?
Maybe the link change because of geolocation?
Comment 9 Alexandre Labarre 2023-12-27 17:34:17 UTC
(In reply to Vladimir Druzenko from comment #5)
Eugene will confirm or not as I don’t use any mod. But if I am not wrong, you must use a specific version like Forge. 
This port is the official Minecraft version, and AFAIK it seems impossible to install a server side mod.
Comment 10 Vladimir Druzenko freebsd_committer freebsd_triage 2023-12-27 18:37:12 UTC
(In reply to Alexandre Labarre from comment #8)
I got the same URL - "piston-data", but I think the maintainer should have his say.

(In reply to Alexandre Labarre from comment #9)
> AFAIK it seems impossible to install a server side mod.
I don't know much about server side mods…
Comment 11 Eugene M. Kim 2023-12-29 23:10:01 UTC
Specifically cleaning /libraries and /versions works for me.  Most of the extra files are outside those two.  In particular, server-side plugins go into the /plugins directory.

I guess, though, that it won't hurt to slap a short README in /usr/local/minecraft-server to note that /libraries and /versions are ephemeral and anything manually placed there will be gone at uninstall time.
Comment 12 Eugene M. Kim 2023-12-29 23:48:18 UTC
BTW, since /libraries and /versions are extracted from server.jar (inside META-INF directory), the following shell one-liner would work to remove only those files and directories when run from /usr/local/minecraft-server, while leaving :

bsdtar tf server.jar | sed -En 's@^META-INF/(libraries|versions)/@\1/@p' | sort -r | tr '\n' '\0' | xargs -0 rm -d

(Yep, abusing the facts that 1) the libarchive-backed bsdtar handles .zip/.jar archives and that 2) rm -d handles both files and directories uniformly. :-p)

This works on my server:

root@chips:/usr/local/minecraft-server # mkdir s
root@chips:/usr/local/minecraft-server # cp -Rp server.jar libraries versions s/
root@chips:/usr/local/minecraft-server # cd s
root@chips:/usr/local/minecraft-server/s # touch libraries/omg versions/1.20.4/wtf bbq                                        root@chips:/usr/local/minecraft-server/s # tar tf server.jar | sed -En 's@^META-INF/(libraries|versions)/@\1/@p' | sort -r | tr \\n \\0 | xargs -0 rm -d
rm: versions/1.20.4/: Directory not empty
rm: versions/: Directory not empty
rm: libraries/: Directory not empty
root@chips:/usr/local/minecraft-server/s # find .
.
./versions
./versions/1.20.4
./versions/1.20.4/wtf
./server.jar
./libraries
./libraries/omg
./bbq
Comment 13 Eugene M. Kim 2023-12-29 23:50:57 UTC
(In reply to Eugene M. Kim from comment #12)

> while leaving :

while leaving other locally introduced files/directories intact (see the omg/wtf/bbq files)
Comment 14 Jonathan Price 2024-02-03 22:11:26 UTC
(In reply to Vladimir Druzenko from comment #10)

Apologies for the huge delay in reviewing this patch, been super busy training to fly the 737!

I am happy with the proposed URL for fetching the new version. It matches what I see when I try to fetch it from the website.

I will try to review the change in behaviour to the libraries and versions folder in the next 1-2 days, but given that the existing behaviour is already to delete the entire folders, I suspect it's fine.
Comment 15 Eugene M. Kim 2024-02-06 04:04:16 UTC
(In reply to Jonathan Price from comment #14)

> given that the existing behaviour is already to delete the entire folders, I suspect it's fine.

The current behavior is NOT to delete the entire folders; it surgically deletes specific files one by one (@rmtry), then selectively removes empty directories, leaf-/depth-first (the two "find" commands in the deinstall script – they do not nuke the entire hierarchies).  If there are any other things than empty directories, the current method keeps them intact.

(P.S. 737!  I envy you +_+)
Comment 16 Vladimir Druzenko freebsd_committer freebsd_triage 2024-02-09 13:25:41 UTC
Despite the fact that I previously proposed the option of deleting the entire directory, I now believe that the original option is more correct, although more difficult to maintain: when updating, files not related to port will not be accidentally deleted.
Comment 17 Jonathan Price 2024-02-25 15:41:22 UTC
Created attachment 248739 [details]
Patch to 1.20.4 - maintaining existing strategy for cleaning on uninstall. See comments

Once again, apologies for the delay on this, but my outside work has finally slowed down for a bit.

I have decided to create a patch keeping the existing process for finding and removing files on uninstallation. Do not take this to mean that I don't welcome future suggestions / patches for alternative methods though! Thank you to all that have contributed in this discussion.

I have tested this for both the daemon and standalone config options and it appears to be behaving as intended for both, but feel free to also complete your own testing.
Comment 18 Alexandre Labarre 2024-02-27 15:42:33 UTC
(In reply to Jonathan Price from comment #17)
Thank you Johnathan!
I understand your comment: it's OK for me :-)
It works fine on 14.0-RELEASE amd64.

I tried things with @preunexec to detect files downloaded by JAR itself before server.jar deletion (with the command suggested by Eugene: thank you for your tip), but without success.
Comment 19 Vladimir Druzenko freebsd_committer freebsd_triage 2024-03-10 23:17:47 UTC
ok, I'll commit it soon (I hope :-D).
Comment 20 commit-hook freebsd_committer freebsd_triage 2024-03-24 18:41:52 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6b5a47c1f9f1b6b49654bf9903538fcec9e8b56b

commit 6b5a47c1f9f1b6b49654bf9903538fcec9e8b56b
Author:     Alexandre Labarre <freebsd.tug890@passmail.net>
AuthorDate: 2024-03-24 18:39:15 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2024-03-24 18:39:15 +0000

    games/minecraft-server: Update to 1.20.4

    Changelog:
    https://www.minecraft.net/en-us/article/minecraft-java-edition-1-20-3
    https://www.minecraft.net/en-us/article/minecraft-java-edition-1-20-4

    PR:             275606
    Approved by:    arrowd (mentor, implicit)

 games/minecraft-server/Makefile  | 4 ++--
 games/minecraft-server/distinfo  | 6 +++---
 games/minecraft-server/pkg-plist | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)
Comment 21 Vladimir Druzenko freebsd_committer freebsd_triage 2024-03-24 18:42:36 UTC
Committed, thanks!
Comment 22 Vladimir Druzenko freebsd_committer freebsd_triage 2024-03-24 18:45:57 UTC
Oh, indicated the author Alexandre Labarre…
Is it ok?