Skip to content

Commit 5ea4e95

Browse files
committed
Improve speed of package ordering
1 parent a948460 commit 5ea4e95

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

package/toltec-bootstrap/toltecctl

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,18 +309,17 @@ reenable() {
309309
# its dependencies. Dependency cycles are broken arbitrarily
310310
list-installed-ordered() {
311311
# shellcheck disable=SC2016
312-
local awk_trim='NR>1 {print gensub(/^[ \t]+|[ \t]+$/, "", "g", $0);}'
313-
314-
opkg list-installed | awk -F' - ' '{print $1}' | while read -r srcpkg; do
315-
# Make sure all packages are included even when they don’t have
316-
# any dependencies
317-
echo "$srcpkg $srcpkg"
318-
319-
# List all dependencies for this package
320-
opkg depends "$srcpkg" | awk "$awk_trim" | while read -r dstpkg; do
321-
echo "$srcpkg $dstpkg"
322-
done
323-
done | tsort 2> /dev/null || true
312+
local awk_list_to_graph='
313+
/^.* depends on:$/{
314+
from=$1;
315+
print from " " from;
316+
}
317+
318+
/^\t/{
319+
print from " " $1;
320+
}
321+
'
322+
opkg depends '*' | awk "$awk_list_to_graph" | tsort 2> /dev/null || true
324323
# tsort reports errors if there are dependency cycles, we ignore them
325324
}
326325

@@ -338,7 +337,6 @@ uninstall() {
338337
chmod u+x "$opkg_path"
339338

340339
# Remove installed packages in reverse dependency order
341-
echo "Collecting installed packages"
342340
list-installed-ordered | while read -r pkgname; do
343341
"$opkg_path" remove --force-depends --force-remove "$pkgname"
344342
done

0 commit comments

Comments
 (0)