summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-07 09:09:08 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-07 09:09:08 +0000
commit665a629eb40eb52026e905ec70f149459db5732a (patch)
tree49949b660f947a4e423ba78e269b75cda6761ba6 /usr.sbin/pkg_add/OpenBSD/PackingElement.pm
parent4eb0dcc5a813ae9fab8fbfa8f585457f551ad6a3 (diff)
split common code into run_if_exists
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD/PackingElement.pm')
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackingElement.pm29
1 files changed, 18 insertions, 11 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
index 7d734b402a1..0c11cc5c2dd 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackingElement.pm,v 1.102 2007/05/07 09:03:44 espie Exp $
+# $OpenBSD: PackingElement.pm,v 1.103 2007/05/07 09:09:07 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -1077,6 +1077,19 @@ sub restore_fontdir
}
}
+sub run_if_exists
+{
+ my ($cmd, @l) = @_;
+
+ require OpenBSD::Error;
+
+ if (-x $cmd) {
+ OpenBSD::Error::System($cmd, @l);
+ } else {
+ OpenBSD::Error::Warn("$cmd not found\n");
+ }
+}
+
sub finish_fontdirs
{
my $state = shift;
@@ -1087,17 +1100,11 @@ sub finish_fontdirs
map { update_fontalias($_) } @l unless $state->{not};
print "You may wish to update your font path for ", join(' ', @l), "\n";
return if $state->{not};
- if (-x "/usr/X11R6/bin/mkfontdir") {
- OpenBSD::Error::System("/usr/X11R6/bin/mkfontdir", @l);
- } else {
- OpenBSD::Error::Warn("/usr/X11R6/bin/mkfontdir not found\n");
- }
+ run_if_exists("/usr/X11R6/bin/mkfontdir");
+
map { restore_fontdir($_) } @l;
- if (-x "/usr/X11R6/bin/fc-cache") {
- OpenBSD::Error::System("/usr/X11R6/bin/fc-cache", @l);
- } else {
- OpenBSD::Error::Warn("/usr/X11R6/bin/fc-cache not found\n");
- }
+
+ run_if_exists("/usr/X11R6/bin/fc-cache");
}
}