File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,7 +21,11 @@ self_hosted_helper() {
2121 trap " sudo rm -f /usr/bin/apt-fast 2>/dev/null" exit
2222 fi
2323 sudo mkdir -p /opt/hostedtoolcache > /dev/null 2>&1 || true
24- install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
24+ local packages=()
25+ mapfile -t packages < <( filter_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg)
26+ if [ " ${# packages[@]} " -gt 0 ]; then
27+ install_packages " ${packages[@]} "
28+ fi
2529}
2630
2731# Function to fix broken packages.
@@ -90,6 +94,21 @@ check_package() {
9094 apt-cache policy " $1 " 2> /dev/null | grep -q ' Candidate'
9195}
9296
97+ # Function to filter out installed packages
98+ filter_packages () {
99+ [ " $# " -gt 0 ] || return 0
100+ local package architecture status
101+ local -A installed=()
102+ while IFS=$' \t ' read -r package architecture status; do
103+ [[ " $status " = [ih]' i ' ]] && status=1 || status=0
104+ installed[" $package " ]=$(( ${installed["$package"]:- 1} && status ))
105+ installed[" $package :$architecture " ]=$status
106+ done < <( dpkg-query -W -f=' ${Package}\t${Architecture}\t${db:Status-Abbrev}\n' -- " $@ " 2> /dev/null)
107+ for package in " $@ " ; do
108+ [ " ${installed[$package]:- 0} " -eq 1 ] || printf ' %s\n' " $package "
109+ done
110+ }
111+
93112# Helper function to add an extension.
94113add_extension_helper () {
95114 local extension=$1
You can’t perform that action at this time.
0 commit comments