From d64a18a08a18368ac71f5d6ec3af99db96b114f3 Mon Sep 17 00:00:00 2001 From: Enguerrand de Ribaucourt Date: Tue, 12 Nov 2024 10:45:00 +0100 Subject: [PATCH 1/2] Doc: Add ssh-agent option to kas Kas will not forward the ssh-agent socket by default which means authentication to private git repositories will fail through our commands. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d6e68348..29a97725 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "type": "string", "examples": [ "docker run --rm -v ${workspaceFolder}:${workspaceFolder} crops/poky --workdir=${workspaceFolder} /bin/bash -c", - "kas shell -c", + "kas-container --ssh-agent shell -c", "cqfd run", "${workspaceFolder}/build.sh --" ], From 7a1954973794dbba7a1a44f4abf574fd3bf506be Mon Sep 17 00:00:00 2001 From: Enguerrand de Ribaucourt Date: Tue, 12 Nov 2024 10:45:46 +0100 Subject: [PATCH 2/2] Refactor: Use stric shell env for commands The previous code duplicated the logic to prepare the shell environment in temrinal profile and regular commands. Let's properly define the same one in both places. --- client/src/driver/BitbakeDriver.ts | 12 +++++------- client/src/ui/BitbakeTerminalProfile.ts | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/client/src/driver/BitbakeDriver.ts b/client/src/driver/BitbakeDriver.ts index ef0312ab..2f6b2b2d 100644 --- a/client/src/driver/BitbakeDriver.ts +++ b/client/src/driver/BitbakeDriver.ts @@ -46,17 +46,15 @@ export class BitbakeDriver { /// Execute a command in the bitbake environment async spawnBitbakeProcess (command: string): Promise { - const { shell, script } = this.prepareCommand(command) - const cwd = this.getBuildConfig('workingDirectory') - const shellEnv = this.getBuildConfig('shellEnv') + const { shell, shellEnv, script, workingDirectory } = this.prepareCommand(command) await this.waitForBitbakeToFinish() - logger.debug(`Executing Bitbake command with ${shell} in ${cwd}: ${script}`) + logger.debug(`Executing Bitbake command with ${shell} in ${workingDirectory}: ${script}`) const child = pty.spawn( shell, ['-c', script], { - cwd: typeof(cwd) === 'string' ? cwd : undefined, - env: { ...process.env, ...(typeof shellEnv === 'object' ? shellEnv : {}) } + cwd: workingDirectory, + env: shellEnv } ) this.bitbakeProcess = child @@ -86,7 +84,7 @@ export class BitbakeDriver { } { const shell = process.env.SHELL ?? '/bin/sh' const tempShellEnv = this.getBuildConfig('shellEnv') - const shellEnv = typeof tempShellEnv === 'object' ? tempShellEnv : {} + const shellEnv = {...process.env, ...(typeof tempShellEnv === 'object' ? tempShellEnv : {}) } const script = this.composeBitbakeScript(command) const tempWorkingDirectory = this.getBuildConfig('workingDirectory') const workingDirectory = typeof tempWorkingDirectory === 'string' ? tempWorkingDirectory : '.' diff --git a/client/src/ui/BitbakeTerminalProfile.ts b/client/src/ui/BitbakeTerminalProfile.ts index 9bbef52c..cf2dea89 100644 --- a/client/src/ui/BitbakeTerminalProfile.ts +++ b/client/src/ui/BitbakeTerminalProfile.ts @@ -29,6 +29,7 @@ export class BitbakeTerminalProfileProvider implements vscode.TerminalProfilePro shellPath: shell, shellArgs: ['-c', script], env: shellEnv, + strictEnv: true, cwd: workingDirectory, iconPath: vscode.Uri.file(path.resolve(__dirname, '../../images/yocto-view-icon.svg')) } satisfies vscode.TerminalOptions