Gentoo custom portage

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Gentoo custom portage

Post by lazyleopard »

I have put a gzipped tar file of my portage stuff into zm-1.21.0-portage.tgz.

It's my custom ebuild, and, as I mentioned, I don't use ffmpeg, so it may need tweaks if it's to work with ffmpeg. Also, note that it is customised, and it isn't in an install and run out of the box state. To make some use of it, fetch the file, and then do:

Code: Select all

# cd /usr/local/portage  # or wherever you put your *local* portage tree
# tar zvxf /path/to/zm-1.21.0-portage.tgz
# cd www-misc/zoneminder
# ls
In there you'll find the ebuild and a directory called files which contains patches.

Code: Select all

-rw-r--r--  1 rick users 2774 May 16 23:44 zoneminder-1.21.0.ebuild
drwxr-xr-x  2 rick users  256 May 17 10:31 files
-rw-r--r--  1 rick users 14793 May 17 10:31 files/zm-1.21.0-config.txt
-rw-r--r--  1 rick users  2581 Mar 30 00:02 files/zm-1.21.0-local_camera.patch
-rw-r--r--  1 rick users 21120 Mar 30 00:02 files/zm-1.21.0-scripts.patch
-rw-r--r--  1 rick users  5010 Mar 30 00:02 files/zm-1.21.0-security.patch
-rw-r--r--  1 rick users  2845 Mar 30 00:02 files/zm-1.21.0-zone.patch
The one you most want to worry about is files/zm-1.21.0-config.txt so open it in your favourite editor and make sure it looks sensible, or, better still, if you have a copy of zmconfig.txt from an earlier installation, copy that:

Code: Select all

# cp /path/to/my/zmconfig.txt files/zm-1.21.0-config.txt
Make sure things like the ZM_DB_USER and ZM_DB_PASS are sane. Other things you may want to change are ZM_AUTH_SECRET and various email addresses and URLs.
Once you're happy with that, and you've had a look in the ebuild and you're happy with that too, try:

Code: Select all

