# old version (without -$pkgrel): ${1%%-*}
# new version (without -$pkgrel): ${2%%-*}

PKGNAME="ubl-config-overlay"
source /usr/share/makepkg/util/message.sh
colorize

# arg 1:  the new package version
pre_install() {
    true
}

# arg 1:  the new package version
post_install() {
    cd /usr/share/${PKGNAME}
    find * -type d -exec install -dm0755 /{} \;
    find * -type f -exec install -Dm0644 {} /{} \;
    find * -type l -exec cp -af --no-preserve=ownership {} /{} \;

    [[ -f /etc/tor/torrc ]] && find etc/tor/* -type f -name "torrc" -exec chown root:474 "/{}" \;
    [[ -f /etc/ddclient/ddclient.conf ]] && find etc/ddclient/* -type f -name "ddclient.conf" -exec chmod 0600 "/{}" \;
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
    true
}

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
    true
}

# arg 1:  the old package version
pre_remove() {
    msg2 "IMPORTANT!!!"
    msg2 "  The configuration files will not be deleted from the system:"
    cd /usr/share/${PKGNAME}/
    find * -type f -exec msg2 "  /{}" \;
}

# arg 1:  the old package version
post_remove() {
    true
}
