mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 18:23:59 +08:00
Add TarExec parameter (#82)
Add TarExec parameter to provide an alternative tar-command (E.g. On old non-Linux systems it may be necessary to use gtar).
This commit is contained in:
committed by
Bo-Yi Wu
parent
147005589b
commit
d798a8cc75
@@ -187,6 +187,12 @@ func main() {
|
||||
Usage: "Remove the specified number of leading path elements.",
|
||||
EnvVar: "PLUGIN_STRIP_COMPONENTS,TAR_STRIP_COMPONENTS",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "tar.exec",
|
||||
Usage: "Alternative `tar` executable to on the dest host",
|
||||
EnvVar: "PLUGIN_TAR_EXEC,SCP_TAR_EXEC",
|
||||
Value: "tar",
|
||||
},
|
||||
}
|
||||
|
||||
// Override a template
|
||||
@@ -265,6 +271,7 @@ func run(c *cli.Context) error {
|
||||
Source: c.StringSlice("source"),
|
||||
Remove: c.Bool("rm"),
|
||||
StripComponents: c.Int("strip.components"),
|
||||
TarExec: c.String("tar.exec"),
|
||||
Proxy: easyssh.DefaultConfig{
|
||||
Key: c.String("proxy.ssh-key"),
|
||||
KeyPath: c.String("proxy.key-path"),
|
||||
|
||||
@@ -49,6 +49,7 @@ type (
|
||||
Source []string
|
||||
Remove bool
|
||||
StripComponents int
|
||||
TarExec string
|
||||
Proxy easyssh.DefaultConfig
|
||||
}
|
||||
|
||||
@@ -256,9 +257,9 @@ func (p *Plugin) Exec() error {
|
||||
// untar file
|
||||
p.log(host, "untar file", p.DestFile)
|
||||
if p.Config.StripComponents > 0 {
|
||||
_, _, _, err = ssh.Run(fmt.Sprintf("tar -xf %s --strip-components=%d -C %s", p.DestFile, p.Config.StripComponents, target), p.Config.CommandTimeout)
|
||||
_, _, _, err = ssh.Run(fmt.Sprintf("%s -xf %s --strip-components=%d -C %s", p.Config.TarExec, p.DestFile, p.Config.StripComponents, target), p.Config.CommandTimeout)
|
||||
} else {
|
||||
_, _, _, err = ssh.Run(fmt.Sprintf("tar -xf %s -C %s", p.DestFile, target), p.Config.CommandTimeout)
|
||||
_, _, _, err = ssh.Run(fmt.Sprintf("%s -xf %s -C %s", p.Config.TarExec, p.DestFile, target), p.Config.CommandTimeout)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user