Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package rpm (Fedora, CentOS, RedHat) #7

Closed
ReenigneArcher opened this issue Jan 12, 2022 · 29 comments · Fixed by #190
Closed

Package rpm (Fedora, CentOS, RedHat) #7

ReenigneArcher opened this issue Jan 12, 2022 · 29 comments · Fixed by #190
Labels
added This feature has been added and will be available in the next release. os:Linux:Fedora OS is Fedora

Comments

@ReenigneArcher
Copy link
Member

ReenigneArcher commented Jan 12, 2022

Sunshine does not currently have a method to package rpm.

If you have experience with packaging rpm and would like to contribute a PR would be very appreciated!

Edit: Should we consider using CPack? https://cmake.org/cmake/help/latest/module/CPack.html
Here is an example: https://github.com/docopt/docopt.cpp/blob/6f5de76970be94a6f1e4556d1716593100e285d2/CMakeLists.txt#L136

@GeoDerp
Copy link

GeoDerp commented Feb 9, 2022

Attempted to build rpms via OBS (openSUSE Build Service)

As talked about here: loki-47-6F-64/sunshine#317 (comment)

However, I came to have a few issues, openSUSE has a boost dependency issue.
And Fedora tried to build, but resulted in a few c11 issues (looks related to ffmpeg encoders).

