From facc1b9a5e0f81b144c1649b0475f47fc7da50cf Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 7 Jan 2003 09:31:30 +0000 Subject: - simplify by reusing list_passwd() - simplify program flow - one perl_checker fix - simplify directories list building - simplify test: if a file is a plain regular file, testing if it's a directory is useless; anyway, this test is probably bogus and should just be -e and not -f --- perl-install/printer/gimp.pm | 47 +++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'perl-install/printer') diff --git a/perl-install/printer/gimp.pm b/perl-install/printer/gimp.pm index b3cfe8f1e..883d5cd10 100644 --- a/perl-install/printer/gimp.pm +++ b/perl-install/printer/gimp.pm @@ -212,34 +212,27 @@ sub makeprinterentry { } sub findconfigfiles { - my @configfilenames; - push @configfilenames, ".gimp-1.2/printrc" if -d "$::prefix/usr/lib/gimp/1.2"; - push @configfilenames, ".gimp-1.3/printrc" if -d "$::prefix/usr/lib/gimp/1.3"; + my @configfilenames = (if_(-d "$::prefix/usr/lib/gimp/1.2", ".gimp-1.2/printrc"), + if_( -d "$::prefix/usr/lib/gimp/1.3", ".gimp-1.3/printrc")); + return () unless @configfilenames; my @filestotreat; - local *PASSWD; - open PASSWD, "< $::prefix/etc/passwd" or die "Cannot read /etc/passwd!\n"; - local $_; - while () { - chomp; - if (/^([^:]+):[^:]*:([^:]+):([^:]+):[^:]*:([^:]+):[^:]*$/) { - my ($username, $uid, $gid, $homedir) = ($1, $2, $3, $4); - if (($uid == 0 || $uid >= 500) && $username ne "nobody") { - foreach my $file (@configfilenames) { - my $dir = "$homedir/$file"; - $dir =~ s,/[^/]*$,,; - next if -f $dir && ! -d $dir; - if (! -d "$::prefix$dir") { - eval { mkdir_p("$::prefix$dir") } or next; - run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", $dir) or next; - } - if (! -f "$::prefix$homedir/$file") { - eval { output("$::prefix$homedir/$file", "#PRINTRCv1 written by GIMP-PRINT 4.2.2 - 13 Sep 2002\n") } or next; - run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", "$homedir/$file") or next; - } - push @filestotreat, "$homedir/$file"; - } - } - } + foreach (&list_passwd()) { + my ($username, undef, $uid, $gid, undef, undef, undef, $homedir) = @$_; + next if 0 < $uid && $uid < 500 || $username eq "nobody"; + foreach my $file (@configfilenames) { + my $dir = "$homedir/$file"; + $dir =~ s,/[^/]*$,,; + next if -f $dir; + if (! -d "$::prefix$dir") { + eval { mkdir_p("$::prefix$dir") } or next; + run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", $dir) or next; + } + if (! -f "$::prefix$homedir/$file") { + eval { output("$::prefix$homedir/$file", "#PRINTRCv1 written by GIMP-PRINT 4.2.2 - 13 Sep 2002\n") } or next; + run_program::rooted($::prefix, "/bin/chown", "$uid.$gid", "$homedir/$file") or next; + } + push @filestotreat, "$homedir/$file"; + } } @filestotreat; } -- cgit v1.2.1