diff -Nru libconfig-augeas-perl-0.201/Build.PL libconfig-augeas-perl-0.301/Build.PL --- libconfig-augeas-perl-0.201/Build.PL 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/Build.PL 2008-08-29 12:42:44.000000000 +0100 @@ -20,17 +20,35 @@ use warnings FATAL => qw(all) ; use strict ; +# snatched from ExtUtils::PkgConfig +# don't go any further if pkg-config cannot be found. +my $have_pkg_config = `pkg-config --version`; + +if ($have_pkg_config eq "") { + # Warn and exit with status 0 to indicate (to the user and the CPAN + # testers infrastructure) that this module won't work on this machine. +warn <<"__EOW__"; +*** +*** Config::Augeas requires the pkg-config utility, but it doesn't +*** seem to be in your PATH. Is it correctly installed? +*** PATH=$ENV{PATH} +*** +__EOW__ + exit 0; +} + my $aug_libs = `pkg-config --libs augeas` ; my $aug_cflags = `pkg-config --cflags augeas` ; -if (not defined $aug_libs or not defined $aug_cflags) { - die "could not run 'pkg-config' to determine compiler/linker", - "flags for augeas library: $!\n"; -} - -if (not $aug_libs or not $aug_cflags) { - die "'pkg-config' didn't report any compiler/linker flags for", - "augeas library\n"; +if (not defined $aug_libs or not defined $aug_cflags + or not $aug_libs or not $aug_cflags) { + warn << "EOW1" ; +*** +*** 'pkg-config' did not find augeas lib or augeas header files. Config::Augeas +*** needs both augeas library and augeas header files to be compiled. +*** +EOW1 + exit 0; } chomp($aug_cflags, $aug_libs) ; diff -Nru libconfig-augeas-perl-0.201/ChangeLog libconfig-augeas-perl-0.301/ChangeLog --- libconfig-augeas-perl-0.201/ChangeLog 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/ChangeLog 2008-08-29 12:42:44.000000000 +0100 @@ -1,3 +1,30 @@ +2008-08-29 Dominique Dumont v0.301 + + * lib/Config/Augeas.pm (move): New method for Augeas 0.3.0 new + aug_mv function. 'move' can also be called with 'mv' + +2008-07-30 Dominique Dumont v0.203 + + * t/Config-Augeas.t: Fixed test that broke with Augeas 0.2.2 + +2008-07-29 Dominique Dumont v0.202 + + * t/Config-Augeas*.t: Removed hardcoded lense path now that this + bug is fixed in Augeas + +2008-07-28 Dominique Dumont + + * lib/Config/Augeas.xs: Backported for Perl 5.8 + + * lib/Config/Augeas.pm (insert): Can now use 'after' parameter + +2008-07-20 Dominique Dumont + + * Fixed minor error in tests + + * Fix Build.PL to avoid test failure reports when augeas library + is not installed. + 2008-07-01 Dominique Dumont v0.201 * t/Config-Augeas*.t: Documented work-around Augeas 0.2.0 diff -Nru libconfig-augeas-perl-0.201/debian/changelog libconfig-augeas-perl-0.301/debian/changelog --- libconfig-augeas-perl-0.201/debian/changelog 2008-10-25 14:50:06.000000000 +0100 +++ libconfig-augeas-perl-0.301/debian/changelog 2008-10-25 14:50:06.000000000 +0100 @@ -1,3 +1,9 @@ +libconfig-augeas-perl (0.301-1) unstable; urgency=low + + * New upstream version. (Closes: #493340) + + -- Jose Parrella Wed, 22 Oct 2008 10:24:58 -0430 + libconfig-augeas-perl (0.201-1) unstable; urgency=low * Initial Release (Closes: #490956) diff -Nru libconfig-augeas-perl-0.201/lib/Config/Augeas.pm libconfig-augeas-perl-0.301/lib/Config/Augeas.pm --- libconfig-augeas-perl-0.201/lib/Config/Augeas.pm 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/lib/Config/Augeas.pm 2008-08-29 12:42:44.000000000 +0100 @@ -21,7 +21,7 @@ use warnings; use Carp; -our $VERSION = '0.201'; +our $VERSION = '0.301'; require XSLoader; XSLoader::load('Config::Augeas', $VERSION); @@ -190,7 +190,7 @@ my $path = shift || croak __PACKAGE__,"insert: undefined path"; my $before = $where eq 'before' ? 1 - : $where eq 'before' ? 0 + : $where eq 'after' ? 0 : undef ; croak __PACKAGE__,"insert: 'where' must be 'before' or 'after' not $where" unless defined $before ; @@ -211,7 +211,7 @@ Remove path and all its children. Returns the number of entries removed. All nodes that match C, and their descendants, are -removed. +removed. (C can also be called with C) =cut @@ -223,10 +223,39 @@ my $self = shift ; my $path = shift || croak __PACKAGE__,"remove: undefined path"; - my $result ; return $self->{aug_c} -> rm($path) ; } +=head2 move ( src, dest ) + +Move the node SRC to DST. SRC must match exactly one node in the +tree. DST must either match exactly one node in the tree, or may not +exist yet. If DST exists already, it and all its descendants are +deleted. If DST does not exist yet, it and all its missing ancestors +are created. + +Note that the node SRC always becomes the node DST: when you move +C to C, the node C is now called C, no matter +whether C existed initially or not. (C can also be called +with C) + +Returns 1 in case of success, 0 otherwise. + +=cut + +sub mv { + goto &move ; +} + +sub move { + my $self = shift ; + my $src = shift || croak __PACKAGE__,"move: undefined src"; + my $dst = shift || croak __PACKAGE__,"move: undefined dst"; + + my $result = $self->{aug_c} -> mv($src,$dst) ; + return $result == 0 ? 1 : 0 ; +} + =head2 match ( pattern ) Returns an array of the elements that match of the path expression diff -Nru libconfig-augeas-perl-0.201/lib/Config/Augeas.xs libconfig-augeas-perl-0.301/lib/Config/Augeas.xs --- libconfig-augeas-perl-0.201/lib/Config/Augeas.xs 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/lib/Config/Augeas.xs 2008-08-29 12:42:44.000000000 +0100 @@ -47,31 +47,60 @@ } Config_Augeas* -aug_init(char* root = NULL ,char* loadpath = NULL ,unsigned int flags = 0) +aug_init(root = NULL ,loadpath = NULL ,flags = 0) + char* root + char* loadpath + unsigned int flags MODULE = Config::Augeas PACKAGE = Config::AugeasPtr PREFIX = aug_ void -aug_DESTROY(Config_Augeas* aug) +aug_DESTROY(aug) + Config_Augeas* aug CODE: //printf("destroying aug object\n"); aug_close(aug); -int -aug_get(IN Config_Augeas* aug, IN char* path, OUTLIST const char* value) +const char* +aug_get(aug, path) + Config_Augeas* aug + char* path + PREINIT: + int ret ; + CODE: + ret = aug_get(aug, path, &RETVAL); + OUTPUT: + RETVAL int -aug_set(Config_Augeas* aug, const char* path, char* c_value) +aug_set(aug, path, c_value) + Config_Augeas* aug + const char* path + char* c_value + +int +aug_insert(aug, path, label, before) + Config_Augeas* aug + const char* path + const char* label + int before int -aug_insert(Config_Augeas* aug, const char* path, const char* label, int before) +aug_rm(aug, path); + Config_Augeas *aug + const char *path int -aug_rm(Config_Augeas *aug, const char *path); +aug_mv(aug, src, dst); + Config_Augeas *aug + const char *src + const char *dst void -aug_match(Config_Augeas *aug, const char *pattern); +aug_match(aug, pattern); + Config_Augeas *aug + const char *pattern PREINIT: char** matches; int i ; @@ -93,7 +122,9 @@ free(matches); int -aug_count_match(Config_Augeas *aug, const char *pattern); +aug_count_match(aug, pattern); + Config_Augeas *aug + const char *pattern CODE: RETVAL = aug_match(aug, pattern,NULL); OUTPUT: @@ -101,11 +132,15 @@ int -aug_save(Config_Augeas *aug); +aug_save( aug ); + Config_Augeas *aug # See example 9 in perlxstut man page int -aug_print(Config_Augeas *aug, OutputStream stream, const char* path); +aug_print(aug, stream, path); + Config_Augeas *aug + OutputStream stream + const char* path PREINIT: FILE *fp ; CODE: diff -Nru libconfig-augeas-perl-0.201/META.yml libconfig-augeas-perl-0.301/META.yml --- libconfig-augeas-perl-0.201/META.yml 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/META.yml 2008-08-29 12:42:44.000000000 +0100 @@ -1,6 +1,6 @@ --- name: Config-Augeas -version: 0.201 +version: 0.301 author: - Dominique Dumont (ddumont at cpan dot org) abstract: Edit configuration files through Augeas C library @@ -11,7 +11,7 @@ provides: Config::Augeas: file: lib/Config/Augeas.pm - version: 0.201 + version: 0.301 generated_by: Module::Build version 0.280801 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html diff -Nru libconfig-augeas-perl-0.201/t/Config-AugeasC.t libconfig-augeas-perl-0.301/t/Config-AugeasC.t --- libconfig-augeas-perl-0.201/t/Config-AugeasC.t 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/t/Config-AugeasC.t 2008-08-29 12:42:44.000000000 +0100 @@ -6,9 +6,14 @@ # change 'tests => 2' to 'tests => last_test_to_print'; -use Test::More tests => 15; +use Test::More tests => 18; +use ExtUtils::testlib; + BEGIN { use_ok('Config::Augeas') }; +use strict; +use warnings ; + package Config::Augeas; # constants are not exported so we switch package @@ -34,16 +39,11 @@ ok(1,"Compilation done"); my $aug_root = 'augeas-box/'; -my $lens_dir ; - -# work-around augeas bug. Remove after augeas >0.2.0 is released -foreach my $d ('/usr/local/share/augeas/lenses/') { - $lens_dir = $d if -d $d; -} +my $written_file = $aug_root."etc/hosts.augnew" ; +unlink ($written_file) if -e $written_file ; -my @initargs = ($aug_root) ; -push @initargs , $lens_dir if defined $lens_dir ; -my $augc = Config::Augeas::init(@initargs) ; +my $augc = Config::Augeas::init($aug_root, '' , + &Config::Augeas::AUG_SAVE_NEWFILE) ; ok($augc,"Created new Augeas object"); @@ -56,17 +56,29 @@ is($ret,0,"Set new host"); +$ret = $augc->save ; +is($ret,0,"First save done") ; + +ok(-e $written_file, "File was written" ) ; +unlink ($written_file) if -e $written_file ; + $ret = $augc->get("/files/etc/hosts/2/canonical") ; is($ret,'bilbo',"Called get after set (returned $ret )"); -$augc->insert("/files/etc/hosts/1", inserted_host => 1 ) ; - -ok($augc,"insert new label"); +#$ret = $augc->insert("/files/etc/hosts/1", inserted_host => 1 ) ; +# is($ret ,0,"insert new label"); $augc->set("/files/etc/hosts/3/ipaddr","192.168.0.2") ; $augc->rm("/files/etc/hosts/3") ; ok($augc,"removed entry"); +$augc->set("/files/etc/hosts/5/ipaddr","192.168.0.3") ; +$augc->set("/files/etc/hosts/5/canonical","gandalf") ; + +$ret = $augc->mv("/files/etc/hosts/5","/files/etc/hosts/4") ; +# get return value directly from Augeas +is($ret ,0,"mv ok"); + my @a = $augc->match("/files/etc/hosts/") ; is_deeply(\@a,["/files/etc/hosts"],"match result") ; @@ -76,6 +88,10 @@ $ret = $augc->save ; is($ret,0,"save done") ; +# $augc->print(*STDOUT,'') ; + +ok(-e $written_file,"augnew file written") ; + my $wr_dir = 'wr_test' ; my $wr_file = "$wr_dir/print_test" ; if (not -d $wr_dir) { @@ -83,13 +99,12 @@ } open(WR, ">$wr_file") or die "cannot open $wr_file:$!"; -$augc->print(WR, "/files/etc/") ; +$augc->print(*WR, "/files/etc/") ; close WR; ok( -e $wr_file, "$wr_file exists" ); $ENV{AUG_ROOT} = $aug_root; -$ENV{AUGEAS_LENS_LIB}= $lens_dir if defined $lens_dir; # test may fail with augeas 0.2.0 installed in /usr/local my $augc2 = Config::Augeas::init() ; diff -Nru libconfig-augeas-perl-0.201/t/Config-Augeas.t libconfig-augeas-perl-0.301/t/Config-Augeas.t --- libconfig-augeas-perl-0.201/t/Config-Augeas.t 2008-07-01 17:21:21.000000000 +0100 +++ libconfig-augeas-perl-0.301/t/Config-Augeas.t 2008-08-29 12:42:44.000000000 +0100 @@ -8,18 +8,14 @@ use strict; use Test::More tests => 14 ; - ok(1,"Compilation done"); my $aug_root = 'augeas-box/'; -my $lens_dir ; -# work-around augeas 0.2.0. Hard-coded path will be removed -foreach my $d ('/usr/local/share/augeas/lenses/') { - $lens_dir = $d if -d $d; -} +my $written_file = $aug_root."etc/hosts.augnew" ; +unlink ($written_file) if -e $written_file ; -my $aug = Config::Augeas->new( root => $aug_root, loadpath => $lens_dir ) ; +my $aug = Config::Augeas->new( root => $aug_root, save => 'newfile' ) ; ok($aug,"Created new Augeas object"); @@ -31,21 +27,28 @@ is($ret,'localhost',"Called get (returned $ret )"); -$aug->set("/files/etc/hosts/2/ipaddr","192.168.0.1") ; -$aug->set("/files/etc/hosts/2/canonical","bilbo") ; +$aug->set("/files/etc/hosts/2/canonical","newbilbo") ; ok($aug,"Set new host"); $ret = $aug->get("/files/etc/hosts/2/canonical") ; -is($ret,'bilbo',"Called get after set (returned $ret )"); +is($ret,'newbilbo',"Called get after set (returned $ret )"); + +$aug->set("/files/etc/hosts/5/ipaddr","192.168.0.4") ; +$aug->set("/files/etc/hosts/5/canonical","gandalf") ; + +$ret = $aug->move("/files/etc/hosts/5","/files/etc/hosts/4") ; +is($ret,1,"Called move"); + +$aug->insert(3 => before => "/files/etc/hosts/4" ) ; -$aug->insert(inserted_host => before => "/files/etc/hosts/1" ) ; +ok($aug,"inserted new host"); -ok($aug,"insert new label"); +$aug->set("/files/etc/hosts/3/ipaddr","192.168.0.3") ; +$aug->set("/files/etc/hosts/3/canonical","gandalf") ; -$aug->set("/files/etc/hosts/3/ipaddr","192.168.0.2") ; -$aug->rm("/files/etc/hosts/3") ; +$aug->rm("/files/etc/hosts/4") ; ok($aug,"removed entry"); my @a = $aug->match("/files/etc/hosts/") ; @@ -57,19 +60,16 @@ $ret = $aug->save ; ok($ret,"save done") ; -$ENV{AUG_ROOT} = $aug_root; -$ENV{AUGEAS_LENS_LIB}= $lens_dir if defined $lens_dir; +ok(-e $written_file, "File was written" ) ; -# work-around: augeas 0.2.0 does not understand env variables -# this test will fail with auges 0.2.0 installed in /usr/local -my $aug2 = Config::Augeas->new(root => $aug_root) ; +open(SAVED,$written_file) || die "can't read $written_file"; +my @expect = ("127.0.0.1 localhost localhost", + "192.168.0.1 newbilbo", + "192.168.0.3 gandalf", + ); +my @content = ; +map{ chomp; s/\s+/ /g;} @content ; -ok($aug2,"Created 2nd Augeas object"); +is_deeply(\@content,\@expect,"check written file content"); -$ret = $aug2->get("/files/etc/hosts/1/ipaddr") ; -is($ret,'127.0.0.1',"Called get (returned $ret )"); - -$ret = $aug2->get("/files/etc/hosts/1/canonical") ; - -is($ret,'localhost',"Called get (returned $ret )");