diff --git a/installer/ogboot_installer.py b/installer/ogboot_installer.py index be35769..73966c5 100755 --- a/installer/ogboot_installer.py +++ b/installer/ogboot_installer.py @@ -93,13 +93,6 @@ def check_distribution(): ###:::::::::::::::::::::::::::::: INSTALL ::::::::::::::::::::::::::::::::::### ############################################################################### -def is_installed(package): - try: - subprocess.run(["dpkg", "-s", package], check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) - return True - except subprocess.CalledProcessError: - return False - def get_missing_packages(): global PACKAGES_TO_INSTALL faltantes = [] @@ -120,30 +113,32 @@ def get_missing_packages(): PACKAGES_TO_INSTALL = ["nfs-common", "xorriso", "genisoimage", "syslinux", "liblzma-dev", "nginx", "arp-scan", "automake", "build-essential", "btrfs-progs", "composer", "curl", "ctorrent", "debootstrap", "g++-multilib", "gawk", "gettext", "graphviz", "grub-efi-amd64-signed", "jq", "libdbi-dev", "libdbi1", "libev-dev", "libjansson-dev", "liblz4-tool", "libssl-dev", "moreutils", "netpipes", "php8.3", "php8.3-bcmath", "php8.3-cli", "php8.3-curl", "php8.3-fpm", "php8.3-gd", "php8.3-ldap", "php8.3-mbstring", "php8.3-mysql", "php8.3-common", "php-pear", "php8.3-xml", "php8.3-zip", "procps", "coreutils", "rsync", "samba", "samba-common-bin", "schroot", "shim-signed", "squashfs-tools", "subversion", "tftpd-hpa", "udpcast", "unzip", "wakeonlan", "wget", "xinetd", "jq", "moreutils", "isolinux", "syslinux", "file"] case _: PACKAGES_TO_INSTALL = ["bash", "rsync"] - case "suse": - match OSVERSION: - case "15": - PACKAGES_TO_INSTALL = ["zypper", "mc", "gcc"] - case "12": - PACKAGES_TO_INSTALL = ["perl", "tar", "man"] - case _: - PACKAGES_TO_INSTALL = ["openssl", "ncurses", "zip"] - case "redhat": - match OSVERSION: - case "8": - PACKAGES_TO_INSTALL = ["yum", "tar", "perl"] - case "7": - PACKAGES_TO_INSTALL = ["bash", "rpm", "tcpdump"] - case _: - PACKAGES_TO_INSTALL = ["grep", "sed", "awk"] + #case "suse": + # match OSVERSION: + # case "15": + # PACKAGES_TO_INSTALL = ["zypper", "mc", "gcc"] + # case "12": + # PACKAGES_TO_INSTALL = ["perl", "tar", "man"] + # case _: + # PACKAGES_TO_INSTALL = ["openssl", "ncurses", "zip"] + #case "redhat": + # match OSVERSION: + # case "8": + # PACKAGES_TO_INSTALL = ["yum", "tar", "perl"] + # case "7": + # PACKAGES_TO_INSTALL = ["bash", "rpm", "tcpdump"] + # case _: + # PACKAGES_TO_INSTALL = ["grep", "sed", "awk"] case _: logger.error("Distribution not supported by ogBoot.") exit(1) - for package in PACKAGES_TO_INSTALL: - if not is_installed(package): - faltantes.append(package) - logger.info(f"Package to install: {package}...") + installed = [] + for l in subprocess.run (['dpkg', '-s'] + PACKAGES_TO_INSTALL, capture_output=True, text=True).stdout.splitlines(): + if l.startswith ('Package:'): + installed.append (l.split (':')[1].strip()) + faltantes = list (set(PACKAGES_TO_INSTALL) - set(installed)) + logger.info(f"Packages to install: {faltantes}") return faltantes def install_packages(log_packages_file="/tmp/installed_packages.log"):