
# Copy/update time zone database to the /etc hierarchy

cp -Rpf "${packagedir}/${name}"/etc/zoneinfo* etc/

# Delete unneeded .nograft files under etc
find etc/zoneinfo* -type f -name '.nograft' -exec rm -f {} +

# Set default zone info file, default points to 'UTC'

if test -r etc/zoneinfo/UTC
then
    if test -L etc/localtime && test ! -e etc/localtime
    then
        echo "etc/localtime is a dangling symlink, trying to recreate it" 1>&2
        ln -sf zoneinfo/UTC etc/localtime
    elif test ! -e etc/localtime
    then
        ln -s zoneinfo/UTC etc/localtime
    fi
fi

if test ! -e etc/localtime
then
    echo "Setting default time zone to UTC (etc/localtime -> zoneinfo/UTC) ..."
    ln -sf zoneinfo/UTC etc/localtime
fi

# Re-create symlink for "zoneinfo-posix" directory

rm -f etc/zoneinfo-posix
cd etc && ln -sf zoneinfo zoneinfo-posix

