更新Linux批量打包脚本

This commit is contained in:
Tlntin
2022-11-20 10:35:21 +08:00
parent 5b9e5a7228
commit be9aeb64b4
40 changed files with 39 additions and 211 deletions

69
script/build.bat Normal file
View File

@@ -0,0 +1,69 @@
@echo off
chcp 65001
if not exist node_modules (
call npm i
)
if not exist output (
mkdir output
)
if not exist output\windows (
mkdir output\windows
)
echo.
echo =======================
echo "build for windows"
echo =======================
echo.
:: total package number
set /A index=1
for /f %%a in (' find /c /v "" ^<"app.csv" ') do set /A total=%%a
set old_name=weread
set old_zh_name=微信阅读
set old_url=weread.qq.com
for /f "skip=1 tokens=1-3 delims=," %%i in (app.csv) do (
setlocal enabledelayedexpansion
set name=%%i
set name_zh=%%j
set url=%%k
@echo on
::echo name is !name! !name_zh! !url!
:: replace url
.\sd.exe !old_url! !url! src-tauri\tauri.conf.json
::replace pacakge name
.\sd.exe !old_name! !name! src-tauri\tauri.conf.json
echo update ico with 32x32 pictue
echo .\sd.exe !old_name! !name! src-tauri\src\main.rs
.\sd.exe !old_name! !name! src-tauri\src\main.rs
::copy src-tauri\png\!name!_32.ico src-tauri\icons\icon.ico
echo.
::update package info
set old_zh_name=!name_zh!
set old_name=!name!
set old_url=!url!
::build package
echo building package !index!/!total!
echo package name is !name! !name_zh!
echo npm run build:windows
@echo off
call npm run tauri build -- --target x86_64-pc-windows-msvc
move src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi output\windows
@echo on
echo package build success!
echo.
echo.
set /A index=index+1
@echo off
)
echo "output dir is output\windows"

118
script/build.sh Executable file
View File

@@ -0,0 +1,118 @@
#!/bin/bash
if [ ! -d "node_modules" ]; then
npm i
fi
if [ ! -d "output" ]; then
mkdir output
fi
if [[ "$OSTYPE" =~ ^linux ]]; then
if [ ! -d "output/linux" ]; then
mkdir output/linux
fi
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
if [ ! -d "output/macos" ]; then
mkdir output/macos
fi
fi
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
# total app number, ignore first line
export total=`sed -n '$=' app.csv`
total=$(($total-1))
export index=1
old_name="weread"
old_title="WeRead"
old_zh_name="微信阅读"
old_url="https://weread.qq.com/"
package_prefix="com-tw93"
if [[ "$OSTYPE" =~ ^linux ]]; then
echo "==============="
echo "Build for Linux"
echo "==============="
export sd=${SHELL_FOLDER}/sd-linux-x64
# for linux, package name may be com.xxx.xxx
echo "rename package name"
export desktop_file="src-tauri/assets/${package_prefix}.weread.desktop"
# sed -i "s/\"productName\": \"weread\"/\"productName\": \"${package_prefix}-weread\"/g" src-tauri/tauri.conf.json
$sd "\"productName\": \"weread\"" "\"productName\": \"${package_prefix}-weread\"" src-tauri/tauri.conf.json
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
echo "==============="
echo "Build for MacOS"
echo "==============="
export sd=${SHELL_FOLDER}/sd-apple-x64
echo "rename package name"
$sd "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri/tauri.conf.json
fi
tail -n +2 app.csv | while IFS=, read -r -a arr;
do
package_name=${arr[0]}
package_title=${arr[1]}
package_zh_name=${arr[2]}
url=${arr[3]}
echo "update package name and url"
# replace package info
$sd ${old_url} ${url} src-tauri/tauri.conf.json
$sd ${old_name} ${package_name} src-tauri/tauri.conf.json
echo "update ico with 32x32 pictue"
$sd ${old_name} ${package_name} src-tauri/src/main.rs
# for apple, need replace title
if [[ "$OSTYPE" =~ ^darwin ]]; then
$sd ${old_title} ${package_title} src-tauri/tauri.conf.json
fi
# echo "update ico with 32x32 pictue"
# cp "src-tauri/png/${package_name}_32.ico" "src-tauri/icons/icon.ico"
if [[ "$OSTYPE" =~ ^linux ]]; then
echo "update desktop"
old_desktop="src-tauri/assets/${package_prefix}-${old_name}.desktop"
new_desktop="src-tauri/assets/${package_prefix}-${package_name}.desktop"
mv ${old_desktop} ${new_desktop}
$sd ${old_zh_name} ${package_zh_name} ${new_desktop}
$sd ${old_name} ${package_name} ${new_desktop}
fi
# update package info
old_name=${package_name}
old_title=${package_title}
old_zh_name=${package_zh_name}
old_url=${url}
echo "building package ${index}/${total}"
echo "package name is ${package_name} (${package_zh_name})"
npm run tauri build
echo "package build success!"
index=$(($index+1))
if [[ "$OSTYPE" =~ ^linux ]]; then
mv src-tauri/target/release/bundle/deb/*.deb output/linux
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
mv src-tauri/target/release/bundle/dmg/*.dmg output/macos
echo ""
fi
done
echo "build all package success!"
if [[ "$OSTYPE" =~ ^linux ]]; then
echo "result file in output/linux"
fi
if [[ "$OSTYPE" =~ ^darwin ]]; then
echo "result file in output/macos"
fi

BIN
script/sd-apple-x64 Normal file

Binary file not shown.

BIN
script/sd-linux-x64 Executable file

Binary file not shown.

BIN
script/sd.exe Normal file

Binary file not shown.