(ctx context.Context, client *wsl.Distro, clientOs string, clientArch string)
| 130 | } |
| 131 | |
| 132 | func CpWshToRemote(ctx context.Context, client *wsl.Distro, clientOs string, clientArch string) error { |
| 133 | wshLocalPath, err := shellutil.GetLocalWshBinaryPath(wavebase.WaveVersion, clientOs, clientArch) |
| 134 | if err != nil { |
| 135 | return err |
| 136 | } |
| 137 | // warning: does not work on windows remote yet |
| 138 | bashInstalled, err := hasBashInstalled(ctx, client) |
| 139 | if err != nil { |
| 140 | return err |
| 141 | } |
| 142 | |
| 143 | var selectedTemplatesRaw map[string]string |
| 144 | if bashInstalled { |
| 145 | selectedTemplatesRaw = installTemplatesRawBash |
| 146 | } else { |
| 147 | log.Printf("bash is not installed on remote. attempting with default shell") |
| 148 | selectedTemplatesRaw = installTemplatesRawDefault |
| 149 | } |
| 150 | |
| 151 | // I need to use toSlash here to force unix keybindings |
| 152 | // this means we can't guarantee it will work on a remote windows machine |
| 153 | var installWords = map[string]string{ |
| 154 | "installDir": filepath.ToSlash(filepath.Dir(wavebase.RemoteFullWshBinPath)), |
| 155 | "tempPath": wavebase.RemoteFullWshBinPath + ".temp", |
| 156 | "installPath": wavebase.RemoteFullWshBinPath, |
| 157 | } |
| 158 | |
| 159 | blocklogger.Infof(ctx, "[conndebug] copying %q to remote server %q\n", wshLocalPath, wavebase.RemoteFullWshBinPath) |
| 160 | installStepCmds := make(map[string]*CancellableCmd) |
| 161 | for cmdName, selectedTemplateRaw := range selectedTemplatesRaw { |
| 162 | cancellableCmd, err := makeCancellableCommand(ctx, client, selectedTemplateRaw, installWords) |
| 163 | if err != nil { |
| 164 | return err |
| 165 | } |
| 166 | installStepCmds[cmdName] = cancellableCmd |
| 167 | } |
| 168 | |
| 169 | _, err = installStepCmds["mkdir"].Cmd.Output() |
| 170 | if err != nil { |
| 171 | return err |
| 172 | } |
| 173 | |
| 174 | // the cat part of this is complicated since it requires stdin |
| 175 | catCmd := installStepCmds["cat"].Cmd |
| 176 | catStdin, err := catCmd.StdinPipe() |
| 177 | if err != nil { |
| 178 | return err |
| 179 | } |
| 180 | err = catCmd.Start() |
| 181 | if err != nil { |
| 182 | return err |
| 183 | } |
| 184 | input, err := os.Open(wshLocalPath) |
| 185 | if err != nil { |
| 186 | return fmt.Errorf("cannot open local file %s to send to host: %v", wshLocalPath, err) |
| 187 | } |
| 188 | go func() { |
| 189 | defer func() { |
no test coverage detected