diff options
author | James Le Cuirot <chewi@gentoo.org> | 2024-05-11 18:44:51 +0100 |
---|---|---|
committer | James Le Cuirot <chewi@gentoo.org> | 2024-05-11 18:44:51 +0100 |
commit | dd44b9aa5c745304ea924fb12b8503bb8ecd9545 (patch) | |
tree | 68d62bf43cc39720c3b2a4ece62a348d0d1b2eee | |
parent | dev-python/wsproto: Enable py3.13 (diff) | |
download | gentoo-dd44b9aa5c745304ea924fb12b8503bb8ecd9545.tar.gz gentoo-dd44b9aa5c745304ea924fb12b8503bb8ecd9545.tar.bz2 gentoo-dd44b9aa5c745304ea924fb12b8503bb8ecd9545.zip |
net-misc/sunshine: Fix NPM issue by shipping pre-compiled assets
It turns out the NPM cache is sensitive to the NPM version. Yarn is better in
this regard, but it wanted to cache 90MB of files covering irrelevant operating
systems and architectures. This is a lot more than 1.3MB of pre-compiled assets.
Closes: https://bugs.gentoo.org/930441
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
-rw-r--r-- | net-misc/sunshine/Manifest | 2 | ||||
-rw-r--r-- | net-misc/sunshine/files/sunshine-find-npm.patch | 100 | ||||
-rw-r--r-- | net-misc/sunshine/sunshine-0.23.1.ebuild | 16 | ||||
-rw-r--r-- | net-misc/sunshine/sunshine-9999.ebuild | 16 |
4 files changed, 115 insertions, 19 deletions
diff --git a/net-misc/sunshine/Manifest b/net-misc/sunshine/Manifest index 4392f4217e78..2efe3ef8929a 100644 --- a/net-misc/sunshine/Manifest +++ b/net-misc/sunshine/Manifest @@ -6,5 +6,5 @@ DIST moonlight-common-c-cbd0ec1b25edfb8ee8645fffa49ff95b6e04c70e.tar.gz 148691 B DIST moonlight-enet-04e27590670a87a7cd40f5a05cda97467e4e25a3.tar.gz 86434 BLAKE2B 8a5535843e4c650b945882abac1542bf8c79dc420607b88433d239aa5a17380f02e77bb8f1fcbe45dcb8ef894e6c9b4d940f4d3b34b956ce42d86f6a8ca5227a SHA512 6d2e9447e546489365b1fb563ed52664a91981717a3a3a9faa9600ab62be5ac09bd24ee9dd505833d31981ce6222f5ef430268a9f92aa83fa288b5b8d681e2aa DIST nanors-e9e242e98e27037830490b2a752895ca68f75f8b.tar.gz 194694 BLAKE2B 1effd7c0884ffd38b63d61a7872337797529ef2012f9de0950088a5004cb32a2fb2c14bcab2ec6719968864e5e6b9a67e96afa39466e2071bf4a0cd752ae4b29 SHA512 548be25650619a6c31944cd7a745fd40d5bc5008f2d7f91e0207a10b923764cb88fd2ddcb71eaed7c4863ec89b34d61011b666e292da071ac3b4429e4d7dd027 DIST sunshine-0.23.1.tar.gz 24503568 BLAKE2B 0c589f38a7d638c49af6385def2676de04af422f85d37228988bd7c822ffc006dbac0a1695e01527ac7a1d5ee28103cff00d78a97d57f61247772a6e6cc1fe18 SHA512 7a9150baf4ecdad1035666993c60744390e227ebeaf467447c53675dc0aecc7031cd9c9b253fbbbbac072f5592c3690c6acfde41f38d441497a17157417f1e16 -DIST sunshine-npm-cache-0.23.1.tar.xz 23477572 BLAKE2B 24674a6c6ebed1cc31e3fbee2ededef27c1c24cc7f1be63fba19023b1a6171b9e1a0e83363f7eabad1957a96eede471ae3df4df5e5ba66f5c80f57b56781bf52 SHA512 84ec1d393b1c2f333954bf0f5a42e491bf4d7ff2031c8065c56e06eb0eb7f7b750e2d2f6a1da321067212fdf55aa4c917b2ce0db7c957231821282a33966cd93 +DIST sunshine-assets-0.23.1.tar.xz 1269348 BLAKE2B 36dd00fbf4bb1bfa213d53fd9dc78ed1fee9e12efcfb138dbd54932c3f19447d832da506175a982be7564408e06b0699b0b7cb4b9811ab81b47e30681c915bab SHA512 9fe9e0ee29864faa0f67dd4d501d116be1476f2c7ec688646b91eb87cb38e9e9d2baecb8335df29075fd3f60bf05b900c20dcb8406306d68a62c30ff55d1b7aa DIST wlr-protocols-2b8d43325b7012cc3f9b55c08d26e50e42beac7d.tar.bz2 19708 BLAKE2B fe20f21ee8282d7afcdbb8f3863e50b217fb71e7814f404f288b0d09d30c9e30135769b12342d9e9126a8cb2ab35d6ced0c5562807d274b1d97224f5f3d02511 SHA512 7935b5089820304aa8cb0e1a8f4e0db6ccd5285973a3f3554ccc935dd88e379eb03c3b2dd199da97b6ff8dfbbbf124ca65fb1c12821a168d34bd7e26d8514edb diff --git a/net-misc/sunshine/files/sunshine-find-npm.patch b/net-misc/sunshine/files/sunshine-find-npm.patch new file mode 100644 index 000000000000..42b91299cca5 --- /dev/null +++ b/net-misc/sunshine/files/sunshine-find-npm.patch @@ -0,0 +1,100 @@ +From 0fa3273af349089b7d62c996fcaea67b10ed2a0c Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Sat, 4 May 2024 23:32:29 +0100 +Subject: [PATCH 1/2] build: Unify asset building by leveraging CMake's env + command + +`add_custom_target` can also accept multiple commands to be run in +sequence. It isn't clear how quoting applies here, but I've tested it, +and it seems to be behave as expected when spaces are present. +--- + cmake/targets/common.cmake | 7 +++++++ + cmake/targets/unix.cmake | 6 ------ + cmake/targets/windows.cmake | 6 ------ + 3 files changed, 7 insertions(+), 12 deletions(-) + +diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake +index ee79528c..04d8e954 100644 +--- a/cmake/targets/common.cmake ++++ b/cmake/targets/common.cmake +@@ -15,6 +15,13 @@ else() + set(NPM_BUILD_HOMEBREW "") + endif() + ++#WebUI build ++add_custom_target(web-ui ALL ++ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" ++ COMMENT "Installing NPM Dependencies and Building the Web UI" ++ COMMAND npm install ++ COMMAND "${CMAKE_COMMAND}" -E env "SUNSHINE_BUILD_HOMEBREW=${NPM_BUILD_HOMEBREW}" "SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR}" "SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR}" npm run build) # cmake-lint: disable=C0301 ++ + # platform specific target definitions + if(WIN32) + include(${CMAKE_MODULE_PATH}/targets/windows.cmake) +diff --git a/cmake/targets/unix.cmake b/cmake/targets/unix.cmake +index 5527a987..047a0b3d 100644 +--- a/cmake/targets/unix.cmake ++++ b/cmake/targets/unix.cmake +@@ -1,8 +1,2 @@ + # unix specific target definitions + # put anything here that applies to both linux and macos +- +-#WebUI build +-add_custom_target(web-ui ALL +- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" +- COMMENT "Installing NPM Dependencies and Building the Web UI" +- COMMAND sh -c \"npm install && SUNSHINE_BUILD_HOMEBREW=${NPM_BUILD_HOMEBREW} SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR} SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR} npm run build\") # cmake-lint: disable=C0301 +diff --git a/cmake/targets/windows.cmake b/cmake/targets/windows.cmake +index e429feaa..341d7c2e 100644 +--- a/cmake/targets/windows.cmake ++++ b/cmake/targets/windows.cmake +@@ -4,9 +4,3 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll") + find_library(ZLIB ZLIB1) + list(APPEND SUNSHINE_EXTERNAL_LIBRARIES + Wtsapi32.lib) +- +-#WebUI build +-add_custom_target(web-ui ALL +- WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" +- COMMENT "Installing NPM Dependencies and Building the Web UI" +- COMMAND cmd /C "npm install && set \"SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR}\" && set \"SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR}\" && npm run build") # cmake-lint: disable=C0301 +-- +2.44.0 + + +From f7f93c787bc7c6e82296f0b28c1684ba93cb0956 Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Sun, 5 May 2024 23:30:36 +0100 +Subject: [PATCH 2/2] build: Use find_program to find NPM so it can be + overridden + +This is useful for Gentoo, which needs to be able to do entirely offline +builds, because it can override this with `true` while shipping +pre-compiled assets. Gentoo has tried to ship cached NPM modules +instead, but it turns out these are very sensitive to the NPM version. +--- + cmake/targets/common.cmake | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake +index 04d8e954..5c489551 100644 +--- a/cmake/targets/common.cmake ++++ b/cmake/targets/common.cmake +@@ -16,11 +16,12 @@ else() + endif() + + #WebUI build ++find_program(NPM npm REQUIRED) + add_custom_target(web-ui ALL + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + COMMENT "Installing NPM Dependencies and Building the Web UI" +- COMMAND npm install +- COMMAND "${CMAKE_COMMAND}" -E env "SUNSHINE_BUILD_HOMEBREW=${NPM_BUILD_HOMEBREW}" "SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR}" "SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR}" npm run build) # cmake-lint: disable=C0301 ++ COMMAND "${NPM}" install ++ COMMAND "${CMAKE_COMMAND}" -E env "SUNSHINE_BUILD_HOMEBREW=${NPM_BUILD_HOMEBREW}" "SUNSHINE_SOURCE_ASSETS_DIR=${NPM_SOURCE_ASSETS_DIR}" "SUNSHINE_ASSETS_DIR=${NPM_ASSETS_DIR}" "${NPM}" run build) # cmake-lint: disable=C0301 + + # platform specific target definitions + if(WIN32) +-- +2.44.0 + diff --git a/net-misc/sunshine/sunshine-0.23.1.ebuild b/net-misc/sunshine/sunshine-0.23.1.ebuild index 7b106a011c0a..a708fffba539 100644 --- a/net-misc/sunshine/sunshine-0.23.1.ebuild +++ b/net-misc/sunshine/sunshine-0.23.1.ebuild @@ -13,13 +13,10 @@ SWS_COMMIT="27b41f5ee154cca0fce4fe2955dd886d04e3a4ed" WLRP_COMMIT="2b8d43325b7012cc3f9b55c08d26e50e42beac7d" FFMPEG_VERSION="6.1.1" -# To make the node-modules tarball: +# To make the assets tarball: # PV= -# git fetch -# git checkout v$PV -# rm -rf node_modules npm_cache package-lock.json -# npm_config_cache="${PWD}"/npm_cache npm install --logs-max=0 --omit=optional -# XZ_OPT=-9 tar --xform="s:^:Sunshine-$PV/:" -Jcf /var/cache/distfiles/sunshine-npm-cache-$PV.tar.xz npm_cache package-lock.json +# EGIT_OVERRIDE_COMMIT_LIZARDBYTE_SUNSHINE=v$PV ebuild sunshine-9999.ebuild clean compile +# XZ_OPT=-9 tar --xform="s:^:Sunshine-$PV/:" -Jcf /var/cache/distfiles/sunshine-assets-$PV.tar.xz -C /var/tmp/portage/net-misc/sunshine-9999/work/sunshine-9999 assets/ if [[ ${PV} = 9999* ]]; then inherit git-r3 @@ -40,7 +37,7 @@ else https://gitlab.com/eidheim/Simple-Web-Server/-/archive/${SWS_COMMIT}/Simple-Web-Server-${SWS_COMMIT}.tar.bz2 https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/archive/${WLRP_COMMIT}/wlr-protocols-${WLRP_COMMIT}.tar.bz2 https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz - https://dev.gentoo.org/~chewi/distfiles/${PN}-npm-cache-${PV}.tar.xz + https://dev.gentoo.org/~chewi/distfiles/${PN}-assets-${PV}.tar.xz " KEYWORDS="~amd64 ~arm64" S="${WORKDIR}/Sunshine-${PV}" @@ -181,6 +178,7 @@ BDEPEND=" PATCHES=( "${FILESDIR}"/${PN}-custom-ffmpeg.patch "${FILESDIR}"/${PN}-0.22.0-nvcodec.patch + "${FILESDIR}"/${PN}-find-npm.patch ) # Make this mess a bit simpler. @@ -188,7 +186,6 @@ CMAKE_IN_SOURCE_BUILD=1 # Make npm behave. export npm_config_audit=false -export npm_config_cache="${S}"/npm_cache export npm_config_color=false export npm_config_foreground_scripts=true export npm_config_loglevel=verbose @@ -353,6 +350,7 @@ src_configure() { -DSYSTEMD_USER_UNIT_INSTALL_DIR=$(systemd_get_userunitdir) -DUDEV_RULES_INSTALL_DIR=$(get_udevdir)/rules.d ) + [[ ${PV} = 9999* ]] || mycmakeargs+=( -DNPM="${BROOT}"/bin/true ) CMAKE_USE_DIR="${S}" cmake_src_configure } @@ -361,7 +359,7 @@ src_compile() { emake -C "${WORKDIR}"/ffmpeg-build V=1 install CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_compile CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_build install - CMAKE_USE_DIR="${S}" npm_config_offline=1 cmake_src_compile + CMAKE_USE_DIR="${S}" cmake_src_compile } pkg_postinst() { diff --git a/net-misc/sunshine/sunshine-9999.ebuild b/net-misc/sunshine/sunshine-9999.ebuild index 7b106a011c0a..a708fffba539 100644 --- a/net-misc/sunshine/sunshine-9999.ebuild +++ b/net-misc/sunshine/sunshine-9999.ebuild @@ -13,13 +13,10 @@ SWS_COMMIT="27b41f5ee154cca0fce4fe2955dd886d04e3a4ed" WLRP_COMMIT="2b8d43325b7012cc3f9b55c08d26e50e42beac7d" FFMPEG_VERSION="6.1.1" -# To make the node-modules tarball: +# To make the assets tarball: # PV= -# git fetch -# git checkout v$PV -# rm -rf node_modules npm_cache package-lock.json -# npm_config_cache="${PWD}"/npm_cache npm install --logs-max=0 --omit=optional -# XZ_OPT=-9 tar --xform="s:^:Sunshine-$PV/:" -Jcf /var/cache/distfiles/sunshine-npm-cache-$PV.tar.xz npm_cache package-lock.json +# EGIT_OVERRIDE_COMMIT_LIZARDBYTE_SUNSHINE=v$PV ebuild sunshine-9999.ebuild clean compile +# XZ_OPT=-9 tar --xform="s:^:Sunshine-$PV/:" -Jcf /var/cache/distfiles/sunshine-assets-$PV.tar.xz -C /var/tmp/portage/net-misc/sunshine-9999/work/sunshine-9999 assets/ if [[ ${PV} = 9999* ]]; then inherit git-r3 @@ -40,7 +37,7 @@ else https://gitlab.com/eidheim/Simple-Web-Server/-/archive/${SWS_COMMIT}/Simple-Web-Server-${SWS_COMMIT}.tar.bz2 https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/archive/${WLRP_COMMIT}/wlr-protocols-${WLRP_COMMIT}.tar.bz2 https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz - https://dev.gentoo.org/~chewi/distfiles/${PN}-npm-cache-${PV}.tar.xz + https://dev.gentoo.org/~chewi/distfiles/${PN}-assets-${PV}.tar.xz " KEYWORDS="~amd64 ~arm64" S="${WORKDIR}/Sunshine-${PV}" @@ -181,6 +178,7 @@ BDEPEND=" PATCHES=( "${FILESDIR}"/${PN}-custom-ffmpeg.patch "${FILESDIR}"/${PN}-0.22.0-nvcodec.patch + "${FILESDIR}"/${PN}-find-npm.patch ) # Make this mess a bit simpler. @@ -188,7 +186,6 @@ CMAKE_IN_SOURCE_BUILD=1 # Make npm behave. export npm_config_audit=false -export npm_config_cache="${S}"/npm_cache export npm_config_color=false export npm_config_foreground_scripts=true export npm_config_loglevel=verbose @@ -353,6 +350,7 @@ src_configure() { -DSYSTEMD_USER_UNIT_INSTALL_DIR=$(systemd_get_userunitdir) -DUDEV_RULES_INSTALL_DIR=$(get_udevdir)/rules.d ) + [[ ${PV} = 9999* ]] || mycmakeargs+=( -DNPM="${BROOT}"/bin/true ) CMAKE_USE_DIR="${S}" cmake_src_configure } @@ -361,7 +359,7 @@ src_compile() { emake -C "${WORKDIR}"/ffmpeg-build V=1 install CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_compile CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_build install - CMAKE_USE_DIR="${S}" npm_config_offline=1 cmake_src_compile + CMAKE_USE_DIR="${S}" cmake_src_compile } pkg_postinst() { |