summaryrefslogtreecommitdiffstats
path: root/mkosi.conf.d/10-debian-ubuntu/mkosi.prepare
blob: ffff10d2a4288cb132b12d22a372a6f5c2e8ed75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e

if [[ "$1" == "build" ]]; then
    exit 0
fi

mapfile -t PACKAGES < <(jq --raw-output .VolatilePackages[] <"$MKOSI_CONFIG")

apt-cache depends "${PACKAGES[@]}" |
    grep --invert-match --regexp "<" --regexp "|" | # Remove e.g. <python3:any> and |dbus-broker like results
    grep --extended-regexp --invert-match --regexp "$(IFS=\| ; echo "${PACKAGES[*]}")" |
    grep --extended-regexp "Depends|Suggests|Recommends" |
    sed --quiet 's/.*: //p' | # Get every line with ": " in it and strip it at the same time.
    sort --unique |
    xargs --delimiter '\n' --no-run-if-empty mkosi-install