I believe the rpm package could work, however I have not enough knowledge in cmake to fix the Fedora issue.
The openSUSE dependencie issue seems to be a repentance of an issue people have had in the past (possibly fixed in Fedora's boost-static). This may be resulted automatically with boost updates, could be a problem with the cmake process, or could be fixed by making a custom boost depedencie in the poeject for the rpm to build with.

Feel free to use this spec file as a jumping off point for future work on this issue.

Thanks,
John Whately

@ReenigneArcher
Copy link
Member Author

@GeoDerp Thanks for looking into this issue! Once we resolve it I think it will be a valuable addition to Sunshine. Tried looking at the logs but not sure exactly where to see the details.

I see the run history here: https://build.opensuse.org/packages/Sunshine/job_history/home:GeoDerp:Sunshine/Fedora_35/x86_64

But no logs. Do I need to be logged in to opensuse?

Also, what exactly is opensuse? Ideally we could create the rpm using github actions as part of the create_package.yml... Fedora already being built using that. If we can package it there, the asset would be automatically uploaded with our automated release as well.

@GeoDerp
Copy link

GeoDerp commented Feb 9, 2022

Fedora 35:

[  143s] /usr/bin/ranlib libenet.a
[  143s] /usr/bin/ranlib libminiupnpc.a
[  143s] gmake[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build'
[  143s] [ 43%] Built target enet
[  143s] gmake[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build'
[  143s] [ 43%] Built target libminiupnpc-static
[  146s] cc1: some warnings being treated as errors
[  146s] gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:107: third-party/cbs/CMakeFiles/cbs.dir/cbs_av1.c.o] Error 1
[  149s] cc1: some warnings being treated as errors
[  150s] gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:93: third-party/cbs/CMakeFiles/cbs.dir/cbs_h2645.c.o] Error 1
[  150s] gmake[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build'
[  150s] gmake[1]: *** [CMakeFiles/Makefile2:237: third-party/cbs/CMakeFiles/cbs.dir/all] Error 2
[  150s] gmake[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build'
[  150s] gmake: *** [Makefile:94: all] Error 2
[  150s] error: Bad exit status from /var/tmp/rpm-tmp.cSjTBj (%build)

Fedora Rawhide:

[   93s] [ 38%] Linking C static library libminiupnpc.a
[   93s] cd /home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build/third-party/miniupnp/miniupnpc && /usr/bin/cmake -P CMakeFiles/libminiupnpc-static.dir/cmake_clean_target.cmake
[   93s] cd /home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build/third-party/miniupnp/miniupnpc && /usr/bin/cmake -E cmake_link_script CMakeFiles/libminiupnpc-static.dir/link.txt --verbose=1
[   93s] /usr/bin/ar qc libminiupnpc.a CMakeFiles/libminiupnpc-static.dir/igd_desc_parse.c.o CMakeFiles/libminiupnpc-static.dir/miniupnpc.c.o CMakeFiles/libminiupnpc-static.dir/minixml.c.o CMakeFiles/libminiupnpc-static.dir/minisoap.c.o CMakeFiles/libminiupnpc-static.dir/minissdpc.c.o CMakeFiles/libminiupnpc-static.dir/miniwget.c.o CMakeFiles/libminiupnpc-static.dir/upnpcommands.c.o CMakeFiles/libminiupnpc-static.dir/upnpdev.c.o CMakeFiles/libminiupnpc-static.dir/upnpreplyparse.c.o CMakeFiles/libminiupnpc-static.dir/upnperrors.c.o CMakeFiles/libminiupnpc-static.dir/connecthostport.c.o CMakeFiles/libminiupnpc-static.dir/portlistingparse.c.o CMakeFiles/libminiupnpc-static.dir/receivedata.c.o CMakeFiles/libminiupnpc-static.dir/addr_is_reserved.c.o
[   93s] /usr/bin/ranlib libminiupnpc.a
[   93s] gmake[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build'
[   93s] [ 38%] Built target libminiupnpc-static
[   93s] gmake[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.11.1.r0.ge4c9c29/redhat-linux-build'
[   93s] gmake: *** [Makefile:94: all] Error 2
[   93s] error: Bad exit status from /var/tmp/rpm-tmp.vfinwL (%build)

But no logs. Do I need to be logged in to opensuse?

you should be able to view the spec file and also click the "failed" button here under each repo to view there logs: https://build.opensuse.org/package/show/home:GeoDerp:Sunshine/Sunshine

however, for a shortcut, here's the link to the Fedora's:

Fedora 35: https://build.opensuse.org/package/live_build_log/home:GeoDerp:Sunshine/Sunshine/Fedora_35/x86_64

Fedora Rawhide: https://build.opensuse.org/package/live_build_log/home:GeoDerp:Sunshine/Sunshine/Fedora_Rawhide/x86_64

Also, what exactly is opensuse?

Simple answer, imagine Fedora but German (by SUSE). They run things very similarly to RedHat (use rpm's however use Zypper instead of DNF) and I'm my option they trade blows with pros and cons in the workstation space. Both big names in Linux and possibly primary competitors of each other. https://www.opensuse.org/

I personally am using Fedora, and the Fedora package is way further in working. So I would recommend getting that working first. Then we can have a look at this weird boost dependencie issue of openSUSE. OBS (openSUSE build Service) is a cloud service for maintaining and creating RPM's, they also allow you to add custom variables in place to support building for diffrent Linux distributions. You can also download the project's repo locally and have that supply updates for you. Also, for my case, can input a _service file to tell OBS to pull the latest version of the git repo before build. AKA, it's quite nice.

Ideally we could create the rpm using github actions as part of the create_package.yml...
This is also a good idea, for me, building and testing in OBS works really well, however that doesn't stop you from then exporting all the work in OBS to get it to be done in github actions once you know the spec file works for the Linux distributions.

one note: I have been building it without cuda, I dont know if you want to build with or have an option for one with and one without

I'm doing also local RPM tests of Fedora 35 so if there is any local generated logs you need let me know

@ReenigneArcher
Copy link
Member Author

one note: I have been building it without cuda, I dont know if you want to build with or have an option for one with and one without

Probably best to include it, I would think. Are there advantages to not including it?

Again, just to re-iterate. It would be best to have everything packaging inside the workflow, either via scripts or some other means. I will try to describe the automatons, so maybe it make more sense why this would be best.

trigger event
PR submitted to this repo action ensure PR is on nightly branch
PR submitted to nightly build and package each version (AppImage, deb packages, Windows, Fedora (build only)), upload artifacts for testing
PR submitted to master only allowed from nightly branch, same as PR submitted to nightly + verify that changelog and version number were updated
PR merged into master same as PR submitted to master + use information from changelog to create release and upload packages as release assets

So basically the process of releasing is completely automated.

Perhaps we could add your spec file (once it's working) to this repo, and then use this github action (https://github.com/marketplace/actions/rpm-build) in our workflow to build the rpm?

Regarding why the build is failing, I'm not entirely sure and I'm no expert on Linux. Just comparing your spec file to the dockerfile this is what I notice.

Then I notice you have some extra things not in the dockerfile, maybe not a big deal, but potentially one of them is interfering? Probably some of these should be added to the dockerfile as well.
BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_log-devel
BuildRequires: libboost_system-devel
BuildRequires: libboost_thread-devel
BuildRequires: libboost_atomic-devel
BuildRequires: libcap-devel
BuildRequires: wayland-devel
BuildRequires: wayland-protocols-devel

@GeoDerp
Copy link

GeoDerp commented Feb 10, 2022

Perhaps we could add your spec file (once it's working) to this repo, and then use this github action (https://github.com/marketplace/actions/rpm-build) in our workflow to build the rpm?

Sounds like a plan


Having a look at it now, but I have used your docker file : in my local build
note: using silverblue (running version 35 of Fedora) and podman (ex.podman-compose)

./build-container.sh -f Dockerfile-fedora_35
./build-sunshine.sh -p -s ..

and I get:

...
-- found avutil: include /usr/include/ffmpeg lib /usr/lib64/libavutil.so
-- Checking for module 'swscale'
--   Package 'swscale', required by 'virtual:world', not found
-- look for newer strcture
-- Checking for module 'libswscale'
--   Found libswscale, version 5.9.100
-- Found swscale include dirs: /usr/include/ffmpeg
-- Using FFMpeg dir parent as hint: /usr/include
-- Found swscale libs: /usr/lib64/libswscale.so
-- found swscale: include /usr/include/ffmpeg lib /usr/lib64/libswscale.so
-- /usr/lib64/libavformat.so/usr/lib64/libavdevice.so/usr/lib64/libavcodec.so/usr/lib64/libavutil.so/usr/lib64/libswscale.so
-- Found FFMPEG: /usr/lib64/libavformat.so;/usr/lib64/libavdevice.so;/usr/lib64/libavcodec.so;/usr/lib64/libavutil.so;/usr/lib64/libswscale.so  
-- Configuring incomplete, errors occurred!
See also "/root/sunshine-build/CMakeFiles/CMakeOutput.log".
See also "/root/sunshine-build/CMakeFiles/CMakeError.log".

note: thats after adding "libcap-devel" to the dokerfile, as it was having an error with that first

@GeoDerp
Copy link

GeoDerp commented Feb 10, 2022

okay, I may have got it running inside of toolbox. Doing more testing...

@GeoDerp
Copy link

GeoDerp commented Feb 10, 2022

With the RPM's I can indeed confirm there are issues with the third party cbs files

more specifically:
cbs.dir/cbs_vp9.c.o
enet.dir/host.c.o

errors:

[ 12%] Building C object third-party/moonlight-common-c/enet/CMakeFiles/enet.dir/host.c.o
cd /var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build/third-party/moonlight-common-c/enet && /usr/bin/gcc -DHAS_FCNTL=1 -DHAS_GETADDRINFO=1 -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_GETNAMEINFO=1 -DHAS_INET_NTOP=1 -DHAS_INET_PTON=1 -DHAS_IOCTL=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_POLL=1 -DHAS_SOCKLEN_T=1 -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/moonlight-common-c/enet/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DNDEBUG   -Wno-error -MD -MT third-party/moonlight-common-c/enet/CMakeFiles/enet.dir/host.c.o -MF CMakeFiles/enet.dir/host.c.o.d -o CMakeFiles/enet.dir/host.c.o -c /var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/moonlight-common-c/enet/host.c
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]

or with build type set to debug DCMAKE_BUILD_TYPE=Debug

[ 12%] Building C object third-party/miniupnp/miniupnpc/CMakeFiles/libminiupnpc-static.dir/miniupnpc.c.o
cd /var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build/third-party/moonlight-common-c/enet && /usr/bin/gcc -DHAS_FCNTL=1 -DHAS_GETADDRINFO=1 -DHAS_GETHOSTBYADDR_R=1 -DHAS_GETHOSTBYNAME_R=1 -DHAS_GETNAMEINFO=1 -DHAS_INET_NTOP=1 -DHAS_INET_PTON=1 -DHAS_IOCTL=1 -DHAS_MSGHDR_FLAGS=1 -DHAS_POLL=1 -DHAS_SOCKLEN_T=1 -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/moonlight-common-c/enet/include -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -g   -Wno-error -MD -MT third-party/moonlight-common-c/enet/CMakeFiles/enet.dir/callbacks.c.o -MF CMakeFiles/enet.dir/callbacks.c.o.d -o CMakeFiles/enet.dir/callbacks.c.o -c /var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/moonlight-common-c/enet/callbacks.c
cd /var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build/third-party/miniupnp/miniupnpc && /usr/bin/gcc -DMINIUPNPC_SET_SOCKET_TIMEOUT -DMINIUPNP_STATICLIB -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build/third-party/miniupnp/miniupnpc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -g -fPIC -Wall -MD -MT third-party/miniupnp/miniupnpc/CMakeFiles/libminiupnpc-static.dir/miniupnpc.c.o -MF CMakeFiles/libminiupnpc-static.dir/miniupnpc.c.o.d -o CMakeFiles/libminiupnpc-static.dir/miniupnpc.c.o -c /var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/miniupnp/miniupnpc/miniupnpc.c
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
[ 14%] Building C object third-party/moonlight-common-c/enet/CMakeFiles/enet.dir/list.




[ 22%] Building C object third-party/cbs/CMakeFiles/cbs.dir/cbs_vp9.c.o
cd /var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build/third-party/cbs && /usr/bin/gcc -DCONFIG_CBS_AV1=1 -DCONFIG_CBS_H264=1 -DCONFIG_CBS_H265=1 -DCONFIG_CBS_JPEG=1 -DCONFIG_CBS_MPEG2=1 -DCONFIG_CBS_VP9=1 -DHAVE_FAST_UNALIGNED -DHAVE_THREADS=1 -DPIC=1 -DSUNSHINE_BUILD_DRM -DSUNSHINE_PLATFORM=\"linux\" -Dcbs_EXPORTS -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/miniupnp -I/usr/include/libdrm -I/usr/include/libevdev-1.0 -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/nv-codec-headers/include -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/glad/include -I/var/home/Geo/rpmbuild/BUILD/sunshine-master -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/cbs/include -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/moonlight-common-c/enet/include -I/var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/moonlight-common-c/reedsolomon -I/usr/include/ffmpeg -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DNDEBUG -fPIC -Wall -Wno-incompatible-pointer-types -Wno-maybe-uninitialized -Wno-format -Wno-format-extra-args -MD -MT third-party/cbs/CMakeFiles/cbs.dir/cbs_vp9.c.o -MF CMakeFiles/cbs.dir/cbs_vp9.c.o.d -o CMakeFiles/cbs.dir/cbs_vp9.c.o -c /var/home/Geo/rpmbuild/BUILD/sunshine-master/third-party/cbs/cbs_vp9.c
cc1: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
gmake[2]: Leaving directory '/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
[ 46%] Built target enet
cc1: some warnings being treated as errors
gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:107: third-party/cbs/CMakeFiles/cbs.dir/cbs_av1.c.o] Error 1
cc1: some warnings being treated as errors
gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:93: third-party/cbs/CMakeFiles/cbs.dir/cbs_h2645.c.o] Error 1
gmake[2]: Leaving directory '/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
gmake[1]: *** [CMakeFiles/Makefile2:237: third-party/cbs/CMakeFiles/cbs.dir/all] Error 2
gmake[1]: Leaving directory '/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
gmake: *** [Makefile:94: all] Error 2

These are possibly errors you have always had. But because rpm building is more strict on the CMake, it only shows up here and not just as a warning

I dont have enough knowledge to know what varibles to feed cmake to give to full debug

for the reason why toolbox could build fine and not the Dockerfile, it could be a security issue, with toolbox patching in something that isnt configured in the Dockerfile, causing it to have issues. maybe some local binarys or the local Nvidia driver???

@ReenigneArcher
Copy link
Member Author

Should we use cpack? https://cmake.org/cmake/help/latest/cpack_gen/rpm.html

@ReenigneArcher ReenigneArcher changed the title Package rpm (Fedora, CentOS, RedHad) Package rpm (Fedora, CentOS, RedHat) Feb 21, 2022
@GeoDerp
Copy link

GeoDerp commented Feb 21, 2022

Should we use cpack? https://cmake.org/cmake/help/latest/cpack_gen/rpm.html

I dont see why not to try it. Been looking into it, however my cmake knowledge is low, so it will require a bit of effort to know now to modify the CMakeList to support CPack correctly.

On a side note: this might just be me, but when building, even with CUDA installed when running the cmake it spits out:

-- Looking for a CUDA compiler
-- Looking for a CUDA compiler - NOTFOUND

This could be just because im running the build in a toolbox session

Also, wayland is enabled in the cmake, however I dont believe sunshine has wayland support correct? (from my testing it just shows a black screen), or am I too tired and have gotten something wrong

@GeoDerp
Copy link

GeoDerp commented Mar 1, 2022

Should we use cpack? https://cmake.org/cmake/help/latest/cpack_gen/rpm.html

I'm sorry, I just don't know enough of CMake yet to work out CPack.

However, I did do some more testing on my .spec file and found when building the cbs third-party package alone, it came to quite a few dependencies issues.
I found on all the ffmpeg includes (ex: #include <libavutil/avassert.h>) needed to have ffmpeg/ appended to the front (ex: #include <ffmpeg/libavutil/avassert.h>) in order for make to find the packages. (I'm sure there is a variable you could feed it, like an include dir to resolve help). However, I bet this isnt the cause of the errors.

When doing my testing with cmake, I now feed it:

%cmake \
       -DCMAKE_BUILD_TYPE=Release \
       -DSUNSHINE_EXECUTABLE_PATH=%{SUNSHINE_EXECUTABLE_PATH} \
       -DSUNSHINE_ASSETS_DIR=%{SUNSHINE_ASSETS_DIR} \
       -DSUNSHINE_ENABLE_WAYLAND=%{SUNSHINE_ENABLE_WAYLAND} \
       -DSUNSHINE_ENABLE_X11=%{SUNSHINE_ENABLE_X11} \
       -DSUNSHINE_ENABLE_DRM=ON \
       -DSUNSHINE_ENABLE_CUDA=%{SUNSHINE_ENABLE_CUDA} \
       -DLIBAVDEVICE_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVDEVICE_LIBRARIES=/usr/lib64/libavdevice.so \
       -DLIBAVFORMAT_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVFORMAT_LIBRARIES=/usr/lib64/libavformat.so \
       -DLIBAVUTIL_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVUTIL_LIBRARIES=/usr/lib64/libavutil.so \
       -DLIBSWSCALE_INCLUDE_DIR=/usr/include/ffmpeg -DLIBSWSCALE_LIBRARIES=/usr/lib64/libswscale.so \
       -DLIBAVCODEC_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVCODEC_LIBRARIES=/usr/lib64/libavcodec.so

however, still the same error occurs:

gmake[2]: Leaving directory '/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
[ 43%] Built target enet
cc1: some warnings being treated as errors
gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:107: third-party/cbs/CMakeFiles/cbs.dir/cbs_av1.c.o] Error 1
cc1: some warnings being treated as errors
gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:93: third-party/cbs/CMakeFiles/cbs.dir/cbs_h2645.c.o] Error 1
gmake[2]: Leaving directory '/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
gmake[1]: *** [CMakeFiles/Makefile2:237: third-party/cbs/CMakeFiles/cbs.dir/all] Error 2
gmake[1]: Leaving directory '/var/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
gmake: *** [Makefile:94: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.hU0DE4 (%build)


RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.hU0DE4 (%build)

@ReenigneArcher
Copy link
Member Author

@thatsysadmin mind if we move discussion here?

@ReenigneArcher I know it's been a while, got backlogged with other stuff. But I'm going to see if I can try my hand at building an RPM package in a couple of days using the SunshineStream/Sunshine repo. I'm aware you suggested cpack in SunshineStream/Sunshine#7 , but I don't have any experience in cmake/cpack, so I might try my hand in writing a script that uses rpmbuild to build a package. I'm not sure if that's acceptable for a PR though.

One more thing, is there an option to temporarily build without the CUDA toolkit on NVIDIA systems? I'm having trouble with getting the CUDA toolkit on my machine in check for NVENC support so CMake is spitting out a can't find toolkit error. I don't want to worry about NVENC right now.

EDIT: Forget it. I forked the repo and the cmake command worked. Maybe it was because it was not my own fork. Whatever it was, it works now.

Using a script to build an rpm would be acceptable for now (I think cpack would be ideal in the end, as it supports a whole bunch of packaging methods). A script is how the deb package is currently done, so no issue with that method. The build scripts and dockerfiles will likely need to be updated. Scripts may need an additional argument or some way to know which type of package to build.

Currently, there is a -p argument to generate a debian package. Perhaps this should be renamed to -p_deb, then another arg added -p_rpm.
https://github.com/SunshineStream/Sunshine/blob/4b658cd86ba0b7520f6f7cb5b5f07d6775845a81/scripts/build-sunshine.sh#L7

The deb script is here: https://github.com/SunshineStream/Sunshine/blob/master/gen-deb.in

It's converted to an .sh script during the cmake build process. This allows variables to set in the file, such as version number, and directories.
https://github.com/SunshineStream/Sunshine/blob/4b658cd86ba0b7520f6f7cb5b5f07d6775845a81/gen-deb.in#L40

Would certainly appreciate any help implementing this!

@thatsysadmin
Copy link
Contributor

thatsysadmin commented Mar 12, 2022

@ReenigneArcher

mind if we move discussion here?

Sure; no problem.

@GeoDerp
Copy link

GeoDerp commented Mar 14, 2022

This is what I have done @ReenigneArcher so far:

spec file: Version set up for openSUSE build

#
# spec file for package Sunshine
#
# GNU General Public License v3.0 2022
#
Name:           sunshine
Version:        @SERVICE@
Release:        %{version}
Summary:        Sunshine is a Gamestream host for Moonlight
License:        GPL-3.0 License
Group:          System/GUI/Other
URL:            https://github.com/SunshineStream/Sunshine
Source0:        %{name}-%{version}.tar.xz

#change to "without" to disable
%bcond_with Wayland 
%bcond_with X11
%bcond_with Cuda

%define SUNSHINE_EXECUTABLE_PATH /usr/bin/sunshine
%define SUNSHINE_ASSETS_DIR /etc/sunshine

#set off by default 
%define SUNSHINE_ENABLE_WAYLAND OFF
%define SUNSHINE_ENABLE_X11 OFF
%define SUNSHINE_ENABLE_DRM OFF
%define SUNSHINE_ENABLE_CUDA OFF

BuildRequires:  boost-devel
%if 0%{?is_opensuse}
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_log-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
BuildRequires:  libboost_atomic-devel
%else
BuildRequires:  boost-static
%endif
BuildRequires:  cmake

BuildRequires:  ffmpeg-devel
BuildRequires:  pkgconfig(libavutil)

BuildRequires:  gcc-c++
BuildRequires:  libevdev-devel
BuildRequires:  mesa-libGL-devel
BuildRequires:  openssl-devel
BuildRequires:  opus-devel
BuildRequires:  pulseaudio-libs-devel
BuildRequires:  libcap-devel
        

%if %{without X11}
BuildRequires:  libX11-devel
BuildRequires:  libxcb-devel
BuildRequires:  libXcursor-devel
BuildRequires:  libXinerama-devel
BuildRequires:  libXi-devel
BuildRequires:  libXrandr-devel
BuildRequires:  libXtst-devel
BuildRequires:  libXfixes-devel
%endif

%if %{without Wayland}
BuildRequires:  wayland-devel
BuildRequires:  wayland-protocols-devel 
%endif

# if with then on
%if %{without Wayland}
%define SUNSHINE_ENABLE_WAYLAND ON
%endif

%if %{without X11}
%define SUNSHINE_ENABLE_X11 ON
%endif

%if %{without Cuda}
%define SUNSHINE_ENABLE_CUDA ON
%endif


%description
Sunshine is a Gamestream host for Moonlight

%prep
#%setup -q
%autosetup -p1 -n %{name}-%{version}


%build
%cmake \
       -DCMAKE_BUILD_TYPE=Release \
       -DSUNSHINE_EXECUTABLE_PATH=%{SUNSHINE_EXECUTABLE_PATH} \
       -DSUNSHINE_ASSETS_DIR=%{SUNSHINE_ASSETS_DIR} \
       -DSUNSHINE_ENABLE_WAYLAND=%{SUNSHINE_ENABLE_WAYLAND} \
       -DSUNSHINE_ENABLE_X11=%{SUNSHINE_ENABLE_X11} \
       -DSUNSHINE_ENABLE_DRM=ON \
       -DSUNSHINE_ENABLE_CUDA=%{SUNSHINE_ENABLE_CUDA} \
       -DLIBAVDEVICE_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVDEVICE_LIBRARIES=/usr/lib64/libavdevice.so \
       -DLIBAVFORMAT_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVFORMAT_LIBRARIES=/usr/lib64/libavformat.so \
       -DLIBAVUTIL_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVUTIL_LIBRARIES=/usr/lib64/libavutil.so \
       -DLIBSWSCALE_INCLUDE_DIR=/usr/include/ffmpeg -DLIBSWSCALE_LIBRARIES=/usr/lib64/libswscale.so \
       -DLIBAVCODEC_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVCODEC_LIBRARIES=/usr/lib64/libavcodec.so
%cmake_build

%install
%cmake_install -j ${nproc}

%check
%ctest

%files
%dir "/etc/sunshine/"
%config "/etc/sunshine/apps_linux.json"
%dir "/etc/sunshine/shaders/"
%dir "/etc/sunshine/shaders/opengl/"
%config "/etc/sunshine/sunshine.conf"
%dir "/etc/sunshine/web/"
%dir "/etc/sunshine/web/third_party/"
"/etc/udev/rules.d/85-sunshine-rules.rules"
"/usr/bin/sunshine"
"/usr/lib/systemd/user/sunshine.service"

general errors:

...
[  125s] gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:79: third-party/cbs/CMakeFiles/cbs.dir/cbs.c.o] Error 1
...
[  134s] cc1: some warnings being treated as errors
[  134s] gmake[2]: *** [third-party/cbs/CMakeFiles/cbs.dir/build.make:93: third-party/cbs/CMakeFiles/cbs.dir/cbs_h2645.c.o] Error 1
[  134s] gmake[2]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.13.0.r28.g3b8b465/redhat-linux-build'
[  134s] gmake[1]: *** [CMakeFiles/Makefile2:237: third-party/cbs/CMakeFiles/cbs.dir/all] Error 2
[  134s] gmake[1]: Leaving directory '/home/abuild/rpmbuild/BUILD/sunshine-v0.13.0.r28.g3b8b465/redhat-linux-build'
[  134s] gmake: *** [Makefile:94: all] Error 2
[  134s] error: Bad exit status from /var/tmp/rpm-tmp.WJq2xr (%build)
[  134s] 

How I have tried to fix this:

today I tried my best to bump the cps sub module and using ffmpeg5. (not saying that this is the cause or will fix anything)

right now I having had errors with config.h, where there is an issue with finding the endianness (haven't tried a spec file test locally today so this may just be a issue with openSUSE build)

[   99s] /home/abuild/rpmbuild/BUILD/sunshine-master/third-party/cbs/config.h:24:2: error: #error "Unknown Endianness"
[   99s]    24 | #error "Unknown Endianness"
[   99s]       |  ^~~~~

and some repeating errors in, different files, like this:

expected ')' before 'SIZE_SPECIFIER'
[   99s]   808 |                        "too short (%"SIZE_SPECIFIER" bytes).\n", size);
[   99s]       |                                      ^~~~~~~~~~~~~~
[   99s]       |                                      )

however I believe replacing those sections of the code from the old (Current Sunshine) version will fix this issue (I think I haev already successfully done it with one file).

Please understand that im learning as I go, which includes me possibly going on a wild goose chase to fix all the issues

@ReenigneArcher
Copy link
Member Author

I tried my best to bump the cps sub module and using ffmpeg5

This is a known problem. We have a couple of PRs related to this, but could use some help fixing on the linux side.
#50
#77

My attempt at building ffmpeg libraries for linux (at least on debian)... but the Windows build started failing due to changes on media-autobuild_suite. I believe the libraries for linux are okay.
https://github.com/SunshineStream/Sunshine-Windows-Prebuilt/pull/7

We've been discussing some other ways to use ffmpeg instead of these manual builds. Perhaps vcpkg.

Please understand that im learning as I go, which includes me possibly going on a wild goose chase to fix all the issues

No worries! We're all learning! We appreciate your efforts!

@thatsysadmin
Copy link
Contributor

thatsysadmin commented Mar 15, 2022

@ReenigneArcher

I sort of got my gen-rpm script working, but my rpmbuild command seems to be targeting the rpmbuild folder inside my home directory instead of the one that's in the build folder that gets generated by cmake. I'm pretty sure there's an argument to specify an alternate rpmbuild directory, but I'm too tired at the moment. I probably have a couple more kinks to work out in the preinstall and postinstall scripts, because I copied it from the gen-deb script and getting the udev rule file, systemd unit file, and the apps_linux.json file into the package. But I feel like I'm pretty close. I already pushed what I have so far onto my fork already.

I'll see if I can wrap it up tomorrow, then test out the RPM package that comes out of it.

I've modified the Fedora dockerfiles to call an option (-rpm would be the argument) in the build-private.sh scripts that are in the scripts folder, which in turn, build-private.sh calls gen-rpm instead of gen-deb, so if you run the Fedora docker containers, you'd get an RPM package instead of a Debian one. I'm not sure if it's possible to install the Fedora package that comes out of this on a RHEL/Rocky 8/CentOS Stream box yet.

@ReenigneArcher
Copy link
Member Author

@thatsysadmin Perfect! Having added the gen-rpm the -rpm arg, there would just be some small tweaks to the CI workflow then, which I can take care of. Appreciate your work on this!

@GeoDerp GeoDerp mentioned this issue Mar 16, 2022
7 tasks
@GeoDerp
Copy link

GeoDerp commented Mar 16, 2022

There has been progress on my side!

Using @PapyKahan pull request #50 and using ffmpeg5 RPM I branched: https://build.opensuse.org/package/show/home:GeoDerp:Sunshine/ffmpeg-5
it was able to 100% on the build process... but then spat out some errors:

....
[100%] Linking CXX executable sunshine
/usr/bin/cmake -E cmake_link_script CMakeFiles/sunshine.dir/link.txt --verbose=1
/usr/bin/g++ -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -DNDEBUG -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -rdynamic CMakeFiles/sunshine.dir/third-party/moonlight-common-c/reedsolomon/rs.c.o CMakeFiles/sunshine.dir/third-party/moonlight-common-c/src/RtspParser.c.o CMakeFiles/sunshine.dir/sunshine/upnp.cpp.o CMakeFiles/sunshine.dir/sunshine/cbs.cpp.o CMakeFiles/sunshine.dir/sunshine/config.cpp.o CMakeFiles/sunshine.dir/sunshine/main.cpp.o CMakeFiles/sunshine.dir/sunshine/crypto.cpp.o CMakeFiles/sunshine.dir/sunshine/nvhttp.cpp.o CMakeFiles/sunshine.dir/sunshine/httpcommon.cpp.o CMakeFiles/sunshine.dir/sunshine/confighttp.cpp.o CMakeFiles/sunshine.dir/sunshine/rtsp.cpp.o CMakeFiles/sunshine.dir/sunshine/stream.cpp.o CMakeFiles/sunshine.dir/sunshine/video.cpp.o CMakeFiles/sunshine.dir/sunshine/input.cpp.o CMakeFiles/sunshine.dir/sunshine/audio.cpp.o CMakeFiles/sunshine.dir/sunshine/process.cpp.o CMakeFiles/sunshine.dir/sunshine/network.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/x11grab.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/kmsgrab.cpp.o CMakeFiles/sunshine.dir/generated-src/xdg-output-unstable-v1.c.o CMakeFiles/sunshine.dir/generated-src/wlr-export-dmabuf-unstable-v1.c.o CMakeFiles/sunshine.dir/sunshine/platform/linux/wlgrab.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/wayland.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/publish.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/vaapi.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/graphics.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/misc.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/audio.cpp.o CMakeFiles/sunshine.dir/sunshine/platform/linux/input.cpp.o CMakeFiles/sunshine.dir/third-party/glad/src/egl.c.o CMakeFiles/sunshine.dir/third-party/glad/src/gl.c.o -o sunshine-0.11.1  third-party/miniupnp/miniupnpc/libminiupnpc.a -lstdc++fs third-party/moonlight-common-c/enet/libenet.a -lopus -lavformat -lavdevice -lavcodec -lavutil -lswscale -Wl,-Bstatic -lboost_log -lboost_filesystem -lboost_date_time -lboost_log_setup -lboost_thread -lboost_regex -lboost_chrono -lboost_atomic -Wl,-Bdynamic -lssl -lcrypto -ldrm -lcap -lwayland-client -lwayland-server -lwayland-egl -lwayland-cursor -ldl -levdev -lpulse -lpulse-simple /usr/lib64/libboost_log.a /usr/lib64/libboost_log_setup.a /usr/lib64/libboost_filesystem.a /usr/lib64/libboost_thread.a /usr/lib64/libboost_date_time.a /usr/lib64/libboost_regex.a /usr/lib64/libboost_chrono.a /usr/lib64/libboost_atomic.a 
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::close(CodedBitstreamContext*)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::write(util::uniq_ptr<CodedBitstreamContext, util::Destroy<CodedBitstreamContext*, void, &cbs::close> > const&, unsigned char, void*, AVCodecID)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:53: undefined reference to `ff_cbs_insert_unit_content'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:61: undefined reference to `ff_cbs_write_fragment_data'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::write(unsigned char, void*, AVCodecID)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:78: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::make_sps_h264(AVCodecContext const*)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:78: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:108: undefined reference to `ff_h264_guess_level'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::make_sps_hevc(AVCodecContext const*, AVPacket const*)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:173: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:179: undefined reference to `ff_cbs_read_packet'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:229: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::read_sps_h264(AVPacket const*)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:247: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:253: undefined reference to `ff_cbs_read_packet'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:78: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::validate_sps(AVPacket const*, int)':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:274: undefined reference to `ff_cbs_init'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:280: undefined reference to `ff_cbs_read_packet'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::write(util::uniq_ptr<CodedBitstreamContext, util::Destroy<CodedBitstreamContext*, void, &cbs::close> > const&, unsigned char, void*, AVCodecID) [clone .cold]':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::write(unsigned char, void*, AVCodecID) [clone .cold]':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::make_sps_h264(AVCodecContext const*) [clone .cold]':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::make_sps_hevc(AVCodecContext const*, AVPacket const*) [clone .cold]':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::read_sps_h264(AVPacket const*) [clone .cold]':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
/usr/bin/ld: /tmp/ccTKRHGW.ltrans0.ltrans.o: in function `cbs::validate_sps(AVPacket const*, int) [clone .cold]':
/home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:46: undefined reference to `ff_cbs_fragment_free'
/usr/bin/ld: /home/Geo/rpmbuild/BUILD/sunshine-master/sunshine/cbs.cpp:16: undefined reference to `ff_cbs_close'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/sunshine.dir/build.make:611: sunshine-0.11.1] Error 1
gmake[2]: Leaving directory '/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
gmake[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/sunshine.dir/all] Error 2
gmake[1]: Leaving directory '/home/Geo/rpmbuild/BUILD/sunshine-master/redhat-linux-build'
gmake: *** [Makefile:94: all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.1kxv7Q (%build)

spec file:

#
# spec file for package Sunshine
#
# GNU General Public License v3.0 2022
#
Name:           sunshine
Version:        master
Release:        %{version}
Summary:        Sunshine is a Gamestream host for Moonlight
License:        GPL-3.0 License
Group:          System/GUI/Other
URL:            https://github.com/SunshineStream/Sunshine
Source0:        %{name}-%{version}.tar.xz

#change to "without" to disable
%bcond_with Wayland 
%bcond_with X11
%bcond_with Cuda

%define SUNSHINE_EXECUTABLE_PATH /usr/bin/sunshine
%define SUNSHINE_ASSETS_DIR /etc/sunshine

#set off by default 
%define SUNSHINE_ENABLE_WAYLAND OFF
%define SUNSHINE_ENABLE_X11 OFF
%define SUNSHINE_ENABLE_DRM OFF
%define SUNSHINE_ENABLE_CUDA OFF

BuildRequires:  boost-devel
%if 0%{?is_opensuse}
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_log-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
BuildRequires:  libboost_atomic-devel
%else
BuildRequires:  boost-static
%endif
BuildRequires:  cmake

BuildRequires:  ffmpeg-private-devel
BuildRequires:  ffmpeg-5-libavdevice-devel                                         
BuildRequires:  ffmpeg-5-libavfilter-devel                                      
BuildRequires:  ffmpeg-5-libpostproc-devel                                                                                  
BuildRequires:  ffmpeg-5-libswscale-devel  
BuildRequires:  pkgconfig(libavutil)

BuildRequires:  gcc-c++
BuildRequires:  libevdev-devel
BuildRequires:  mesa-libGL-devel
BuildRequires:  openssl-devel
BuildRequires:  opus-devel
BuildRequires:  pulseaudio-libs-devel
BuildRequires:  libcap-devel
        

%if %{without X11}
BuildRequires:  libX11-devel
BuildRequires:  libxcb-devel
BuildRequires:  libXcursor-devel
BuildRequires:  libXinerama-devel
BuildRequires:  libXi-devel
BuildRequires:  libXrandr-devel
BuildRequires:  libXtst-devel
BuildRequires:  libXfixes-devel
%endif

%if %{without Wayland}
BuildRequires:  wayland-devel
BuildRequires:  wayland-protocols-devel 
%endif

# if with then on
%if %{without Wayland}
%define SUNSHINE_ENABLE_WAYLAND ON
%endif

%if %{without X11}
%define SUNSHINE_ENABLE_X11 ON
%endif

%if %{without Cuda}
%define SUNSHINE_ENABLE_CUDA ON
%endif


%description
Sunshine is a Gamestream host for Moonlight

%prep
#%setup -q
%autosetup -p1 -n %{name}-%{version}


%build
%cmake \
       -DCMAKE_BUILD_TYPE=Release \
       -DSUNSHINE_EXECUTABLE_PATH=%{SUNSHINE_EXECUTABLE_PATH} \
       -DSUNSHINE_ASSETS_DIR=%{SUNSHINE_ASSETS_DIR} \
       -DSUNSHINE_ENABLE_WAYLAND=%{SUNSHINE_ENABLE_WAYLAND} \
       -DSUNSHINE_ENABLE_X11=%{SUNSHINE_ENABLE_X11} \
       -DSUNSHINE_ENABLE_DRM=ON \
       -DSUNSHINE_ENABLE_CUDA=%{SUNSHINE_ENABLE_CUDA} \
       -DLIBAVDEVICE_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVDEVICE_LIBRARIES=/usr/lib64/libavdevice.so \
       -DLIBAVFORMAT_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVFORMAT_LIBRARIES=/usr/lib64/libavformat.so \
       -DLIBAVUTIL_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVUTIL_LIBRARIES=/usr/lib64/libavutil.so \
       -DLIBSWSCALE_INCLUDE_DIR=/usr/include/ffmpeg -DLIBSWSCALE_LIBRARIES=/usr/lib64/libswscale.so \
       -DLIBAVCODEC_INCLUDE_DIR=/usr/include/ffmpeg -DLIBAVCODEC_LIBRARIES=/usr/lib64/libavcodec.so
%cmake_build

%install
%cmake_install -j ${nproc}

%check
%ctest

%files
%dir "/etc/sunshine/"
%config "/etc/sunshine/apps_linux.json"
%dir "/etc/sunshine/shaders/"
%dir "/etc/sunshine/shaders/opengl/"
%config "/etc/sunshine/sunshine.conf"
%dir "/etc/sunshine/web/"
%dir "/etc/sunshine/web/third_party/"
"/etc/udev/rules.d/85-sunshine-rules.rules"
"/usr/bin/sunshine"
"/usr/lib/systemd/user/sunshine.service

Im too tired to debug any more, but Ill have a look next time im free and see what might be the cause

@thatsysadmin
Copy link
Contributor

@ReenigneArcher

It's not ideal, but I might need to do the rpmbuild in the home folder. I wanted it to be in the build folder, but there seems to be no way to set an alternate rpmbuild directory. Ugh.
If anyone else that comes across this knows how to set an alternate rpmbuild directory easily, please let me know.

@GeoDerp
Copy link

GeoDerp commented Mar 17, 2022

@ReenigneArcher

It's not ideal, but I might need to do the rpmbuild in the home folder. I wanted it to be in the build folder, but there seems to be no way to set an alternate rpmbuild directory. Ugh. If anyone else that comes across this knows how to set an alternate rpmbuild directory easily, please let me know.

Sorry @thatsysadmin, but I'm currently quite busy and can't unfortunately have a look at this right now.
However, after looking it up quickly. maybe have a look at fedpkg for your builds.
rpmlint is also apparently good for testing RPM's/
spec files. However like you I have used rpmbuild for most of my tests recently so I don't have much personal experience.

Alternatively you could use GitHub Actions, openSUSE Build Service or an alternative CI/CD to build and delver a result or an error.

Tip, if your testing through rpmbuild, Toolbox/Podman is your friend

@thatsysadmin
Copy link
Contributor

thatsysadmin commented Mar 18, 2022

@ReenigneArcher

All right; I may have something that works somewhat. That took way more time than I thought it would.
I refactored the gen-rpm script to build in the user's home directory (again, not ideal, wanted it to be self-contained). It successfully manages to build an RPM, I'm going to try the package that came out of it tomorrow.

The catches with this are that it packages the sunshine binary as a bash script, it doesn't compile from source; meaning that it will never output SRPMs. If I want to do that, I have to use rpmbuild to call cmake (Instead of calling the cmake command string, you'd call rpmbuild -ba ~/rpmbuild/SPECS/sunshine.spec or whatever the spec file is named). That's something I might be able to get working later though now that I have some experience with rpmbuild.

Couple more things I will have to figure out are where to slip the unit files and the .desktop files, plus potentially tweaking the preinstall and postinstall scripts. After that, it may be PR ready.

EDIT: I'm also kinda hoping I replaced all the hard paths with the cmake "@" labels. Otherwise it's going to fail if someone tries to run it.

@ReenigneArcher
Copy link
Member Author

@thatsysadmin stupid question... would it be possible to use the same .desktop file as we're using for the AppImage? https://github.com/SunshineStream/Sunshine/blob/master/sunshine.desktop.in

You're method uses a Dockerfile correct? If that is the case I don't see an issue with use the home directory, as it within the container.

So, as I understand you are building sunshine normally, instead of using rpmbuild, where rpmbuild would normally call cmake itself? I think that's okay for now, and I believe exactly how the deb package is handled. I agree, it's probably not ideal, but it's a good starting point.

We can figure out if it fails when you submit the PR. There will some automated builds when that happens.

Appreciate your efforts!

@thatsysadmin
Copy link
Contributor

thatsysadmin commented Mar 18, 2022

@thatsysadmin stupid question... would it be possible to use the same .desktop file as we're using for the AppImage? https://github.com/SunshineStream/Sunshine/blob/master/sunshine.desktop.in

Very likely. I have to figure out where they usually go though.

You're method uses a Dockerfile correct? If that is the case I don't see an issue with use the home directory, as it within the container.

You can, but if someone calls the gen-rpm shell script directly after make, it's going to build it in the user's rpmbuild folder. That's kind of sorta what I did to build the RPM package that I have now. I've added a check into the script, and if it sees one, it'll temporarily rename the existing folder, then rename it back when it's done.

So, as I understand you are building sunshine normally, instead of using rpmbuild, where rpmbuild would normally call cmake itself? I think that's okay for now, and I believe exactly how the deb package is handled. I agree, it's probably not ideal, but it's a good starting point.

Correct. I'll probably build a specfile that'll generate an SRPM for Fedora COPR/OpenSUSE OBS later.

@thatsysadmin
Copy link
Contributor

@ReenigneArcher

Stupid question: Do you know where the sunshine.desktop file is usually put by the Appimage?

@ReenigneArcher
Copy link
Member Author

@ReenigneArcher

Stupid question: Do you know where the sunshine.desktop file is usually put by the Appimage?

It's in the repo root initially. Cmake should put it in the build directory next to gen-deb.

@thatsysadmin
Copy link
Contributor

thatsysadmin commented Apr 8, 2022

@ReenigneArcher

The package I built is mostly complete now, including the supplemental files needed. Just tested it. Right now, the main issue is that you can't run it as your user; you have to run it as root because it can't create a mouse device and also presumably a keyboard device. Running with sudo sunshine /etc/sunshine/sunshine.conf in a terminal works.

Running the systemd user unit file (systemctl --user start sunshine; systemctl --user status sunshine) will fail because of the aforementioned issue as well. systemd coredumps the sunshine binary with a stacktrace error, but I'm pretty confident the error is not being able to create the mouse/keyboard devices plus probably a couple of other things. If I or someone else can figure out how to fix it, users should just be able to install the package and run systemctl --user enable --now sunshine and have it running every time they log in locally.

@ReenigneArcher
Copy link
Member Author

@ReenigneArcher

The package I built is mostly complete now, including the supplemental files needed. Just tested it. Right now, the main issue is that you can't run it as your user; you have to run it as root because it can't create a mouse device and also presumably a keyboard device. Running with sudo sunshine /etc/sunshine/sunshine.conf in a terminal works.

Running the systemd user unit file (systemctl --user start sunshine; systemctl --user status sunshine) will fail because of the aforementioned issue as well. systemd coredumps the sunshine binary with a stacktrace error, but I'm pretty confident the error is not being able to create the mouse/keyboard devices plus probably a couple of other things. If I or someone else can figure out how to fix it, users should just be able to install the package and run systemctl --user enable --now sunshine and have it running every time they log in locally.

Are you trying to get the package to take care of these setup commands? https://github.com/SunshineStream/Sunshine/wiki/Usage#linux

@thatsysadmin
Copy link
Contributor

Yeah, pretty much. That's what the Debian package sort of does too.

@ReenigneArcher
Copy link
Member Author

Yeah, pretty much. That's what the Debian package sort of does too.

Oh, I thought that was a manual step. Didn't realize the package does that automatically.

@ReenigneArcher ReenigneArcher added added This feature has been added and will be available in the next release. and removed help wanted Extra attention is needed labels Apr 13, 2022
@github-actions
Copy link

This feature has been added and will be available in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
added This feature has been added and will be available in the next release. os:Linux:Fedora OS is Fedora
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants