Update file executable_install-program

This commit is contained in:
Brian Zalewski 2023-01-09 12:30:16 +00:00
parent bd33a990fd
commit 3fd1142b20

View file

@ -579,10 +579,16 @@ async function ensurePackage(dep) {
} }
try { try {
log('info', 'apt-get Installation', `Checking if ${dep} is already installed`) log('info', 'apt-get Installation', `Checking if ${dep} is already installed`)
runCommand(`Checking if ${dep} is already installed via apt-get`, `dpkg -l ${dep} | grep -E '^ii' > /dev/null`) runCommand(
`Checking if ${dep} is already installed via apt-get`,
`dpkg -l ${dep} | grep -E '^ii' > /dev/null`
)
log('info', 'Filter', `${pkg} already installed via apt-get`) log('info', 'Filter', `${pkg} already installed via apt-get`)
} catch (e) { } catch (e) {
runCommand(`Installing ${dep} via apt-get`, `sudo apt-get -o DPkg::Options::=--force-confdef install -y ${dep}`) runCommand(
`Installing ${dep} via apt-get`,
`sudo apt-get -o DPkg::Options::=--force-confdef install -y ${dep}`
)
log('success', 'Install', `Successfully installed ${pkg} via apt-get`) log('success', 'Install', `Successfully installed ${pkg} via apt-get`)
} }
} else if (dnf) { } else if (dnf) {
@ -661,7 +667,7 @@ async function beforeInstall(packageManager) {
updateDone[packageManager] = true updateDone[packageManager] = true
const logStage = 'Pre-Install Package Manager' const logStage = 'Pre-Install Package Manager'
if (packageManager === 'appimage') { if (packageManager === 'appimage') {
if(!fileExists(`${process.env.HOME}/Applications)) { if (!fileExists(`${process.env.HOME}/Applications`)) {
runSilentCommand(`mkdir -p "${process.env.HOME}/Applications"`) runSilentCommand(`mkdir -p "${process.env.HOME}/Applications"`)
} }
} else if (packageManager === 'ansible') { } else if (packageManager === 'ansible') {
@ -937,7 +943,10 @@ async function ensurePackageManager(packageManager) {
} else if (apt) { } else if (apt) {
runCommand('Installing flatpak via apt-get', 'sudo apt-get install -y flatpak') runCommand('Installing flatpak via apt-get', 'sudo apt-get install -y flatpak')
if (fileExists('/usr/bin/gnome-shell')) { if (fileExists('/usr/bin/gnome-shell')) {
runCommand('Installing gnome-software-plugin-flatpak via apt-get', 'sudo apt-get install -y gnome-software-plugin-flatpak') runCommand(
'Installing gnome-software-plugin-flatpak via apt-get',
'sudo apt-get install -y gnome-software-plugin-flatpak'
)
} }
if (fileExists('/usr/bin/plasmashell')) { if (fileExists('/usr/bin/plasmashell')) {
runCommand('Installing plasmashell via apt-get', 'sudo apt-get install -y plasmashell') runCommand('Installing plasmashell via apt-get', 'sudo apt-get install -y plasmashell')
@ -1154,7 +1163,10 @@ async function installPackageList(packageManager, packages) {
} else if (packageManager === 'apt') { } else if (packageManager === 'apt') {
for (let pkg of packages) { for (let pkg of packages) {
try { try {
runCommand(`Installing ${pkg} via ${packageManager}`, `sudo apt-get -o DPkg::Options::=--force-confdef install -y ${pkg}`) runCommand(
`Installing ${pkg} via ${packageManager}`,
`sudo apt-get -o DPkg::Options::=--force-confdef install -y ${pkg}`
)
log('success', 'Install', `${pkg} successfully installed via ${packageManager}`) log('success', 'Install', `${pkg} successfully installed via ${packageManager}`)
} catch (e) { } catch (e) {
log('error', 'Install Failure', `There was an error installing ${pkg} with apt-get`) log('error', 'Install Failure', `There was an error installing ${pkg} with apt-get`)
@ -1173,7 +1185,7 @@ async function installPackageList(packageManager, packages) {
} else if (packageManager === 'binary') { } else if (packageManager === 'binary') {
for (let pkg of packages) { for (let pkg of packages) {
try { try {
const bins = installData.softwarePackages.filter(x => x.appimage === pkg) const bins = installData.softwarePackages.filter((x) => x.appimage === pkg)
if (bins && bins[0]) { if (bins && bins[0]) {
const binName = bins[0]['_bin'] const binName = bins[0]['_bin']
await $`TMP="$(mktemp)" && curl -sSL ${pkg} > "$TMP" && sudo mv "$TMP" /usr/local/src/${binName} && chmod +x /usr/local/src/${binName}` await $`TMP="$(mktemp)" && curl -sSL ${pkg} > "$TMP" && sudo mv "$TMP" /usr/local/src/${binName} && chmod +x /usr/local/src/${binName}`
@ -1452,9 +1464,9 @@ async function updateService(service) {
* Filter that resolves when all asynchronous filter actions are done * Filter that resolves when all asynchronous filter actions are done
*/ */
const asyncFilter = async (arr, predicate) => { const asyncFilter = async (arr, predicate) => {
const results = await Promise.all(arr.map(predicate)); const results = await Promise.all(arr.map(predicate))
return arr.filter((_v, index) => results[index]); return arr.filter((_v, index) => results[index])
} }
async function pruneInstallOrders(installOrders) { async function pruneInstallOrders(installOrders) {
@ -1486,7 +1498,7 @@ async function pruneInstallOrders(installOrders) {
for (const pkg of newOrders[pkgManager]) { for (const pkg of newOrders[pkgManager]) {
try { try {
runCommand(`Ensuring Homebrew package is not already installed - ${pkg}`, `brew list ${pkg}`) runCommand(`Ensuring Homebrew package is not already installed - ${pkg}`, `brew list ${pkg}`)
newVal = newVal.filter(x => x === pkg) newVal = newVal.filter((x) => x === pkg)
} catch (e) { } catch (e) {
// Do nothing // Do nothing
} }
@ -1579,17 +1591,23 @@ async function linkBin(installOrdersBinLink) {
if (!which.sync(binLink.bin, { nothrow: true })) { if (!which.sync(binLink.bin, { nothrow: true })) {
if (binLink.preference === 'flatpak' && flatpak) { if (binLink.preference === 'flatpak' && flatpak) {
try { try {
runCommand(`Adding bin link for ${pkg} (${binLink.bin})`, `bash -c 'test -d ${flatpakDir}/app/${pkg} && mkdir -p "${process.env.HOME}/.local/bin/flatpak" && echo "flatpak run ${pkg} \"$*\"" > "${process.env.HOME}/.local/bin/flatpak/${binLink.bin}" && chmod +x "${process.env.HOME}/.local/bin/flatpak/${binLink.bin}"'`) runCommand(
`Adding bin link for ${pkg} (${binLink.bin})`,
`bash -c 'test -d ${flatpakDir}/app/${pkg} && mkdir -p "${process.env.HOME}/.local/bin/flatpak" && echo "flatpak run ${pkg} \"$*\"" > "${process.env.HOME}/.local/bin/flatpak/${binLink.bin}" && chmod +x "${process.env.HOME}/.local/bin/flatpak/${binLink.bin}"'`
)
log('success', 'Bin', `Linked ~/.local/bin/flatpak/${binLink.bin} to the ${pkg} Flatpak`) log('success', 'Bin', `Linked ~/.local/bin/flatpak/${binLink.bin} to the ${pkg} Flatpak`)
} catch (e) { } catch (e) {
log('warn', 'Bin', `Expected flatpak directory not available - ${flatpakDir}/app/${pkg}`) log('warn', 'Bin', `Expected flatpak directory not available - ${flatpakDir}/app/${pkg}`)
} }
} else if (binLink.preference === 'cask') { } else if (binLink.preference === 'cask') {
try { try {
const caskWhen = softwarePackages[binLink.package]["_when:cask"] const caskWhen = softwarePackages[binLink.package]['_when:cask']
const caskDir = caskWhen.replace('! test -d ', '').replace(/"/g, '') const caskDir = caskWhen.replace('! test -d ', '').replace(/"/g, '')
if (fileExists(caskDir)) { if (fileExists(caskDir)) {
runCommand(`Adding shortcut bin link for ${binLink.package}`, `bash -c 'mkdir -p "${process.env.HOME}/.local/bin/cask" && echo "open ${caskDir}" > "${process.env.HOME}/.local/bin/cask/${binLink.bin}" && chmod +x "${process.env.HOME}/.local/bin/cask/${binLink.bin}"'`) runCommand(
`Adding shortcut bin link for ${binLink.package}`,
`bash -c 'mkdir -p "${process.env.HOME}/.local/bin/cask" && echo "open ${caskDir}" > "${process.env.HOME}/.local/bin/cask/${binLink.bin}" && chmod +x "${process.env.HOME}/.local/bin/cask/${binLink.bin}"'`
)
} else { } else {
log('warn', 'Bin', `Expected Homebrew cask directory not found - ${pkg}`) log('warn', 'Bin', `Expected Homebrew cask directory not found - ${pkg}`)
} }
@ -1617,11 +1635,7 @@ async function installSoftware(pkgsToInstall) {
installData = await downloadInstallData() installData = await downloadInstallData()
log('info', 'Filter', `Calculating the install orders`) log('info', 'Filter', `Calculating the install orders`)
await generateInstallOrders(pkgsToInstall ? pkgsToInstall : process.argv.slice(3)) await generateInstallOrders(pkgsToInstall ? pkgsToInstall : process.argv.slice(3))
log( log('info', 'Pre-Reqs', `Ensuring any package managers that will be used are installed / configured`)
'info',
'Pre-Reqs',
`Ensuring any package managers that will be used are installed / configured`
)
const packageManagers = Object.keys(installOrders) const packageManagers = Object.keys(installOrders)
for (const packageManager of packageManagers) { for (const packageManager of packageManagers) {
await ensurePackageManager(packageManager) await ensurePackageManager(packageManager)