File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,15 @@ package os
22
33import (
44 "fmt"
5+ "io/ioutil"
6+ "runtime"
7+ "strings"
8+
59 "github.com/linuxsuren/http-downloader/pkg/exec"
610 "github.com/linuxsuren/http-downloader/pkg/os/apt"
711 "github.com/linuxsuren/http-downloader/pkg/os/core"
812 "github.com/linuxsuren/http-downloader/pkg/os/yum"
913 "gopkg.in/yaml.v3"
10- "io/ioutil"
11- "runtime"
12- "strings"
1314)
1415
1516type genericPackages struct {
@@ -91,16 +92,23 @@ func (i *genericPackage) Install() (err error) {
9192 for index := range i .PreInstall {
9293 preInstall := i .PreInstall [index ]
9394
95+ needInstall := false
9496 if preInstall .IssuePrefix != "" && runtime .GOOS == "linux" {
9597 var data []byte
9698 if data , err = ioutil .ReadFile ("/etc/issue" ); err != nil {
9799 return
98100 }
99101
100102 if strings .HasPrefix (string (data ), preInstall .IssuePrefix ) {
101- if err = exec .RunCommand (preInstall .Cmd .Cmd , preInstall .Cmd .Args ... ); err != nil {
102- return
103- }
103+ needInstall = true
104+ }
105+ } else if preInstall .IssuePrefix == "" {
106+ needInstall = true
107+ }
108+
109+ if needInstall {
110+ if err = exec .RunCommand (preInstall .Cmd .Cmd , preInstall .Cmd .Args ... ); err != nil {
111+ return
104112 }
105113 }
106114 }
You can’t perform that action at this time.
0 commit comments