fix(script/build): Issues indicated by ShellCheck

This commit is contained in:
pan93412
2022-11-20 14:07:53 +08:00
parent b66f0e4da7
commit 40d9f7655b

View File

@@ -21,10 +21,11 @@ if [[ "$OSTYPE" =~ ^darwin ]]; then
mkdir output/macos
fi
fi
SHELL_FOLDER=$(cd "$(dirname "$0")";pwd)
SHELL_FOLDER=$(cd "$(dirname "$0")" || exit 1; pwd)
# total app number, ignore first line
export total=`sed -n '$=' app.csv`
total=$(($total-1))
total=$(sed -n '$=' app.csv)
export total=$((total-1))
export index=1
old_name="weread"
@@ -38,13 +39,12 @@ if [[ "$OSTYPE" =~ ^linux ]]; then
echo "Build for Linux"
echo "==============="
export sd=${SHELL_FOLDER}/sd-linux-x64
chmod +x $sd
chmod +x "$sd"
# 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
@@ -53,7 +53,7 @@ if [[ "$OSTYPE" =~ ^darwin ]]; then
echo "==============="
export sd=${SHELL_FOLDER}/sd-apple-x64
chmod +x $sd
chmod +x "$sd"
echo "rename package name"
$sd "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri/tauri.conf.json
fi
@@ -66,14 +66,14 @@ do
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
$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
$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
$sd "${old_title}" "${package_title}" src-tauri/tauri.conf.json
fi
# echo "update ico with 32x32 pictue"
@@ -83,9 +83,9 @@ do
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}
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
@@ -98,7 +98,7 @@ do
echo "package name is ${package_name} (${package_zh_name})"
npm run tauri build
echo "package build success!"
index=$(($index+1))
index=$((index+1))
if [[ "$OSTYPE" =~ ^linux ]]; then
mv src-tauri/target/release/bundle/deb/*.deb output/linux