Skip to content

Commit bfc0d9d

Browse files
committed
feat: Added retry for broken packages
1 parent 33c47ae commit bfc0d9d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codifycli/plugin-core",
3-
"version": "1.1.0-beta23",
3+
"version": "1.1.0-beta24",
44
"description": "TypeScript library for building Codify plugins to manage system resources (applications, CLI tools, settings) through infrastructure-as-code",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",

src/utils/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,24 @@ Brew can be installed using Codify:
225225
}
226226

227227
if (status === SpawnStatus.ERROR) {
228-
throw new Error(`Failed to install package ${packageName} via apt: ${data}`);
228+
// Attempt to fix broken dependencies then retry
229+
const fixResult = await $.spawnSafe('apt-get install -f -y -o Dpkg::Use-Pty=0 -o Dpkg::Progress-Fancy=0', {
230+
requiresRoot: true,
231+
env: { DEBIAN_FRONTEND: 'noninteractive', NEEDRESTART_MODE: 'a' }
232+
});
233+
234+
if (fixResult.status === SpawnStatus.ERROR) {
235+
throw new Error(`Failed to install package ${packageName} via apt: ${data}`);
236+
}
237+
238+
const retryResult = await $.spawnSafe(`apt-get -y -qq install -o Dpkg::Use-Pty=0 -o Dpkg::Progress-Fancy=0 ${packageName}`, {
239+
requiresRoot: true,
240+
env: { DEBIAN_FRONTEND: 'noninteractive', NEEDRESTART_MODE: 'a' }
241+
});
242+
243+
if (retryResult.status === SpawnStatus.ERROR) {
244+
throw new Error(`Failed to install package ${packageName} via apt after fixing dependencies: ${retryResult.data}`);
245+
}
229246
}
230247
}
231248

0 commit comments

Comments
 (0)