Ticket #52144: 0001-mariadb-server-support-mpkg-mdmg-packaging-with-scri.patch

File 0001-mariadb-server-support-mpkg-mdmg-packaging-with-scri.patch, 4.2 KB (added by ctreleaven (Craig Treleaven), 8 years ago)
  • databases/mariadb/Portfile

    From 6a757fc7c7118d187cf66f82fd5c71b0959b242f Mon Sep 17 00:00:00 2001
    From: Craig Treleaven <ctreleaven@macports.org>
    Date: Mon, 16 Jan 2017 14:29:49 -0500
    Subject: [PATCH] mariadb-server: support mpkg/mdmg packaging with scripts to
     automatically instantiate and start the deployed server.  Refs #52144
    
    ---
     databases/mariadb/Portfile          | 20 ++++++++++++++++++++
     databases/mariadb/files/postinstall | 37 +++++++++++++++++++++++++++++++++++++
     databases/mariadb/files/preinstall  |  9 +++++++++
     3 files changed, 66 insertions(+)
     create mode 100755 databases/mariadb/files/postinstall
     create mode 100644 databases/mariadb/files/preinstall
    
    diff --git a/databases/mariadb/Portfile b/databases/mariadb/Portfile
    index 78a5fee026..3c30bfaca7 100644
    a b subport ${name_mysql}-server { 
    259259            ${destroot}${prefix}/var/run/${name_mysql}
    260260    }
    261261
     262    pre-pkg {
     263        xinstall -m 0755 ${filespath}/preinstall ${filespath}/postinstall \
     264            ${package.scripts}/
     265        reinplace -locale C "s|@SUBPORT@|${subport}|g" \
     266            ${package.scripts}/preinstall ${package.scripts}/postinstall
     267        reinplace -locale C "s|@NAMEMYSQL@|${name_mysql}|g" \
     268            ${package.scripts}/preinstall ${package.scripts}/postinstall
     269        reinplace -locale C "s|@PREFIX@|${prefix}|g" \
     270            ${package.scripts}/preinstall ${package.scripts}/postinstall
     271        reinplace -locale C "s|@USER@|${mysqluser}|g" \
     272            ${package.scripts}/postinstall
     273
     274        # give installer splash screen a friendly message
     275        long_description \
     276            MariaDB is a fast, scalable and robust relational database providing an SQL \
     277            interface for accessing structured data and is made by the original developers \
     278            of MySQL.  Install prefix: ${prefix}
     279
     280    }
     281
    262282    notes "
    263283If this is a new install you might want to run:
    264284
  • new file databases/mariadb/files/postinstall

    diff --git a/databases/mariadb/files/postinstall b/databases/mariadb/files/postinstall
    new file mode 100755
    index 0000000000..938cfb2d9b
    - +  
     1#!/bin/sh
     2
     3# MariaDB installer support, postinstall script
     4# runs as root after installer successfully copies payload to destination
     5# Adapted from https://github.com/MariaDB/server/blob/5.5/support-files/MacOSX/postflight.sh
     6
     7# Have experienced cases where installed directories/files have different
     8# ownership or permissions than what was fed to PackageMaker.
     9# Just use blunt force to set the required permissions
     10
     11chmod 644 @PREFIX@/etc/LaunchDaemons/org.macports.@SUBPORT@/org.macports.@SUBPORT@.plist || exit 1
     12if [ -f /Library/LaunchDaemons/org.macports.@SUBPORT@.plist ] ; then
     13   rm /Library/LaunchDaemons/org.macports.@SUBPORT@.plist
     14fi
     15ln -s @PREFIX@/etc/LaunchDaemons/org.macports.@SUBPORT@/org.macports.@SUBPORT@.plist \
     16    /Library/LaunchDaemons/org.macports.@SUBPORT@.plist || exit 1
     17
     18chown _mysql:_mysql @PREFIX@/var/run/@NAMEMYSQL@ || exit 1
     19chown _mysql:_mysql @PREFIX@/var/db/@NAMEMYSQL@ || exit 1
     20chown _mysql:_mysql @PREFIX@/var/log/@NAMEMYSQL@ || exit 1
     21
     22
     23# standard mysql initialization
     24if [ ! -f @PREFIX@/var/db/@NAMEMYSQL@/mysql/db.frm ] ; then
     25    @PREFIX@/lib/@NAMEMYSQL@/bin/mysql_install_db --user=@USER@ \
     26    --datadir=@PREFIX@/var/db/@NAMEMYSQL@ \
     27    --tmpdir=@PREFIX@/var/db/@NAMEMYSQL@
     28fi
     29
     30# we should be able to trust that preinstall did this, but...
     31# just in case still loaded, unload
     32if /bin/launchctl list "org.macports.@SUBPORT@" &> /dev/null; then
     33    /bin/launchctl unload "/Library/LaunchDaemons/org.macports.@SUBPORT@.plist"
     34fi
     35
     36# my.cnf may not be in place yet, but the server will run anyway
     37/bin/launchctl load -w /Library/LaunchDaemons/org.macports.@SUBPORT@.plist
  • new file databases/mariadb/files/preinstall

    diff --git a/databases/mariadb/files/preinstall b/databases/mariadb/files/preinstall
    new file mode 100644
    index 0000000000..6cc150fb08
    - +  
     1#!/bin/sh
     2
     3# MariaDB installer support, preinstall script
     4# runs as root just after user clicks "Install"
     5
     6# if daemon loaded, unload
     7if /bin/launchctl list "org.macports.@SUBPORT@" &> /dev/null; then
     8    /bin/launchctl unload "/Library/LaunchDaemons/org.macports.@SUBPORT@.plist"
     9fi