fix(build): 署名注入改走 Node 规范化 + for /f 直读文件
上一版用 PowerShell 管道读取:PS 5.1 的 Get-Content 默认按 ANSI 读,输出再经 cmd(chcp 65001) 解码一次,中文署名被转成乱码 —— 日志写着 injected,但 exe 里的 字节与预期不符(实测 sig_in_exe=False)。 改为 deploy/prepare-signature.mjs 读 UTF-8 并剥 BOM/空白,写出 signature.build.txt (gitignore),build.bat 用 for /f 直接读文件(不经过任何编码转换)。 另加一条 findstr 自检:注入后若 exe 里找不到署名就打印 [warn]。
This commit is contained in:
1 parent
13f1f03cd0
commit
e7948088df
3 files changed
+33
-3
No files matched your search
+6
-3
@@ -30,13 +30,16 @@ echo === [3/4] server build ===
|
||||
cd server
|
||||
if not exist ..\dist mkdir ..\dist
|
||||
REM internal signature is injected from a machine-local file (gitignored, never in repo).
|
||||
REM set /p returns empty under chcp 65001, so read the first line with for /f instead.
|
||||
REM PowerShell reads the file as text and strips a BOM; for /f file-read does not.
|
||||
REM set /p returns empty under chcp 65001; PowerShell piping re-encodes the text and
|
||||
REM corrupts non-ASCII. So a Node script normalizes it (BOM/whitespace stripped) into
|
||||
REM deploy\signature.build.txt, and for /f reads that file directly (no re-encoding).
|
||||
node ..\deploy\prepare-signature.mjs || exit /b 1
|
||||
set "INTERNAL_SIGNATURE="
|
||||
if exist "..\deploy\signature.local.txt" for /f "usebackq delims= eol=" %%A in (`powershell -NoProfile -Command "Get-Content -LiteralPath '..\deploy\signature.local.txt' -TotalCount 1"`) do if not defined INTERNAL_SIGNATURE set "INTERNAL_SIGNATURE=%%A"
|
||||
if exist "..\deploy\signature.build.txt" for /f "usebackq delims= eol=" %%A in ("..\deploy\signature.build.txt") do if not defined INTERNAL_SIGNATURE set "INTERNAL_SIGNATURE=%%A"
|
||||
if defined INTERNAL_SIGNATURE (
|
||||
REM single quotes keep spaces inside the value intact for go's ldflags parser
|
||||
go build -ldflags "-X 'git.yeij.top/AskaEth/Scoreboard/server/internal/version.InternalSignature=%INTERNAL_SIGNATURE%'" -o ..\dist\scoreboard.exe . || exit /b 1
|
||||
findstr /m /c:"%INTERNAL_SIGNATURE%" ..\dist\scoreboard.exe >nul || echo [warn] signature NOT found in exe
|
||||
echo internal signature injected
|
||||
) else (
|
||||
go build -o ..\dist\scoreboard.exe . || exit /b 1
|
||||
|
||||
Reference in new issue
Block a user