Skip to content

(Português) Vídeo: Augeas no Locaweb 5o. TechDay

Sorry, this entry is only available in Português.

This blog has a new domain name: ppadron.blog.br

Compared to the old address (ppadron.w3p.com.br), the new one (ppadron.blog.br) is easier to remember and more intuitive. If you happen to follow this blog, please update your RSS reader. The old address will still work though, thanks to Apache’s RedirectMatch directive. This is the .htaccess file at ppadron.w3p.com.br:

RedirectMatch permanent (.*)$ http://ppadron.blog.br$1

This will redirect (301 Moved Permanently) anything from the old domain to the new one, preserving WordPress permalinks.

PHP Augeas extension released

A few weeks ago I did the first release of augeas, my first PECL extension. Augeas is a configuration editing tool that provides an unified API to different configuration file formats. Quoting the official website:

Augeas is a configuration editing tool. It parses configuration files in their native formats and transforms them into a tree. Configuration changes are made by manipulating this tree and saving it back into native config files.

After the second release, I notified David Lutterkort, who was kind enough to add the PHP extension to the list of language bindings in the Augeas website.

Well, today I just released version 0.4.0 (thanks to Pierre Joye for fixing the upload page), which includes a new method (Augeas::mv()) and finally a PHPUnit test suite (AllTests.php).

The next items in my TODO list regarding this project are (in no particular order):

Here’s a sample of what you can do with Augeas:

$aug = new Augeas();
 
// let's disable register_globals!
$aug->set("/files/etc/php.ini/PHP/register_globals", "Off");
 
if (!$aug->save()) {
    die("You do not have enough privileges to edit php.ini file.");
}

How easy was that? No regex, no fopen, no hassle.

Resources on how to write your own PHP extension

A few days ago I started to write my first PHP extension, and I have to admit it was a pain in the beginning. Actually it still is, but I’m the one to blame for lacking some C skills. Anyway, my advice is: if you want to write your own extension you’d better have a good reason to do so. Here are some of the most common ones:

  • increase performance
  • change PHP behavior (take a look at these PECL extensions)
  • wrap a C library
  • you are very curious and want to know how to do it anyway

If you still want to give it a try, here are some of the things that helped me along the way:

Maybe I’ll write some posts about this. Maybe.

How to install Ruby 1.8.6 RPM package on RHEL3

I have to manage a few RHEL3 servers (i386), and since I’m using Puppet in my environment, it would be great to use it in those servers also. However, Puppet requires ruby >= 1.8.1, and RHEL3 ships ruby 1.6.8.

Instead of compiling ruby on the server (quick and dirty), I rebuilt the RPM based on the specs from Fedora 11. The only change I had to make was in the list of build dependencies. Here’s my note in the %changelog section of the specfile:

* Tue Oct 27 2009 Pedro Padron <ppadron@w3p.com.br> - 1.8.6.369-2
- build-deps: XFree86-devel instead of libX11-devel to build in RHEL3

Here’s the source RPM package:

ruby-1.8.6.369-2.src.rpm

To rebuild it:

$ rpmbuild --rebuild --define 'dist .el3' ruby-1.8.6.369-2.src.rpm

Here’s the list of packages that will be generated:

ruby-1.8.6.369-2.el3.i386.rpm
ruby-devel-1.8.6.369-2.el3.i386.rpm
ruby-docs-1.8.6.369-2.el3.i386.rpm
ruby-irb-1.8.6.369-2.el3.i386.rpm
ruby-libs-1.8.6.369-2.el3.i386.rpm
ruby-mode-1.8.6.369-2.el3.i386.rpm
ruby-rdoc-1.8.6.369-2.el3.i386.rpm
ruby-ri-1.8.6.369-2.el3.i386.rpm
ruby-tcltk-1.8.6.369-2.el3.i386.rpm

If you are interested in installing puppet as well, you will also need augeas and it’s ruby bindings:

augeas-0.5.0-2.src.rpm
ruby-augeas-0.3.0-1.src.rpm

And again:

$ rpmbuild --rebuild --define 'dist .el3' augeas-0.5.0-2.src.rpm
$ rpmbuild --rebuild --define 'dist .el3' ruby-augeas-0.3.0-1.src.rpm