Install an arbitrary package name inside a distro (best-effort). Returns tracking id or None.
(cfg: Dict, distro: str, pkg: str)
| 1187 | return pkg |
| 1188 | |
| 1189 | def install_custom_package(cfg: Dict, distro: str, pkg: str) -> Optional[str]: |
| 1190 | """Install an arbitrary package name inside a distro (best-effort). Returns tracking id or None.""" |
| 1191 | pkg = _validate_pkg_name(pkg) |
| 1192 | if not pkg: |
| 1193 | print(tr(cfg, "invalid")) |
| 1194 | return None |
| 1195 | |
| 1196 | family = detect_family(distro) |
| 1197 | if family == "debian": |
| 1198 | cmd = f"apt-get update -y && apt-get install -y {pkg}" |
| 1199 | elif family == "arch": |
| 1200 | cmd = f"pacman -Syu --noconfirm || true; pacman -S --noconfirm {pkg}" |
| 1201 | elif family == "alpine": |
| 1202 | cmd = f"apk update && apk add {pkg}" |
| 1203 | elif family == "fedora": |
| 1204 | cmd = f"dnf -y upgrade || true; dnf -y install {pkg}" |
| 1205 | elif family == "suse": |
| 1206 | cmd = f"zypper --non-interactive refresh || true; zypper --non-interactive install {pkg}" |
| 1207 | elif family == "void": |
| 1208 | cmd = f"xbps-install -Suy || true; xbps-install -y {pkg}" |
| 1209 | else: |
| 1210 | print(tr(cfg, "programs_not_supported")) |
| 1211 | return None |
| 1212 | |
| 1213 | print(f"{tr(cfg,'programs_installing')} {pkg}") |
| 1214 | run(proot_login_cmd(distro, cmd), check=False) |
| 1215 | |
| 1216 | pid = f"pkg:{pkg}" |
| 1217 | mark_program_installed(cfg, distro, pid, True) |
| 1218 | print(tr(cfg, "programs_done")) |
| 1219 | return pid |
| 1220 | |
| 1221 | def remove_custom_package(cfg: Dict, distro: str, pkg: str) -> None: |
| 1222 | pkg = _validate_pkg_name(pkg) |
no test coverage detected