Bug 274026 - games/moonlight-embedded update to 2.6.0
Summary: games/moonlight-embedded update to 2.6.0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Robert Clausecker
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-22 14:13 UTC by Armin Zhu
Modified: 2023-10-04 20:14 UTC (History)
2 users (show)

See Also:


Attachments
There are 3 files in this archiver.1 is diff file(git diff a b). 2 is files in ports tree. 3 is moonlight-embedded-2.6.0.tar.xz(make extract) (361.50 KB, patch)
2023-09-22 14:13 UTC, Armin Zhu
no flags Details | Diff
games/moonlight-embedded patch for the ports in ports tree. (24.75 KB, patch)
2023-09-23 04:05 UTC, Armin Zhu
no flags Details | Diff
games/moonlight-embedded patch for the package:moonlight-embedded2.6.0.tar.xz (711.13 KB, patch)
2023-09-23 04:07 UTC, Armin Zhu
no flags Details | Diff
games/moonlight-embedded patch for the ports in ports tree. (41.31 KB, patch)
2023-09-24 07:25 UTC, Armin Zhu
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Armin Zhu 2023-09-22 14:13:39 UTC
Created attachment 245118 [details]
There are 3 files in this archiver.1 is diff file(git diff a b). 2 is files in ports tree. 3 is moonlight-embedded-2.6.0.tar.xz(make extract)

