LinHES Forums
http://forum.linhes.org/

My compile MythTV from SVN script.
http://forum.linhes.org/viewtopic.php?f=11&t=11985
Page 1 of 8

Author:  WattoToydarian [ Tue Oct 03, 2006 4:18 pm ]
Post subject:  My compile MythTV from SVN script.

Hello everyone. I made a script that downloads MythTV from SVN, compiles it, and installs it.
I just thought I might share it with everyone and maybe get some feedback about it.
So without further a due, I present my script.
[url=HTTP://Watto.HomeIP.net/mythsvn.sh]MythTV from SVN[/url]
Usage:
mythsvn.sh [head|fixes] [pause]
Selecting head will compile from the SVN head, fixes will compile the fixes branch, and pause will pause before MythTV installation so you can finish up anything your doing before it gets shutdown.
This script has three simple stages:
First, it downloads all of the source code, compiles MythTV with nice so you can still use your Knoppmyth box during this stage (not something I recommend for most users), and performs a backup.
Second, it automatically shuts down MythTV and installs it with the themes.
Last, it starts up the new MythTV and compiles MythPlugins with nice so you can try out the new MythTV during this step and at the end it closes the Frontend, installs the Plugins, and reloads the Frontend.

I think you need about 500MB of free space on the partition that you run this on and you must be root.
If anyone has any enhancements or suggestions for my script please let me know. ;)
*Added misterflibble's suggestions
*Added Greg Frost's enhancements
*Added tjc's suggestion
*Added more suggestions from tjc and mrshark
*10-9-06 Added more enhancements from tjc and comments.
*10-15-06 Added "pause" option that pauses before mythtv installation /w help from tjc.
*11-16-06 Fixed Athlon64 compile problem thanks to tjc.

Author:  misterflibble [ Tue Oct 03, 2006 8:03 pm ]
Post subject: 

Very nice set of scripts 8)

Just a few suggestions:
1)mythsvnfixes.sh should probably be called myth-0.20fixes.sh or something similar because it's actually the release 0.20 (and any backported fixes) not to be confused with the current svn.
2)I think line 31 (sleep 5; irexec...) is unnecessary. Don't most people start irexec when their window manager starts?
3)Why disable mythflix, mythnews, mythbrowser, and mythphone? I think these should all compile with what's provided in Knoppmyth, and are listed in the menus. Also, since you don't move the old myth directories out of the way, they would still have the old versions of these plugins installed, which would then fail. Also a lot of the config options for mythplugins are unnecessary. Most of them are turned on by default, check ./configure --help, any that say [yes] will.
4)Does line 38 (copying mythweb) result in the proper permissions for the directories, so it can run under apache? Also, apache should be restarted after this.
5)I'd suggest doing a dump of mythconverg, since the upgrade will change the schema and every user should have this done since things can get hosed and there's not really any going back on the database.
6)Running the make while gdm and everything's running is perfectly fine. But the make installs should occur after stopping mythbackend and gdm because overwriting the files often results in crashes in a running system and database errors.

Author:  WattoToydarian [ Wed Oct 04, 2006 2:22 pm ]
Post subject: 

Ok, I made the changes for numbers 1, 3, and 5.
#2 I have because I use my remote to restart gdm whenever theres a crash so it needs root privileges.
#4 It works for me, if anyone has a problem with it and a solution let me know.
#6 If you look closely, you'll see that it actually stops everything just before it installs and doesn't the plugIns only effect the frontend?

Author:  Greg Frost [ Wed Oct 04, 2006 3:30 pm ]
Post subject: 

I wouldn't have 2 scripts that do essentially the same thing. It would be better to pass an argument to tell it whether you wanted to compile svn head or fixes. Then you only need to maintain one script.

Also, you may wish to check the status of the builds and exit if they fail. There is no gaurentee that the changeset that you happen to get actually compiles, and you probably don't want to continue if it doesn't.

Nice work. The Knoppmyth community could really do with this.

Author:  WattoToydarian [ Wed Oct 04, 2006 3:32 pm ]
Post subject: 

That would be nice to have in the script but I dont know how to do that.
Could you post some lines that would do that?

Author:  Greg Frost [ Wed Oct 04, 2006 3:43 pm ]
Post subject: 

WattoToydarian wrote:
That would be nice to have in the script but I dont know how to do that.
Could you post some lines that would do that?


Arguments done something like this:

Code:
if [ "$1" = fixes ] ; then
  TARGET=branches/release-0-20-fixes
elif [ "$1" = fixes ] ; then
  TARGET=trunk
elif [ -z "$1" ] ; then
  echo "\
Usage:
  mythsvn.sh [head|fixes]
