diff --git a/index.js b/index.js index 13c3528..61ed79a 100644 --- a/index.js +++ b/index.js @@ -3,20 +3,17 @@ const exec = require('@actions/exec'); const core = require('@actions/core') -async function start() { - await exec.exec("sudo su -c \"echo 'deb http://archive.ubuntu.com/ubuntu/ lunar universe' > /etc/apt/sources.list.d/lunar.list\""); - await exec.exec("sudo su -c \"echo 'deb-src http://archive.ubuntu.com/ubuntu/ lunar universe' >> /etc/apt/sources.list.d/lunar.list\""); - +async function installPkg(pkgname) { let attempts = 0; - while (true) { try { await exec.exec("sudo apt update -y"); - await exec.exec("sudo apt install pacman-package-manager -y"); + await exec.exec("sudo apt install " + pkgname + " -y"); break; } catch (error) { - if (attempts > 2) { + if (attempts > 3) { core.setFailed("Something went wrong :/"); + break; } attempts += 1; continue; @@ -24,4 +21,13 @@ async function start() { } } +async function start() { + installPkg("libarchive-tools"); + + await exec.exec("sudo su -c \"echo 'deb http://archive.ubuntu.com/ubuntu/ lunar universe' > /etc/apt/sources.list.d/lunar.list\""); + await exec.exec("sudo su -c \"echo 'deb-src http://archive.ubuntu.com/ubuntu/ lunar universe' >> /etc/apt/sources.list.d/lunar.list\""); + + installPkg("pacman-package-manager"); +} + start();