Skip to content

Commit b91cdf8

Browse files
committed
reactor: 重构linux安装脚本和linux策略
1 parent d504726 commit b91cdf8

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

src/c#/GeneralUpdate.Bowl/Applications/Linux/install.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/bash
22

3+
# 获取脚本的实际名称
4+
SCRIPT_NAME=$(basename "\$0")
5+
36
# 检查是否提供了参数
47
if [ "$#" -ne 1 ]; then
5-
echo "Usage: install_package.sh <package-file>"
8+
echo "Usage: $SCRIPT_NAME <package-file>"
69
exit 1
710
fi
811

@@ -11,19 +14,19 @@ PACKAGE_FILE=\$1
1114
# 检查文件类型并安装
1215
if [[ "$PACKAGE_FILE" == *.rpm ]]; then
1316
if command -v rpm &> /dev/null; then
14-
sudo rpm -ivh "$PACKAGE_FILE"
17+
sudo rpm -ivh "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using rpm"; exit 1; }
1518
elif command -v dnf &> /dev/null; then
16-
sudo dnf install -y "$PACKAGE_FILE"
19+
sudo dnf install -y "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using dnf"; exit 1; }
1720
elif command -v yum &> /dev/null; then
18-
sudo yum install -y "$PACKAGE_FILE"
21+
sudo yum install -y "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using yum"; exit 1; }
1922
else
2023
echo "RPM package manager not found."
2124
exit 1
2225
fi
2326
elif [[ "$PACKAGE_FILE" == *.deb ]]; then
2427
if command -v dpkg &> /dev/null; then
25-
sudo dpkg -i "$PACKAGE_FILE"
26-
sudo apt-get install -f -y # 修复依赖问题
28+
sudo dpkg -i "$PACKAGE_FILE" || { echo "Failed to install $PACKAGE_FILE using dpkg"; exit 1; }
29+
sudo apt-get install -f -y || { echo "Failed to fix dependencies"; exit 1; }
2730
else
2831
echo "DEB package manager not found."
2932
exit 1

src/c#/GeneralUpdate.Bowl/Strategys/LinuxStrategy.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ public override void Launch()
2727

2828
private void Install()
2929
{
30-
//TODO: 安装路径需要调整
30+
string scriptPath = "./install.sh";
31+
string packageFile = GetPacketName();
32+
3133
ProcessStartInfo processStartInfo = new ProcessStartInfo()
3234
{
3335
FileName = "/bin/bash",
34-
Arguments = $"install.sh {GetPacketName()}",
36+
Arguments = $"{scriptPath} {packageFile}",
3537
RedirectStandardOutput = true,
3638
RedirectStandardError = true,
3739
UseShellExecute = false,

src/c#/GeneralUpdate.Bowl/Strategys/WindowStrategy.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.IO;
2-
using System.Runtime.InteropServices;
1+
using System.Runtime.InteropServices;
32

43
namespace GeneralUpdate.Bowl.Strategys;
54

0 commit comments

Comments
 (0)