summaryrefslogtreecommitdiffstats
path: root/libalpm/scripts/mkinitcpio-install
blob: 215640b266337d2de30bf81784d7d425b9b4adb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash

args=()
all=0

while read -r line; do
    if [[ $line != */vmlinuz ]]; then
        all=1
        continue
    fi

    pkgbase=$(<"${line%/vmlinuz}/pkgbase")
    [[ -n ${pkgbase} ]]

    preset="/etc/mkinitcpio.d/${pkgbase}.preset"
    if [[ ! -e $preset ]]; then
        sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \
            | install -Dm644 /dev/stdin "$preset"
    fi

    install -Dm644 "${line}" "/boot/vmlinuz-${pkgbase}"
    args+=(-p "${pkgbase}")
done

if (( all )); then
    args=(-P)
fi

if ! compgen -G /etc/mkinitcpio.d/*.preset > /dev/null; then
    exit 0
fi

mkinitcpio "${args[@]}"