Skip to content

Commit

Permalink
update deb build script, fix config loss and config read issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericwyn committed Mar 1, 2024
1 parent db0e912 commit 010ca6a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
## 2. 安装

### Release 下载
直接前往 [Release](https://github.com/Ericwyn/EzeTranslate/releases) 下载即可
直接前往 [Release](https://github.com/Ericwyn/EzeTranslate/releases) 下载即可, 提供以下类型安装包
- 二进制执行文件安装包
- 解压之后可直接运行
- .deb 安装包, 需要 `sudo dpkg -i` 方式安装
- ubuntu 22 / ubuntu 20 上测试通过

### 编译安装
```shell
Expand Down
5 changes: 5 additions & 0 deletions RELEASE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# EzeTranslate Release Log
## V1.4
- 发布: 2024-03-01
- 说明
1. 更新 Fyne 版本
2. 支持 debian 安装包

## V1.4
- 发布: 2022-11-22
Expand Down
5 changes: 4 additions & 1 deletion build-deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ echo ""
# 复制 deb-build-tpl 到 $TARGET_DIR/EzeTranslate-deb 里面
# 复制 EzeTranslate, config.yaml, res-static/ 到 $TARGET_DIR/EzeTranslate-deb/opt/EzeTranslate/ 里
cp -r "./deb-build-tpl" "$TARGET_DIR/eze-translate"
cp -r "./EzeTranslate" "./config.yaml" "./res-static" "$TARGET_DIR/eze-translate/opt/EzeTranslate"
mkdir -p "$TARGET_DIR/eze-translate/opt/EzeTranslate"

cp -r "./EzeTranslate" "./res-static" "$TARGET_DIR/eze-translate/opt/EzeTranslate"
cp "./config.yaml" "$TARGET_DIR/eze-translate/opt/EzeTranslate/default-config.yaml"

# 开始 build deb
cd "$TARGET_DIR"
Expand Down
8 changes: 8 additions & 0 deletions deb-build-tpl/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@
# 创建符号链接, 使得安装之后可以在命令行调用 EzeTranslate
ln -sf /opt/EzeTranslate/EzeTranslate /usr/bin/EzeTranslate

# 检查 config.yaml 是否存在
CONFIG_PATH="/opt/EzeTranslate/config.yaml"
if [ ! -f "$CONFIG_PATH" ]; then
# 如果 config.yaml 不存在,则复制或创建文件
# 假设您的默认配置文件位于 DEBIAN/config.yaml
cp /opt/EzeTranslate/default-config.yaml "$CONFIG_PATH"
fi

exit 0
7 changes: 7 additions & 0 deletions ui/resource/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ var runnerPath = ""

func GetRunnerPath() string {
if runnerPath == "" {
// 如果 /opt/EzeTranslate/config.yaml 存在的话, 优先使用 /opt/EzeTranslate/ 作为 runPath
if _, err := os.Stat("/opt/EzeTranslate/config.yaml"); err == nil {
runnerPath = "/opt/EzeTranslate/"
log.D("程序运行目录:" + runnerPath)
return runnerPath
}

//返回绝对路径 filepath.Dir(os.Args[0])去除最后一个元素的路径

log.D("os.Args[0]:" + os.Args[0])
Expand Down

0 comments on commit 010ca6a

Please sign in to comment.