« Another eye exam, another pair of glasses?Apparently my dd-wrt does loopback now »

Wonder if this will work - package_method=>freebsd_portmaster and /var/db/pkg

08/04/13

  06:03:00 pm, by The Dreamer   , 976 words  
Categories: FreeBSD, CFEngine

Wonder if this will work - package_method=>freebsd_portmaster and /var/db/pkg

Then later I found there's another problem....while an update to php results in all the installed extensions getting updated, largely because they're all sub ports of the main php distfile. It doesn't update the extensions, namely the pecl-* ports.

So, with the appearance of body package_method freebsd_portmaster with 3.5.0, I decided to see about having CFEngine 3 manage the update of these ports. Couldn't use the "need_fix_php" class, because updating these ports updates 'extensions.ini'....needed to look at something else.

While some ports cease as part of having the package get uninstalled out from under them, and aren't restarted when the
updated package is put into place. Which was an annoyance that I was able to quickly resolve with CFEngine and processes: and commands: promises, or services: promises, to start the service back up... apache will keep on running. So, I wanted a quick and dirty way to restart (rather than reload) apache when apache get's updated.

For this I went with laying a tripwire on the executable file "/usr/local/sbin/httpd", it kind of works...sometimes cf-agent is invoked while the port is being replaced, so I'll get an angry message to the effect that "/usr/local/etc/rc.d/apache22" was supposed to exist and be executable.... Perhaps I need a way to compare the oldest running process to the file date? U-( Or perhaps, there's something simple that I've overlooked....

But, for the update pecl-* ports after php is updated, I went with laying a tripwire on the php executable "/usr/local/bin/php" and then try to figure out a way to use body package_method freebsd_portmaster....

:hmm:

Well, which pecl-* ports are installed on a given host varies, and not wanting to create and maintain the lists in the CFEngine inputs file...thinking there should be a way to do it using a function. I with with this as my first attempt.

Code

vars:
 
    "pecl_list"    slist => lsdir("/var/db/pkg", "pecl-.*", "false");
 
packages:
 
    "$(pecl_list)"
 
                   package_policy  => "update",
                   package_method  => freebsd_portmaster;

Unfortunately, an update rolls around and it doesn't work.

While I would update the pecl-* ports this way:

Shell

root@zen:/var/db/pkg 1# portmaster pecl-*

freebsd_portmaster wants 'pecl-memcache' instead of 'pecl-memcache-3.0.8' that the above method would generate, nor does it want its ORIGIN 'databases/pecl-memcache'....which is how I call portmaster when installing a new port or restarting after portmaster bails on me. Instead its going to try a list of '/usr/ports/[categories]/' prepended to the port and go with the first one. This would result in it performing '/usr/local/sbin/portmaster -D -G --noconfirm /usr/ports/databases/pecl-memcache'

Kind of a poor way to map CFEngine package naming conventions to FreeBSD ports. Since there are ports of similar names, of totally different purpose.

The first obvious example is 'nut'. I have nut (Network Ups Tools) installed on some FreeBSD servers, so they can get signaling from the UPS its plugged into. That port is 'sysutils/nut', but the package_file_repositories list is alphabetical, so 'misc/nut' will match first....which is some kind of nutrition software. If they were both installed, they wouldn't collide in /var/db/pkg if the kept the same package name as the versions are hugely different and the contained ORIGIN: would point to the correct location in /usr/ports. As it is, 'misc/nut' has a PKGNAMEPREFIX defined....so it would be installed as 'health-nut-$(version)'

A worse example might be 'archivers/rvm' - "Archive manager that uses rsync to manage backups", 'devel/rvm' - "A persistent VM library - used by the Code distributed filesystem", and 'sysutils/rvm' - "Tool which allows you to install, manage and work with multiple ruby environments" ... the latter doesn't actually exist as a port though. :> So not sure that I would install or use it... vagrant not available as port is the first barrier to using my FreeBSD workstation for that work....

Anyhoo....this meant just hacking the version off of the string "pecl-memcache-3.0.8" wasn't guaranteed to work. It would in this case though. At first I thought about parsing the +CONTENTS file to get ORIGIN...when I decided that the output from "/usr/sbin/pkg_info -oQ pecl-memcache-3.0.8" would be easier to deal with in CFEngine.

So, my untested solution is:

Code

bundle agent apache
{
vars:
 
    ...
    "php_file"    string => "/usr/local/bin/php";
    "pecl_list"    slist => lsdir("/var/db/pkg", "pecl-.*", "false");
    ...
 
...
 
files:
 
    ...
    "$(php_file)"
        comment => "Check if php executable has been updated",
        changes => detect_all_change_using(md5),
        classes => if_repaired("update_pecl");
    ...
 
methods:
 
    freebsd.update_pecl::
 
        "any"   usebundle => package_update("$(pecl_list)");
 
...
 
}
 
bundle agent package_update(pkg_dir)
{
vars:
 
    "pkg_info" string => execresult("/usr/sbin/pkg_info -oQ $(pkg_dir)","noshell");
    "port"     string => lastnode("$(pkg_info)","/");
 
packages:
 
    "$(port)"  package_policy => "update",
               package_method => freebsd_portmater;
}

Now to just wait until the next update to see if this works :lalala:

Pages: · 2

1 comment

Comment from: The Dreamer [Member]  

It didn’t….and neither did package_policy => “reinstall”

Next up is add package_select/package_version, since that’s what it complained about in refusing to reinstall.

09/18/13 @ 19:07
Now instead of subjecting some poor random forum to a long rambling thought, I will try to consolidate those things into this blog where they can be more easily ignored profess to be collected thoughts from my mind.

Latest Poopli Updaters -- http://lkc.me/poop

bloglovin

There are 20 years 5 months 27 days 1 hour 22 minutes and 53 seconds until the end of time.
And, it has been 4 years 7 months 1 day 12 hours 40 minutes and 3 seconds since The Doctor saved us all from the end of the World!

Search

July 2017
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Google

Linkblog

  XML Feeds

Who's Online?

  • Guest Users: 34
This seal is issued to lawrencechen.net by StopTheHacker Inc.
powered by b2evolution

hosted by
Green Web Hosting! This site hosted by DreamHost.

monitored by
Monitored by eXternalTest
SiteUptime Web Site Monitoring Service
website uptime