|
|
|
@ -6,6 +6,7 @@ import (
|
|
|
|
|
"fmt" |
|
|
|
|
"os" |
|
|
|
|
"path" |
|
|
|
|
pathUtils "path" |
|
|
|
|
"regexp" |
|
|
|
|
"strings" |
|
|
|
|
"sync" |
|
|
|
@ -231,8 +232,6 @@ func handleSnapTar(sourceDir, targetDir, name, exclusionRules string, secret str
|
|
|
|
|
exMap := make(map[string]struct{}) |
|
|
|
|
exStr := "" |
|
|
|
|
excludes := strings.Split(exclusionRules, ";") |
|
|
|
|
excludes = append(excludes, "*.sock") |
|
|
|
|
excludes = append(excludes, "*.socket") |
|
|
|
|
for _, exclude := range excludes { |
|
|
|
|
if len(exclude) == 0 { |
|
|
|
|
continue |
|
|
|
@ -258,10 +257,14 @@ func handleSnapTar(sourceDir, targetDir, name, exclusionRules string, secret str
|
|
|
|
|
commands := "" |
|
|
|
|
if len(secret) != 0 { |
|
|
|
|
extraCmd := "| openssl enc -aes-256-cbc -salt -k '" + secret + "' -out" |
|
|
|
|
commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read -zcf %s %s %s %s", " -"+exStr, path, extraCmd, targetDir+"/"+name) |
|
|
|
|
commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read --exclude-from=<(find %s -type s -print) -zcf %s %s %s %s", sourceDir, " -"+exStr, path, extraCmd, targetDir+"/"+name) |
|
|
|
|
global.LOG.Debug(strings.ReplaceAll(commands, fmt.Sprintf(" %s ", secret), "******")) |
|
|
|
|
} else { |
|
|
|
|
commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read -zcf %s %s -C %s .", targetDir+"/"+name, exStr, sourceDir) |
|
|
|
|
itemPrefix := pathUtils.Base(sourceDir) |
|
|
|
|
if itemPrefix == "/" { |
|
|
|
|
itemPrefix = "" |
|
|
|
|
} |
|
|
|
|
commands = fmt.Sprintf("tar --warning=no-file-changed --ignore-failed-read --exclude-from=<(find %s -type s -printf '%s' | sed 's|^|%s/|') -zcf %s %s -C %s .", sourceDir, "%P\n", itemPrefix, targetDir+"/"+name, exStr, sourceDir) |
|
|
|
|
global.LOG.Debug(commands) |
|
|
|
|
} |
|
|
|
|
stdout, err := cmd.ExecWithTimeOut(commands, 30*time.Minute) |
|
|
|
|