##################### GENERAL ##################### 
GARNAME = mysql
GARVERSION = 8.0.16
GARELEASE = 3
HOME_URL = https://mysql.org
CATEGORIES = app/database
MASTER_SITES += https://dev.mysql.com/get/Downloads/MySQL-8.0/
MASTER_SITES += https://dl.bintray.com/boostorg/release/1.69.0/source/
DISTFILES = mysql-$(GARVERSION).tar.gz boost_$(BOOST_VERSION).tar.bz2
PATCHFILES = s6_notification.patch
MAINTAINER = Felipe Sanchez <izto@asic-linux.com.mx>
LICENSE = GPL


DESCRIPTION = A dual-license SQL database server
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 \"    mysql-server\"
echo \"    mysql-log\"
echo \"    mysql\"
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 mysql\' 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
mysql57
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)/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 rpcsvc-proto git perl

##################### 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)
