Skip to content

Commit 85f55bc

Browse files
committed
Wrapping dnf commands in sudo
1 parent 239556b commit 85f55bc

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

packages/compass-smoke-tests/src/installers/linux-rpm.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,30 @@ import { execute } from '../execute';
99
* Call dnf to get the package name
1010
*/
1111
function getPackageName(filepath: string) {
12-
const result = cp.spawnSync(
13-
'dnf',
14-
['repoquery', '--queryformat', '%{NAME}', filepath],
12+
const { status, stdout, stderr } = cp.spawnSync(
13+
'rpm',
14+
['--query', '--queryformat', '%{NAME}', '--package', filepath],
1515
{ encoding: 'utf8' }
1616
);
1717
assert.equal(
18-
result.status,
18+
status,
1919
0,
20-
`Expected a clean exit, got status ${result.status || 'null'}`
20+
`Expected a clean exit, got status ${status || 'null'}: ${stderr}`
2121
);
22-
return result.stdout.trim();
22+
return stdout.trim();
2323
}
2424

2525
/**
2626
* Check if a package is installed (by name)
2727
*/
2828
export function isInstalled(packageName: string) {
29-
const result = cp.spawnSync('dnf', ['list', 'installed', packageName], {
30-
stdio: 'inherit',
31-
});
29+
const result = cp.spawnSync(
30+
'sudo',
31+
['dnf', 'list', 'installed', packageName],
32+
{
33+
stdio: 'inherit',
34+
}
35+
);
3236
return result.status === 0;
3337
}
3438

@@ -41,7 +45,7 @@ export function installLinuxRpm({
4145
const appPath = path.resolve(installPath, appName);
4246

4347
function uninstall() {
44-
execute('dnf', ['dnf', 'remove', '-y', packageName]);
48+
execute('sudo', ['dnf', 'remove', '-y', packageName]);
4549
}
4650

4751
if (isInstalled(packageName)) {
@@ -59,7 +63,7 @@ export function installLinuxRpm({
5963
!fs.existsSync(installPath),
6064
`Expected no install directory to exist: ${installPath}`
6165
);
62-
execute('dnf', ['install', '-y', filepath]);
66+
execute('sudo', ['dnf', 'install', '-y', filepath]);
6367

6468
assert(isInstalled(packageName), 'Expected the package to be installed');
6569
assert(
@@ -68,7 +72,7 @@ export function installLinuxRpm({
6872
);
6973

7074
// Check that the executable will run without being quarantined or similar
71-
execute('xvfb-run', [appPath, '--version', '--no-sandbox']); // Remove '--no-sandbox' if we don't plan on running this as root
75+
execute('xvfb-run', [appPath, '--version']);
7276

7377
return {
7478
appPath: installPath,

0 commit comments

Comments
 (0)