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

sunshine: new Portfile #15143

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions multimedia/Sunshine/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup cmake 1.1
PortGroup github 1.0
PortGroup boost 1.0

# bump revision when changes are made to this file
revision 1
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved

github.setup sunshinestream sunshine master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should become something like (not tested so please verify):

github.setup             sunshinestream sunshine 0.14.0 v
github.tarball_from      releases

after this change you'll need to update the checksums as well, so do sudo port clean --all ; sudo port -dv checksum in the port directory to recalculate them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I see upstream doesn't actually provide "releases"; so you should use "archive" instead in the above snippet.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We provide releases... but the port file will be generated before a release is published/tagged. Is it possible to use a commit instead? Also, I'm working on integration building the port inside PR checks, to ensure no breaking changes so using the commit would be the preferred option if it's possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds like the "wrong" order from our point of view ;) Automation is great, but updating a Portfile to actually use the release is what we would want - so no, we don't want to have a commit hash (unless it's a -devel port).

name Sunshine
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
version 0.14.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this field is set automatically from the github.setup line

categories multimedia emulators games
platforms darwin
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
license GPL-3
maintainers {@SunshineStream sunshinestream}
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
description Sunshine is a Gamestream host for Moonlight.
long_description {*}${description}
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
homepage https://sunshinestream.github.io
master_sites https://github.com/sunshinestream/sunshine/releases
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved

fetch.type git
post-fetch {
system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive"
}

ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
depends_lib port:avahi \
port:ffmpeg \
port:libopus

boost.version 1.76
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved

configure.args -DBOOST_ROOT=[boost::install_area] \
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
-DSUNSHINE_ASSETS_DIR=${prefix}/etc/sunshine/assets \
-DSUNSHINE_CONFIG_DIR=${prefix}/etc/sunshine/config

cmake.out_of_source yes
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved

startupitem.create yes
startupitem.executable "${prefix}/bin/{$name}"
startupitem.location LaunchDaemons
startupitem.name ${name}
startupitem.netchange yes

# is this actually necessary? this should all be handled by CMakeLists
ReenigneArcher marked this conversation as resolved.
Show resolved Hide resolved
destroot {
# install assets
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/*.*] ${destroot}${prefix}/etc/${name}/assets
xinstall {*}[glob ${worksrcpath}/src_assets/macos/assets/*.*] ${destroot}${prefix}/etc/${name}/assets

# install web assets
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/css
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/webfonts
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/*.*] ${destroot}${prefix}/etc/${name}/assets/web
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/css/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/css
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/webfonts/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/webfonts
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/images
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/third_party
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/images/*.*] ${destroot}${prefix}/etc/${name}/assets/web/images
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/third_party/*.*] ${destroot}${prefix}/etc/${name}/assets/web/third_party

xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/config

# install sunshine.conf
xinstall {*}[glob ${worksrcpath}/src_assets/common/config/*.*] ${destroot}${prefix}/etc/${name}/config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably don't want to overwrite a configuration file if someone would update to a newer version. I'm sure there are many Portfiles that take care of things like that and/or there might be a description in the guide/Wiki on how to handle this. Perhaps the phpmyadmin is one example where you can see that it checks if a configuration file is already present and depending on the outcome does a different action.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to find examples but couldn't find one.

The documentation is not complete. https://guide.macports.org/#development.practices.dont-overwrite

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggested a port that does similar things to check how one could do this (i.e., phpadmin); another one that uses glob is the cppcheck port.

I agree that some parts of the guide are incomplete; sometimes you can find that information in the Wiki. For example, in this case you could check here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, sorry I must have read it too fast previously... The link you provided is good though!

I'll use these as references:
https://trac.macports.org/browser/trunk/dports/security/stegdetect/Portfile#L49
https://trac.macports.org/browser/trunk/dports/sysutils/bacula/Portfile#L210

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure I did something wrong, but tested this and it doesn't appear the post-activate works with a pkg generated using sudo port pkg sunshine

# Rename files in `destroot`
post-destroot {
    file rename ${destroot}${prefix}/etc/${name}/config/sunshine.conf ${destroot}${prefix}/etc/${name}/config/sunshine.conf.sample
    file rename ${destroot}${prefix}/etc/${name}/config/apps.json ${destroot}${prefix}/etc/${name}/config/apps.json.sample
}

# Don't overwrite existing preference files
post-activate {
    if {![file exists ${prefix}/etc/${name}/config/apps.json]} {
        file copy ${destroot}${prefix}/etc/${name}/config/apps.json.sample \
            ${prefix}/etc/${name}/config/apps.json
        }
    if {![file exists ${prefix}/etc/${name}/config/sunshine.conf]} {
        file copy ${destroot}${prefix}/etc/${name}/config/sunshine.conf.sample \
            ${prefix}/etc/${name}/config/sunshine.conf
        }
}
reenignearcher@ReenigneArchers-iMac-Pro MacOS % ls /opt/local/etc/Sunshine/config
apps.json.mp_1655322422		sunshine.conf.mp_1655322422
apps.json.sample		sunshine.conf.sample

It does work when installing using the Portfile. Is there a way to do this that will work for the pkg as well?


# install apps.json
xinstall {*}[glob ${worksrcpath}/src_assets/macos/config/*.*] ${destroot}${prefix}/etc/${name}/config

# install the binary
xinstall ${workpath}/build/${name} ${destroot}${prefix}/bin
}