Update file executable_install-program

This commit is contained in:
Brian Zalewski 2023-01-04 03:52:32 +00:00
parent 39d5d8d9fd
commit 703c623820

View file

@ -504,6 +504,7 @@ async function ensurePackage(dep) {
const apk = which.sync('apk', { nothrow: true }) const apk = which.sync('apk', { nothrow: true })
const apt = which.sync('apt-get', { nothrow: true }) const apt = which.sync('apt-get', { nothrow: true })
const dnf = which.sync('dnf', { nothrow: true }) const dnf = which.sync('dnf', { nothrow: true })
const pkg = which.sync('pkg', { nothrow: true })
const yum = which.sync('yum', { nothrow: true }) const yum = which.sync('yum', { nothrow: true })
const pacman = which.sync('pacman', { nothrow: true }) const pacman = which.sync('pacman', { nothrow: true })
const zypper = which.sync('zypper', { nothrow: true }) const zypper = which.sync('zypper', { nothrow: true })
@ -513,28 +514,69 @@ async function ensurePackage(dep) {
if (updateDone['apt-get'] !== true) { if (updateDone['apt-get'] !== true) {
await beforeInstall('apt-get') await beforeInstall('apt-get')
} }
try {
log('info', 'apt-get Installation', `Checking if ${dep} is already installed`)
await $`dpkg -l ${dep} | grep -E '^ii' > /dev/null`
} catch (e) {
log('info', 'apt-get Installation', `Installing ${dep} since it is not already present on the system`)
await $`sudo apt-get install -y ${dep}` await $`sudo apt-get install -y ${dep}`
}
} else if (dnf) { } else if (dnf) {
if (updateDone['dnf'] !== true) { if (updateDone['dnf'] !== true) {
await beforeInstall('dnf') await beforeInstall('dnf')
} }
try {
log('info', 'dnf Installation', `Checking if ${dep} is already installed`)
await $`rpm -qa | grep ${dep} > /dev/null`
} catch (e) {
log('info', 'dnf Installation', `Installing ${dep} since it is not already present on the system`)
await $`sudo dnf install -y ${dep}` await $`sudo dnf install -y ${dep}`
}
} else if (yum) { } else if (yum) {
if (updateDone['yum'] !== true) { if (updateDone['yum'] !== true) {
await beforeInstall('yum') await beforeInstall('yum')
} }
try {
log('info', 'YUM Installation', `Checking if ${dep} is already installed`)
await $`rpm -qa | grep ${dep} > /dev/null`
} catch (e) {
log('info', 'YUM Installation', `Installing ${dep} since it is not already present on the system`)
await $`sudo yum install -y ${dep}` await $`sudo yum install -y ${dep}`
}
} else if (pacman) { } else if (pacman) {
if (updateDone['pacman'] !== true) { if (updateDone['pacman'] !== true) {
await beforeInstall('pacman') await beforeInstall('pacman')
} }
try {
log('info', 'Pacman Installation', `Checking if ${dep} is already installed`)
await $`pacman -Qs ${dep}`
} catch (e) {
log('info', 'Pacman Installation', `Installing ${dep} since it is not already present on the system`)
await $`sudo pacman -Sy ${dep}` await $`sudo pacman -Sy ${dep}`
}
} else if (zypper) { } else if (zypper) {
if (updateDone['zypper'] !== true) { if (updateDone['zypper'] !== true) {
await beforeInstall('zypper') await beforeInstall('zypper')
} }
try {
log('info', 'Zypper Installation', `Checking if ${dep} is already installed`)
await $`rpm -qa | grep ${dep} > /dev/null`
} catch (e) {
log('info', 'Zypper Installation', `Installing ${dep} since it is not already present on the system`)
await $`sudo zypper install -y ${dep}` await $`sudo zypper install -y ${dep}`
} }
} else if (pkg) {
if (updateDone['pkg'] !== true) {
await beforeInstall('pkg')
}
try {
log('info', 'pkg Installation', `Checking if ${dep} is already installed`)
await $`pkg info -Ix ${dep} > /dev/null`
} catch (e) {
log('info', 'pkg Installation', `Installing ${dep} since it is not already present on the system`)
await $`sudo pkg install -y ${dep}`
}
}
} else if (osType === 'darwin') { } else if (osType === 'darwin') {
if (updateDone['brew'] !== true) { if (updateDone['brew'] !== true) {
await beforeInstall('brew') await beforeInstall('brew')
@ -1087,7 +1129,13 @@ async function installPackageList(packageManager, packages) {
if (dnf) { if (dnf) {
for (let pkg of packages) { for (let pkg of packages) {
try { try {
try {
log('info', 'dnf Installation', `Checking if ${pkg} is already installed`)
await $`rpm -qa | grep ${pkg} > /dev/null`
} catch (e) {
log('info', 'dnf Installation', `Installing ${pkg} since it is not already present on the system`)
await $`sudo dnf install -y ${pkg}` await $`sudo dnf install -y ${pkg}`
}
} catch (e) { } catch (e) {
log('error', 'dnf Failure', `There was an error installing ${pkg} with dnf`) log('error', 'dnf Failure', `There was an error installing ${pkg} with dnf`)
} }
@ -1095,7 +1143,13 @@ async function installPackageList(packageManager, packages) {
} else if (yum) { } else if (yum) {
for (let pkg of packages) { for (let pkg of packages) {
try { try {
try {
log('info', 'YUM Installation', `Checking if ${pkg} is already installed`)
await $`rpm -qa | grep ${pkg} > /dev/null`
} catch (e) {
log('info', 'YUM Installation', `Installing ${pkg} since it is not already present on the system`)
await $`sudo yum install -y ${pkg}` await $`sudo yum install -y ${pkg}`
}
} catch (e) { } catch (e) {
log('error', 'yum Failure', `There was an error installing ${pkg} with yum`) log('error', 'yum Failure', `There was an error installing ${pkg} with yum`)
} }
@ -1137,7 +1191,13 @@ async function installPackageList(packageManager, packages) {
} else if (packageManager === 'pacman') { } else if (packageManager === 'pacman') {
for (let pkg of packages) { for (let pkg of packages) {
try { try {
await $`sudo pacman -Sy --noconfirm --needed ${pkg}` try {
log('info', 'Pacman Installation', `Checking if ${pkg} is already installed`)
await $`pacman -Qs ${pkg}`
} catch (e) {
log('info', 'Pacman Installation', `Installing ${pkg} since it is not already present on the system`)
await $`sudo pacman -Sy --noconfirm --needed ${dep}`
}
} catch (e) { } catch (e) {
log('error', 'Pacman Failure', `There was an error installing ${pkg} with pacman`) log('error', 'Pacman Failure', `There was an error installing ${pkg} with pacman`)
} }
@ -1227,7 +1287,13 @@ async function installPackageList(packageManager, packages) {
} else if (packageManager === 'zypper') { } else if (packageManager === 'zypper') {
for (let pkg of packages) { for (let pkg of packages) {
try { try {
await $`sudo zypper install -y ${packages}` try {
log('info', 'Zypper Installation', `Checking if ${pkg} is already installed`)
await $`rpm -qa | grep ${pkg} > /dev/null`
} catch (e) {
log('info', 'Zypper Installation', `Installing ${pkg} since it is not already present on the system`)
await $`sudo zypper install -y ${pkg}`
}
} catch (e) { } catch (e) {
log('error', 'Zypper Failure', `There was an error installing ${pkg} with zypper`) log('error', 'Zypper Failure', `There was an error installing ${pkg} with zypper`)
} }