Selecting head will compile from the SVN head, fixes will compile the fixes branch."
  exit
fi

svn co http://svn.mythtv.org/svn/$TARGET/mythtv
etc...



to abort if the build fails, something like this would probably work:
Code:
if ! nice -n17 make ; then
  echo "The build failed!"
  exit
fi

Author:  WattoToydarian [ Wed Oct 04, 2006 3:54 pm ]
Post subject: 

Great! I added those lines to the mythsvn.sh script. Can you check it to see if I put them in the right place?
Thanks a BUNCH! :D

Author:  Greg Frost [ Wed Oct 04, 2006 4:34 pm ]
Post subject: 

oops/ it is checking for "fixes" in both ifs. one should check for "head".

Author:  WattoToydarian [ Wed Oct 04, 2006 5:00 pm ]
Post subject: 

Greg Frost wrote:
oops/ it is checking for "fixes" in both ifs. one should check for "head".
ok I changed:
Code:
elif [ "$1" = fixes ] ; then
  TARGET=trunk

to
Code:
elif [ "$1" = head ] ; then
  TARGET=trunk

Author:  tjc [ Wed Oct 04, 2006 6:44 pm ]
Post subject: 

For misterflibble's #5 above why not just run the mythbackup script. It's well behaved and intended to be callable from other scripts. Not only that, but then you can use mythrestore to revert the DB if needed.

With a bit of cleverness with the backup.list and restore.list, you can have it backup the currently installed version of MythTV as well. Being able to test updates to MythTV (debs, locally compiled, ...) and restore the previous version easily was actually one of the things that inspired adding the supplemental lists after all...

Author:  WattoToydarian [ Wed Oct 04, 2006 9:54 pm ]
Post subject: 

Thanks for the input tjc, I made the change do it runs mythbackup just before the install.
Though, I don't know anything about the backup.list and restore.list.

Author:  tjc [ Thu Oct 05, 2006 6:03 pm ]
Post subject: 

Easily remedied. See this posting - http://mysettopbox.tv/phpBB2/viewtopic.php?t=10117 Basically all you need to do is creatre a text file that lists the directories or files you want it to include. Say for example "./usr/share/mythtv" ;)

A few other code reveiew comments:

- Missing #! magic at the beginning. Make the first line of the file say either:
Code:
#!/bin/bash

or:
Code:
#!/bin/sh


- I'm guessing the lines that just say "y" don't do what you intended. ;-) and instead produces a message like this:
Code:
-bash: y: command not found

To get rid of the interactive prompting by cp/mv/rm either unalias them at the start of the script or go directly to the real binaries using "/bin/cp", "/bin/mv", and "/bin/rm".

- I think you can dispense with the use of nice. If you're trying to recompile the backend and frontend with other acticvity on the system you're going to disrupt it pretty seriously no matter what. At the very least when you do the backup and the installs. ;-)

- I would add some more success/failure checks along the way. For example use "&&" between the "make" and the "make install", or create a fatal_error function and use it to bomb out anything goes all pear shaped. For example:
Code:
fatal_error () {
    echo 1>&2 "Fatal error - $*, exiting."
    exit 1
}

Then later:
Code:
make || fatal_error "failed to make mytthemes"
make install || fatal_error "failed to install mytthemes"

This is a very useful idiom for a script that should stop as soon as something goes wrong to avoid compounding any damage.

Author:  Greg Frost [ Thu Oct 05, 2006 7:02 pm ]
Post subject: 

tjc wrote:
- I think you can dispense with the use of nice. If you're trying to recompile the backend and frontend with other acticvity on the system you're going to disrupt it pretty seriously no matter what. At the very least when you do the backup and the installs. ;-)
I disagree with this. It may take hours to complete the compile stage (depending on hardware) during which time, the nice will help.

Author:  mrshark [ Thu Oct 05, 2006 11:02 pm ]
Post subject: 

tjc wrote:
To get rid of the interactive prompting by cp/mv/rm either unalias them at the start of the script or go directly to the real binaries using "/bin/cp", "/bin/mv", and "/bin/rm".

use absolute paths to binaries in scripts is always needed: you don't know if they're in the path, or if their path is equal to yours...

aliases could be temporarily overridden prepending them with a backslash: \cp is like an unaliased cp...

interactive mode for cp/rm/mv could be turned off with che -f switch (force), as opposed to -i (interactive).

my 2c... :wink:

Author:  sjerome [ Fri Oct 06, 2006 7:46 am ]
Post subject: 

:D Hey, thanks for the script. It makes it easy. I am hoping that it makes my mythcenter run a bit smoother. Maybe even XvMC will work again. But anyways, the script works great. Nice job. And thanks to all who helped make it easy.

:D

Page 1 of 8 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/