# Runs with the target root as the current directory: set up lpm's OpenPGP keyring there
# and (re)import the LE-OS keys, so new and revoked keys take effect on upgrade.
_populate() {
    local root
    root=$(pwd -P)
    if ! lpm key init --root "$root" >/dev/null 2>&1; then
        echo "warning: 'lpm key init' failed (lpm 1.2 or later and gnupg are needed);"
        echo "         run: lpm key init && lpm key populate le-os"
        return 0
    fi
    lpm key populate le-os --root "$root" \
        || echo "warning: 'lpm key populate le-os' failed; run it by hand"
}
post_install() { _populate; }
post_upgrade() { _populate; }
