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

PKGNAME="ublinux-init"
DATA_FILE_CONF="ublinux*ini"

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

# arg 1:  the new package version
post_install() {
    post_upgrade $@
}

# 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() {
    if [[ ! ${LC_ALL:-${LC_CTYPE:-$LANG}} == "en_US.UTF-8" ]]; then
	[[ -n $(/usr/bin/ubconfig --raw --source system get [locale] LANG) ]] || /usr/bin/ubconfig --target global --noexecute set [locale] LANG="${LC_ALL:-${LC_CTYPE:-$LANG}}"
	[[ -n $(/usr/bin/ubconfig --raw --source system get [locale] LOCALE) ]] || /usr/bin/ubconfig --target global --noexecute set [locale] LOCALE="en_US.UTF-8,${LC_ALL:-${LC_CTYPE:-$LANG}}"
    fi
    [[ -w $(find /memory/layer-base/ -maxdepth 2 -path "*" -name "${DATA_FILE_CONF}" | tail -1 2>/dev/null) ]] && /usr/bin/ubconfig update || true
}

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

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