games/moonlight-embedded :  Hi friend, I have updated the Moonlight-embedded and would like to become the maintainer of this app. Here's what's new:
 Major: Update moonlight-embedded version to 2.6.0.(https://github.com/moonlight-stream/moonlight-embedded)
 Fix:
        1.Fixed "video decode buffer too small" errors
        2.Fixed keyboard no response on platform x11*
        3.Fixed no sound on platform x11*
        4.Fixed fixed pin code
        5.Update man page for moonlight
        6.Fixed too slow network response
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2023-09-22 15:07:24 UTC
Thank you for your contribution.

Please only submit the diff in the future.  The distfile is downloaded by the port and the files in the ports tree can be constructed from the diff.  So these
two other files are not required.  Also, submitting an archive makes it harder to
review the patch as it cannot be viewed in bugzilla's UI.  Lastly, please submit 
the diff in "git-format-patch" format if possible.

As for the patch itself, here are some items to check:

 - REINPLACE_CMD must not be used for static replacements (i.e. where the text to 
   be changed is always the same).  Use patch files instead.  The original port
   did this wrong, please switch to patch files for this update.  You can keep
   REINPLACE_CMD for dynamic replacements, such as the one where ${PREFIX} is
   patched in.
 - I see that you have added quite a few patches.  Could you please explain what
   they do?  Have you submitted them to upstream?  If yes, could you link the 
   pull requests / bug reports?  While some of the patches look like obvious
   portability patches, others seem like they do more complicated things.  We
   usually try to keep ports as close to upstream as possible.  It would be
   better if upstream included these patches instead.
Comment 2 Armin Zhu 2023-09-23 04:05:30 UTC
Created attachment 245136 [details]
games/moonlight-embedded  patch for the ports in ports tree.

Put some static substitutions in the makefile into patch.
Comment 3 Armin Zhu 2023-09-23 04:07:16 UTC
Created attachment 245137 [details]
games/moonlight-embedded  patch for the package:moonlight-embedded2.6.0.tar.xz

patch for the package:moonlight-embedded2.6.0.tar.xz
The Major: Update to 2.6.0
Comment 4 Armin Zhu 2023-09-23 04:46:14 UTC
(In reply to Robert Clausecker from comment #1)
Excited to hear from you, this is my first time submitting my own code. 
I added patch files to make it easier for future contributors to identify changes that need to be made specifically for the FreeBSD system.
I have not paid attention to the issue information of the moonlight-embedded in the upstream, these patchs are all to solve the problems I have encountered when using it myself.It is not committed upstream at the moment.
1. The relevant code for REINPLACE_CMD in MAKEFLE has been put into patch files. 
2. Explanation of PATCHS:
          * patch-libgamestream_client.c : This is the patch of the previous contributor, not modified.
          *patch-libgamestream_http.c :  This is to fix the issue of slow host response times. 
                                                                            Before modifying, the app attempts to restore the previous connection, and after a few minutes of attempts, 
                                                                            returns an error and reinitiates a new connection. The simplest attempt was made to fix this issue.
          *patch-src_platform.c : Here are some of the same that previous contributors commit.The modifications I made were for 2 things. 
                                                           1 for re-enable x11* platform.
                                                               The upstream code forces the sdl platform and disables the x11 platform, which is strange, I reverted this and tried it out without issue.
                                                           2 for add oss sound support.
                                                               FreeBSD natively only supports OSS sounds, so I added this and made it the sound playback method for the x11* platform by default.
           *patch-src_input_evdev.c : Here are some of the same that previous contributors commit.The modifications I made were for 3 things.
                                                           1 for More strictly limit the way the keyboard is judged.Because acpi button such as shutown/sleep will also be recognized as 
                                                               a keyboard by libevdev.And when libevdev tries grab the device, the keyboard becomes unresponsive.
                                                           2 for use sdl to drive gamepad.
                                                               When I tried to drive the gamepad with libevdev, the gamepad did not respond, but with the SDL platform to drive the gamepad 
                                                               that some gamepads were available, so I changed to use the SDL drive gamepad by default, but someone can also use the libevdev.
                                                           3 for add grab/ungrab keyboard shortcut for x11* platform.This is purely for the convenience of using other FreeBSD apps when streaming.
          *patch-src_main.c : The modifications I made were for 3 things.
                                                           1 for add -nosdl option for switching sdl and libevdev  to drive gamepad when use x11* platform.
                                                           2 for fix the issue of fixed PIN code generated by the openssl random() function.use rand() and srand() instead.
                                                           3 for comment out the related code for HDR support.Because FreeBSD does not have HDR support now.
Comment 5 Robert Clausecker freebsd_committer freebsd_triage 2023-09-23 15:26:26 UTC
(In reply to Armin Zhu from comment #4)

Hi Armin,

Thank you for the update.  There is no need to upload the changes in the project (i.e. attachment #245137 [details]).  I just need the changes to the port (i.e. attachment #245136 [details]).  What you should link to though is upstream's changelog so I can put it into the commit message.

Please avoid long lines on bugzilla.  As you see, they'll be broken up and your
comment is hard to read.

I strongly recommend that you submit these patches upstream.  They seem to achieve sensible goals.  Please avoid patches that just change whitespace, as they blow up the patch file with no benefit to the port.  You also don't need to comment out code, you can just remove it.  People can look at the patch to see what you changed.

As for your patches to src/platform.c, we don't have /sys/... on FreeBSD, so I'm not sure why you patch code relating to these.

Apart from that, your patch looks good and I'll be seeing that I can include it with my next batch.
Comment 6 Robert Clausecker freebsd_committer freebsd_triage 2023-09-23 15:45:36 UTC
On build test, the port first fails with a checksum error:

=> Attempting to fetch https://github.com/moonlight-stream/moonlight-embedded/releases/download/v2.6.0/moonlight-embedded-2.6.0.tar.xz
fetch: https://github.com/moonlight-stream/moonlight-embedded/releases/download/v2.6.0/moonlight-embedded-2.6.0.tar.xz: size mismatch: expected 324996, actual 324572
=> Attempting to fetch http://distcache.FreeBSD.org/ports-distfiles/moonlight-embedded-2.6.0.tar.xz
fetch: http://distcache.FreeBSD.org/ports-distfiles/moonlight-embedded-2.6.0.tar.xz: Not Found
=> Couldn't fetch it - please try to retrieve this
=> port manually into /data/distfiles/ and try again.
*** Error code 1

Please check distinfo.  Has upstream perhaps updated the distfile?
If I fix this error, the build next fails during configuration:

CMake Error at CMakeLists.txt:81 (add_executable):
  Cannot find source file:

    ./src/audio/oss.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc

It seems like you perhaps forgot to attach that file to the patch.
As for the patch, it was a bit hard to apply as you didn't provide
a patch against the FreeBSD ports tree, but rather against what
seems to be a local repository of just this one port.  My
recommendation: clone the FreeBSD ports tree, then develop your
changes in it and submit them in "git-format-patch" format (as you
did before).  This ensures that they'll be easy to apply.

I have also noticed that your patch files (in the files directory)
were not created with "make makepatch".  I can fix this on commit.
You should read up on the makepatch target as it makes your life a
lot easier!
Comment 7 Armin Zhu 2023-09-24 01:10:44 UTC
(In reply to Robert Clausecker from comment #6)
Thank you very much for your guidance, which taught me a lot. Sorry not to make it clear, 
moonlight-embedded-2.6.0.tar.xz can't be downloaded from github because 
I'm making changes based on packages on the ports tree and don't fully use all the code 
on github. So you can use the moonlight-embedded-2.6.0.tar.xz package attached to 
the attachment or 'make extract' on moonlight-embedded on the ports tree. And apply 
moonlight-package.patch in the moonlight-embedded-2.5.3 folder, because I didn't 
generate a patch file in this folder, you may have trouble applying patch. The upstream 
relies on many Linux-specific drivers or libraries, and cannot all 
be ported to FreeBSD. Thanks again.
Comment 8 Robert Clausecker freebsd_committer freebsd_triage 2023-09-24 01:26:00 UTC
(In reply to Armin Zhu from comment #7)

Sorry, this won't do.  The distfile must be fetched from an upstream website, the port must be written such that "make fetch" downloads the correct distfile from the internet.  I will not use distfiles you attach to this bug report.  Even if I were to use them, how would I teach our build server to use these distfiles?  It just doesn't work.

Either provide patch files for all the things you have changed in the port (you can add patches that create new files by creating an empty file.orig and then running "make makepatch") so it builds with the upstream distfile.  Alternatively, fork the project on github, apply the changes to your fork, and use that as the upstream to fetch the distfile from.  You can of course also use any other code hosting site or even anay web server to supply the file.
Comment 9 Armin Zhu 2023-09-24 07:25:46 UTC
Created attachment 245178 [details]
games/moonlight-embedded  patch for the ports in ports tree.

newst patch for games/moonlight-embedded.
Comment 10 Armin Zhu 2023-09-24 07:28:24 UTC
(In reply to Robert Clausecker from comment #8)
Hello Robert !
The most concise version of patchs is submitted to you.
And this time it can be compiled with the installation package on GitHub.
Comment 11 Robert Clausecker freebsd_committer freebsd_triage 2023-09-29 19:19:50 UTC
(In reply to Armin Zhu from comment #10)

Thank you for your submission.  Once again it is really hard to apply your patch as the patch is not against the FreeBSD ports collection.  Please submit future patches against the FreeBSD ports collection, not just an individual port.

A build test now passes, but yields a bunch of warnings in stage-qa:

Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libepoll-shim.so.0 from devel/libepoll-shim but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libepoll-shim.so:devel/libepoll-shim
Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libX11.so.6 from x11/libX11 but it is not declared as a dependency
Warning: you need USE_XORG+=x11
Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libEGL.so.1 from graphics/libglvnd but it is not declared as a dependency
Warning: you need USE_GL+=egl
Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libGLESv2.so.2 from graphics/libglvnd but it is not declared as a dependency
Warning: you need USE_GL+=glesv2
Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libvdpau.so.1 from multimedia/libvdpau but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libvdpau.so:multimedia/libvdpau
Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libva.so.2 from multimedia/libva but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libva.so:multimedia/libva
Error: /usr/local/bin/moonlight is linked to /usr/local/lib/libva-x11.so.2 from multimedia/libva but it is not declared as a dependency
Warning: you need LIB_DEPENDS+=libva-x11.so:multimedia/libva
Warning: you might not need LIB_DEPENDS on libenet.so
Warning: you might not need LIB_DEPENDS on libSDL2.so
Warning: Possible REINPLACE_CMD issues:
- - REINPLACE_CMD ran, but did not modify file contents: docs/README.pod

Please check these issues.  If you think there are no problems except for the missing dependencies, I can just add them on commit.
Comment 12 Armin Zhu 2023-09-30 14:57:27 UTC
(In reply to Robert Clausecker from comment #11)
Oh friend.Talking to you always allows me to learn something new. Regarding the warning to 
make stage-qa, I think there is no problem, I tried to make stage-qa in the current 2.5.3_2 version 
and found the same warning, I guess this is currently harmless. I will fix this later when 
there is time, but this doesn't affect the patch submitted this time. Regarding the matter of 
generating patches in individual  ports, I misunderstood your previous teaching. So generating 
a patch in ports collect means 'cd /usr/ports' first, and then 'git init/git add./git format-patch....'.
 Is that true, I'll pay attention to doing it in the way you mentioned in future patch submissions.
Comment 13 Robert Clausecker freebsd_committer freebsd_triage 2023-09-30 16:18:01 UTC
(In reply to Armin Zhu from comment #12)

The best way to do ports development is to clone the ports tree:

    git clone https://git.FreeBSD.org/ports.git

You can clone it to whatever directory you like, it doesn't need to be /usr/ports.

Then develop your patch there, make a commit and use git-format-patch to generate a file you can submit via bugzilla.  What's important is that this diff is the only thing we need really.  The distfiles and so on must be downloaded by the port from the location indicated therein.  However, some times you may be asked to provide build logs showing a successful build.

The warnings are relevant because our packaging infrastructure must track library dependencies to know when to reinstall packages because dependent libraries changed.  I'll just go ahead and add a fix for that on commit (later today).
Comment 14 commit-hook freebsd_committer freebsd_triage 2023-09-30 20:01:33 UTC
A commit in branch main references this bug:

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

commit f01ecd7106e46d41ff9cfa250cfe819c7a746a66
Author:     Armin Zhu <lisp_25689@163.com>
AuthorDate: 2023-09-24 06:30:00 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-09-30 20:00:01 +0000

    games/moonlight-embedded: update to 2.6.0

     - Fixed "video decode buffer too small" errors
     - Fixed keyboard no response on platform x11*
     - Fixed no sound on platform x11*
     - Fixed fixed pin code
     - Update man page for moonlight
     - Fixed too slow network response

    In addition, we now ship a number of patches to improve the experience
    on FreeBSD:

     - fix slow host response times
     - add OSS sound support
     - handle keyboard more strictly, avoiding unresponsive keyboards
     - default to SDL for gamepad handling
     - add a grab/ungrab keyboard shortcut for X11
     - add a -nosdl option to switch between libsdl and libevdev on X11
     - disable HDR, as it is not supported on FreeBSD.

    Submitter becomes maintainer.

    PR:             274026

 games/moonlight-embedded/Makefile                  |  30 +++---
 games/moonlight-embedded/distinfo                  |   6 +-
 .../files/patch-CMakeLists.txt (new)               |  45 +++++++++
 .../files/patch-docs_CMakeLists.txt (new)          |   8 ++
 .../files/patch-docs_README.pod (new)              | 105 +++++++++++++++++++++
 .../files/patch-libgamestream_CMakeLists.txt (new) |  29 ++++++
 .../files/patch-libgamestream_client.c             |   8 +-
 .../files/patch-libgamestream_http.c (new)         |  12 +++
 .../files/patch-src_audio_audio.h (new)            |   7 ++
 .../files/patch-src_audio_oss.c (new)              | 105 +++++++++++++++++++++
 .../files/patch-src_input_evdev.c                  |  44 ++++++++-
 .../files/patch-src_main.c (new)                   |  64 +++++++++++++
 .../moonlight-embedded/files/patch-src_platform.c  |  31 +++++-
 .../files/patch-src_video_ffmpeg__vaapi.c (new)    |  19 ++++
 ...ty_moonlight-common-c_enet_CMakeLists.txt (new) |  14 +++
 games/moonlight-embedded/pkg-descr                 |   5 +
 16 files changed, 499 insertions(+), 33 deletions(-)
Comment 15 Robert Clausecker freebsd_committer freebsd_triage 2023-09-30 20:03:09 UTC
Thank you for your contribution.
Comment 16 Gleb Popov freebsd_committer freebsd_triage 2023-09-30 20:12:15 UTC
This is a great work, Armin, thanks for doing this! Do you plan to upstream your changes?
Comment 17 Armin Zhu 2023-10-01 10:17:06 UTC
(In reply to Gleb Popov from comment #16)
Next, I will continue to test and improve the code, and if the code is mature
 enough, it will be committed upstream.If the ability allows, I would like to
 migrate Moonlight-related streaming software to FreeBSD.
Comment 18 Gleb Popov freebsd_committer freebsd_triage 2023-10-01 10:27:04 UTC
That sounds just great, looking forward to it.