# ebuild zoneminder-1.21.0.ebuild digest
If that's ok you can be daring and go straight to try an emerge (with -p first, of course), or you can work in stages using ebuild to unpack and patch, compile, and install. ("man ebuild" and "man 5 ebuild" will be helpful here.)
It will put:
  • executable stuff into /usr/bin
  • the init script into /etc/init.d
  • config stuff (including a copy of zmconfig.txt) into /etc/zm
  • logs into /var/log/zm
  • runstate stuff into /var/run/zm
  • web stuff into ~apache/zm
  • CGI stuff into ~apache/zm/bin (I probably oughtto move this...)
  • documentation including all the zmalter scripts (which you may need if you're upgrading) into /usr/share/doc/zoneminder-1.21.0
so you'll need to do some tweaks to your apache config too. If ~apache were at /www you'd need something a bit like this:

Code: Select all

    Alias /zm/ /www/zm/
    <Directory /www/zm>
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ScriptAlias /cgi-bin/ /www/zm/bin/
    <Directory /www/zm/bin>
        AllowOverride None
        Options ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
Rick Hewett
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

GrauWolf said
"The security patch included in the ZM 1.21.0 portage package causes a build failure in something to do with mysqlclient libs. Compiled without the patch."
Weird... Only thing it does which affects anything other than ownerships and access permissions is to cause zmfix to link statically ('cos something in ebuild bitches when a suid program is dynamically linked). I guess if you don't have static versions of the appropriate libraries then it would fail though...
Rick Hewett
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

I've put together a similar collection for 1.21.1. You can find it here: zm-1.21.1-portage.tgz

Mostly, the instructions above should translate easily enough. The local_camera patch isn't there any more, as it's now in the main-line code (with a configuration setting to activate it). Thanks Phil.

I have shifted the zmalter scripts into /etc/zm and hacked zmalter.pl accordingly. If you're upgrading from 1.21.0 you'll need to run the database update SQL after the emerge:

Code: Select all

/usr/bin/zmupdate.pl -version=1.21.0 --user=root --pass=?????
I've fixed (I hope) the ebuild so it doesn't throw any mysqlclient library errors.

16th June: I've added the patch for timestamps from this thread: http://www.zoneminder.com/forums/viewtopic.php?t=4560
Rick Hewett
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

...and there's one for 1.21.2 here: zm-1.21.2-portage.tgz
Rick Hewett
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

...and one for zm-1.21.3. Usual caveats apply. Instructions above should be adapted appropriately.

It's probably worth noting that, if you've been tracking the latest security updates on Gentoo, you've probably got PHP 4.4.0 installed by now, and there are a few things somewhere in the changes between 4.3.11 and 4.4.0 that break things like zoneminder's login. I havn't yet figured a patch to fix this...

(...and Phil, the "files" sub-directory in that contains patches I've made to get zoneminder working under Gentoo, along with one customisation that isn't actually used by default. The ebuild file contains a few notes about each patch.)
Rick Hewett
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post by zoneminder »

Thanks for keeping this up-to-date. I'll have a look at your patches and see if I can mainstream any of them.

Phil
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

There are 3 patch files.

zm-1.21.3-security.patch contains changes required to keep Gentoo's security checks happy. I think this could probably go mainstream without ill effect.

zm-1.21.3-scripts.patch contains script patches, including an appropriate zm init script and patches to zmupdate.pl and zmpkg.pl to account for where things go in a Gentoo system. There are a couple of extra scripts (zmextract.pl and zmforce.pl) that I use but which most users can ignore.

zm-1.21.3-zone.patch contains a patch to the score calculation, and is not applied by default. Folks would have to edit the ebuild to un-comment its application. Again, it's something I use that probably has very limited application.
Rick Hewett
KaZeR
Posts: 10
Joined: Fri Oct 21, 2005 9:20 am

Post by KaZeR »

LazyLeopard, you did a great job with that ebuild.

The one in portage is incomplete, and i posted some minor corrections to it there http://bugs.gentoo.org/show_bug.cgi?id=106913 before finding your ebuild.

You should definitely propose your ebuild there.

Anyhow, there's three minor annoyance with you current ebuild (hehe).
Both regarding apache.

* On the various system i tried it on (4 total) apache user has /home/httpd as home directory. This folder don't even exists, and my apache docroot is the good old /var/www/localhost/htdocs.
This needs to be changed in /etc/passwd *before* emerging your ebuild, or .pl files will be compiled with hardcoded erroneus paths.

* Second thing, your /etc/init.d/zm script won't work with apache default's shell which is /bin/false. This need to be changed to a valid shell before trying to run the zm init script.

* Lastly, the two cgi script don't get installed in /cgi-bin. I need to move them to the correct location. I believe it's maybe because you're using vhosts?

I'm using apache-2+ everywhere, if you have an older version this may explain why it may work for you.

Last thing : for your custom patch, maybe we could add a custom use flag?

Anyhow, thanks for the great job you made on that ebuild, which should definitely get more publicity, and thank you also Phil for Zoneminder :)
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

Yeah, that ebuild was based on the old way of doing things. I've been meaning to take a look at the one in the current portage tree and see whether I can get things to match better.

Yeah, I'm using vhosts, and apache2. No idea whether my ebuild gets anywhere with apache1.

My custom patch is a very idiosyncratic fudge to the way zones are scored, and I don't expect really anyone else to use it.

Thanks for your comments.
Rick Hewett
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

...and one for 1.21.4. Note, this does not follow the same pattern as the one now in the official portage set, but it works for me. If you're upgrading, make sure to take care of the database updates (as described in announcement in this forum) the first time you build this.
Rick Hewett
OpHI
Posts: 3
Joined: Sun Nov 27, 2005 3:17 pm

Post by OpHI »

hello all & thank you Lazyleopard for the amazing job you have done.

Like most of all i tryed to get zoneminder to work with the gentoo ebuild or even tryed to install it from the latest tarball downloaded in here and i failed all the time. so i found very usefull to use the ebuild you provided
in here.

As i am getting an error message when i try to emerge it. I wonder if i am missing something on my system or if i have done something wrong while preparing it. if you have any idea why it happens, here is my error message i hope it will helps.

Code: Select all

>>> emerge (1 of 1) www-misc/zoneminder-1.21.4 to /
>>> md5 files   ;-) zoneminder-0.9.12.ebuild
>>> md5 files   ;-) zoneminder-1.21.2.ebuild
>>> md5 files   ;-) zoneminder-1.21.3.ebuild
>>> md5 files   ;-) zoneminder-1.21.4.ebuild
>>> md5 files   ;-) files/digest-zoneminder-0.9.12
>>> md5 files   ;-) files/digest-zoneminder-1.21.2
>>> md5 files   ;-) files/digest-zoneminder-1.21.3
>>> md5 files   ;-) files/zmconfig-gentoo.txt
>>> md5 files   ;-) files/postinstall.txt
>>> md5 files   ;-) files/zm-1.21.4-security.patch
>>> md5 files   ;-) files/zm-1.21.4-zone.patch
>>> md5 files   ;-) files/zm-1.21.4-config.txt
>>> md5 files   ;-) files/zm-1.21.4-scripts.patch
>>> md5 files   ;-) files/digest-zoneminder-1.21.4
>>> md5 src_uri ;-) zm-1.21.4.tar.gz
>>> Unpacking source...
>>> Unpacking zm-1.21.4.tar.gz to /var/tmp/portage/zoneminder-1.21.4/work
 * Applying zm-1.21.4-security.patch ...                                                                                 [ ok
 * Applying zm-1.21.4-scripts.patch ...

 * Failed Patch: zm-1.21.4-scripts.patch !
 *  ( /usr/portage/www-misc/zoneminder/files/zm-1.21.4-scripts.patch )
 *
 * Include in your bugreport the contents of:
 *
 *   /var/tmp/portage/zoneminder-1.21.4/temp/zm-1.21.4-scripts.patch-4883.out


!!! ERROR: www-misc/zoneminder-1.21.4 failed.
!!! Function epatch, Line 363, Exitcode 0
!!! Failed Patch: zm-1.21.4-scripts.patch!
!!! If you need support, post the topmost build error, NOT this status message.
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

Hmmm... I expect that one of the patches in zm-1.21.4-scripts.patch has subsequently been applied to the main distribution tar file, so trying to apply it again causes the build to crash.

Try editing the zm-1.21.4-scripts.patch file to remove this patch

Code: Select all

--- db/zmschema.sql.z.orig	2005-11-07 12:03:21.000000000 +0000
+++ db/zmschema.sql.z	2005-11-12 23:08:37.000000000 +0000
@@ -375,7 +375,7 @@
 --
 -- Create a default admin user.
 --
-insert into Users values ('','admin',password('admin'),'',1,'View','Edit','Edit','Edit',NULL);
+insert into Users values ('','admin',password('admin'),'',1,'View','Edit','Edit','Edit','',NULL);
 --
 -- Add in a sample filter to purge the oldest 5 events when the disk is 95% full, delete is disabled though
 --
then re-run the "ebuild zoneminder-1.21.4.ebuild digest", and re-try the emerge...

PS: I'd have put the custom ebuilds in /usr/local/portage (or wherever you have PORTDIR_OVERLAY in /etc/make.conf pointing) rather than in /usr/portage, as /usr/portage will get clobbered next time you run "emerge --sync".
Rick Hewett
OpHI
Posts: 3
Joined: Sun Nov 27, 2005 3:17 pm

Post by OpHI »

ok got it, i ll try right now after diner and let you know how it works, will fix that portage thing too, ty for the tip.

ok well now everything is patching fine, but it seems that i am missing some dependencies cause the compilation starts fine but it end on the following error:

Code: Select all

zm_mpeg.cpp: In member function `double VideoStream::EncodeFrame(uint8_t*, int,
   bool, unsigned int)':
zm_mpeg.cpp:331: error: 'struct AVCodecContext' has no member named 'time_base'
zm_mpeg.cpp:331: error: `av_rescale_q' undeclared (first use this function)
zm_mpeg.cpp:331: error: (Each undeclared identifier is reported only once for
   each function it appears in.)
make[2]: *** [zm_mpeg.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/portage/zoneminder-1.21.4/work/zm-1.21.4/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/zoneminder-1.21.4/work/zm-1.21.4'
make: *** [all] Error 2
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post by lazyleopard »

Uh oh. Now you're into ffmpeg territory, and I've never tried installing with ffmpeg. I think, if you search this forum for references to AVCodecContext you may well find posts that give some hints, though.
Rick Hewett
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

There are two versions that I have tried to compile with and worked 0.4.8 and CVS. The 0.4.9-1 version does not seem to work.
Regards,
Cordel
Post Reply