forked from rob4226/code-server-freebsd-port
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
140 lines (126 loc) · 6.23 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
PORTNAME= code-server
DISTVERSION= 3.10.2
CATEGORIES= www
MASTER_SITES= https://registry.npmjs.org/code-server/-/:codeserver \
http://mikael.urankar.free.fr/code-server/:npm_cache \
http://mikael.urankar.free.fr/code-server/:yarn_cache \
https://nodejs.org/dist/v${NODE_VER}/:node_headers
DISTFILES= ${PORTNAME}-${DISTVERSION}.tgz:codeserver \
${PORTNAME}-npm-modules-${DISTVERSION}${EXTRACT_SUFX}:npm_cache \
${PORTNAME}-yarn-modules-${DISTVERSION}${EXTRACT_SUFX}:yarn_cache \
node-v${NODE_VER}-headers.tar.gz:node_headers
MAINTAINER= FreeBSD@appkingsoftware.com
COMMENT= Run VS Code on any machine anywhere and access it in the browser
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE.txt
BUILD_DEPENDS= npm-node${NODE_VER_MAJOR}>0:www/npm-node${NODE_VER_MAJOR} \
yarn-node${NODE_VER_MAJOR}>0:www/yarn-node${NODE_VER_MAJOR} \
pkgconf>0:devel/pkgconf \
libsecret>0:security/libsecret \
libxkbfile>0:x11/libxkbfile \
libX11>0:x11/libX11 \
libinotify>0:devel/libinotify
LIB_DEPENDS= libinotify.so:devel/libinotify
RUN_DEPENDS= npm-node${NODE_VER_MAJOR}>0:www/npm-node${NODE_VER_MAJOR}
USES= tar:tgz shebangfix python:3.6+
USE_RC_SUBR= ${PORTNAME}
WRKSRC= ${WRKDIR}/package
SHEBANG_FILES= lib/vscode/extensions/ms-vscode.node-debug/dist/terminateProcess.sh \
lib/vscode/extensions/ms-vscode.js-debug/src/terminateProcess.sh \
lib/vscode/extensions/ms-vscode.node-debug2/out/src/terminateProcess.sh \
lib/vscode/extensions/ms-vscode.node-debug2/src/terminateProcess.sh
# Taken from https://github.com/tagattie/FreeBSD-Electron
NODE_VER= 14.17.0
NODE_VER_MAJOR= ${NODE_VER:C/\..*$//}
PREFETCH_TIMESTAMP= 1616313125 # epoch ??? Sunday, 21 March 2021
PKGJSONSDIR= ${FILESDIR}/packagejsons
YARN_CMD= ${LOCALBASE}/bin/${_YARN_BASE_CMD}
_YARN_BASE_CMD= yarn
# Helper targets for port maintainers
# xxx move this in pre-fetch?
make-npm-cache:
# do "make configure" before executing this target
cd ${WRKDIR} && ${RM} -r .npm
cd ${WRKSRC} && \
${SETENV} HOME=${WRKDIR} npm install --ignore-scripts
cd ${WRKDIR}/.npm && \
${RM} -r _locks anonymous-cli-metrics.json
cd ${WRKDIR} && \
${TAR} -czf npm-cache-${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX} .npm
# to create the yarn.lock, basically:
# for i in lib/vscode lib/vscode/extensions lib/vscode/extensions/notebook-markdown-extensions lib/vscode/extensions/npm
# do
# cd ${WRKSRC}/$i
# yarn --ignore-script --production
# cp package.json yarn.lock ${FILESDIR}/packagejsons/${i}
# done
#
pre-fetch:
@if [ ! -f ${DISTDIR}/${PORTNAME}-yarn-modules-${DISTVERSION}${EXTRACT_SUFX} ]; then \
${ECHO_MSG} "===> Distfile ${DISTDIR}/${PORTNAME}-yarn-modules-${DISTVERSION}${EXTRACT_SUFX} not found"; \
${ECHO_MSG} "===> Pre-fetching and archiving node modules"; \
${MKDIR} ${WRKDIR}; \
${ECHO_CMD} 'yarn-offline-mirror "./yarn-offline-cache"' >> \
${WRKDIR}/.yarnrc; \
${CP} -r ${PKGJSONSDIR}/* ${WRKDIR}; \
cd ${PKGJSONSDIR} && \
for dir in `${FIND} . -type f -name package.json -exec dirname {} ';'`; do \
cd ${WRKDIR}/$${dir} && \
${SETENV} HOME=${WRKDIR} XDG_CACHE_HOME=${WRKDIR}/.cache \
${YARN_CMD} --frozen-lockfile --ignore-scripts --production && \
${RM} package.json yarn.lock; \
done; \
cd ${WRKDIR}; \
${MTREE_CMD} -cbnSp yarn-offline-cache | ${MTREE_CMD} -C | ${SED} \
-e 's:time=[0-9.]*:time=${PREFETCH_TIMESTAMP}.000000000:' \
-e 's:\([gu]id\)=[0-9]*:\1=0:g' \
-e 's:flags=.*:flags=none:' \
-e 's:^\.:./yarn-offline-cache:' > yarn-offline-cache.mtree; \
${TAR} -cz --options 'gzip:!timestamp' \
-f ${DISTDIR}/${PORTNAME}-yarn-modules-${DISTVERSION}${EXTRACT_SUFX} @yarn-offline-cache.mtree; \
fi
pre-build:
@${ECHO_MSG} "===> Copying package.json and yarn.lock to WRKSRC"
@cd ${PKGJSONSDIR} && \
for dir in `${FIND} . -type f -name package.json -exec dirname {} ';'`; do \
for f in package.json yarn.lock; do \
if [ -f ${WRKSRC}/$${dir}/$${f} ]; then \
${MV} -f ${WRKSRC}/$${dir}/$${f} ${WRKSRC}/$${dir}/$${f}.bak; \
fi; \
${CP} -f $${dir}/$${f} ${WRKSRC}/$${dir}; \
done; \
done
@${ECHO_MSG} "===> Installing node modules from pre-fetched cache"
@${ECHO_CMD} 'yarn-offline-mirror "../yarn-offline-cache"' >> ${WRKSRC}/.yarnrc
@${ECHO_CMD} 'nodedir "${WRKDIR}/node-v${NODE_VER}"' >> ${WRKSRC}/.yarnrc
@cd ${PKGJSONSDIR} && \
for dir in lib/vscode lib/vscode/extensions lib/vscode/extensions/notebook-markdown-extensions lib/vscode/extensions/npm; do \
cd ${WRKSRC}/$${dir} && ${SETENV} HOME=${WRKDIR} XDG_CACHE_HOME=${WRKDIR}/.cache \
${YARN_CMD} --production --frozen-lockfile --offline; \
done
do-build:
cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} \
npm install --production --unsafe-perm
pre-install:
${RM} ${WRKSRC}/node_modules/pem/bin/test_build_openssl.sh
${RM} ${WRKSRC}/lib/vscode/node_modules/vscode-sqlite3/Dockerfile
${RM} ${WRKSRC}/lib/vscode/node_modules/vscode-sqlite3/tools/docker/architecture/linux-arm64/Dockerfile
${RM} ${WRKSRC}/lib/vscode/node_modules/spdlog/deps/spdlog/format.sh
${RM} ${WRKSRC}/lib/vscode/node_modules/spdlog/deps/spdlog/tests/install_libcxx.sh
${RM} ${WRKSRC}/lib/vscode/node_modules/spdlog/deps/spdlog/bench/latency/compare.sh
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/nsfw/build/Release/nsfw.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/nsfw/build/Release/obj.target/nsfw.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/node-pty/build/Release/pty.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/vscode-sqlite3/build/Release/obj.target/sqlite.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/vscode-sqlite3/build/Release/sqlite.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/native-is-elevated/build/Release/obj.target/iselevated.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/native-is-elevated/build/Release/iselevated.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/spdlog/build/Release/obj.target/spdlog.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/spdlog/build/Release/spdlog.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/native-watchdog/build/Release/obj.target/watchdog.node
${STRIP_CMD} ${WRKSRC}/lib/vscode/node_modules/native-watchdog/build/Release/watchdog.node
do-install:
${MKDIR} ${STAGEDIR}${DATADIR}
${CP} -R ${WRKSRC}/* ${STAGEDIR}${DATADIR}
${RLN} ${STAGEDIR}${DATADIR}/out/node/entry.js ${STAGEDIR}${PREFIX}/bin/${PORTNAME}
.include <bsd.port.mk>