##################### GENERAL ##################### 
GARNAME = mysql57
GARVERSION = 5.7.26
GARELEASE = 3
HOME_URL = http://mysql.org
CATEGORIES = app/database
MASTER_SITES += https://dev.mysql.com/get/Downloads/MySQL-5.7/
DISTFILES = mysql-boost-$(GARVERSION).tar.gz
PATCHFILES =  
MAINTAINER = Felipe Sanchez <izto@asic-linux.com.mx>
LICENSE = GPL


DESCRIPTION = A dual-license SQL database server (Version 5.7.x).
define BLURB
For the avoidance of doubt, this particular copy of the software
is released under the version 2 of the GNU General Public License.
MySQL is brought to you by Oracle.
endef

##################### PACKAGING #####################


#IZTACI_PACKAGE_PATH =

# Users and groups the binary package will create
# WHEN INSTALLED ON THE DESTINATION SYSTEM
CREATE_GROUPS = mysql:60
CREATE_USERS =  mysql:60:60

# This is to be appended to the package's installation script
# Use it to set file owners, permissions, DB initialization, etc.
# Remember any shell variables (Such as $ROOT) have to be escaped
# like this: \$$ROOT

define DOINST_APPEND
if ! [ -d \$$ROOT/$(MYSQL_DATA_DIR) ]; then
   mkdir -vp \$$ROOT/$(MYSQL_DATA_DIR)
   chown -vR mysql:mysql \$$ROOT/$(MYSQL_DATA_DIR)
fi
echo
echo ------------------------------------------------------------------
echo s6-rc services installed:
echo
echo \"    mysql57-server\"
echo \"    mysql57-log\"
echo \"    mysql57\"
echo
echo Run \'rc update\' to add them to the live services database.
echo
echo ------------------------------------------------------------------
echo If this is a new installation you can initialize your database with:
echo
echo  $(prefix)/libexec/mysqld --initialize --datadir=$(MYSQL_DATA_DIR) --user=mysql
echo
echo Afterwards, start the MySQL server with \'rc up mysql57\' and
echo secure your new MySQL installation:
echo
echo  $(prefix)/bin/mysql_secure_installation
echo
echo ------------------------------------------------------------------
echo
endef

# Required dependencies
define SLACK_REQUIRED
gcc-so | gcc
libaio
libtirpc
ncurses
openssl
zlib
endef

# Suggested dependencies
define SLACK_SUGGESTS
endef

# Package conflicts (lprng vs cups for example)
define SLACK_CONFLICTS
mysql
endef



##################### BUILDING #####################


CONFIGURE_SCRIPTS = custom
BUILD_SCRIPTS = $(BUILD_DIR)/Makefile
INSTALL_SCRIPTS = $(BUILD_DIR)/Makefile

CONFIGURE_ARGS = $(DIRPATHS)
NODIRPATHS = 

# If some dirs are trying to install into /, list their names
# here, such as: prefix bindir mandir
INSTALL_OVERRIDE_DIRS = 

# Directories to be created as part of the install process.
# Can be inside the final package or just transient dirs we need
# while building it.
INSTALL_DIRS += $(DESTDIR)/srv/mysql57
INSTALL_DIRS += $(DESTDIR)/etc/sysconfig
INSTALL_DIRS += $(DESTDIR)/etc/s6-rc/source

# Dependencies are of the form categorydir/packagedir
# LIBDEPS are for libraries, and DEPENDS are for everything else
DEPENDS =
LIBDEPS =
DEPENDS =
# Builddeps are installed in the build DESTIMG
BUILDDEPS += cmake
BUILDDEPS += rpcsvc-proto
BUILDDEPS += git

##################### GAR #####################

# This should go before any hand-made rules.
include config.mk
include ../level.mk

##################### CUSTOMIZING #####################


configure-custom:
	cd $(WORKSRC); cmake $(CMAKE_OPTS)
	$(MAKECOOKIE)

post-install:
	$(MAKE) sysconfig
	$(MAKE) etc-new
	$(MAKE) s6rc
	rm -rf $(DESTDIR)/usr/mysql-test
	$(MAKE) strip
	rm -vf $(DESTDIR)/$(prefix)/lib/*.a
	rm -rf $(DESTDIR)/usr/doc
	$(MAKECOOKIE)
