Skip to content

Commit

Permalink
mythtv.28: add packaging support
Browse files Browse the repository at this point in the history
add preinstall and postinstall scripts to gracefully either intall or
reinstall Myth.  Makes sure that initial configuration of Myth's database
(mythconverg) is done including time zone support.
  • Loading branch information
ctreleaven committed Feb 13, 2017
1 parent 89b58fc commit ee87964
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions multimedia/mythtv.28/Portfile
Expand Up @@ -638,4 +638,12 @@ if {$subport eq "mythtv${majorversion}"} {
xinstall -m 0755 ${filespath}/README_mythtv${majorversion}_MacPorts.txt \
${destroot}${prefix}/share/mythtv-readme
}

pre-pkg {
xinstall -m 0755 ${filespath}/preinstall ${filespath}/postinstall \
${package.scripts}/
reinplace -locale C "s|@PREFIX@|${prefix}|g" \
${package.scripts}/preinstall \
${package.scripts}/postinstall
}
}
33 changes: 33 additions & 0 deletions multimedia/mythtv.28/files/postinstall
@@ -0,0 +1,33 @@
#!/bin/sh

# MythTV installer support, postinstall script
# runs as root after installer successfully copies payload to destination
# assume database installer package has initialized and started db server

DB_BIN=@PREFIX@/lib/mariadb/bin

echo $0 Starting
echo make sure database has a config
if [ ! -f @PREFIX@/etc/mariadb/my.cnf ] ; then
cp @PREFIX@/share/mythtv/database/my.cnf @PREFIX@/etc/mariadb
echo start/restart db for pick up our config
if /bin/launchctl list "org.macports.mariadb-server" &> /dev/null; then
echo Unload db server...
/bin/launchctl unload "/Library/LaunchDaemons/org.macports.mariadb-server.plist"
fi
echo Load the db server
/bin/launchctl load -w /Library/LaunchDaemons/org.macports.mariadb-server.plist
fi

echo MariaDB server may be starting...
sleep 6
echo ...should be up now

# Check mythconverg database
if [ ! -d "/opt/local/var/db/mariadb/mythconverg" ] ; then
echo Set up mythconverg db and mythtv user
$DB_BIN/mysql -u root < @PREFIX@/share/mythtv/database/mythconverg_init.sql
echo Add time zone support tables
$DB_BIN/mysql_tzinfo_to_sql /usr/share/zoneinfo | $DB_BIN/mysql -u root mysql
fi
echo $0 Finished
17 changes: 17 additions & 0 deletions multimedia/mythtv.28/files/preinstall
@@ -0,0 +1,17 @@
#!/bin/sh

# MythTV installer support, preinstall script
# Note that all the preinstall scripts are run (as root), then the payload is 'shove'd into place
# After that, all the postinstall scripts are run.
# Script also runs in a sandbox with no access to /Private and other directories
# note that launchctl requires sudo

echo mythtv.28 preinstall script starting

echo if backend loaded, unload before continuing install
if /bin/launchctl list "org.mythtv.mythbackend" &> /dev/null; then
/bin/launchctl unload "/Library/LaunchDaemons/org.mythtv.mythbackend.plist"
echo ...backend now unloaded
fi

echo mythtv.28 preinstall script finished

0 comments on commit ee87964

Please sign in to comment.