Skip to content

Commit

Permalink
fix:add real depend file for pump, issue: #274
Browse files Browse the repository at this point in the history
  • Loading branch information
tbs60 committed Aug 7, 2024
1 parent e63ec13 commit 81e28e6
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ func getLddFiles(exe string) []string {
if inWhiteList && dcFile.Lstat(f).Exist() {
files = append(files, f)
}

// if dcFile.Lstat(f).Exist() {
// files = append(files, f)
// }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/backend/booster/bk_dist/executor/pkg/dist_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func getAbsPath(cmd string) string {
}
}

// no path, noly file name
// no path, only file name
newcmd, err := exec.LookPath(cmd)
if err == nil {
return newcmd
Expand Down
23 changes: 3 additions & 20 deletions src/backend/booster/bk_dist/handler/cc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,9 @@ func (cc *TaskCC) resolveDependFile(sep, workdir string, includes *[]string) err
*includes = append(*includes, commonUtil.FormatFilePath(targetf))

// 如果是链接,则将相关指向的文件都包含进来
tempf := targetf
for {
loopagain := false
i := dcFile.Lstat(tempf)
if i.Basic().Mode()&os.ModeSymlink != 0 {
originFile, err := os.Readlink(tempf)
if err == nil {
if !filepath.IsAbs(originFile) {
originFile, _ = filepath.Abs(filepath.Join(workdir, originFile))
}
*includes = append(*includes, commonUtil.FormatFilePath(originFile))

loopagain = true
tempf = originFile
}
}

if !loopagain {
break
}
fs := commonUtil.GetAllLinkFiles(targetf, workdir)
if len(fs) > 0 {
*includes = append(*includes, fs...)
}
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/backend/booster/bk_dist/handler/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,30 @@ func FormatFilePath(f string) string {

return f
}

func GetAllLinkFiles(f, workdir string) []string {
fs := []string{}
tempf := f
for {
loopagain := false
i := dcFile.Lstat(tempf)
if i.Basic().Mode()&os.ModeSymlink != 0 {
originFile, err := os.Readlink(tempf)
if err == nil {
if !filepath.IsAbs(originFile) {
originFile, _ = filepath.Abs(filepath.Join(workdir, originFile))
}
fs = append(fs, FormatFilePath(originFile))

loopagain = true
tempf = originFile
}
}

if !loopagain {
break
}
}

return fs
}
23 changes: 3 additions & 20 deletions src/backend/booster/bk_dist/handler/ue4/cc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,26 +357,9 @@ func (cc *TaskCC) resolveDependFile(sep, workdir string, includes *[]string) err
*includes = append(*includes, commonUtil.FormatFilePath(targetf))

// 如果是链接,则将相关指向的文件都包含进来
tempf := targetf
for {
loopagain := false
i := dcFile.Lstat(tempf)
if i.Basic().Mode()&os.ModeSymlink != 0 {
originFile, err := os.Readlink(tempf)
if err == nil {
if !filepath.IsAbs(originFile) {
originFile, _ = filepath.Abs(filepath.Join(workdir, originFile))
}
*includes = append(*includes, commonUtil.FormatFilePath(originFile))

loopagain = true
tempf = originFile
}
}

if !loopagain {
break
}
fs := commonUtil.GetAllLinkFiles(targetf, workdir)
if len(fs) > 0 {
*includes = append(*includes, fs...)
}
}
}
Expand Down
46 changes: 6 additions & 40 deletions src/backend/booster/bk_dist/handler/ue4/cl/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,26 +486,9 @@ func (cl *TaskCL) copyPumpHeadFile(workdir string) error {
includes = append(includes, commonUtil.FormatFilePath(l))

// 如果是链接,则将相关指向的文件都包含进来
tempf := l
for {
loopagain := false
i := dcFile.Lstat(tempf)
if i.Basic().Mode()&os.ModeSymlink != 0 {
originFile, err := os.Readlink(tempf)
if err == nil {
if !filepath.IsAbs(originFile) {
originFile, _ = filepath.Abs(filepath.Join(workdir, originFile))
}
includes = append(includes, commonUtil.FormatFilePath(originFile))

loopagain = true
tempf = originFile
}
}

if !loopagain {
break
}
fs := commonUtil.GetAllLinkFiles(l, workdir)
if len(fs) > 0 {
includes = append(includes, fs...)
}
}
} else {
Expand All @@ -522,26 +505,9 @@ func (cl *TaskCL) copyPumpHeadFile(workdir string) error {
includes = append(includes, commonUtil.FormatFilePath(l))

// 如果是链接,则将相关指向的文件都包含进来
tempf := l
for {
loopagain := false
i := dcFile.Lstat(tempf)
if i.Basic().Mode()&os.ModeSymlink != 0 {
originFile, err := os.Readlink(tempf)
if err == nil {
if !filepath.IsAbs(originFile) {
originFile, _ = filepath.Abs(filepath.Join(workdir, originFile))
}
includes = append(includes, commonUtil.FormatFilePath(originFile))

loopagain = true
tempf = originFile
}
}

if !loopagain {
break
}
fs := commonUtil.GetAllLinkFiles(l, workdir)
if len(fs) > 0 {
includes = append(includes, fs...)
}
}
}
Expand Down

0 comments on commit 81e28e6

Please sign in to comment.