[libconfig-model-dpkg-perl] 03/06: Backend::Dpkg can cope with root arg without /
dod at debian.org
dod at debian.org
Sat Jan 20 10:05:49 UTC 2018
This is an automated email from the git hooks/post-receive script.
dod pushed a commit to annotated tag debian/2.105
in repository libconfig-model-dpkg-perl.
commit 8fbe5065c20d0ad303f99562b0f5d586e75292ae
Author: Dominique Dumont <dod at debian.org>
Date: Fri Jan 19 20:50:20 2018 +0100
Backend::Dpkg can cope with root arg without /
Config::Model used to provide $args{root} for tests with a trailing
slash.
All Backends are being reworked to use Path::Tiny (and be simplified).
WIth this commit, this backend can cope with old root arg (a string
with trailing /) and new root arg (a Path::Tiny object that stringifies
to a string *without* trailing slash)
---
lib/Config/Model/Backend/Dpkg.pm | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/lib/Config/Model/Backend/Dpkg.pm b/lib/Config/Model/Backend/Dpkg.pm
index 708f768..e19ed09 100644
--- a/lib/Config/Model/Backend/Dpkg.pm
+++ b/lib/Config/Model/Backend/Dpkg.pm
@@ -29,8 +29,20 @@ around read_hash => sub ( $orig, $self, $obj, $elt, $file, $check, $args ) {
$self->$method( $obj, $elt, $file, $check, $args );
};
+# TODO: use a role provided by Config::Model
+sub cfg_path {
+ my $self = shift;
+ my %args = @_;
+ my $cfg_dir = $args{config_dir};
+ my $dir
+ = $args{root} ? path($args{root})->child($cfg_dir)
+ : ref($cfg_dir) ? $cfg_dir
+ : path( $cfg_dir);
+ return $dir;
+}
+
sub read_install_files ( $self, $hash, $elt, $file, $check, $args ) {
- my $dir = path($args->{root} . $args->{config_dir});
+ my $dir = $self->cfg_path(%$args);
return unless $dir->exists;
@@ -44,7 +56,7 @@ sub read_install_files ( $self, $hash, $elt, $file, $check, $args ) {
}
sub read_patch_series ( $self, $hash, $elt, $file, $check, $args ) {
- my $patch_dir = $args->{root} . $args->{config_dir} . "patches";
+ my $patch_dir = $self->cfg_path(%$args)->child("patches");
$logger->info("Checking patches directory ($patch_dir)");
my $series_files = "$patch_dir/series";
@@ -110,7 +122,9 @@ sub write {
# check => yes|no|skip
my $check = $args{check} || 'yes';
- my $dir = $args{root} . $args{config_dir};
+
+ my $dir = $self->cfg_path(%args);
+
mkpath( $dir, { mode => 0755 } ) unless -d $dir;
my $node = $args{object};
$logger->debug( "Dpkg write called on node ", $node->name );
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-dpkg-perl.git
More information about the Pkg-perl-cvs-commits
mailing list