diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-01-07 09:31:30 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-01-07 09:31:30 +0000 |
commit | facc1b9a5e0f81b144c1649b0475f47fc7da50cf (patch) | |
tree | 004ce31c84b179736378b4258b5bf7f27f79c030 /perl-install/printer/gimp.pm | |
parent | 7268d96dfe90cfbbd8d44ee506ae29f55c05adbc (diff) | |
download | drakx-backup-do-not-use-facc1b9a5e0f81b144c1649b0475f47fc7da50cf.tar drakx-backup-do-not-use-facc1b9a5e0f81b144c1649b0475f47fc7da50cf.tar.gz drakx-backup-do-not-use-facc1b9a5e0f81b144c1649b0475f47fc7da50cf.tar.bz2 drakx-backup-do-not-use-facc1b9a5e0f81b144c1649b0475f47fc7da50cf.tar.xz drakx-backup-do-not-use-facc1b9a5e0f81b144c1649b0475f47fc7da50cf.zip |
- 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
Diffstat (limited to 'perl-install/printer/gimp.pm')
-rw-r--r-- | perl-install/printer/gimp.pm | 47 |
1 files changed, 20 insertions, 27 deletions
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 (<PASSWD>) { - 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; } |