summaryrefslogtreecommitdiff
path: root/recipes-support/mysql/mysql.inc
blob: c9e38536318542a60d9651589d000e71e4bfa143 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
SUMMARY = "The world's most popular open source database"
HOMEPAGE = "http://www.mysql.com"
SECTION = "libs"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=751419260aa954499f7abaabaa882bbe"

PROVIDES = "${PN} ${PN}-client ${PN}-server"
# We need certain native tools compiled during the make process, which are not generated for
# the native system during cross compilation. Therefore we also compile the entire package
# for the native system
DEPENDS += "mysql-native"

RDEPENDS_${PN} = "zlib ncurses-libtinfo perl openssl gmock bash libaio"


SRC_URI = "\
    http://downloads.mysql.com/archives/get/file/mysql-5.5.44.tar.gz \
    file://fix-cmake-module-path.patch \
"

SRC_URI[md5sum] = "b897ffd67fab9c981c448fdbe00e36bf"
SRC_URI[sha256sum] = "85f05b257db39e63c82ff4b5ce4e0c6d2b07560b5fc1646d47d7ae48eab3e5de"

S = "${WORKDIR}/mysql-${PV}"

inherit useradd cmake

EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'"

EXTRA_OECMAKE += "\
    -DSTACK_DIRECTION=-1 \
    -DHAVE_LLVM_LIBCPP=OFF \
    \
    -DWITH_SSL=system \
    -DWITH_ARCHIVE_STORAGE_ENGINE=TRUE \
    -DWITH_BLACKHOLE_STORAGE_ENGINE=TRUE \
    -DWITH_FEDERATED_STORAGE_ENGINE=TRUE \
    \
    -DINSTALL_LAYOUT=RPM \
    -DINSTALL_DOCDIR:PATH=${datadir}/doc/${BPN} \
    -DINSTALL_LIBDIR:PATH=${baselib} \
    -DINSTALL_PLUGINDIR:PATH=${baselib}/plugin \
    -DINSTALL_SYSCONFDIR:PATH=${sysconfdir} \
    -DMYSQL_DATADIR:PATH=/var/mysql \
    \
    -DCAT_EXECUTABLE=`which cat` \
    -DAWK_EXECUTABLE=`which awk` \
    -DCMAKE_AR:FILEPATH="${AR}" \
"

do_generate_toolchain_file_append_class-native () {
	# If these are set cmake will assume we're cross-compiling, which will
	# result in certain things we want being disabled
	sed -i "/set( CMAKE_SYSTEM_NAME/d" ${WORKDIR}/toolchain.cmake
	sed -i "/set( CMAKE_SYSTEM_PROCESSOR/d" ${WORKDIR}/toolchain.cmake
}

do_compile_prepend_class-target () {
	# These need to be in-tree or make will think they need to be built,
	# and since we're cross-compiling that is disabled
	cp ${STAGING_BINDIR_NATIVE}/comp_err ${S}/extra
	cp ${STAGING_BINDIR_NATIVE}/comp_sql ${S}/scripts
}

do_install() {
    oe_runmake 'DESTDIR=${D}' install

    mkdir ${D}/etc/
    mkdir ${D}/etc/mysql/
    mkdir ${D}/etc/init.d/
    install -m 500 -o mysql -g mysql ${B}/support-files/my-huge.cnf ${D}/etc/my.cnf
    install -m 700 -o mysql -g mysql ${B}/support-files/mysql.server ${D}/etc/init.d/mysql

#    install -d ${D}/${sysconfdir}/init.d
#    install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/
 #   mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld

#    install -d ${D}${systemd_unitdir}/system
#    install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system
#    sed -i -e 's,@BINDIR@,${bindir},g' -e 's,@PREFIX@,${prefix},g' ${D}${systemd_unitdir}/system/mysqld.service

#    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
#	install -d ${D}${sysconfdir}/tmpfiles.d
#	echo "f /var/log/mysqld.err 0640 mysql mysql -" \
#            > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf
#    fi
}

# useradd setting for mysql user
USERADD_PACKAGES = "${PN}"
USERADD_PARAM_${PN} = "-g mysql --shell /bin/false mysql"
GROUPADD_PARAM_${PN} = "mysql"

# This is run on the first boot of the system, and configures mysql on target
pkg_postinst_${PN} () {

    # Check if this is the first time we're booting
    if [ "x$D" != "x" ]; then
        exit 1
    fi

    exec < /dev/console > /dev/console

    echo "Configuring MySQL"
    
    #Install the database
    mkdir /var/lib/mysql
    chown mysql:mysql /var/lib/mysql

    mysql_install_db --basedir=${prefix} --user=mysql

    # Generate a CA key and certificate with SHA1 digest
    openssl genrsa 2048 > /etc/mysql/ca-key.pem
    openssl req -sha1 -new -x509 -nodes -days 3650 -key ca-key.pem -subj "/C=US/ST=someState/L=Springfield/O=Anoperation/CN=www.awebsite.com" > /etc/mysql/ca-cert.pem

    # Create server key and certficate with SHA1 digest, sign it and convert
    # the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format
    openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout server-key.pem \
         -subj "/C=US/ST=someState/L=Springfield/O=Anoperation/CN=www.awebsite.com" > /etc/mysql/server-req.pem
    openssl x509 -sha1 -req -in server-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > /etc/mysql/server-cert.pem
    openssl rsa -in server-key.pem -out /etc/mysql/server-key.pem

    # Create client key and certificate with SHA digest, sign it and convert
    # the RSA key from PKCS #8 (OpenSSL 1.0 and newer) to the old PKCS #1 format
    openssl req -sha1 -newkey rsa:2048 -days 730 -nodes -keyout client-key.pem \
        -subj "/C=US/ST=someState/L=Springfield/O=Anoperation/CN=www.awebsite.com" > /etc/mysql/client-req.pem
    openssl x509 -sha1 -req -in client-req.pem -days 730 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > /etc/mysql/client-cert.pem
}


FILES_${PN} = "\
    /etc/my.cnf \
    /etc/init.d/mysql \
    /etc/mysql \
    /usr/mysql-test \
    /usr/share/ \
    /usr/bin \
    /usr/sbin \
    /usr/include \
    /usr/sql-bench \
    /usr/lib64 \
    /usr/include/mysql \
"

FILES_${PN}-dbg += "\
    usr/lib/mysql/.debug/ \
    usr/bin/.debug \
    usr/lib64/plugin/.debug \
    /usr/share/mysql-test/lib/My/SafeProcess/.debug \
"