Building Mythtv 31/32 with Ansible
Re: Building Mythtv 31 with Ansible
Thanks for your efforts in building and distributing the app. I have been using an old laptop as a front end but it can only run El Capitan, not High Sierra. I am wondering if I could follow these instructions to compile for that OS version or if there was a new prerequisite in v31 that requires a newer OS. I guess the later, since otherwise you wouldn't have built it for 10.13, but thought I'd ask since I haven't seen it discussed.
Re: Building Mythtv 31 with Ansible
To be honest - I don't know. I actually was originally building on Catalina but there was a very vocal crowd on the mythtv users mailing list requesting a build for High Sierra - so I installed a VM and gave it a whirl. To my surprise, once I got a High Sierra version of Xcode installed, everything just worked.
On High Sierra I was building with Xcode 10. A quick internet search (non-definitive) tells me El Capitan supports only up to Xcode 9. I am unsure what the differences between the two versions are.
I'd suggest giving it a try. The most likely two failures are that macports reports it can't install a necessary port or that mythtv won't compile. Either way we'll all get to learn something new.
On High Sierra I was building with Xcode 10. A quick internet search (non-definitive) tells me El Capitan supports only up to Xcode 9. I am unsure what the differences between the two versions are.
I'd suggest giving it a try. The most likely two failures are that macports reports it can't install a necessary port or that mythtv won't compile. Either way we'll all get to learn something new.
Re: Building Mythtv 31 with Ansible
Following your instructions, it seems that the file hosts.macports isn't included in the git repo, so installing the prerequisites didn't work.
I did a bit of research. It seems that you can tell clang to compile for an earlier OS version by adding the command line option "-mmacosx-version-min=xxx". However, that seems to depend on whether the right SDK is available. It also seems that the latest version of Qt requires 10.13. Qt 5.9 seems to be the last version that supported 10.11. I don't know whether that would work for v31.
Rather than cross-compiling, I will try building on the target laptop, if someone can provide the hosts.macports file.
I did a bit of research. It seems that you can tell clang to compile for an earlier OS version by adding the command line option "-mmacosx-version-min=xxx". However, that seems to depend on whether the right SDK is available. It also seems that the latest version of Qt requires 10.13. Qt 5.9 seems to be the last version that supported 10.11. I don't know whether that would work for v31.
Rather than cross-compiling, I will try building on the target laptop, if someone can provide the hosts.macports file.
Re: Building Mythtv 31 with Ansible
You're right - Bill and I made some tweaks to the compile - you now only need the following:
I'll fix the instructions.
Code: Select all
ansible-playbook-3.8 qt5.yml --ask-become-pass
Re: Building Mythtv 31 with Ansible
BTW - here is a highly experimental updated version of my script (that actually runs as a script). I've been slowly updating it with the intention of posting once I finish testing it (got sidetracked with the 1/4 screen issues). I believe it is missing the commenting out of the packaging filter lines (I do this on my system with a pactch file now...).
You'll need to save the script into a file named "compileMythtvAnsible.zsh" and make it executable.
To run it, just run
There are some input flags - run the following to print the flags
You'll need to save the script into a file named "compileMythtvAnsible.zsh" and make it executable.
To run it, just run
Code: Select all
./compileMythtvAnsible.zsh
Code: Select all
./compileMythtvAnsible.zsh --help
Code: Select all
#!/bin/zsh
### Note - macports must be installed on your system for this script to work!!!!!
if ! [ -x "$(command -v port)" ]; then
echo 'Error: Macports is not installed.' >&2
exit 1
fi
show_help(){
cat <<EOF
Usage: compileMythtvAnsible.sh [options]
Options: [defaults in brackets after descriptions]
Standard options:
--help Print this message
--build-plugins=BUILD_PLUGINS Build Mythtvplugins (false)
--python-version=PYTHON_VERS Desired Python 3 Version (38)
--version=MYTHTV_VERS Requested mythtv git repo (fixes/31)
Patch Options
--apply-patches=APPLY_PATCHES Apply patches specified in additional arguments (false)
--mythtv-patch-dir=MYTHTV_PATCH_DIR Directory containing patch files to be applied to Mythtv
--packaging-patch-dir=PACK_PATCH_DIR Directory containing patch files to be applied to Packaging
--plugins-patch-dir=PLUGINS_PATCH_DR Directory containing patch files to be applied to Mythplugins
Support Ports Options
--skip-ansible=SKIP_ANSIBLE Skip downloading ports with ansible (false)
NOTE: Only do this if you are sure you have installed ALL dependencies
--update-ports=UPDATE_PORTS Update macports (false)
EOF
exit 0
}
# set flag for building plugins
BUILD_PLUGINS=false
PYTHON_VERS="38"
UPDATE_PORTS=false
MYTHTV_VERS="fixes/31"
SKIP_ANSIBLE=false
APPLY_PATCHES=false
MYTHTV_PATCH_DIR=""
PACK_PATCH_DIR=""
PLUGINS_PATCH_DIR=""
for i in "$@"
do
case $i in
-h|--help)
show_help
exit 0
;;
--build-plugins=*)
BUILD_PLUGINS="${i#*=}"
;;
--python-version=*)
PYTHON_VERS="${i#*=}"
;;
--update-ports=*)
UPDATE_PORTS="${i#*=}"
;;
--skip-ansible=*)
SKIP_ANSIBLE="${i#*=}"
;;
--version=*)
MYTHTV_VERS="${i#*=}"
;;
--apply-patches=*)
APPLY_PATCHES="${i#*=}"
;;
--mythtv-patch-dir=*)
MYTHTV_PATCH_DIR="${i#*=}"
;;
--packaging-patch-dir=*)
PACK_PATCH_DIR="${i#*=}"
;;
--plugins-patch-dir=*)
PLUGINS_PATCH_DIR="${i#*=}"
;;
*)
echo "Unknown option $i"
# unknown option
exit 1
;;
esac
done
# Specify mythtv version to pull from git
VERS=${MYTHTV_VERS: -2}
REPO_DIR=~/mythtv-$VERS
INSTALL_DIR=$REPO_DIR/$VERS-osx-64bit
PYTHON_DOT_VERS="${PYTHON_VERS:0:1}.${PYTHON_VERS:1:4}"
ANSIBLE_PLAYBOOK="ansible-playbook-$PYTHON_DOT_VERS"
# setup some paths to make the following commands easier to understand
SRC_DIR=$REPO_DIR/mythtv/mythtv
APP_DIR=$SRC_DIR/programs/mythfrontend
PLUGINS_DIR=$REPO_DIR/mythtv/mythplugins
THEME_DIR=$REPO_DIR/mythtv/myththemes
PKGING_DIR=$REPO_DIR/mythtv/packaging/
OSX_PKGING_DIR=$PKGING_DIR/OSX/build/
PKG_CONFIG_SYSTEM_INCLUDE_PATH=/opt/local/include
export PATH=/opt/local/lib/mysql57/bin:$PATH
OS_VERS=$(/usr/bin/sw_vers -productVersion)
echo "------------ Setting Up Directory Structure ------------"
# setup the working directory structure
mkdir -p $REPO_DIR
cd $REPO_DIR
# create the install temporary directory
mkdir -p $INSTALL_DIR
# install and configure ansible and gsed
# ansible to install the missing required ports,
# gsed for the makebundle.sh fix later
echo "------------ Setting Up Initial Ports for Ansible ------------"
if $UPDATE_PORTS; then
sudo port selfupdate
sudo port upgrade
fi
$ check if ansible is installed
if ! [ -x "$(command -v $ANSIBLE_PLAYBOOK)" ]; then
echo Installing python and ansilble
sudo port -N install py$PYTHON_VERS-ansible
sudo port select --set python python$PYTHON_VERS
sudo port select --set python3 python$PYTHON_VERS
sudo port select --set ansible py$PYTHON_VERS-ansible
else
echo "skipping ansible install - it is already installed"
fi
# check is gsed is installed (for patching the .plist file)
if ! [ -x "$(command -v gsed)" ]; then
sudo port -N install gsed
else
echo "skipping gsed install - it is already installed"
fi
echo "------------ Running Ansible ------------"
if $SKIP_ANSIBLE; then
echo "Skipping port installation via ansible"
else
# get mythtv's ansible playbooks, and install required ports
if [ -d "$REPO_DIR/ansible" ]; then
echo "updating mythtv-anisble git repo"
cd $REPO_DIR/ansible
git stash
git reset
git pull
else
echo "cloning mythtv-anisble git repo"
git clone https://github.com/MythTV/ansible.git
fi
cd $REPO_DIR/ansible
DISPLAY_SKIPPED_HOSTS=0
ANSIBLE_PLAYBOOK qt5.yml --ask-become-pass
fi
echo "------------ Cloning / Updating Mythtv Git Repository ------------"
# setup mythtv source from git
cd $REPO_DIR
if [ -d "$REPO_DIR/mythtv" ]; then
echo "updating mythtv git repo"
cd $REPO_DIR/mythtv
git stash
git reset
git pull
else
echo "cloning mythtv git repo"
git clone -b $MYTHTV_VERS git://github.com/MythTV/mythtv.git
fi
# apply specified patches
if [ $APPLY_PATCHES ] && [ ! -z $MYTHTV_PATCH_DIR ]; then
cd $REPO_DIR/mythtv
for file in $MYTHTV_PATCH_DIR
do
if [ -f "$file" ]; then
echo "Applying Mythtv patch: $file"
patch -p1 < $f
fi
done
fi
echo "------------ Cloning / Updating Packaging Git Repository ------------"
# get packaging
cd $REPO_DIR/mythtv
if [ -d $PKGING_DIR ]; then
echo "updating mythtv-packaging git repo"
cd $PKGING_DIR
git stash
git reset
git pull
else
echo "cloning mythtv-packaging git repo"
git clone -b $MYTHTV_VERS https://github.com/MythTV/packaging.git
fi
if [ $APPLY_PATCHES ] && [ ! -z $PACK_PATCH_DIR ]; then
cd $PKGING_DIR
for file in $PACK_PATCH_DIR
do
if [ -f "$file" ]; then
echo "Applying Packaging patch: $file"
patch -p1 < $f
fi
done
fi
echo "------------ Configuring Mythtv ------------"
# configure mythfrontend
cd $SRC_DIR
GIT_VERS=$(git rev-parse --short HEAD)
./configure --prefix=$INSTALL_DIR \
--runprefix=../Resources \
--enable-mac-bundle \
--qmake=/opt/local/libexec/qt5/bin/qmake \
--cc=clang \
--cxx=clang++ \
--extra-cxxflags=-I/opt/local/include \
--extra-ldflags=-L/opt/local/lib \
--disable-backend \
--disable-distcc \
--disable-firewire \
--enable-libmp3lame \
--enable-libxvid \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-bdjava \
--python=/opt/local/bin/python3.8
echo "------------ Coompiling Mythtv ------------"
#compile mythfrontend
make
echo "------------ Installing Mythtv ------------"
# need to do a make install or macdeployqt will not copy everything in and makebundle.sh will fail.
make install
if $BUILD_PLUGINS; then
echo "------------ Configuring Mythplugins ------------"
# apply specified patches
if [ $APPLY_PATCHES ] && [ ! -z $PLUGINS_PATCH_DIR ]; then
cd $PLUGINS_DIR
for file in $PLUGINS_PATCH_DIR
do
if [ -f "$file" ]; then
echo "Applying Plugins patch: $file"
patch -p1 < $f
fi
done
fi
# configure plugins
cd $PLUGINS_DIR
./configure --prefix=$INSTALL_DIR \
--runprefix=../Resources \
--qmake=/opt/local/libexec/qt5/bin/qmake \
--cc=clang \
--cxx=clang++ \
--enable-mythgame \
--enable-mythmusic \
--enable-fftw \
--enable-cdio \
--enable-mythnews \
--enable-mythweather \
--disable-mytharchive \
--disable-mythnetvision \
--disable-mythzoneminder \
--disable-mythzmserver \
--python=/opt/local/bin/python3.8
echo "------------ Compiling Mythplugins ------------"
#compile mythfrontend
/opt/local/libexec/qt5/bin/qmake mythplugins.pro
make
echo "------------ Installing Mythplugins ------------"
make install
fi
echo "------------ Deploying QT to Mythfrontend Executable ------------"
# Package up the executable
cd $APP_DIR
# run macdeployqt
/opt/local/libexec/qt5/bin/macdeployqt $APP_DIR/mythfrontend.app
echo "------------ Update Mythfrontend.app to use internal dylibs ------------"
# run makebundle to copy all of the libraries into the bundle as Frameworks
$OSX_PKGING_DIR/makebundle.sh $APP_DIR/mythfrontend.app
echo "------------ Installing libcec and libmythbase into Mythfrontend.app ------------"
# copy in libcec (missing for some reason...)
cp /opt/local/lib/libcec.4.*.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks/
install_name_tool -add_rpath "@executable_path/../Frameworks/libcec.4.0.5.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
cp /opt/local/lib/libcec.4.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Frameworks/libcec.4.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
cp /opt/local/lib/libcec.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Resources/libcec.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
# copy in libmythbase (missing for some reason...)
cp $INSTALL_DIR/lib/libmythbase-31.31.0.0.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Frameworks/libmythbase-31.31.0.0.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
cp $INSTALL_DIR/lib/libmythbase-31.31.0.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Frameworks/libmythbase-31.31.0.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
cp $INSTALL_DIR/lib/libmythbase-31.31.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Frameworks/libmythbase-31.31.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
cp $INSTALL_DIR/lib/libmythbase-31.dylib $APP_DIR/mythfrontend.app/Contents/Frameworks
install_name_tool -add_rpath "@executable_path/../Frameworks/libmythbase-31.dylib" $APP_DIR/mythfrontend.app/Contents/MacOS/mythfrontend
echo "------------ Installing additional mythtv utility executables intoe Mtntend.app ------------"
# copy in mythpreviewgen and mythavtest (for good measure...)
cp -r $INSTALL_DIR/bin/mythmetadatalookup.app/Contents/MacOS/mythmetadatalookup $APP_DIR/mythfrontend.app/Contents/MacOS
cp -r $INSTALL_DIR/bin/mythreplex.app/Contents/MacOS/mythreplex $APP_DIR/mythfrontend.app/Contents/MacOS
cp -r $INSTALL_DIR/bin/mythutil.app/Contents/MacOS/mythutil $APP_DIR/mythfrontend.app/Contents/MacOS
cp -r $INSTALL_DIR/bin/mythpreviewgen.app/Contents/MacOS/mythpreviewgen $APP_DIR/mythfrontend.app/Contents/MacOS
cp -r $INSTALL_DIR/bin/mythavtest.app/Contents/MacOS/mythavtest $APP_DIR/mythfrontend.app/Contents/MacOS
echo "------------ Copying mythtv share directory into executable ------------"
# copy in i18n, fonts, themes, plugin resources, etc from the install directory (share)
mkdir -p $APP_DIR/mythfrontend.app/Contents/Resources/share/mythtv
cp -r $INSTALL_DIR/share/mythtv/* $APP_DIR/mythfrontend.app/Contents/Resources/share/mythtv/
echo "------------ Copying in dejavu and liberation fonts into Mythfrontend.app ------------"
# copy in missing fonts
cp /opt/local/share/fonts/dejavu-fonts/*.ttf $APP_DIR/mythfrontend.app/Contents/Resources/share/mythtv/fonts/
cp /opt/local/share/fonts/liberation-fonts/*.ttf $APP_DIR/mythfrontend.app/Contents/Resources/share/mythtv/fonts/
echo "------------ Copying in Mythfrontend.app icon ------------"
# copy in the icon
cp mythfrontend.icns $APP_DIR/mythfrontend.app/Contents/Resources/application.icns
echo "------------ Add symbolic link structure for copied in files ------------"
# make some symbolic links to match past working copies
cd $APP_DIR/mythfrontend.app/Contents/MacOS
if $BUILD_PLUGINS; then
ln -s ../PlugIns/sqldrivers .
fi
cd $APP_DIR/mythfrontend.app/Contents/Resources
ln -s ../MacOS bin
if $BUILD_PLUGINS; then
mkdir -p $APP_DIR/mythfrontend.app/Contents/Resources/lib/mythtv
cd $APP_DIR/mythfrontend.app/Contents/Resources/lib/mythtv
ln -s ../../../PlugIns plugins
fi
echo "------------ Updating application plist ------------"
# Update the plist
gsed -i "8c\ <string>application.icns</string>" $APP_DIR/mythfrontend.app/Contents/Info.plist
gsed -i "10c\ <string>org.osx-bundler.mythfrontend</string>\n <key>CFBundleInfoDictionaryVersion</key>\n <string>6.0</string>" $APP_DIR/mythfrontend.app/Contents/Info.plist
gsed -i "14a\ <key>CFBundleShortVersionString</key>\n <string>31</string>" $APP_DIR/mythfrontend.app/Contents/Info.plist
gsed -i "18c\ <string>osx-bundler</string>\n <key>NSAppleScriptEnabled</key>\n <string>NO</string>\n <key>CFBundleGetInfoString</key>\n <string></string>\n <key>CFBundleVersion</key>\n <string>1.0</string>\n <key>NSHumanReadableCopyright</key>\n <string>MythTV Team</string>" $APP_DIR/mythfrontend.app/Contents/Info.plist
echo "------------ Generating .dmg file ------------"
# Package up the build
cd $APP_DIR
VOL_NAME=MythFrontend-$VERS-intel-$OS_VERS-v$VERS-$GIT_VERS
if [ -f $APP_DIR/$VOL_NAME.dmg ] ; then
mv $APP_DIR/$VOL_NAME.dmg $APP_DIR/$VOL_NAME$(date +'%d%m%Y%H%M%S').dmg
fi
hdiutil create $APP_DIR/$VOL_NAME.dmg -fs HFS+ -srcfolder $APP_DIR/Mythfrontend.app -volname $VOL_NAME
Re: Building Mythtv 31 with Ansible
FYI, I figured out an alternative solution to my problem: a hack that let me install 10.13 on the old laptop, which lets me run your version.