Ticket #52144: patch_port_mariadb-server_startupitem_and_pkg_2016Sep04.diff

File patch_port_mariadb-server_startupitem_and_pkg_2016Sep04.diff, 6.9 KB (added by ctreleaven (Craig Treleaven), 8 years ago)
  • Portfile

    $ svn diff
     
    99set version_branch  [join [lrange [split ${version} .] 0 1] .]
    1010# Please set revision_client and revision_server to 0 if you bump version.
    1111set revision_client 0
    12 set revision_server 0
     12set revision_server 3
    1313categories          databases
    1414platforms           darwin
    1515license             GPL-2
     
    202202    revision            ${revision_server}
    203203    license             BSD
    204204    description         Run ${name_mysql} as server
    205     long_description    ${description}
     205    long_description    MariaDB is one of the most popular database servers in the world. \
     206        It’s made by the original developers of MySQL and is a fast, scalable and robust \
     207        relational database providing an SQL interface for accessing structured data.
    206208
    207209    supported_archs     noarch
    208210    distfiles
     211    set plistlabel      org.macports.mariadb-server
     212    set plistfile       ${plistlabel}.plist
     213    set plistdir        ${prefix}/etc/LaunchDaemons/${plistlabel}
    209214
    210215    depends_run         port:${name_mysql}
    211216
     217    pre-patch {
     218        file mkdir ${worksrcpath}/macports
     219        copy ${filespath}/${plistfile} ${worksrcpath}/macports/
     220    }
     221
     222    post-patch {
     223        reinplace -locale C "s|@NAME@|${name_mysql}|g" \
     224            ${worksrcpath}/macports/${plistfile}
     225        reinplace -locale C "s|@PREFIX@|${prefix}|g" \
     226            ${worksrcpath}/macports/${plistfile}
     227    }
     228
    212229    if {"darwin" eq ${os.platform} && ${os.major} > 8} {
    213230        set mysqluser       _mysql
    214231    } else {
     
    216233    }
    217234    add_users ${mysqluser} group=${mysqluser} realname=MySQL\ Server
    218235
    219     startupitem.create      yes
    220     startupitem.executable  ${prefix}/lib/${name_mysql}/bin/mysqld --user=${mysqluser}
    221 
    222236    use_configure       no
    223237
    224238    build {}
     
    235249            ${destroot}${prefix}/var/db/${name_mysql} \
    236250            ${destroot}${prefix}/var/log/${name_mysql} \
    237251            ${destroot}${prefix}/var/run/${name_mysql}
     252        xinstall -d -m 0755 ${destroot}${plistdir}
     253        xinstall ${worksrcpath}/macports/${plistfile} ${destroot}${plistdir}
     254    }
     255
     256    post-activate {
     257        # delete leftover file, if any
     258        if [file exists /Library/LaunchDaemons/${plistfile}] {
     259            file delete -force /Library/LaunchDaemons/${plistfile}
     260        }
     261        ln -s ${plistdir}/${plistfile} /Library/LaunchDaemons
     262    }
     263
     264    pre-deactivate {
     265         file delete -force /Library/LaunchDaemons/${plistfile}
     266    }
     267
     268    pre-pkg {
     269        file copy ${filespath}/preinstall \
     270            ${filespath}/postinstall \
     271            ${package.scripts}/
     272        reinplace -locale C "s|@NAME@|${name_mysql}|g" \
     273            ${package.scripts}/preinstall \
     274            ${package.scripts}/postinstall
     275        reinplace -locale C "s|@PREFIX@|${prefix}|g" \
     276            ${package.scripts}/preinstall \
     277            ${package.scripts}/postinstall
     278        file attributes ${package.scripts}/preinstall -permissions 0755
     279        file attributes ${package.scripts}/postinstall -permissions 0755
    238280    }
    239281
    240282    notes "
  • files/org.macports.mariadb-server.plist

     
     1<?xml version="1.0" encoding="UTF-8"?>
     2<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     3<plist version="1.0">
     4<dict>
     5    <key>Label</key>             <string>org.macports.@NAME@-server</string>
     6    <key>ProcessType</key>       <string>Interactive</string>
     7    <key>Disabled</key>          <false/>
     8    <key>RunAtLoad</key>         <true/>
     9    <key>KeepAlive</key>         <true/>
     10    <key>SessionCreate</key>     <true/>
     11    <key>LaunchOnlyOnce</key>    <false/>
     12    <key>UserName</key>          <string>_mysql</string>
     13    <key>GroupName</key>         <string>_mysql</string>
     14    <key>ExitTimeOut</key>       <integer>600</integer>
     15    <key>ProgramArguments</key>
     16        <array>
     17            <string>@PREFIX@/lib/@NAME@/bin/mysqld</string>
     18            <string>--datadir=@PREFIX@/var/db/@NAME@</string>
     19            <string>--plugin-dir=@PREFIX@/lib/@NAME@/plugin</string>
     20            <string>--log-error=@PREFIX@/var/log/@NAME@/mysqld.local.err</string>
     21            <string>--pid-file=@PREFIX@/var/run/@NAME@/mysqld.local.pid</string>
     22        </array>
     23</dict>
     24</plist>
  • files/postinstall

     
     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.@NAME@-server/org.macports.@NAME@-server.plist || exit 1
     12if [ -f /Library/LaunchDaemons/org.macports.@NAME@-server.plist ] ; then
     13   rm /Library/LaunchDaemons/org.macports.@NAME@-server.plist
     14fi
     15ln -s @PREFIX@/etc/LaunchDaemons/org.macports.@NAME@-server/org.macports.@NAME@-server.plist \
     16    /Library/LaunchDaemons/org.macports.@NAME@-server.plist || exit 1
     17
     18chown _mysql:_mysql @PREFIX@/var/run/@NAME@ || exit 1
     19chown _mysql:admin  @PREFIX@/var/db/@NAME@ || exit 1
     20chown _mysql:_mysql @PREFIX@/var/log/@NAME@ || exit 1
     21
     22
     23# standard mysql initialization
     24if [ ! -f @PREFIX@/var/db/@NAME@/mysql/db.frm ] ; then
     25    @PREFIX@/lib/@NAME@/bin/mysql_install_db --user=_mysql --datadir=@PREFIX@/var/db/@NAME@
     26fi
     27
     28# we should be able to trust that preinstall did this, but...
     29# just in case still loaded, unload
     30if /bin/launchctl list "org.macports.@NAME@-server" &> /dev/null; then
     31    /bin/launchctl unload "/Library/LaunchDaemons/org.macports.@NAME@-server.plist"
     32fi
     33
     34# my.cnf may not be in place yet, but the server will run anyway
     35/bin/launchctl load -w /Library/LaunchDaemons/org.macports.@NAME@-server.plist
  • files/preinstall

    Property changes on: files/postinstall
    ___________________________________________________________________
    Added: svn:executable
    ## -0,0 +1 ##
    +*
    \ No newline at end of property
     
     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.@NAME@-server" &> /dev/null; then
     8    /bin/launchctl unload "/Library/LaunchDaemons/org.macports.@NAME@-server.plist"
     9fi