diff options
Diffstat (limited to 'recipes-support/mysql/mysql.inc')
-rwxr-xr-x | recipes-support/mysql/mysql.inc | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/recipes-support/mysql/mysql.inc b/recipes-support/mysql/mysql.inc new file mode 100755 index 0000000..c9e3853 --- /dev/null +++ b/recipes-support/mysql/mysql.inc @@ -0,0 +1,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 \ +" |