Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

Commit fbfc450

Browse files
patch the hardlink to /bin/arch file
1 parent be19361 commit fbfc450

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

build/linux/x86_64/Linux-x86_64-lpmx

4.61 KB
Binary file not shown.

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var (
2020
)
2121

2222
const (
23-
VERSION = "alpha-1.9.0"
23+
VERSION = "alpha-1.9.1"
2424
)
2525

2626
func checkCompleteness() *Error {

utils/utils.go

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,44 @@ func Untar(file string, folder string) *Error {
987987
case tar.TypeLink:
988988
//fmt.Printf("-----hardlink---- %s, %s, %s\n", header.Linkname, folder, target)
989989
//only works on linking to the file inside the same folder
990-
os.Symlink(header.Linkname, target)
990+
991+
//here we need to add a patch for specific bin/arch, for debian 10, all binaries are hardlinked to bin/arch
992+
if strings.Compare(header.Linkname, "bin/arch") == 0 {
993+
//if it is bin/arch, then we need to copy it to binaries
994+
t_file_mode := os.FileMode(header.Mode)
995+
//here we check file mode, if file does not have at least rw mode, we change it
996+
//fixing "permission denied" error on cluster
997+
permission := permbits.FileMode(t_file_mode)
998+
if !(permission.UserRead() && permission.UserWrite()) {
999+
permission.SetUserRead(true)
1000+
permission.SetUserWrite(true)
1001+
permbits.UpdateFileMode(&t_file_mode, permission)
1002+
}
1003+
1004+
//write target
1005+
f, err := os.OpenFile(target, os.O_CREATE|os.O_RDWR, t_file_mode)
1006+
if err != nil {
1007+
cerr := ErrNew(err, fmt.Sprintf("untar create file %s error", target))
1008+
return cerr
1009+
}
1010+
1011+
// copy over contents
1012+
source_file := fmt.Sprintf("%s%s", folder, header.Linkname)
1013+
sf, err := os.Open(source_file)
1014+
if err != nil {
1015+
cerr := ErrNew(err, fmt.Sprintf("untar read source file %s error", source_file))
1016+
return cerr
1017+
}
1018+
if _, err := io.Copy(f, sf); err != nil {
1019+
cerr := ErrNew(err, "untar copying file content error")
1020+
return cerr
1021+
}
1022+
1023+
f.Close()
1024+
sf.Close()
1025+
} else {
1026+
os.Symlink(header.Linkname, target)
1027+
}
9911028
}
9921029
}
9931030
}

0 commit comments

Comments
 (0)