config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

# Keep same perms on rc.mysqld.new:
if [ -e etc/rc.d/rc.mysqld ]; then
  cp -a etc/rc.d/rc.mysqld etc/rc.d/rc.mysqld.new.incoming
  cat etc/rc.d/rc.mysqld.new > etc/rc.d/rc.mysqld.new.incoming
  mv etc/rc.d/rc.mysqld.new.incoming etc/rc.d/rc.mysqld.new
fi

config etc/rc.d/rc.mysqld.new
config etc/mysqlaccess.conf.new
config etc/my.cnf.new
config etc/my.cnf.d/client.cnf.new
config etc/my.cnf.d/mysql-clients.cnf.new
config etc/my.cnf.d/server.cnf.new
config etc/logrotate.d/mysql.new

# Not supported in every $ARCH:
if [ -r etc/my.cnf.d/tokudb.cnf.new ]; then
  config etc/my.cnf.d/tokudb.cnf.new
fi

( cd usr/bin ; rm -rf mariadb )
( cd usr/bin ; ln -sf mysql mariadb )
( cd usr/bin ; rm -rf mariadb-access )
( cd usr/bin ; ln -sf mysqlaccess mariadb-access )
( cd usr/bin ; rm -rf mariadb-admin )
( cd usr/bin ; ln -sf mysqladmin mariadb-admin )
( cd usr/bin ; rm -rf mariadb-backup )
( cd usr/bin ; ln -sf mariabackup mariadb-backup )
( cd usr/bin ; rm -rf mariadb-binlog )
( cd usr/bin ; ln -sf mysqlbinlog mariadb-binlog )
( cd usr/bin ; rm -rf mariadb-check )
( cd usr/bin ; ln -sf mysqlcheck mariadb-check )
( cd usr/bin ; rm -rf mariadb-client-test )
( cd usr/bin ; ln -sf mysql_client_test mariadb-client-test )
( cd usr/bin ; rm -rf mariadb-client-test-embedded )
( cd usr/bin ; ln -sf mysql_client_test_embedded mariadb-client-test-embedded )
( cd usr/bin ; rm -rf mariadb-convert-table-format )
( cd usr/bin ; ln -sf mysql_convert_table_format mariadb-convert-table-format )
( cd usr/bin ; rm -rf mariadb-dump )
( cd usr/bin ; ln -sf mysqldump mariadb-dump )
( cd usr/bin ; rm -rf mariadb-dumpslow )
( cd usr/bin ; ln -sf mysqldumpslow mariadb-dumpslow )
( cd usr/bin ; rm -rf mariadb-embedded )
( cd usr/bin ; ln -sf mysql_embedded mariadb-embedded )
( cd usr/bin ; rm -rf mariadb-find-rows )
( cd usr/bin ; ln -sf mysql_find_rows mariadb-find-rows )
( cd usr/bin ; rm -rf mariadb-fix-extensions )
( cd usr/bin ; ln -sf mysql_fix_extensions mariadb-fix-extensions )
( cd usr/bin ; rm -rf mariadb-hotcopy )
( cd usr/bin ; ln -sf mysqlhotcopy mariadb-hotcopy )
( cd usr/bin ; rm -rf mariadb-import )
( cd usr/bin ; ln -sf mysqlimport mariadb-import )
( cd usr/bin ; rm -rf mariadb-install-db )
( cd usr/bin ; ln -sf mysql_install_db mariadb-install-db )
( cd usr/bin ; rm -rf mariadb-ldb )
( cd usr/bin ; ln -sf mysql_ldb mariadb-ldb )
( cd usr/bin ; rm -rf mariadb-plugin )
( cd usr/bin ; ln -sf mysql_plugin mariadb-plugin )
( cd usr/bin ; rm -rf mariadb-secure-installation )
( cd usr/bin ; ln -sf mysql_secure_installation mariadb-secure-installation )
( cd usr/bin ; rm -rf mariadb-setpermission )
( cd usr/bin ; ln -sf mysql_setpermission mariadb-setpermission )
( cd usr/bin ; rm -rf mariadb-show )
( cd usr/bin ; ln -sf mysqlshow mariadb-show )
( cd usr/bin ; rm -rf mariadb-slap )
( cd usr/bin ; ln -sf mysqlslap mariadb-slap )
( cd usr/bin ; rm -rf mariadb-test )
( cd usr/bin ; ln -sf mysqltest mariadb-test )
( cd usr/bin ; rm -rf mariadb-test-embedded )
( cd usr/bin ; ln -sf mysqltest_embedded mariadb-test-embedded )
( cd usr/bin ; rm -rf mariadb-tzinfo-to-sql )
( cd usr/bin ; ln -sf mysql_tzinfo_to_sql mariadb-tzinfo-to-sql )
( cd usr/bin ; rm -rf mariadb-upgrade )
( cd usr/bin ; ln -sf mysql_upgrade mariadb-upgrade )
( cd usr/bin ; rm -rf mariadb-waitpid )
( cd usr/bin ; ln -sf mysql_waitpid mariadb-waitpid )
( cd usr/bin ; rm -rf mariadbd-multi )
( cd usr/bin ; ln -sf mysqld_multi mariadbd-multi )
( cd usr/bin ; rm -rf mariadbd-safe )
( cd usr/bin ; ln -sf mysqld_safe mariadbd-safe )
( cd usr/bin ; rm -rf mariadbd-safe-helper )
( cd usr/bin ; ln -sf mysqld_safe_helper mariadbd-safe-helper )
( cd usr/bin ; rm -rf wsrep_sst_rsync_wan )
( cd usr/bin ; ln -sf wsrep_sst_rsync wsrep_sst_rsync_wan )
( cd usr/lib64 ; rm -rf libmariadb.so )
( cd usr/lib64 ; ln -sf libmariadb.so.3 libmariadb.so )
( cd usr/lib64 ; rm -rf libmariadbd.so )
( cd usr/lib64 ; ln -sf libmariadbd.so.19 libmariadbd.so )
( cd usr/lib64 ; rm -rf libmysqlclient.so )
( cd usr/lib64 ; ln -sf libmariadb.so.3 libmysqlclient.so )
( cd usr/lib64 ; rm -rf libmysqlclient_r.so )
( cd usr/lib64 ; ln -sf libmariadb.so.3 libmysqlclient_r.so )
( cd usr/lib64 ; rm -rf libmysqld.so )
( cd usr/lib64 ; ln -sf libmariadbd.so.19 libmysqld.so )
( cd usr/libexec ; rm -rf mariadbd )
( cd usr/libexec ; ln -sf mysqld mariadbd )
