PORTNAME= linkwarden DISTVERSIONPREFIX= v DISTVERSION= 2.17.0 PORTREVISION= 1 CATEGORIES= www MASTER_SITES= LOCAL/feld:buildkit DISTFILES= linkwarden-freebsd-buildkit-${DISTVERSION}${EXTRACT_SUFX}:buildkit MAINTAINER= feld@FreeBSD.org COMMENT= Self-hosted collaborative bookmark manager and web archive WWW= https://linkwarden.app/ LICENSE= AGPLv3 LICENSE_FILE= ${WRKSRC}/LICENSE.md ONLY_FOR_ARCHS= amd64 ONLY_FOR_ARCHS_REASON= Next.js only ships SWC bindings for x86_64-unknown-freebsd BUILD_DEPENDS= ${LOCALBASE}/libexec/prisma-engines/query-engine:databases/prisma-engines RUN_DEPENDS= ${LOCALBASE}/bin/chrome:www/chromium \ ${LOCALBASE}/bin/monolith:www/monolith \ ${LOCALBASE}/libexec/prisma-engines/query-engine:databases/prisma-engines USES= cpe gmake nodejs:22,build,run python:build ssl CPE_VENDOR= linkwarden USE_GITHUB= yes GH_ACCOUNT= linkwarden USE_RC_SUBR= linkwarden_web linkwarden_worker USERS= linkwarden GROUPS= linkwarden # The buildkit distfile is generated by the maintainer and uploaded to his # LOCAL distfiles area. It carries the Yarn Berry cache, the Yarn 4 bundle, the # lockfile pinned to the prisma version of databases/prisma-engines and the # WebAssembly SWC bindings, so that the build needs no network. It is important # that the files/patch-package.json declares prisma to be the same version as # the databases/prisma-engines port. # # It is made by running the scripts/make-freebsd-buildkit-distfile.sh which # automates these steps for you, but the manual process is as follows: # # Unpack the release tarball / git clone, apply the patches of this port # and run with the yarn version from packageManager in package.json. # Note, the versions here are examples and need to be discovered manually from # package.json and yarn.lock. The provided script will do it automatically. # # npm pack @yarnpkg/cli-dist@4.12.0 -> creates tarball, then extract its yarn.js # npm pack @next/swc-wasm-nodejs@15.5.21 -> creates tarball, then extract its swc-wasm-nodejs/ # # Those should be placed into the directory which will hold the buildkit distfiles, # preferably named linkwarden-freebsd-buildkit-. This dir is referred to as . # # In .yarnrc.yml of the release/clone, append the following: # # cacheFolder: /yarn-cache # enableGlobalCache: false # # Next, run the following to ensure the lockfile is correct and to # gather the node dependencies # # export YARN_ENABLE_IMMUTABLE_INSTALLS=false # node /yarn.js install --mode=update-lockfile # node /yarn.js workspaces focus linkwarden @linkwarden/web \ # @linkwarden/worker # cp yarn.lock / # # Finally, fetch two fonts that next/font would otherwise fetch from Google at build # time, taken from the https://github.com/google/fonts repository (OFL): # fonts/Bentham-Regular.ttf, fonts/Caveat-Variable.ttf and their OFL.txt licenses # renamed as fonts/OFL-Bentham.txt and fonts/OFL-Caveat.txt # # This should be sufficient to create a tarball to be used as the port distfile. # BUILDKIT= ${WRKDIR}/linkwarden-freebsd-buildkit-${DISTVERSION} YARN= ${LOCALBASE}/bin/node ${BUILDKIT}/yarn.js PRISMA_ENGINES= ${LOCALBASE}/libexec/prisma-engines MAKE_ENV= CI=1 \ NEXT_TELEMETRY_DISABLED=1 \ NODE_OPTIONS=--max-old-space-size=8192 \ PLAYWRIGHT_BROWSERS_PATH=${WRKDIR}/playwright \ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \ PRISMA_CLI_QUERY_ENGINE_TYPE=binary \ PRISMA_FMT_BINARY=${PRISMA_ENGINES}/prisma-fmt \ PRISMA_HIDE_UPDATE_MESSAGE=1 \ PRISMA_QUERY_ENGINE_BINARY=${PRISMA_ENGINES}/query-engine \ PRISMA_QUERY_ENGINE_LIBRARY=${WRKDIR}/libquery_engine.node \ PRISMA_SCHEMA_ENGINE_BINARY=${PRISMA_ENGINES}/schema-engine \ PYTHON=${PYTHON_CMD} \ npm_config_nodedir=${LOCALBASE} \ npm_config_python=${PYTHON_CMD} PLIST_SUB= BUILDID=linkwarden-${DISTVERSIONPREFIX}${DISTVERSION} SUB_FILES= pkg-message SUB_LIST= NODE=${LOCALBASE}/bin/node \ WWWDIR=${WWWDIR} .include .if ${OSVERSION} >= 1600000 IGNORE= fails to build on FreeBSD 16-CURRENT due to prisma .endif pre-build: ${CP} ${BUILDKIT}/yarn.lock ${WRKSRC}/yarn.lock ${LN} -sf ${PRISMA_ENGINES}/libquery_engine.so ${WRKDIR}/libquery_engine.node ${ECHO_CMD} 'cacheFolder: "${BUILDKIT}/yarn-cache"' >> ${WRKSRC}/.yarnrc.yml ${ECHO_CMD} 'enableGlobalCache: false' >> ${WRKSRC}/.yarnrc.yml ${ECHO_CMD} 'enableNetwork: false' >> ${WRKSRC}/.yarnrc.yml ${ECHO_CMD} 'enableTelemetry: false' >> ${WRKSRC}/.yarnrc.yml @${MKDIR} ${WRKSRC}/apps/web/fonts ${INSTALL_DATA} ${BUILDKIT}/fonts/*.ttf ${WRKSRC}/apps/web/fonts/ do-build: cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${YARN} workspaces focus \ linkwarden @linkwarden/web @linkwarden/worker @${MKDIR} ${WRKSRC}/node_modules/next/wasm/@next ${CP} -R ${BUILDKIT}/swc-wasm-nodejs \ ${WRKSRC}/node_modules/next/wasm/@next/swc-wasm-nodejs cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${YARN} workspace \ @linkwarden/prisma generate cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${YARN} workspace \ @linkwarden/web build cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${YARN} workspaces focus \ --production linkwarden @linkwarden/web @linkwarden/worker @${MKDIR} ${WRKSRC}/node_modules/next/wasm/@next ${CP} -R ${BUILDKIT}/swc-wasm-nodejs \ ${WRKSRC}/node_modules/next/wasm/@next/swc-wasm-nodejs cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${YARN} workspace \ @linkwarden/prisma generate ${RM} -r ${WRKSRC}/apps/web/.next/cache do-install: ${MKDIR} ${STAGEDIR}${WWWDIR} cd ${WRKSRC} && ${PAX} -rw -pp package.json yarn.lock .yarnrc.yml \ node_modules apps/web apps/worker packages ${STAGEDIR}${WWWDIR} ${LN} -sf ${PRISMA_ENGINES}/libquery_engine.so \ ${STAGEDIR}${WWWDIR}/libquery_engine.node ${INSTALL_DATA} ${FILESDIR}/linkwarden.env.sample ${STAGEDIR}${PREFIX}/etc/ ${MKDIR} ${STAGEDIR}/var/db/${PORTNAME} ${STAGEDIR}/var/log/${PORTNAME} post-install: # node-gyp is a build tool, it is of no use at runtime and only brings in # python shebangs, and the engine that prisma generate copied is the one of # databases/prisma-engines @${RM} -r ${STAGEDIR}${WWWDIR}/node_modules/node-gyp \ ${STAGEDIR}${WWWDIR}/node_modules/.bin/node-gyp ${LN} -sf ${PRISMA_ENGINES}/libquery_engine.so \ ${STAGEDIR}${WWWDIR}/node_modules/.prisma/client/libquery_engine.node @${RM} -r ${STAGEDIR}${WWWDIR}/apps/web/fonts @${FIND} ${STAGEDIR}${WWWDIR}/node_modules -type d \ \( -name .deps -o -name "build-tmp-*" -o -name node-addon-api \) \ -exec ${RM} -r {} + 2>/dev/null || ${TRUE} @${FIND} ${STAGEDIR}${WWWDIR}/node_modules -type f \ \( -name "*.target.mk" -o -name "*.Makefile" -o -name Makefile \ -o -name nothing.a -o -name config.gypi -o -name "*.stamp" \) -delete @${FIND} ${STAGEDIR}${WWWDIR} -type f \ \( -name "*.map" -o -name "*.md" -o -name "*.markdown" \) -delete @${FIND} ${STAGEDIR}${WWWDIR}/node_modules -type d \ \( -name test -o -name tests -o -name __tests__ -o -name docs \) \ -exec ${RM} -r {} + 2>/dev/null || ${TRUE} @${FIND} ${STAGEDIR}${WWWDIR} -type f -name ".DS_Store" -delete @${FIND} ${STAGEDIR}${WWWDIR} -type f -name "*.sh" -exec ${CHMOD} a-x {} + @${FIND} ${STAGEDIR}${WWWDIR} -type d -empty -delete # Dynamically build pkg-plist because it is very large @(cd ${STAGEDIR}${PREFIX} ; \ ${FIND} www \( -type f -or -type l \) | ${SORT} >> ${TMPPLIST}) @echo "@sample etc/linkwarden.env.sample" >> ${TMPPLIST} @echo "@dir(linkwarden,linkwarden,750) /var/db/linkwarden" >> ${TMPPLIST} @echo "@dir(linkwarden,linkwarden,750) /var/log/linkwarden" >> ${TMPPLIST} .include