Build SPT-AKI under linux
·1035 字
首先配置环境, 安装git curl,并通过nvm安装nodejs环境. 我使用的系统为Debian 12.
apt update
apt install -y git git-lfs curl
git clone https://github.com/nvm-sh/nvm.git $HOME/.nvm
. $HOME/.nvm/nvm.sh
nvm install 20.11.1
通过git将源码从dev.sp-tarkov.com拉回来
root@crazy:~# git clone https://dev.sp-tarkov.com/SPT/Server.git
Cloning into 'Server'...
remote: Enumerating objects: 42386, done.
remote: Counting objects: 100% (42386/42386), done.
remote: Compressing objects: 100% (12215/12215), done.
remote: Total 42386 (delta 32138), reused 39994 (delta 29977)
Receiving objects: 100% (42386/42386), 95.15 MiB | 3.38 MiB/s, done.
Resolving deltas: 100% (32138/32138), done.
Filtering content: 100% (48/48), 293.23 MiB | 21.41 MiB/s, done.
进入工作目录后,通过git checkout
切换到目标分支.目前最新的3.9.4的commit id为45e559efff0a6b5233df4e33b65c34850b425e85
root@crazy:~# cd Server/project/
root@crazy:~/Server/project# git checkout 45e559efff0a6b5233df4e33b65c34850b425e85
Note: switching to '45e559efff0a6b5233df4e33b65c34850b425e85'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 45e559ef Updated crowdin locales
root@crazy:~/Server/project# git log
commit 45e559efff0a6b5233df4e33b65c34850b425e85 (HEAD, tag: 3.9.4, origin/3.9.x-DEV)
Author: Dev <[email protected]>
Date: Fri Jul 26 19:29:39 2024 +0100
Updated crowdin locales
...
然后通过npm安装依赖
root@crazy:~/Server/project# npm install
npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated [email protected]: flatten is deprecated in favor of utility frameworks such as lodash.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: postinstall-build's behavior is now built into npm! You should migrate off of postinstall-build and use the new `prepare` lifecycle script with npm 5.0.0 or greater.
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated [email protected]: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies
npm WARN deprecated [email protected]: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
added 1084 packages, and audited 1085 packages in 3m
128 packages are looking for funding
run `npm fund` for details
16 vulnerabilities (2 moderate, 14 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
依赖安装完成后开始编译.
root@crazy:~/Server/project# npm run build:release -- --arch=x64 --platform=win
> [email protected] build:release
> cross-env PKG_CACHE_PATH="./.pkg-cache" gulp build:release --arch=x64 --platform=win
(node:171145) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
target arch: x64, target platform: win
[22:39:26] Using gulpfile ~/Server/project/gulpfile.mjs
[22:39:26] Starting 'build:release'...
[22:39:26] Starting 'cleanBuild'...
[22:39:26] Finished 'cleanBuild' after 1.51 ms
[22:39:26] Starting 'validateJSONs'...
[22:39:26] Finished 'validateJSONs' after 1.84 ms
[22:39:26] Starting 'compile'...
[22:39:26] [gulp-execa] npx swc src -d obj
Successfully compiled: 704 files with swc (140.74ms)
[22:39:28] Finished 'compile' after 1.94 s
[22:39:28] Starting 'copyAssets'...
[22:39:34] Finished 'copyAssets' after 6.14 s
[22:39:34] Starting 'downloadPnpm'...
[22:39:34] [gulp-execa] npm view @pnpm/[email protected] dist.tarball
Downloading pnpm binary from https://registry.npmjs.org/@pnpm/win-x64/-/win-x64-8.15.4.tgz
[22:39:36] Finished 'downloadPnpm' after 2.49 s
[22:39:36] Starting 'copyLicense'...
[22:39:36] Finished 'copyLicense' after 49 ms
[22:39:36] Starting 'writeBuildDataToJSON'...
[22:39:36] [gulp-execa] git rev-parse HEAD
[22:39:37] Finished 'writeBuildDataToJSON' after 30 ms
[22:39:37] Starting 'createHashFile'...
[22:39:39] Finished 'createHashFile' after 2.3 s
[22:39:39] Starting 'fetchPackageImage'...
node-v20.11.1-win-x64 [====================] 100%
fetched node binary at /root/Server/project/.pkg-cache/v3.5/node-v20.11.1-win-x64
[22:39:52] Finished 'fetchPackageImage' after 13 s
[22:39:52] Starting 'packaging-release'...
> [email protected]
compression: GZip
> Fetching base Node.js binaries to PKG_CACHE_PATH
fetched-v20.11.1-linux-x64 [==== ] 18% Done
fetched-v20.11.1-linux-x64 [====================] 100%
> Warning Cannot resolve 'modpath'
/root/Server/project/obj/loaders/PostDBModLoader.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Cannot resolve 'modpath'
/root/Server/project/obj/loaders/PostSptModLoader.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Cannot resolve 'modFilePath'
/root/Server/project/obj/loaders/PreSptModLoader.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Failed to make bytecode node20-x64 for file C:\snapshot\project\node_modules\@messageformat\date-skeleton\lib\index.js
> Warning Failed to make bytecode node20-x64 for file C:\snapshot\project\node_modules\@messageformat\number-skeleton\lib\index.js
[22:40:31] Finished 'packaging-release' after 39 s
[22:40:31] Starting 'updateBuildProperties'...
[22:40:31] Finished 'updateBuildProperties' after 1.39 ms
[22:40:31] Starting 'cleanCompiled'...
[22:40:31] Finished 'cleanCompiled' after 65 ms
[22:40:31] Finished 'build:release' after 1.07 min
root@crazy:~/Server/project# file build/SPT.Server.exe
build/SPT.Server.exe: PE32+ executable (console) x86-64, for MS Windows, 7 sections
测试运行
┌─────────────────────────────────────────┐
│ SPT 3.9.4 │
│ https://discord.sp-tarkov.com │
│ │
│ This work is free of charge │
│ If you paid money, you were scammed │
│ Commercial use is prohibited │
└─────────────────────────────────────────┘
ModLoader: loading: 3 server mods...
Mod: server version: 2.2.3 by: Fika loaded
Mod: SVM version: 1.9.0 by: GhostFenixx loaded
Mod: easy-ammunition version: 1.4.0 by: Refringe loaded
EasyAmmunition: Color Converter mod installed. Hex colour values are enabled.
Server: executing startup callbacks...
Importing database...
Database import finished.
...
Started webserver at http://0.0.0.0:6969
Started websocket at ws://0.0.0.0:6969
Server is running, do not close while playing SPT, Happy playing!!
程序工作正常,表现符合预期。
参考资料: