Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jozef (8299)

jozef
  (email not shown publicly)
http://jozef.kutej.net/
Jabber: jozef@kutej.net

Journal of jozef (8299)

Monday June 01, 2009
01:05 PM

Parse::Deb::Control

[ #39061 ]

I've created this module for one reason and that is to be able to automatically modify Debian control files. Especially the debian/control where the package names are located together will all Build-Depends, Build-Depends-Indep, Build-Conflicts, Pre-Depends, Depends, Conflicts, Replaces, Provides, Suggests and Recommends. There is already Parse::DebControl which is ok for reading but, I really wanted to make sure that the automated change changes just the minimum that is necessary. Like if someone will just edit "by hand". Editing manually was not an option as there are ~150 places that needed I needed to prefix with "corp-" just in Perl source debian/control file. So I've created a parsing module.

The structure of control files is described in Debian Policy Manual, Chapter 5 and it's quite simple. Basicaly sections separated by empty lines. Each section with key+colon+value. Values can be on more lines, if the next line starts with white space it's part of the previous value.

So how is the Parse::Deb::Control working? When parsing, there are 2 arrays filled in. One @structure, the other one @content. @structure holds the keys+empty lines and @content all the data. Thanks to the @structure the line ordering is preserver and doesn't change through the parse+modify+save cycle. Which allows to use diff to check and see what really changed. After the control file is parsed the ->control function is called that generates back the control file string. This one is compared with the original file and exception is thrown if they doesn't match. After the modification and save the generated control file string is parsed again which triggers the parsing+stringifying+comparing with original again. This mechanism makes sure that control file can be generated equal as the original and no error was introduced that will make the future parsing unpossible.

I've used Parse::Deb::Control to modify >300 control files so far and worked good for all of them. For example usage see deb-control-prefix-perl which modifies - Maintainer, Uploaders, Source, Package, all the dependecy places and the long package description.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.