summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunammx <unammx>2001-03-28 21:10:45 +0000
committerunammx <unammx>2001-03-28 21:10:45 +0000
commit6e572ee13af671bfbea132543b31d441cf40bcb6 (patch)
tree63c144b5edc2bc51621590ba036a84c548f2df7d
parent3c5d3bd7d36eb46d1abd458044b84d8b4ca1c9cc (diff)
2001-03-28 Arturo Espinosa <arturo@ximian.com>
* report.pl.in: New report code, which dumps the use of mayor and minor numbers and uses keys instead. A hash, mapping keys to messages is at the end of this file. Fitted progress report with this scheme. * *.in: use new reporting code. Some other naming and style corrections I found on the way.
-rw-r--r--ChangeLog10
-rw-r--r--boot-conf.in8
-rw-r--r--boot.pl.in38
-rw-r--r--debug.pl.in25
-rwxr-xr-xdisks-conf.in24
-rw-r--r--file.pl.in196
-rw-r--r--general.pl.in18
-rwxr-xr-xhardware-conf.in4
-rwxr-xr-xmemory-conf.in36
-rw-r--r--network.pl.in134
-rw-r--r--parse.pl.in107
-rw-r--r--platform.pl.in20
-rw-r--r--print.pl.in40
-rw-r--r--replace.pl.in52
-rw-r--r--report.pl.in191
-rw-r--r--service.pl.in55
-rwxr-xr-xshares-conf.in92
-rwxr-xr-xtime-conf.in25
-rw-r--r--users-conf.in46
19 files changed, 708 insertions, 413 deletions
diff --git a/ChangeLog b/ChangeLog
index 6923b2d..e92c6eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-03-28 Arturo Espinosa <arturo@ximian.com>
+
+ * report.pl.in: New report code, which dumps the use
+ of mayor and minor numbers and uses keys instead. A
+ hash, mapping keys to messages is at the end of this
+ file. Fitted progress report with this scheme.
+
+ * *.in: use new reporting code. Some other naming and
+ style corrections I found on the way.
+
2001-03-28 Ryan Boren <rboren@fuzzybelly.org>
* print.pl.in (xst_printcap_read): parse the ##PRINTTOOL##
diff --git a/boot-conf.in b/boot-conf.in
index b589719..62a3c6c 100644
--- a/boot-conf.in
+++ b/boot-conf.in
@@ -54,7 +54,7 @@ end_of_description;
# Find the tools
-$tool_lilo = &xst_locate_tool ("lilo");
+$tool_lilo = &xst_file_locate_tool ("lilo");
# --- XML parsing ---
@@ -229,13 +229,13 @@ sub get
sub set_immediate
{
- if (&xst_run("lilo"))
+ if (&xst_file_run("lilo"))
{
- &xst_report_warning(3, "Failed to run lilo");
+ &xst_report ("boot_lilo_failed");
}
else
{
- &xst_report_info(1, "Succesfully executed lilo");
+ &xst_report ("boot_lilo_success");
}
}
diff --git a/boot.pl.in b/boot.pl.in
index 1feb54d..7200328 100644
--- a/boot.pl.in
+++ b/boot.pl.in
@@ -35,7 +35,7 @@ sub xst_boot_parse_global_kw
my ($file, $key) = @_;
my $fd;
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
while (<$fd>)
{
@@ -62,7 +62,7 @@ sub xst_boot_parse_global
my ($fd, @line, $re);
$re = "[ \t]*=[ \t]*";
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
while (<$fd>)
{
@@ -91,7 +91,7 @@ sub xst_boot_parse_images
my ($key, $val);
$found = -1;
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
while (<$fd>)
{
@@ -126,7 +126,7 @@ sub xst_boot_set_global_kw
my ($file, $key) = @_;
my ($buff, $i, $found);
- $buff = &xst_buffer_load ($file);
+ $buff = &xst_file_buffer_load ($file);
$found = 0;
foreach $i (@$buff)
@@ -153,8 +153,8 @@ sub xst_boot_set_global_kw
last if $found;
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
@@ -163,7 +163,7 @@ sub xst_boot_set_global
my ($file, $key, $val) = @_;
my ($buff, $i, $found);
- $buff = &xst_buffer_load ($file);
+ $buff = &xst_file_buffer_load ($file);
$found = 0;
foreach $i (@$buff)
@@ -194,8 +194,8 @@ sub xst_boot_set_global
last if $found;
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
@@ -204,7 +204,7 @@ sub xst_boot_del_global
my ($file, $key) = @_;
my ($buff, $i);
- $buff = &xst_buffer_load ($file);
+ $buff = &xst_file_buffer_load ($file);
foreach $i (@$buff)
{
@@ -217,8 +217,8 @@ sub xst_boot_del_global
}
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
@@ -226,7 +226,7 @@ sub xst_boot_conf_del_images
{
my ($fn, $images) = @_;
- $buf = &xst_buffer_load ($fn);
+ $buf = &xst_file_buffer_load ($fn);
$found = 1;
foreach $i (@$buf)
@@ -247,8 +247,8 @@ sub xst_boot_conf_del_images
$i = "";
}
- &xst_buffer_clean ($buf);
- return &xst_buffer_save ($buf, $fn);
+ &xst_file_buffer_clean ($buf);
+ return &xst_file_buffer_save ($buf, $fn);
}
@@ -275,8 +275,8 @@ sub xst_boot_conf_replace_image
my ($pre_space, $post_comment);
my (@line, $key, $op, $txt);
- $buff = &xst_buffer_load ($file);
- &xst_buffer_join_lines ($buff);
+ $buff = &xst_file_buffer_load ($file);
+ &xst_file_buffer_join_lines ($buff);
$found = 0;
@@ -389,8 +389,8 @@ sub xst_boot_conf_replace_image
}
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
diff --git a/debug.pl.in b/debug.pl.in
index 557aee8..6e2373d 100644
--- a/debug.pl.in
+++ b/debug.pl.in
@@ -65,21 +65,15 @@ sub xst_debug_print_indent
{
my $indent = $_[0];
my $indent_string = "";
- my $i;
-
- for ($i = 0; $i < $indent; $i++)
- {
- $indent_string .= " ";
- }
-
+
+ $indent_string = " " x $indent;
&xst_debug_print_string ($indent_string);
}
sub xst_debug_print_indented_string
{
- my $indent = shift @_;
- my @string = @_;
+ my ($indent, @string) = @_;
&xst_debug_print_indent ($indent);
&xst_debug_print_string (@string);
@@ -148,7 +142,7 @@ sub xst_debug_print_struct_r
}
-$xst_debug_was_made = 0;
+$xst_debug_dir_rotation_was_made = 0;
sub xst_debug_rotate_try
{
@@ -159,25 +153,26 @@ sub xst_debug_rotate_try
# If this is the first debug created by this tool on this invocation,
# rotate the debug directories and create a new, empty one.
- if (!$xst_debug_was_made)
+ if (!$xst_debug_dir_rotation_was_made)
{
my $i;
+ $xst_debug_dir_rotation_was_made = 1;
+
if (stat ("$debug_tool_dir/9"))
{
- &xst_run ("rm -Rf $debug_tool_dir/9");
+ &xst_file_run ("rm -Rf $debug_tool_dir/9");
}
for ($i = 8; $i; $i--)
{
if (stat ("$debug_tool_dir/$i"))
{
- &xst_run ("mv $debug_tool_dir/$i $debug_tool_dir/" . ($i+1));
+ &xst_file_run ("mv $debug_tool_dir/$i $debug_tool_dir/" . ($i+1));
}
}
- &xst_create_path ("$debug_tool_dir/1");
- $xst_debug_was_made = 1;
+ &xst_file_create_path ("$debug_tool_dir/1");
}
}
diff --git a/disks-conf.in b/disks-conf.in
index 775052b..53f88a7 100755
--- a/disks-conf.in
+++ b/disks-conf.in
@@ -271,7 +271,7 @@ sub read_fstab
# Find the file.
- $fstab_file = &xst_open_read_from_names(@fstab_names);
+ $fstab_file = &xst_file_open_read_from_names(@fstab_names);
if (not $fstab_file) { return; } # We didn't find it.
*FSTAB_FILE = $fstab_file;
@@ -319,7 +319,7 @@ sub write_fstab
my ($ifh, $ofh);
local (*INFILE, *OUTFILE);
- ($ifh, $ofh) = &xst_open_filter_write_from_names(@fstab_names);
+ ($ifh, $ofh) = &xst_file_open_filter_write_from_names(@fstab_names);
if (not $ofh) { return; } # No point if we can't write.
*INFILE = $ifh; *OUTFILE = $ofh;
@@ -411,7 +411,7 @@ sub write_fstab
{
my $part = $cf_disks[$i]->{partitions}[$j];
- &xst_report_info(01, "Adding " . $cf_disks[$i]->{partitions}[$j]->{device} . " to fstab");
+ &xst_report ("disks_fstab_add", $cf_disks[$i]->{partitions}[$j]->{device});
# Write record.
@@ -483,13 +483,13 @@ sub get_fdisk
"/dev/xda", "/dev/xdb" );
- $fdisk_tool = &xst_locate_tool("fdisk");
+ $fdisk_tool = &xst_file_locate_tool("fdisk");
for $dev (@check_devs)
{
my ($disk, $device, $point, $fs, $options, $check, $size, $bootable);
- &xst_report_info(02, "Looking for partitions on $dev");
+ &xst_report ("disks_partition_probe", $dev);
open(FDISK_HD, "$fdisk_tool -l $dev 2>/dev/null |");
while (<FDISK_HD>)
@@ -529,7 +529,7 @@ sub get_fdisk
}
close(FDISK_HD);
- &xst_report_info(03, "Querying size of $dev");
+ &xst_report ("disks_size_query", $dev);
open(FDISK_HD, "$fdisk_tool -s $dev 2>/dev/null |");
($size) = (<FDISK_HD> =~ /([0-9]+)/);
@@ -732,8 +732,8 @@ sub set_immediate
my $mount_tool;
my $umount_tool;
- $mount_tool = &xst_locate_tool("mount");
- $umount_tool = &xst_locate_tool("umount");
+ $mount_tool = &xst_file_locate_tool("mount");
+ $umount_tool = &xst_file_locate_tool("umount");
# Count partitions.
@@ -761,24 +761,24 @@ sub set_immediate
{
if ($cf_disks[$i]->{partitions}[$j]->{mounted})
{
- &xst_report_info(4, "Mounting " . $cf_disks[$i]->{partitions}[$j]->{device});
+ &xst_report ("disks_mount", $cf_disks[$i]->{partitions}[$j]->{device});
system "$mount_tool " . $cf_disks[$i]->{partitions}[$j]->{device} . " " .
$cf_disks[$i]->{partitions}[$j]->{point} . " >/dev/null 2>/dev/null";
}
else
{
- &xst_report_info(5, "Unmounting " . $cf_disks[$i]->{partitions}[$j]->{device});
+ &xst_report ("disks_umount", $cf_disks[$i]->{partitions}[$j]->{device});
system "$umount_tool " . $cf_disks[$i]->{partitions}[$j]->{device} . " >/dev/null 2>/dev/null";
}
- $num_done++;
+ $num_done++;
&xst_progress(10 + (80 / ($num_partitions - $num_done + 1)));
}
}
}
else
{
- &xst_report_error(01, "Could not find mount tools. No mounting done");
+ &xst_report ("disks_mount_error");
}
&xst_progress(90);
diff --git a/file.pl.in b/file.pl.in
index 4439cf9..5d6c6c7 100644
--- a/file.pl.in
+++ b/file.pl.in
@@ -60,32 +60,34 @@ sub xst_file_get_data_path
}
-sub xst_create_path
+sub xst_file_create_path
{
- my $path;
-
- $path = $_[0];
+ my $path = $_[0];
+ my @pelem;
+
$path =~ tr/\///s;
+ @pelem = split(/\//, $path); # 'a/b/c/d/' -> 'a', 'b', 'c', 'd', ''
- my @pelem = split(/\//, $path); # 'a/b/c/d/' -> 'a', 'b', 'c', 'd', ''
-
for ($path = ""; @pelem; shift @pelem)
{
$path = "$path$pelem[0]";
mkdir($path, 0770);
$path = "$path/";
}
+
+ &xst_report_enter ();
+ &xst_report ("file_create_path", $_[0]);
+ &xst_report_leave ();
}
-sub xst_create_path_for_file
+sub xst_file_create_path_for_file
{
- my $path;
-
- $path = $_[0];
+ my $path = $_[0];
+ my @pelem;
+
$path =~ tr/\///s;
-
- my @pelem = split(/\//, $path); # 'a/b/c/d/' -> 'a', 'b', 'c', 'd', ''
+ @pelem = split(/\//, $path); # 'a/b/c/d/' -> 'a', 'b', 'c', 'd', ''
for ($path = ""; @pelem; shift @pelem)
{
@@ -96,69 +98,93 @@ sub xst_create_path_for_file
$path = "$path/";
}
}
+
+ &xst_report_enter ();
+ &xst_report ("file_path_create", $_[0]);
+ &xst_report_leave ();
}
-$xst_backup_was_made = 0;
+$xst_file_backup_dir_rotation_was_made = 0;
-sub xst_backup_file
+# If this is the first backup created by this tool on this invocation,
+# rotate the backup directories and create a new, empty one.
+sub xst_file_backup_rotate_dirs
{
- my $backup_file = $_[0];
- my $backup_tool_dir = &xst_file_get_backup_path () . "/$xst_name/";
-
- # If this is the first backup created by this tool on this invocation,
- # rotate the backup directories and create a new, empty one.
-
- if (!$xst_backup_was_made)
+ my $backup_tool_dir = $_[0];
+
+ &xst_report_enter ();
+
+ if (!$xst_file_backup_dir_rotation_was_made)
{
my $i;
+ $xst_file_backup_dir_rotation_was_made = 1;
if (stat ("$backup_tool_dir/9") && !stat ("$backup_tool_dir/First"))
{
# The first rotated-up backup is the beginning of history. It is kept forever.
- &xst_run ("mv $backup_tool_dir/9 $backup_tool_dir/First");
+ &xst_file_run ("mv $backup_tool_dir/9 $backup_tool_dir/First");
}
else
{
# FIXME: rm -Rf might not work on all systems.
- &xst_run ("rm -Rf $backup_tool_dir/9");
+ &xst_file_run ("rm -Rf $backup_tool_dir/9");
}
for ($i = 8; $i; $i--)
{
if (stat ("$backup_tool_dir/$i"))
{
- &xst_run ("mv $backup_tool_dir/$i $backup_tool_dir/" . ($i+1));
+ &xst_file_run ("mv $backup_tool_dir/$i $backup_tool_dir/" . ($i+1));
}
}
- &xst_create_path_for_file ("$backup_tool_dir/1/");
- $xst_backup_was_made = 1;
+ &xst_file_create_path_for_file ("$backup_tool_dir/1/");
+ &xst_report ("file_backup_rotated", $backup_tool_dir);
}
+
+ &xst_report_enter ();
+}
+
+sub xst_file_backup
+{
+ my $backup_file = $_[0];
+ my $backup_tool_dir;
+ &xst_report_enter ();
+
+ $backup_tool_dir = &xst_file_get_backup_path () . "/$xst_name/";
+
+ &xst_file_backup_rotate_dirs ($backup_tool_dir);
+
# If the file hasn't already been backed up on this invocation, copy the
# file to the backup directory.
if (!stat ("$backup_tool_dir/1/$backup_file"))
{
- &xst_create_path_for_file ("$backup_tool_dir/1/$backup_file");
- &xst_run ("cp $backup_file $backup_tool_dir/1/$backup_file");
+ &xst_file_create_path_for_file ("$backup_tool_dir/1/$backup_file");
+ &xst_file_run ("cp $backup_file $backup_tool_dir/1/$backup_file");
+ &xst_report ("file_backup_success", $backup_tool_dir);
}
+
+ &xst_report_leave ();
}
-sub xst_open_read_from_names
+sub xst_file_open_read_from_names
{
local *FILE;
my $fname = "";
-
+
+ &xst_report_enter ();
+
foreach $name (@_)
{
if (open (FILE, "$xst_prefix/$name"))
{
- &xst_debug_print_line ("xst_open_read_from_names:$xst_prefix/$name");
+ &xst_debug_print_line ("xst_file_open_read_from_names:$xst_prefix/$name");
$fname = $name;
last;
}
@@ -168,53 +194,59 @@ sub xst_open_read_from_names
if ($fname eq "")
{
- &xst_report_warning (99, "Could not read \[@_\]");
+ &xst_report ("file_open_read_failed", "@_");
return;
}
- &xst_report_info (99, "Reading options from \[$fullname\]");
+ &xst_report ("file_open_read_success", $fullname);
+ &xst_report_leave ();
+
return *FILE;
}
-sub xst_open_write_from_names
+sub xst_file_open_write_from_names
{
local *FILE;
my $name;
my $fullname;
+
+ &xst_report_enter ();
# Find out where it lives.
- for $elem (@_) { if (stat($elem) ne "") { $name = $elem; last; } }
+ foreach $elem (@_) { if (stat($elem) ne "") { $name = $elem; last; } }
if ($name eq "")
{
$name = $_[0];
(my $fullname = "$xst_prefix/$name") =~ tr/\//\//s;
- &xst_report_warning (97, "Could not find \[@_\]. Writing to \[$fullname\]");
+ &xst_report ("file_open_write_create", "@_", $fullname);
}
else
{
(my $fullname = "$xst_prefix/$name") =~ tr/\//\//s;
- &xst_report_info (98, "Found \[$name\]. Writing to \[$fullname\]");
+ &xst_report ("file_open_write_success", $fullname);
}
($name = "$xst_prefix/$name") =~ tr/\//\//s; # '//' -> '/'
- &xst_create_path_for_file ($name);
+ &xst_file_create_path_for_file ($name);
# Make a backup if the file already exists - if the user specified a prefix,
# it might not.
if (stat ($name))
{
- &xst_backup_file ($name);
+ &xst_file_backup ($name);
}
+ &xst_report_leave ();
+
# Truncate and return filehandle.
if (!open (FILE, ">$name"))
{
- &xst_report_error (99, "Failed to write to \[$name\]");
+ &xst_report ("file_open_write_failed", "Failed to write to \[$name\]");
return;
}
@@ -222,17 +254,22 @@ sub xst_open_write_from_names
}
-sub xst_open_filter_write_from_names
+sub xst_file_open_filter_write_from_names
{
local *INFILE;
local *OUTFILE;
my ($filename, $name, $elem);
+ &xst_report_enter ();
+
# Find out where it lives.
- for $elem (@_) { if (stat ($elem) ne "") { $name = $elem; last; } }
+ foreach $name (@_)
+ {
+ last if (-e $name);
+ }
- if ($name eq "")
+ if (! -e $name)
{
# If we couldn't locate the file, and have no prefix, give up.
@@ -241,32 +278,32 @@ sub xst_open_filter_write_from_names
if ($prefix eq "")
{
- &xst_report_warning (98, "No file to patch: \[@_\]");
+ &xst_report ("file_open_filter_failed", "@_");
return(0, 0);
}
else
{
$name = $_[0];
(my $fullname = "$xst_prefix/$name") =~ tr/\//\//s;
- &xst_report_warning (97, "Could not find \[@_\]. Patching \[$fullname\]");
+ &xst_report ("file_open_filter_create", "@_", $fullname);
}
}
else
{
(my $fullname = "$xst_prefix/$name") =~ tr/\//\//s;
- &xst_report_info (98, "Found \[$name\]. Patching \[$fullname\]");
+ &xst_report ("file_open_filter_success", $name, $fullname);
}
($filename) = $name =~ /.*\/(.+)$/;
($name = "$xst_prefix/$name") =~ tr/\//\//s; # '//' -> '/'
- &xst_create_path_for_file ($name);
+ &xst_file_create_path_for_file ($name);
# Make a backup if the file already exists - if the user specified a prefix,
# it might not.
- if (stat ($name))
+ if (-e $name)
{
- &xst_backup_file ($name);
+ &xst_file_backup ($name);
}
# Return filehandles. Make a copy to use as filter input. It might be
@@ -275,18 +312,20 @@ sub xst_open_filter_write_from_names
my $tmp_path = &xst_file_get_tmp_path ();
- &xst_create_path ("$tmp_path");
+ &xst_file_create_path ("$tmp_path");
unlink ("$tmp_path/$xst_name-$filename");
- &xst_run ("cp $name $tmp_path/$xst_name-$filename");
+ &xst_file_run ("cp $name $tmp_path/$xst_name-$filename");
open (INFILE, "$tmp_path/$xst_name-$filename");
if (!open (OUTFILE, ">$name"))
{
- &xst_report_error (99, "Failed to write to \[$name\]");
+ &xst_report ("file_open_write_failed", $name);
return;
}
+ &xst_report_leave ();
+
return (*INFILE, *OUTFILE);
}
@@ -297,36 +336,42 @@ sub xst_open_filter_write_from_names
# Open $file and put it into @buffer, for in-line editting.
# \%buffer on success, undef on error.
-sub xst_buffer_load
+sub xst_file_buffer_load
{
my $file = $_[0];
my @buffer;
my $fd;
- $fd = &xst_open_read_from_names ($file);
+ &xst_report_enter ();
+ &xst_report ("file_buffer_load", $file);
+
+ $fd = &xst_file_open_read_from_names ($file);
return [] if !$fd;
@buffer = (<$fd>);
+ &xst_report_leave ();
+
return \@buffer;
}
# Take a $buffer and save it in $file. -1 is error, 0 success.
-sub xst_buffer_save
+sub xst_file_buffer_save
{
my ($buffer, $file) = @_;
my ($fd, $i);
- &xst_debug_print_string ("\nfile:$file\n");
+ &xst_report_enter ();
+ &xst_report ("file_buffer_save", $file);
foreach $i (@$buffer)
{
&xst_debug_print_string ("|" . $i);
}
- $fd = &xst_open_write_from_names ($file);
+ $fd = &xst_file_open_write_from_names ($file);
return -1 if !$fd;
if (@$buffer < 1)
@@ -347,13 +392,15 @@ sub xst_buffer_save
close $fd;
+ &xst_report_leave ();
+
return 0;
}
# Erase all empty string elements from the $buffer.
-sub xst_buffer_clean
+sub xst_file_buffer_clean
{
my $buffer = $_[0];
my $i;
@@ -365,7 +412,7 @@ sub xst_buffer_clean
}
-sub xst_buffer_join_lines
+sub xst_file_buffer_join_lines
{
my $buffer = $_[0];
my $i;
@@ -386,7 +433,7 @@ sub xst_buffer_join_lines
# --- Command-line utilities --- #
-# &xst_run (<command line>)
+# &xst_file_run (<command line>)
#
# Assumes the first word on the command line is the command-line utility
# to run, and tries to locate it, replacing it with its full path. The path
@@ -394,16 +441,18 @@ sub xst_buffer_join_lines
# redirection is appended, to make the utility perfectly silent. The
# preprocessed command line is run, and its exit value is returned.
#
-# Example: "mkswap /dev/hda3" -> "/sbin/mkswap /dev/hda3 >/dev/null 2>/dev/null".
+# Example: "mkswap /dev/hda3" -> '/bin/sh -c "/sbin/mkswap /dev/hda3 >/dev/null 2>/dev/null"'.
-sub xst_run
+sub xst_file_run
{
my ($tool_name, $tool_path, @argline);
my $command;
+ &xst_report_enter ();
+
($tool_name, @argline) = split(/ /, $_[0]);
- $tool_path = &xst_locate_tool ($tool_name);
+ $tool_path = &xst_file_locate_tool ($tool_name);
if ($tool_path eq "")
{
# Not found at all.
@@ -412,27 +461,32 @@ sub xst_run
$command = "$tool_path @argline >/dev/null 2>&1";
$command =~ s/\"/\\\"/g;
+
+ &xst_report ("file_run", "/bin/sh -c \"$command\"");
+ &xst_report_leave ();
return (system ("/bin/sh -c \"$command\""));
}
-# &xst_locate_tool
+# &xst_file_locate_tool
#
# Tries to locate a command-line utility from a set of built-in paths
# and a set of user paths (found in the environment). The path (or a negative
# entry) is cached in a hash, to avoid searching for it repeatedly.
-@xst_builtin_paths = ( "/sbin", "/usr/sbin", "/usr/local/sbin", "/bin",
- "/usr/bin", "/usr/local/bin" );
+@xst_builtin_paths = ( "/sbin", "/usr/sbin", "/usr/local/sbin",
+ "/bin", "/usr/bin", "/usr/local/bin" );
%xst_tool_paths = {};
-sub xst_locate_tool
+sub xst_file_locate_tool
{
my $found = "";
my @user_paths;
+ &xst_report_enter ();
+
$found = %xst_tool_paths->{$_[0]};
if ($found eq "0")
{
@@ -468,16 +522,18 @@ sub xst_locate_tool
if ($found)
{
%xst_tool_paths->{$_[0]} = $found;
- &xst_report_info (97, "Found $_[0] tool");
+ &xst_report ("file_locate_tool_success", $_[0]);
}
else
{
%xst_tool_paths->{$_[0]} = "0";
- &xst_report_warning (96, "Couldn't find $_[0] tool");
+ &xst_report ("file_locate_tool_failed", $_[0]);
}
}
- return($found);
+ &xst_report_leave ();
+
+ return ($found);
}
1;
diff --git a/general.pl.in b/general.pl.in
index 570ff96..26d963d 100644
--- a/general.pl.in
+++ b/general.pl.in
@@ -130,22 +130,19 @@ sub xst_print_version
sub xst_begin
{
$| = 1;
- &xst_report_begin ();
+ &xst_report ("begin");
+ &xst_report_enter ();
&xst_progress_begin ();
- if (!$xst_dist) { &xst_platform_guess (); }
-
- if ($xst_dist)
- {
- &xst_report_info (95, "Configuring for platform [$xst_dist]");
- }
+ &xst_platform_guess () if !$xst_dist;
}
sub xst_end
{
&xst_progress_end ();
- &xst_report_end ();
+ &xst_report_leave ();
+ &xst_report ("end");
}
@@ -166,6 +163,9 @@ sub xst_init
{
my @args = @_;
+ # Set the output autoflush.
+ $| = 1;
+
# Set backend descriptors.
$xst_name = $args[0];
@@ -204,7 +204,7 @@ sub xst_init
elsif ($args[0] eq "--disable-immediate") { $xst_do_immediate = 0; }
elsif ($args[0] eq "--verbose" || $args[0] eq "-v") { $xst_verbose = 1; }
elsif ($args[0] eq "--progress") { $xst_progress = 1; }
- elsif ($args[0] eq "--report") { $xst_reporting = 1; }
+ elsif ($args[0] eq "--report") { &xst_report_set_threshold (99); }
elsif ($args[0] eq "--debug") { $xst_debug = 1; }
else
{
diff --git a/hardware-conf.in b/hardware-conf.in
index 54e4da4..f2714bb 100755
--- a/hardware-conf.in
+++ b/hardware-conf.in
@@ -338,7 +338,7 @@ sub read_conf_modules
local (*CONF_MODULES_FILE);
my (%real_names);
- *CONF_MODULES_FILE = &xst_open_read_from_names (@conf_modules_names);
+ *CONF_MODULES_FILE = &xst_file_open_read_from_names (@conf_modules_names);
LINE: while (<CONF_MODULES_FILE>)
{
@@ -398,7 +398,7 @@ sub read_XF86Config
my (%section_handler_table) =
( 'InputDevice' => \&handle_input_device );
- *XF86CONFIG_FILE = &xst_open_read_from_names (@XF86Config_names);
+ *XF86CONFIG_FILE = &xst_file_open_read_from_names (@XF86Config_names);
while (<XF86CONFIG_FILE>)
{
diff --git a/memory-conf.in b/memory-conf.in
index fda3d95..ebf99a8 100755
--- a/memory-conf.in
+++ b/memory-conf.in
@@ -67,11 +67,11 @@ $progress_max = 3;
# Where are the tools?
-$cmd_swapon = &xst_locate_tool ("swapon");
-$cmd_swapoff = &xst_locate_tool ("swapoff");
-$cmd_mkswap = &xst_locate_tool ("mkswap");
-$cmd_fdisk = &xst_locate_tool ("fdisk");
-$cmd_dd = &xst_locate_tool ("dd");
+$cmd_swapon = &xst_file_locate_tool ("swapon");
+$cmd_swapoff = &xst_file_locate_tool ("swapoff");
+$cmd_mkswap = &xst_file_locate_tool ("mkswap");
+$cmd_fdisk = &xst_file_locate_tool ("fdisk");
+$cmd_dd = &xst_file_locate_tool ("dd");
# --- Internal configuration variables --- #
@@ -243,7 +243,7 @@ sub get_memory
my $ifh;
local *FILE;
- $ifh = &xst_open_read_from_names(@meminfo_names);
+ $ifh = &xst_file_open_read_from_names(@meminfo_names);
if (not $ifh) { return; } # We didn't find it.
*FILE = $ifh;
@@ -286,7 +286,7 @@ sub get_fdisk
{
my ($disk, $device, $point, $fs, $options, $check, $size, $bootable);
- &xst_report_info(01, "Looking for partitions on $dev");
+ &xst_report ("disks_partition_probe", $dev);
open(FDISK_HD, "$cmd_fdisk -l $dev 2>/dev/null |");
while (<FDISK_HD>)
@@ -318,7 +318,7 @@ sub get_fdisk
}
close(FDISK_HD);
- &xst_report_info(02, "Querying size of $dev");
+ &xst_report ("disks_size_query", $dev);
# open(FDISK_HD, "$fdisk_tool -s $dev 2>/dev/null |");
# ($size) = (<FDISK_HD> =~ /([0-9]+)/);
@@ -366,7 +366,7 @@ sub get_swap_entries
my $fstab_file;
local *FSTAB_FILE;
- $fstab_file = &xst_open_read_from_names (@fstab_names);
+ $fstab_file = &xst_file_open_read_from_names (@fstab_names);
if (!$fstab_file) { return; }
*FSTAB_FILE = $fstab_file;
@@ -382,7 +382,7 @@ sub get_swap_entries
next if $type ne 'swap';
- &xst_report_info(03, "Found swap entry $device");
+ &xst_report ("memory_swap_found", $device);
if ($device =~ /^#(.*)/)
{
@@ -422,7 +422,7 @@ sub get_swap_entries
sub get
{
- &xst_report_info(04, "Getting swap entries");
+ &xst_report ("memory_swap_probe");
&get_memory; &xst_print_progress();
&get_fdisk; &xst_print_progress();
@@ -440,7 +440,7 @@ sub setup_swap_files
my $command;
$command = "$cmd_swapoff -a"; # To make sure removed swap spaces &get removed
- &xst_run ($command);
+ &xst_file_run ($command);
my $num_done = 0;
@@ -455,11 +455,11 @@ sub setup_swap_files
$size *= 1024; # Make it to Kb
$command = "$cmd_dd if=/dev/null of=$entry->{device} bs=1024 count=$size";
- &xst_run ($command);
+ &xst_file_run ($command);
}
$command = "$cmd_mkswap $entry->{device} >/dev/null 2>/dev/null";
- &xst_run ($command);
+ &xst_file_run ($command);
}
elsif ($entry->{is_file})
@@ -471,10 +471,10 @@ sub setup_swap_files
if ($size != $entry->{size})
{
$command = "$cmd_dd if=/dev/zero of=$entry->{device} bs=1024 count=$size";
- &xst_run ($command);
+ &xst_file_run ($command);
$command = "$cmd_mkswap $entry->{device} >/dev/null 2>/dev/null";
- &xst_run ($command);
+ &xst_file_run ($command);
}
}
@@ -490,7 +490,7 @@ sub setup_swap_files
if ($entry->{enabled})
{
$command = "$cmd_swapon $entry->{device} $priority >/dev/null 2>/dev/null";
- &xst_run ($command);
+ &xst_file_run ($command);
}
$num_done++;
@@ -506,7 +506,7 @@ sub set_swap_entries
my ($priority_str);
($fstab_in_file, $fstab_out_file) =
- &xst_open_filter_write_from_names (@fstab_names);
+ &xst_file_open_filter_write_from_names (@fstab_names);
if (!$fstab_out_file) { return; }
*FSTAB_IN_FILE = $fstab_in_file; *FSTAB_OUT_FILE = $fstab_out_file;
diff --git a/network.pl.in b/network.pl.in
index e571e56..20e4fd9 100644
--- a/network.pl.in
+++ b/network.pl.in
@@ -59,7 +59,9 @@ sub xst_network_dialing_get
my (%ret, @sections);
my ($i, $j, $name, $val);
- &xst_run ("wvdialconf $xst_prefix/$file") if (!-e "$xst_prefix/$file");
+ &xst_report_enter ();
+ &xst_file_run ("wvdialconf $xst_prefix/$file") if (!-e "$xst_prefix/$file");
+ &xst_report ("network_dialing_get");
@sections = &xst_parse_ini_sections ($file);
foreach $i (@sections)
@@ -85,6 +87,7 @@ sub xst_network_dialing_get
}
}
+ &xst_report_leave ();
return \%ret;
}
@@ -96,7 +99,9 @@ sub xst_network_active_interfaces_get
my $tool_ifconfig;
my @ret = ();
- $tool_ifconfig = &xst_locate_tool ("ifconfig");
+ &xst_report_enter ();
+ &xst_report ("network_iface_active_get");
+ $tool_ifconfig = &xst_file_locate_tool ("ifconfig");
open IFCONFIG, "/bin/sh -c \"$tool_ifconfig | sed 's/:\\? .*//;/^\$/D'\" |";
@@ -108,19 +113,25 @@ sub xst_network_active_interfaces_get
close IFCONFIG;
+ &xst_report_leave ();
return @ret;
}
sub xst_network_interface_active
{
my ($search_iface, $proc) = @_;
- my @ifaces = &$proc ();
+ my @ifaces;
+ &xst_report_enter ();
+ &xst_report ("network_iface_is_active", $search_iface);
+
+ @ifaces = &$proc ();
while ($ifaces[0])
{
return 1 if (shift (@ifaces) eq $search_iface);
}
+ &xst_report_leave ();
return 0;
}
@@ -257,7 +268,10 @@ sub xst_network_run_hostname
{
my $hostname = $_[0];
- &xst_run ("hostname $hostname");
+ &xst_report_enter ();
+ &xst_report ("network_hostname_set");
+ &xst_file_run ("hostname $hostname");
+ &xst_report_leave ();
}
sub xst_network_dialing_set
@@ -287,6 +301,9 @@ sub xst_network_dialing_set
my $ret;
my ($i, $j);
+ &xst_report_enter ();
+ &xst_report ("network_dialing_set");
+
foreach $i (keys %$values_hash)
{
%hash = %{$$values_hash{$i}};
@@ -302,6 +319,7 @@ sub xst_network_dialing_set
}
}
+ &xst_report_leave ();
return $ret;
}
@@ -312,12 +330,12 @@ sub xst_network_rh62_interface_activate_by_dev
if ($enabled)
{
&xst_debug_print_string ("\n\nifup $dev\n\n");
- return -1 if &xst_run ("ifup $dev &");
+ return -1 if &xst_file_run ("ifup $dev &");
}
else
{
&xst_debug_print_string ("\n\nifdown $dev\n\n");
- return -1 if &xst_run ("ifdown $dev &");
+ return -1 if &xst_file_run ("ifdown $dev &");
}
return 0;
@@ -344,7 +362,14 @@ sub xst_network_rh62_interface_activate
$dev = $$hash{"file"} if ($old_hash && $$old_hash{"enabled"});
}
- &xst_network_rh62_interface_activate_by_dev ($dev, $enabled) if $dev;
+ if ($dev)
+ {
+ &xst_report_enter ();
+ &xst_report ("network_iface_activate", $dev) if $enabled;
+ &xst_report ("network_iface_deactivate", $dev) if !$enabled;
+ &xst_network_rh62_interface_activate_by_dev ($dev, $enabled);
+ &xst_report_leave ();
+ }
}
sub xst_network_remove_pap_entry
@@ -352,15 +377,19 @@ sub xst_network_remove_pap_entry
my ($file, $login) = @_;
my ($i, $buff);
- $buff = &xst_buffer_load ($file);
+ &xst_report_enter ();
+ &xst_report ("network_remove_pap", $file, $login);
+
+ $buff = &xst_file_buffer_load ($file);
foreach $i (@$buff)
{
$i = "" if ($i =~ /^[ \t]*$login[ \t]/);
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ &xst_report_leave ();
+ return &xst_file_buffer_save ($buff, $file);
}
sub xst_network_rh62_interface_delete
@@ -417,6 +446,8 @@ sub xst_network_interface_set
my (%dist_attrib, %fn);
my ($proc, $i, $res);
+ &xst_report_enter ();
+ &xst_report ("network_iface_set", $dev);
%dist_attrib = &xst_network_get_interface_replace_table ();
$proc = $dist_attrib{"iface_set"};
%fn = %{$dist_attrib{"fn"}};
@@ -432,7 +463,9 @@ sub xst_network_interface_set
$values_hash, $old_hash);
# if success saving the settings for the interface, set up immediatly.
- &$proc ($values_hash, $old_hash, $$values_hash{"enabled"}) if (!$res);
+ &$proc ($values_hash, $old_hash, $$values_hash{"enabled"}) if !$res;
+
+ &xst_report_leave ();
return $res;
}
@@ -445,6 +478,9 @@ sub xst_network_interfaces_set
my ($i, $j);
my ($tmp, $res);
+ &xst_report_enter ();
+ &xst_report ("network_ifaces_set");
+
%dist_attrib = &xst_network_get_interface_replace_table ();
$old_hash = $$old_hash{"interface"};
@@ -464,6 +500,7 @@ sub xst_network_interfaces_set
$res = $tmp if !$res;
}
+ &xst_report_leave ();
return $res;
}
@@ -487,8 +524,11 @@ sub xst_network_get_pap_passwd
my ($file, $login) = @_;
my @arr;
+ &xst_report_enter ();
+ &xst_report ("network_get_pap_passwd", $login, $file);
$arr = &xst_parse_split_first_array ($file, $login, "[ \t]+", "[ \t]+");
-
+ &xst_report_leave ();
+
return $$arr[1];
}
@@ -497,7 +537,10 @@ sub xst_network_get_ppp_options_re
my ($file, $re) = @_;
my ($fd, @res);
- $fd = &xst_open_read_from_names ("$file");
+ &xst_report_enter ();
+ &xst_report ("network_get_ppp_option", &xst_replace_regexp_to_separator ($re), $file);
+ $fd = &xst_file_open_read_from_names ("$file");
+ &xst_report_leave ();
return undef if !$fd;
while (($_ = &xst_parse_chomp_line_hash_comment ($fd)) != -1)
@@ -514,9 +557,12 @@ sub xst_network_get_ppp_options_re
sub xst_network_set_ppp_options_re
{
my ($file, $re, $value) = @_;
- my ($buff, $line, $replaced);
+ my ($buff, $line, $replaced, $ret);
- $buff = &xst_buffer_load ($file);
+ &xst_report_enter ();
+ &xst_report ("network_set_ppp_option", &xst_replace_regexp_to_separator ($re), $file);
+
+ $buff = &xst_file_buffer_load ($file);
foreach $line (@$buff)
{
@@ -529,15 +575,22 @@ sub xst_network_set_ppp_options_re
push @$buff, "$value\n" if !$replaced;
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ $ret = &xst_file_buffer_save ($buff, $file);
+ &xst_report_leave ();
+ return $ret;
}
sub xst_network_set_ppp_options_connect
{
my ($file, $value) = @_;
+ my $ret;
- return &xst_network_set_ppp_options_re ($file, "^connect", "connect \"/usr/bin/wvdial --chat $value\"");
+ &xst_report_enter ();
+ &xst_report ("network_set_ppp_connect", $file);
+ $ret = &xst_network_set_ppp_options_re ($file, "^connect", "connect \"/usr/bin/wvdial --chat $value\"");
+ &xst_report_leave ();
+ return $ret;
}
sub xst_network_get_ppp_options_unsup
@@ -549,7 +602,10 @@ sub xst_network_get_ppp_options_unsup
"remotename", "hide-password", "noauth", "noipdefault", "ipparam");
$res = "";
- $fd = &xst_open_read_from_names ("$file");
+ &xst_report_enter ();
+ &xst_report ("network_get_ppp_unsup", $file);
+ $fd = &xst_file_open_read_from_names ("$file");
+ &xst_report_leave ();
return undef if !$fd;
GET_LINE: while (($line = &xst_parse_chomp_line_hash_comment ($fd)) != -1)
@@ -573,14 +629,17 @@ sub xst_network_get_ppp_options_unsup
sub xst_network_set_ppp_options_unsup
{
my ($file, $value) = @_;
- my ($buff, $line, $re);
+ my ($buff, $line, $re, $ret);
my @known_options = ("usepeerdns", "mtu", "mru", "user", "/dev/[^ \t]+", "[0-9]+",
"defaultroute", "debug", "persist", "escape", "crtscts", "connect",
"remotename", "hide-password", "noauth", "noipdefault", "ipparam");
+
# The options in the last row are those that are on by default in pppd and we don't handle,
# so we ignore them, as they are set implicitly if not specified.
- $buff = &xst_buffer_load ($file);
+ &xst_report_enter ();
+ &xst_report ("network_set_ppp_unsup", $file);
+ $buff = &xst_file_buffer_load ($file);
GET_LINE: foreach $line (@$buff)
{
@@ -593,8 +652,10 @@ sub xst_network_set_ppp_options_unsup
push @$buff, $value . "\n";
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ $ret = &xst_file_buffer_save ($buff, $file);
+ &xst_report_leave ();
+ return $ret;
}
sub xst_network_rh62_parse_bootproto
@@ -637,7 +698,8 @@ sub xst_network_deb22_parse_bootproto
"ppp" => "none",
"static" => "none"
);
-
+
+ &xst_report_enter ();
@stanzas = &xst_parse_interfaces_stanzas ($file);
foreach $stanza (@stanzas)
@@ -656,9 +718,10 @@ sub xst_network_deb22_parse_bootproto
else
{
$bootproto = "none";
- &xst_report_warning ("Boot method $method for $iface not supported");
+ &xst_report ("network_bootproto_unsup", $method, $iface);
}
+ &xst_report_leave ();
return $bootproto;
}
@@ -693,9 +756,14 @@ sub xst_network_debian_parse_remote_address
{
my ($file, $iface) = @_;
my ($str, @tuples, $tuple, @res);
+
+ &xst_report_enter ();
+ &xst_report ("network_get_remote", $iface);
@tuples = &xst_parse_interfaces_option_tuple ($file, $iface, "up", 1);
+ &xst_report_leave ();
+
foreach $tuple (@tuples)
{
@res = $$tuple[1] =~ /[ \t]+pointopoint[ \t]+([^ \t]+)/;
@@ -708,11 +776,16 @@ sub xst_network_debian_parse_remote_address
sub xst_network_debian_replace_remote_address
{
my ($file, $iface, $value) = @_;
- my $ifconfig;
+ my ($ifconfig, $ret);
+
+ &xst_report_enter ();
+ &xst_report ("network_set_remote", $iface);
- $ifconfig = &xst_locate_tool ("ifconfig");
+ $ifconfig = &xst_file_locate_tool ("ifconfig");
- return &xst_replace_interfaces_option_str ($file, $iface, "up", "$ifconfig $iface pointopoint $value");
+ $ret = &xst_replace_interfaces_option_str ($file, $iface, "up", "$ifconfig $iface pointopoint $value");
+ &xst_report_leave ();
+ return $ret;
}
sub xst_network_ensure_loopback_interface
@@ -794,8 +867,13 @@ sub xst_network_ensure_loopback
my $hostname = $$values_hash{"hostname"};
my $statichost = $$values_hash{"statichost"};
+ &xst_report_enter ();
+ &xst_report ("network_ensure_lo");
+
&xst_network_ensure_loopback_statichost ($statichost, $hostname, $lo_ip);
&xst_network_ensure_loopback_interface ($interface, $lo_ip);
+
+ &xst_report_leave ();
}
sub xst_network_get_parse_table
diff --git a/parse.pl.in b/parse.pl.in
index 7dd99af..dc30d23 100644
--- a/parse.pl.in
+++ b/parse.pl.in
@@ -108,6 +108,10 @@ sub xst_parse_trivial
{
my (@res) = @_;
+ &xst_report_enter ();
+ &xst_report ("parse_trivial", "@res");
+ &xst_report_leave ();
+
return $res[0] if $#res == 0;
return \@res;
}
@@ -153,6 +157,21 @@ sub xst_parse_chomp_line_hash_comment
return \$line;
}
+sub xst_parse_chomp_line_sh_export
+{
+ my ($fd) = @_;
+ my $line;
+
+ $line = &xst_parse_chomp_line_hash_comment ($fd);
+ return -1 if $line == -1;
+
+ $line = $$line;
+
+ $line =~ s/^export //;
+
+ return \$line;
+}
+
# Parse a $file, wich is assumed to have a column-based format, with $re matching field separators
# and one record per line. Search for $key, and return either a scalar with the first ocurrence,
# or an array with all the found ocurrences.
@@ -161,9 +180,12 @@ sub xst_parse_split_ref
my ($file, $key, $re, $all, $line_read_proc) = @_;
my ($fd, @line, @res);
+ &xst_report_enter ();
+ &xst_report ("parse_split", $key, $file);
+
$proc = $line_read_proc? $line_read_proc : \&xst_parse_chomp_line_std;
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
$all = 0 if !$fd;
while (($line = &$proc ($fd)) != -1)
@@ -179,12 +201,14 @@ sub xst_parse_split_ref
}
else
{
+ &xst_report_leave ();
close $fd;
return \$line[0];
}
}
}
+ &xst_report_leave ();
close $fd;
return \@res if ($all);
return -1;
@@ -258,7 +282,10 @@ sub xst_parse_split_hash
my ($file, $key_re, $value_re) = @_;
my ($fd, @line, %res, $key);
- $fd = &xst_open_read_from_names ($file);
+ &xst_report_enter ();
+ &xst_report ("parse_split_hash", $file);
+
+ $fd = &xst_file_open_read_from_names ($file);
while (<$fd>)
{
@@ -273,6 +300,7 @@ sub xst_parse_split_hash
}
close $fd;
+ &xst_report_leave ();
return undef if (scalar keys (%res) == 0);
return \%res;
}
@@ -299,9 +327,11 @@ sub xst_parse_sh
my ($file, $key) = @_;
my $ret;
+ &xst_report_enter ();
+ &xst_report ("parse_sh", $key, $file);
$ret = &xst_parse_split_first_str ($file, $key, "[ \t]*=[ \t]*",
\&xst_parse_chomp_line_hash_comment);
-
+ &xst_report_leave ();
return &xst_shell_escape ($ret);
}
@@ -322,26 +352,15 @@ sub xst_parse_sh_bool
sub xst_parse_sh_export
{
my ($file, $key) = @_;
- my ($fd, @line, @res);
-
- $fd = &xst_open_read_from_names ($file);
- $all = 0 if !$fd;
-
- while (($line = &xst_parse_chomp_line_std ($fd)) != -1) {
- $line = $$line;
- $line =~s/#.*//;
- next if $line eq "";
+ my $ret;
- if ($line =~ /^export $key=(.*)/) {
- my $val = $1;
- chomp ($val);
- close $fd;
- return $val;
- }
- }
+ &xst_report_enter ();
+ &xst_report ("parse_sh", $key, $file);
+ $ret = &xst_parse_split_first_str ($file, $key, "[ \t]*=[ \t]*",
+ \&xst_parse_chomp_line_sh_export);
+ &xst_report_leave ();
- close $fd;
- return undef;
+ return &xst_shell_escape ($ret);
}
# Search for $keyword in $file, delimited by $re (default " ") or EOL.
@@ -351,11 +370,22 @@ sub xst_parse_kw
my ($file, $keyword, $re, $line_read_proc) = @_;
my $res;
- return undef if ! -f $file;
+ &xst_report_enter ();
+ &xst_report ("parse_kw", $keyword, $file);
+
+ if (! -f $file)
+ {
+ &xst_report_enter ();
+ &xst_report ("file_open_read_failed", $file);
+ &xst_report_leave ();
+ &xst_report_leave ();
+ return undef;
+ }
$re = " " if $re eq undef;
$res = &xst_parse_split_ref ($file, $keyword, $re, 0, $line_read_proc);
+ &xst_report_leave ();
return 0 if $res == -1;
return 1;
}
@@ -366,7 +396,11 @@ sub xst_parse_line_first
my ($file) = @_;
my ($fd, $res);
- $fd = &xst_open_read_from_names ($file);
+ &xst_report_enter ();
+ &xst_report ("parse_line_first", $file);
+ $fd = &xst_file_open_read_from_names ($file);
+ &xst_report_leave ();
+
return undef if !$fd;
chomp ($res = <$fd>);
@@ -381,7 +415,10 @@ sub xst_parse_chat
my ($file, $re) = @_;
my ($fd, $found);
- $fd = &xst_open_read_from_names ("$file");
+ &xst_report_enter ();
+ &xst_report ("parse_chat", $file);
+ $fd = &xst_file_open_read_from_names ("$file");
+ &xst_report_leave ();
return undef if !$fd;
while (<$fd>)
@@ -452,7 +489,7 @@ sub xst_parse_ini_sections
my ($file) = @_;
my (@sections, $line);
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
while (($line = &xst_parse_ini_line_read ($fd)) != -1)
{
@@ -472,7 +509,10 @@ sub xst_parse_ini
my ($fd, $res, $line);
my $found_section_flag = 0;
- $fd = &xst_open_read_from_names ($file);
+ &xst_report_enter ();
+ &xst_report ("parse_ini", $var, $file, $section);
+ $fd = &xst_file_open_read_from_names ($file);
+ &xst_report_leave ();
$res = undef;
while (($line = &xst_parse_ini_line_read ($fd)) != -1)
@@ -587,7 +627,7 @@ sub xst_parse_interfaces_stanzas
my ($file) = @_;
my ($fd, @res);
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
$res = undef;
while (($_ = &xst_parse_interfaces_get_next_stanza ($fd)) != -1)
@@ -607,7 +647,7 @@ sub xst_parse_interfaces_option_tuple
my ($file, $iface, $key, $all) = @_;
my ($fd, @res);
- $fd = &xst_open_read_from_names ($file);
+ $fd = &xst_file_open_read_from_names ($file);
while (($stanza = &xst_parse_interfaces_get_next_stanza ($fd)) != -1)
{
@@ -637,14 +677,14 @@ sub xst_parse_interfaces_option_kw
my ($file, $iface, $kw) = @_;
my $tuple;
+ &xst_report_enter ();
+ &xst_report ("parse_interfaces_kw", $kw, $file);
$tuple = &xst_parse_interfaces_option_tuple ($file, $iface, $kw);
+ &xst_report_leave ();
if ($tuple != -1)
{
- if ($$tuple[1] ne "")
- {
- &xst_report_warning ("Keyword for interface $iface in $file had unexpected value");
- }
+ &xst_report ("parse_ifaces_kw_strange", $iface, $file) if ($$tuple[1] ne "");
return 1;
}
@@ -667,7 +707,10 @@ sub xst_parse_interfaces_option_str
my ($file, $iface, $key) = @_;
my $tuple;
+ &xst_report_enter ();
+ &xst_report ("parse_interfaces_str", $kw, $file);
$tuple = &xst_parse_interfaces_option_tuple ($file, $iface, $key);
+ &xst_report_leave ();
if ($tuple != -1)
{
diff --git a/platform.pl.in b/platform.pl.in
index 1e80f58..b925a16 100644
--- a/platform.pl.in
+++ b/platform.pl.in
@@ -159,7 +159,7 @@ sub xst_platform_guess
#
# if ($? >> 8)
# {
- # &xst_report_warning ("Couldn't guess system.");
+ # &xst_report ("Couldn't guess system.");
# return;
# }
}
@@ -201,28 +201,32 @@ sub xst_platform_ensure_supported
for $platform (@supported)
{
- if ($platform eq $xst_dist) { return; }
+ if ($platform eq $xst_dist)
+ {
+ &xst_report ("platform_success", $platform);
+ return;
+ }
}
# Not supported. Now list the ones we do support, and die.
- for $platform (@supported)
+ foreach $platform (@supported)
{
- &xst_report_info (96, "Supported: [$platform]");
+ &xst_report ("platform_list", $platform);
}
if ($xst_dist)
{
- &xst_report_fatal (98, "Your platform is not supported");
- if (!$xst_reporting && !$xst_verbose)
+ &xst_report ("platform_unsup");
+ if (!$xst_report_threshold && !$xst_verbose)
{
print STDERR "Fatal error: Your platform is not supported.\n";
}
}
else
{
- &xst_report_fatal (99, "Unable to determine host platform");
- if (!$xst_reporting && !$xst_verbose)
+ &xst_report ("platform_undet");
+ if (!$xst_report_threshold && !$xst_verbose)
{
print STDERR "Fatal error: Unable to determine host platform.\n";
}
diff --git a/print.pl.in b/print.pl.in
index bc44e85..cc88681 100644
--- a/print.pl.in
+++ b/print.pl.in
@@ -31,7 +31,7 @@ require "___scriptsdir___/parse.pl";
require "___scriptsdir___/replace.pl";
#
-# Tried to split thi, but suffered from indirection fatigue
+# Tried to split this, but suffered from indirection fatigue
# before referencing the output hash correctly.
#
sub parse_vars
@@ -40,18 +40,22 @@ sub parse_vars
$$$spools{'lp'}{'lpr'}{'JIM'} = "BOB";
- if (-f $dir . "/$section.cfg") {
- my $j;
-
- print STDERR "Parse vars in section '$i'\n";
-
- foreach $j (@known_options) {
- print STDERR "option '$j'\n";
- $val = &xst_parse_sh_export ($dir . "/$section.cfg", $j);
- $$$spools{$i}{'rhs-general'}{$j} = $val;
- }
- } else {
- &xst_report_info (96, "No $dir/$section.cfg");
+ if (-f $dir . "/$section.cfg")
+ {
+ my $j;
+
+ &xst_debug_print_line ("Parse vars in section '$i'");
+
+ foreach $j (@known_options)
+ {
+ &xst_debug_print_line ("option '$j'");
+ $val = &xst_parse_sh_export ($dir . "/$section.cfg", $j);
+ $$$spools{$i}{'rhs-general'}{$j} = $val;
+ }
+ }
+ else
+ {
+ &xst_report ("file_open_read_failed", "$dir/$section.cfg");
}
}
@@ -62,7 +66,7 @@ sub xst_printcap_read
my (%spools);
my ($type, $description);
- $fd = &xst_open_read_from_names ("$file");
+ $fd = &xst_file_open_read_from_names ("$file");
return undef if !$fd;
$in_spool = 0;
@@ -126,7 +130,7 @@ sub xst_printcap_read
$spools{$i}{"rhs-$section"}{$j} = $val;
}
} else {
- &xst_report_info (96, "No $dir/$section.cfg");
+ &xst_report ("file_open_read_failed", "$dir/$section.cfg");
}
# Parse postscript.cfg.
@@ -145,7 +149,7 @@ sub xst_printcap_read
$spools{$i}{"rhs-$section"}{$j} = $val;
}
} else {
- &xst_report_info (96, "No $dir/$section.cfg");
+ &xst_report ("file_open_read_failed", "$dir/$section.cfg");
}
# Parse textonly.cfg.
@@ -161,11 +165,11 @@ sub xst_printcap_read
$spools{$i}{"rhs-$section"}{$j} = $val;
}
} else {
- &xst_report_info (96, "No $dir/$section.cfg");
+ &xst_report ("file_open_read_failed", "$dir/$section.cfg");
}
} else {
- &xst_report_warning (96, "No printtool setup in directory '$i'");
+ &xst_report ("print_no_printtool", $i);
}
}
diff --git a/replace.pl.in b/replace.pl.in
index 4fbc222..d75e01a 100644
--- a/replace.pl.in
+++ b/replace.pl.in
@@ -61,7 +61,7 @@ sub xst_replace_from_table
# Wacky function that tries to create a field separator from a regular expression.
# Doesn't work with all possible regular expressions: just with the ones we are working with.
-sub regexp_to_separator
+sub xst_replace_regexp_to_separator
{
$_ = $_[0];
@@ -89,7 +89,7 @@ sub set_value
{
my ($key, $val, $re) = @_;
- return $key . &regexp_to_separator ($re) . $val;
+ return $key . &xst_replace_regexp_to_separator ($re) . $val;
}
# Edit a $file, wich is assumed to have a column-based format, with $re matching field separators
@@ -103,7 +103,7 @@ sub xst_replace_split
my ($pre_space, $post_comment);
my ($line_key, $val);
- $buff = &xst_buffer_load ($file);
+ $buff = &xst_file_buffer_load ($file);
foreach $i (@$buff)
{
@@ -139,8 +139,8 @@ sub xst_replace_split
push (@$buff, &set_value ($key, $i, $re) . "\n");
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
sub xst_replace_join_all
@@ -172,7 +172,7 @@ sub xst_replace_join_first_array
{
my ($file, $key, $re1, $re2, $value) = @_;
- return &xst_replace_split ($file, $key, $re1, join (&regexp_to_separator ($re2), @$value));
+ return &xst_replace_split ($file, $key, $re1, join (&xst_replace_regexp_to_separator ($re2), @$value));
}
sub xst_replace_sh
@@ -206,7 +206,7 @@ sub xst_replace_line_first
my ($file, $value) = @_;
my $fd;
- $fd = &xst_open_write_from_names ($file);
+ $fd = &xst_file_open_write_from_names ($file);
return -1 if !$fd;
print $fd $value;
@@ -224,7 +224,7 @@ sub xst_replace_join_hash
foreach $i (keys (%$value))
{
- $val = join (&regexp_to_separator ($re2), @{$$value{$i}});
+ $val = join (&xst_replace_regexp_to_separator ($re2), @{$$value{$i}});
$tmp = &xst_replace_split ($file, $i, $re1, $val);
$res = $tmp if !$res;
}
@@ -237,7 +237,7 @@ sub xst_replace_chat
my ($file, $re, $value) = @_;
my ($buff, $i, $bak, $found, $substr);
- $buff = &xst_buffer_load ($file);
+ $buff = &xst_file_buffer_load ($file);
SCAN: foreach $i (@$buff)
{
@@ -276,7 +276,7 @@ sub xst_replace_chat
$i = $bak . "\n";
}
- return &xst_buffer_save ($buff, $file);
+ return &xst_file_buffer_save ($buff, $file);
}
@@ -288,9 +288,9 @@ sub xst_replace_ini
&xst_debug_print_string ("\nreplace_ini: " . join (',', @_) . "\n");
- $buff = &xst_buffer_load ($file);
+ $buff = &xst_file_buffer_load ($file);
- &xst_buffer_join_lines ($buff);
+ &xst_file_buffer_join_lines ($buff);
$found_flag = 0;
foreach $i (@$buff)
@@ -339,8 +339,8 @@ sub xst_replace_ini
push @$buff, "\n[$section]\n" if (!$found_flag);
push @$buff, "$var = $value\n" if ($found_flag < 2);
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
sub xst_replace_ini_bool
@@ -444,8 +444,8 @@ sub xst_replace_interfaces_stanza_delete
my ($file, $iface) = @_;
my ($buff, $line_no, $stanza);
- $buff = &xst_buffer_load ($file);
- &xst_buffer_join_lines ($buff);
+ $buff = &xst_file_buffer_load ($file);
+ &xst_file_buffer_join_lines ($buff);
$line_no = 0;
return -1 if (!&xst_replace_interfaces_stanza_locate ($buff, \$line_no, $iface));
@@ -458,8 +458,8 @@ sub xst_replace_interfaces_stanza_delete
$line_no ++;
}
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
sub xst_replace_interface_stanza_value
@@ -468,8 +468,8 @@ sub xst_replace_interface_stanza_value
my ($buff, $line_no, $stanza);
my ($pre_space, $line, $line_arr);
- $buff = &xst_buffer_load ($file);
- &xst_buffer_join_lines ($buff);
+ $buff = &xst_file_buffer_load ($file);
+ &xst_file_buffer_join_lines ($buff);
$line_no = 0;
if (!&xst_replace_interfaces_stanza_locate ($buff, \$line_no, $iface))
@@ -487,8 +487,8 @@ sub xst_replace_interface_stanza_value
$line_arr[$pos] = $value;
$$buff[$line_no] = $pre_space . "iface " . join (' ', @line_arr) . "\n";
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
sub xst_replace_interfaces_option_str
@@ -497,8 +497,8 @@ sub xst_replace_interfaces_option_str
my ($buff, $line_no, $stanza);
my ($pre_space, $line, $line_arr);
- $buff = &xst_buffer_load ($file);
- &xst_buffer_join_lines ($buff);
+ $buff = &xst_file_buffer_load ($file);
+ &xst_file_buffer_join_lines ($buff);
$line_no = 0;
if (!&xst_replace_interfaces_stanza_locate ($buff, \$line_no, $iface))
@@ -531,8 +531,8 @@ sub xst_replace_interfaces_option_str
$$buff[$line_no] .= $value . "\n" if $value ne "";
- &xst_buffer_clean ($buff);
- return &xst_buffer_save ($buff, $file);
+ &xst_file_buffer_clean ($buff);
+ return &xst_file_buffer_save ($buff, $file);
}
sub xst_replace_interfaces_option_kw
diff --git a/report.pl.in b/report.pl.in
index aeb8b95..cc6add5 100644
--- a/report.pl.in
+++ b/report.pl.in
@@ -36,30 +36,30 @@ sub xst_progress
{
my $prc = $_[0];
- if ($prc < $xst_progress_last_percentage)
- {
- # Don't go backwards.
- $prc = $xst_progress_last_percentage;
- }
+ # Don't go backwards.
+ $prc = $xst_progress_last_percentage if ($prc < $xst_progress_last_percentage);
- if ($prc >= 100)
- {
- # Don't go above 99%.
- $prc = 99;
- }
+ # Don't go above 99%.
+ $prc = 99 if ($prc >= 100);
if ($xst_progress && (int $prc > int $xst_progress_last_percentage))
{
- printf "%03d percent done.\n", $prc;
+ &xst_report ("progress", $prc);
$xst_progress_last_percentage = $prc;
}
}
-sub xst_progress_begin { &xst_progress (0); }
+sub xst_progress_begin
+{
+ &xst_progress (0);
+}
-sub xst_progress_end { &xst_progress (99); }
+sub xst_progress_end
+{
+ &xst_progress (99);
+}
sub xst_print_progress # Compat with old $progress_max use.
@@ -74,69 +74,150 @@ sub xst_print_progress # Compat with old $progress_max use.
# --- Report printing --- #
-sub xst_report
+sub xst_report_set_threshold
{
- if ($xst_reporting)
- {
- printf "%1d%02d %s.\n", $_[0], $_[1], $_[2];
- }
+ $xst_report_threshold = $_[0];
}
-sub xst_report_begin
+sub xst_report_enter
{
- &xst_report (1, 00, "Start of work report");
+ $xst_report_level ++;
}
-sub xst_report_end
+sub xst_report_leave
{
- &xst_report (1, 01, "End of work report");
- if ($xst_reporting) { print "\n"; }
+ $xst_report_level --;
}
-sub xst_report_info
-{
- if ($xst_verbose)
- {
- printf STDERR "%s.\n", $_[1];
- }
+$xst_report_level = 0;
+$xst_report_started = 0;
- &xst_report (2, $_[0], $_[1]);
-}
-
-
-sub xst_report_warning
+sub xst_report
{
- if ($xst_verbose)
- {
- printf STDERR "Warning: %s.\n", $_[1];
- }
-
- &xst_report (3, $_[0], $_[1]);
-}
+ my ($key, @args) = @_;
+ my ($mayor, $minor, $str, $format, $res);
+
+ &xst_debug_print_line ("Non-existing report key $key") if !exists $xst_report_message{$key};
+
+ ($mayor, $str) = @{$xst_report_message{$key}};
+ $xst_report_started = 1 if !$xst_report_started && $key eq "begin" && $mayor eq "sys";
-sub xst_report_error
-{
- if ($xst_verbose)
+ if ($key ne "progress")
{
- printf STDERR "Error: %s.\n", $_[1];
+ return if ($xst_report_level >= $xst_report_threshold || !$xst_report_started);
}
- &xst_report (4, $_[0], $_[1]);
+ $format = sprintf ("%s %s\n", $key, $str);
+ $res = sprintf ($format, @args);
+ printf (STDOUT $res);
+ printf (STDERR $res) if $xst_verbose;
+
+ &xst_debug_print_indented_string ($xst_report_level, "report $key: $res");
}
-sub xst_report_fatal
-{
- if ($xst_verbose)
- {
- printf STDERR "Fatal error: %s.\n", $_[1];
- }
-
- &xst_report (5, $_[0], $_[1]);
-}
+# This disables reporting.
+&xst_report_set_threshold (0);
+
+%xst_report_message =
+ ("begin" => ["sys", "Start of work report"],
+ "end" => ["sys", "End of work report\n"],
+ "progress" => ["sys", "%d"],
+ "compat" => ["info", "%s."],
+
+ "platform_list" => ["sys", "Supported: [%s]"],
+ "platform_unsup" => ["fatal", "Your platform is not supported."],
+ "platform_undet" => ["fatal", "Unable to determine host platform."],
+ "platform_success" => ["sys", "Configuring for platform [%s]."],
+
+ "xml_unexp_tag" => ["error", "Unexpected tag [%s]."],
+ "xml_unexp_arg" => ["error", "Unexpected argument [%s] to tag [%s]."],
+
+ "file_open_read_failed" => ["warn", "Could not open [%s] for reading."],
+ "file_open_read_success" => ["info", "Reading options from [%s]."],
+ "file_open_write_failed" => ["error", "Failed to write to [%s]."],
+ "file_open_write_create" => ["warn", "Could not find [%s] for writing. Creating [%s]."],
+ "file_open_write_success" => ["info", "Writing to [%s]."],
+ "file_create_path" => ["info", "Directory [%s] created."],
+ "file_backup_rotate" => ["info", "Backup directory [%s] was rotated."],
+ "file_backup_success" => ["info", "Saved backup for [%s]."],
+ "file_open_filter_failed" => ["warn", "No file to patch: [%s]."],
+ "file_open_filter_create" => ["warn", "Could not find [%s] for patching. Creating [%s]."],
+ "file_open_filter_success" => ["info", "Found [%s]. Patching [%s]."],
+ "file_buffer_load" => ["info", "Loading file [%s] to buffer."],
+ "file_buffer_save" => ["info", "Saving buffer to file [%s]."],
+ "file_run" => ["info", "Running command [%s]."],
+ "file_locate_tool_success" => ["info", "Found tool [%s]."],
+ "file_locate_tool_failed" => ["warn", "Couldn't find tool [%s]."],
+
+ "network_dialing_get" => ["info", "Loading ISP configurations."],
+ "network_iface_active_get" => ["info", "Finding active interfaces."],
+ "network_iface_is_active" => ["info", "Checking if interface [%s] is active."],
+ "network_hostname_set" => ["info", "Setting hostname."],
+ "network_dialing_set" => ["info", "Saving ISP configurations."],
+ "network_remove_pap" => ["info", "Removing entry [%s] from [%s]."],
+ "network_iface_set" => ["info", "Configuring interface [%s]."],
+ "network_iface_activate" => ["info", "Activating interface [%s]."],
+ "network_iface_deactivate" => ["info", "Deactivating interface [%s]."],
+ "network_ifaces_set" => ["info", "Setting up interfaces."],
+ "network_get_pap_passwd" => ["info", "Getting PAP/CHAP password for [%s] from [%s]."],
+ "network_get_ppp_option" => ["info", "Getting option [%s] from [%s]."],
+ "network_set_ppp_option" => ["info", "Setting option [%s] in [%s]."],
+ "network_set_ppp_connect" => ["info", "Setting connect option in [%s]."],
+ "network_get_ppp_unsup" => ["info", "Getting additional options from [%s]."],
+ "network_set_ppp_unsup" => ["info", "Setting additional options in [%s]."],
+ "network_bootproto_unsup" => ["warn", "Boot method [%s] for interface [%s] not supported."],
+ "network_get_remote" => ["info", "Getting remote address for interface [%s]."],
+ "network_set_remote" => ["info", "Setting remote address for interface [%s]."],
+ "network_ensure_lo" => ["info", "Ensuring loopback interface configuration."],
+
+ "parse_trivial" => ["info", "Trivialy passing [%s]."],
+ "parse_split" => ["info", "Getting option [%s] from [%s]."],
+ "parse_split_hash" => ["info", "Getting configurations from [%s]."],
+ "parse_sh" => ["info", "Getting shell option [%s] from [%s]."],
+ "parse_kw" => ["info", "Getting keyword [%s] from [%s]."],
+ "parse_line_first" => ["info", "Getting information from [%s]."],
+ "parse_chat" => ["info", "Getting chat information from [%s]."],
+ "parse_ini" => ["info", "Getting option [%s] from [%s], section [%s]."],
+ "parse_ifaces_kw" => ["info", "Getting keyword [%s] from interface [%s]."],
+ "parse_ifaces_str" => ["info", "Getting option [%s] from interface [%s]."],
+ "parse_ifaces_kw_strange" => ["warn", "Keyword for interface [%s] in [%s] had unexpected value."],
+
+ "boot_lilo_failed" => ["warn", "Failed to run lilo."],
+ "boot_lilo_success" => ["info", "Succesfully executed lilo."],
+
+ "disks_fstab_add" => ["info", "Adding [%s] to fstab."],
+ "disks_partition_probe" => ["info", "Looking for partitions on [%s]."],
+ "disks_size_query" => ["info", "Querying size of [%s]."],
+ "disks_mount" => ["info", "Mounting [%s]."],
+ "disks_umount" => ["info", "Unmounting [%s]."],
+ "disks_mount_error" => ["error", "Could not find mount tools. No mounting done."],
+
+ "memory_swap_found" => ["info", "Found swap entry [%s]."],
+ "memory_swap_probe" => ["info", "Looking for swap entries."],
+
+ "print_no_printtool" => ["warn", "No printtool setup in directory [%s]."],
+
+ "service_status_running" => ["info", "Service [%s] is running."],
+ "service_status_stopped" => ["info", "Service [%s] is stopped."],
+ "service_sysv_not_found" => ["warn", "Could not find SystemV scripts for service [%s]."],
+ "service_sysv_no_runlevel" => ["warn", "Could not find SystemV runlevel [%s] directory [%s]."],
+ "service_sysv_remove_link" => ["info", "Removed SystemV link [%s]."],
+ "service_sysv_add_link" => ["info", "Created SystemV link [%s]."],
+ "service_sysv_op_unk" => ["error", "Unknown initd operation [%s]."],
+ "service_sysv_op_success" => ["info", "Service [%s] %s."],
+ "service_sysv_op_failed" => ["warn", "Service [%s] cound not be %s."],
+
+ "time_timezone_scan" => ["info", "Scanning timezones."],
+ "time_timezone_cmp" => ["info", "Scanning timezones: [%s]."],
+ "time_timezone_set" => ["info", "Setting timezone as [%s]."],
+ "time_localtime_set" => ["info", "Setting local time as [%s]."],
+
+ "users_getting_db" => ["info", "Getting user database."]
+ );
1;
diff --git a/service.pl.in b/service.pl.in
index f1fd6fd..c125460 100644
--- a/service.pl.in
+++ b/service.pl.in
@@ -71,29 +71,26 @@ sub xst_service_sysv_get_runlevels
sub xst_service_sysv_get_status
{
my ($service) = @_;
- my ($rc_path, $initd_path);
+ my ($rc_path, $initd_path, $res);
+
+ &xst_report_enter ();
($rcd_path, $initd_path) = &xst_service_sysv_get_paths ();
+ $res = 0;
if (-f "$initd_path/$service")
{
- if (!&xst_run ("$initd_path/$service status"))
- {
- &xst_report_info (2, "Service $service is running");
- return 1;
- }
- else
- {
- &xst_report_info (3, "Service $service is not running");
- return 0;
- }
+ $res = !&xst_file_run ("$initd_path/$service status");
+ &xst_report ("service_status_running", $service) if $res;
+ &xst_report ("service_status_stopped", $service) if !$res;
}
else
{
- &xst_report_warning (1, "Could not find SystemV scripts for service $service");
+ &xst_report ("service_sysv_not_found", $service);
}
- return 0;
+ &xst_report_leave ();
+ return $res;
}
# Setup a link, at the designated runlevel, for the defined
@@ -106,6 +103,10 @@ sub xst_service_sysv_add_link
($rcd_path, $initd_path) = &xst_service_sysv_get_paths ();
symlink ("$initd_path/$service", "$rcd_path/rc$runlevel.d/$pre$service");
+
+ &xst_report_enter ();
+ &xst_report ("service_sysv_add_link", "$rcd_path/rc$runlevel.d/$pre$service");
+ &xst_report_leave ();
}
# Remove any links matching re at the given runlevel.
@@ -117,19 +118,28 @@ sub xst_service_sysv_remove_link
my $dir;
my ($rcd_path, $initd_path);
+ &xst_report_enter ();
+
($rcd_path, $initd_path) = &xst_service_sysv_get_paths ();
$dir = "$xst_prefix/$rcd_path/rc$runlevel.d";
if (!(opendir RC_DIR, $dir))
{
- &xst_report_warning (1, "Could not find SystemV runlevel $runlevel directory");
+ &xst_report ("service_sysv_no_runlevel", $runlevel, $dir);
+ &xst_report_leave ();
return;
}
foreach $link (readdir (RC_DIR))
{
- unlink ("$dir/$link") if ($link =~ /$re/);
+ if ($link =~ /$re/)
+ {
+ &xst_report ("service_sysv_remove_link", "$dir/$link");
+ unlink ("$dir/$link");
+ }
}
+
+ &xst_report_leave ();
}
# Set start links and remove stop links at the usual runlevels.
@@ -182,12 +192,15 @@ sub xst_service_sysv_run_initd_script
my $str;
my %map =
("restart" => "restarted",
- "stop" => "stoped",
+ "stop" => "stopped",
"start" => "started");
+
+ &xst_report_enter ();
if (!exists $map{$arg})
{
- &xst_report_warning (1, "Unknown initd operation $arg");
+ &xst_report ("service_sysv_op_unk", $arg);
+ &xst_report_leave ();
return -1;
}
@@ -197,14 +210,16 @@ sub xst_service_sysv_run_initd_script
if (-f "$initd_path/$service")
{
- if (!&xst_run ("$init_path/$service $arg"))
+ if (!&xst_file_run ("$init_path/$service $arg"))
{
- &xst_report_info (2, "Service $service $str");
+ &xst_report ("service_sysv_op_success", $service, $str);
+ &xst_report_leave ();
return 0;
}
}
- &xst_report_warning (1, "Service $service could not be $str");
+ &xst_report ("service_sysv_op_failed", $service, $str);
+ &xst_report_leave ();
return -1;
}
diff --git a/shares-conf.in b/shares-conf.in
index 901265e..b0082c8 100755
--- a/shares-conf.in
+++ b/shares-conf.in
@@ -150,7 +150,7 @@ sub read_network_interfaces_into_hash
local *FILE;
my (%ifaces, $current_name, $current_iface);
- *FILE = &xst_open_read_from_names(@network_interfaces_names);
+ *FILE = &xst_file_open_read_from_names(@network_interfaces_names);
if (not *FILE) { return; }
# Build a list of all interfaces
@@ -189,7 +189,7 @@ sub read_network_interfaces_into_hash
# NOTE: This will weed out any loopback or dummy interfaces.
if (not &xst_item_is_in_list($line[1], @cf_interface_list))
{
- &xst_report_warning(3, "$line[1] isn't an available, configured interface");
+ &xst_report ("compat", "$line[1] isn't an available, configured interface");
next;
}
@@ -199,7 +199,7 @@ sub read_network_interfaces_into_hash
# Also make sure there is a &set configuration method.
if ($line[3] eq "" || &xst_ignore_line($line[3]))
{
- &xst_report_warning(4, "Interface $line[1] has no configuration method");
+ &xst_report ("compat" "Interface $line[1] has no configuration method");
next;
}
@@ -266,14 +266,14 @@ sub read_network_interfaces
{
$chosen_name = (keys(%ifaces))[0];
- &xst_report_info(9, "Only one interface, $chosen_name, exists. It is being " .
- "selected as the primary interface");
+ &xst_report ("compat" "Only one interface, $chosen_name, exists. It is being " .
+ "selected as the primary interface");
}
# For that matter, do any interfaces exist at all.
elsif ( scalar(keys(%ifaces)) == 0 )
{
- &xst_report_warning(5, "No network interfaces found");
+ &xst_report ("compat", "No network interfaces found");
return;
}
@@ -332,7 +332,7 @@ sub read_sysconfig_network_scripts_ifcfg
# Find the file.
- *FILE = &xst_open_read_from_names("/etc/sysconfig/network-scripts/ifcfg-$_[0]");
+ *FILE = &xst_file_open_read_from_names("/etc/sysconfig/network-scripts/ifcfg-$_[0]");
if (not *FILE) { return; }
# Parse the file.
@@ -438,7 +438,7 @@ sub read_sysconfig_network
# Find the file.
- *FILE = &xst_open_read_from_names(@sysconfig_network_names);
+ *FILE = &xst_file_open_read_from_names(@sysconfig_network_names);
if (not *FILE) { return; } # We didn't find it.
# Parse the file.
@@ -482,7 +482,7 @@ sub read_rc_config
# Find the file.
- *FILE = &xst_open_read_from_names(@rc_config_names);
+ *FILE = &xst_file_open_read_from_names(@rc_config_names);
if (not *FILE) { return; } # We didn't find it.
# Parse the file.
@@ -559,7 +559,7 @@ sub read_smb_conf
# Find the file.
- *FILE = &xst_open_read_from_names(@smb_conf_names);
+ *FILE = &xst_file_open_read_from_names(@smb_conf_names);
if (not *FILE) { return; } # We didn't find it.
# Parse the file.
@@ -655,7 +655,7 @@ sub write_smb_conf
my ($section, $printable, $wrote_security) = ("", 0, 0);
my @buf = ();
- (*INFILE, *OUTFILE) = &xst_open_filter_write_from_names(@smb_conf_names);
+ (*INFILE, *OUTFILE) = &xst_file_open_filter_write_from_names(@smb_conf_names);
if (not *OUTFILE) { return; } # No point if we can't write.
while (<INFILE>)
@@ -762,7 +762,7 @@ sub read_fstab
# Find the file.
- $ifh = &xst_open_read_from_names(@fstab_names);
+ $ifh = &xst_file_open_read_from_names(@fstab_names);
if (not $ifh) { return; } # We didn't find it.
*FILE = $ifh;
@@ -850,7 +850,7 @@ sub write_fstab
my ($ifh, $ofh);
local (*INFILE, *OUTFILE);
- ($ifh, $ofh) = &xst_open_filter_write_from_names(@fstab_names);
+ ($ifh, $ofh) = &xst_file_open_filter_write_from_names(@fstab_names);
if (not $ofh) { return; } # No point if we can't write.
*INFILE = $ifh; *OUTFILE = $ofh;
@@ -1066,7 +1066,7 @@ sub read_exports
# Find the file.
- $ifh = &xst_open_read_from_names(@exports_names);
+ $ifh = &xst_file_open_read_from_names(@exports_names);
if (not $ifh) { return; } # We didn't find it.
*FILE = $ifh;
@@ -1109,7 +1109,7 @@ sub write_exports
# Find the file.
- $ofh = &xst_open_write_from_names(@exports_names);
+ $ofh = &xst_file_open_write_from_names(@exports_names);
if (not $ofh) { return; }
*FILE = $ofh;
@@ -1571,14 +1571,14 @@ sub get_interfaces
# Get a list of all interfaces, both configured and unconfigured.
# Should work on both GNU and Solaris.
- $if_cmd = &xst_locate_tool("ifconfig");
+ $if_cmd = &xst_file_locate_tool("ifconfig");
$iftext = `$if_cmd -a 2>/dev/null`;
@list = ($iftext =~ /^([a-z0-9]+)[ :\t].*/mg);
if (not @list)
{
- &xst_report_warning(01, "Could not find any network devices");
+ &xst_report ("compat", "Could not find any network devices");
return(0);
}
@@ -1598,15 +1598,15 @@ sub get_host_mounts
my @hosts;
my ($i, $j);
- $ping_tool = &xst_locate_tool("ping");
- $showmount_tool = &xst_locate_tool("showmount");
- $nmblookup_tool = &xst_locate_tool("nmblookup");
- $smbclient_tool = &xst_locate_tool("smbclient");
+ $ping_tool = &xst_file_locate_tool("ping");
+ $showmount_tool = &xst_file_locate_tool("showmount");
+ $nmblookup_tool = &xst_file_locate_tool("nmblookup");
+ $smbclient_tool = &xst_file_locate_tool("smbclient");
$broadcast_ip = &ip_calc_broadcast($cf_hostip, $cf_netmask);
$network_ip = &ip_calc_network($cf_hostip, $cf_netmask);
- &xst_report_info(15, "Mapping IP subnet " . $network_ip);
+ &xst_report ("compat", "Mapping IP subnet " . $network_ip);
# Map subnet.
@@ -1638,24 +1638,24 @@ sub get_host_mounts
close(PING_HD);
}
- &xst_report_info(1, "Subnet ping found " . ($#hosts + 1) . " hosts");
+ &xst_report ("compat", "Subnet ping found " . ($#hosts + 1) . " hosts");
&xst_print_progress ();
# List NFS shares.
if ($showmount_tool eq "")
{
- &xst_report_error(1, "Can't locate showmount - NFS scan skipped");
+ &xst_report ("compat", "Can't locate showmount - NFS scan skipped");
}
else
{
- &xst_report_info(16, "Doing NFS detection on broadcast " . $broadcast_ip);
+ &xst_report ("compat", "Doing NFS detection on broadcast " . $broadcast_ip);
$i = 0; $j = 0;
for $host (@hosts)
{
if ($host eq $cf_hostip) { next; }
- &xst_report_info(17, "Querying NFS service on " . $host);
+ &xst_report ("compat", "Querying NFS service on " . $host);
open(MOUNTS_HD, "$showmount_tool --directories --no-headers $host 2>/dev/null |");
while (<MOUNTS_HD>)
{
@@ -1679,7 +1679,7 @@ sub get_host_mounts
$i++;
}
- &xst_report_info(02, "Found $j NFS exports on $i hosts");
+ &xst_report ("compat", "Found $j NFS exports on $i hosts");
&xst_print_progress ();
}
@@ -1690,7 +1690,7 @@ sub get_host_mounts
my ($smb_master_ip, $smb_master_name);
my @smb_hosts;
- &xst_report_info(03, "Doing SMB detection in workgroup $cf_workgroup");
+ &xst_report ("compat", "Doing SMB detection in workgroup $cf_workgroup");
# Find the workgroup master.
@@ -1713,7 +1713,7 @@ sub get_host_mounts
if ($smb_master_name ne "")
{
- &xst_report_info(04, "Workgroup master is $smb_master_name ($smb_master_ip)");
+ &xst_report ("compat", "Workgroup master is $smb_master_name ($smb_master_ip)");
# List computers.
@@ -1730,10 +1730,10 @@ sub get_host_mounts
}
close(FD);
- if ($#smb_hosts + 1) { &xst_report_info(05, "Master reported " . ($#smb_hosts + 1) . " hosts in workgroup"); }
- else { &xst_report_info(06, "No hosts reported by master - asking others"); }
+ if ($#smb_hosts + 1) { &xst_report ("compat", "Master reported " . ($#smb_hosts + 1) . " hosts in workgroup"); }
+ else { &xst_report ("compat", "No hosts reported by master - asking others"); }
}
- else { &xst_report_warning(02, "No workgroup master found"); }
+ else { &xst_report ("compat", "No workgroup master found"); }
if (!@smb_hosts)
{
@@ -1749,7 +1749,7 @@ sub get_host_mounts
# since they have service entries for their own IPs, whereas Windows
# boxen don't.
- &xst_report_info(07, "Asking $host for host list");
+ &xst_report ("compat", "Asking $host for host list");
open(FD, "$smbclient_tool -N -U % -L $host -I $host |");
while (<FD>) { if (/^[ \t]+Server[ \t]+Comment/) { last; } }
@@ -1766,10 +1766,10 @@ sub get_host_mounts
if (@smb_hosts)
{
- &xst_report_info(8, "Got " . ($#smb_hosts + 1) . " SMB hosts");
+ &xst_report ("compat", "Got " . ($#smb_hosts + 1) . " SMB hosts");
last;
}
- else { &xst_report_warning(9, "No SMB hosts found"); }
+ else { &xst_report ("compat", "No SMB hosts found"); }
}
}
@@ -1810,16 +1810,16 @@ sub get_host_mounts
$i++;
}
- &xst_report_info(10, "Found $j SMB exports on $i hosts");
+ &xst_report ("compat", "Found $j SMB exports on $i hosts");
&xst_print_progress ();
}
- else { &xst_report_warning(10, "No workgroup configured - SMB scan skipped"); }
+ else { &xst_report ("compat", "No workgroup configured - SMB scan skipped"); }
}
sub get
{
- &xst_report_info(20, "Finding interfaces");
+ &xst_report ("compat", "Finding interfaces");
&get_interfaces; &xst_print_progress (); # Needed for primary interface detection.
&read_rc_config; # Ditto.
@@ -1846,9 +1846,9 @@ sub set_immediate
my $mount_tool;
my $umount_tool;
- $exportfs_tool = &xst_locate_tool("exportfs");
- $mount_tool = &xst_locate_tool("mount");
- $umount_tool = &xst_locate_tool("umount");
+ $exportfs_tool = &xst_file_locate_tool("exportfs");
+ $mount_tool = &xst_file_locate_tool("mount");
+ $umount_tool = &xst_file_locate_tool("umount");
# Update exports.
@@ -1857,12 +1857,12 @@ sub set_immediate
if ($exportfs_tool eq "")
{
- &xst_report_error(4, "Could not reload NFS export tables");
+ &xst_report ("compat", "Could not reload NFS export tables");
}
else
{
system "$exportfs_tool -a >/dev/null 2>/dev/null";
- &xst_report_info(12, "NFS export tables reloaded");
+ &xst_report ("compat", "NFS export tables reloaded");
}
&xst_progress(80);
@@ -1881,12 +1881,12 @@ sub set_immediate
{
if ($shares[3])
{
- &xst_report_info(13, "Mounting $shares[8]");
+ &xst_report ("compat", "Mounting $shares[8]");
system "$mount_tool $shares[8] >/dev/null 2>/dev/null";
}
else
{
- &xst_report_info(14, "Unmounting $shares[8]");
+ &xst_report ("compat", "Unmounting $shares[8]");
system "$umount_tool $shares[8] >/dev/null 2>/dev/null";
}
}
@@ -1901,7 +1901,7 @@ sub set_immediate
}
else
{
- &xst_report_error(6, "Could not find mount tools. No mounting done");
+ &xst_report ("compat", "Could not find mount tools. No mounting done");
}
}
diff --git a/time-conf.in b/time-conf.in
index b5c3269..7e77541 100755
--- a/time-conf.in
+++ b/time-conf.in
@@ -263,10 +263,10 @@ sub time_get_rh62_zone
my $size_search;
my $size_test;
- *TZLIST = &xst_open_read_from_names($zoneinfo_dir . "/zone.tab");
+ *TZLIST = &xst_file_open_read_from_names($zoneinfo_dir . "/zone.tab");
if (not *TZLIST) { return; }
- &xst_report_info(8, "Scanning timezones");
+ &xst_report ("time_timezone_scan");
# Get the filesize for /etc/localtime so that we don't have to execute
# a diff for every file, only for file with the correct size. This speeds
@@ -281,12 +281,12 @@ sub time_get_rh62_zone
# See if this zone file matches the installed one.
- &xst_report_info(9, "Scanning timezones: $zone");
+ &xst_report ("time_timezone_cmp", $zone);
&xst_print_progress();
$size_test = (stat("$zoneinfo_dir/$zone"))[7];
if ($size_test eq $size_search)
{
- if (!&xst_run ("diff $zoneinfo_dir/$zone $local_time_file"))
+ if (!&xst_file_run ("diff $zoneinfo_dir/$zone $local_time_file"))
{
# Found a match.
last;
@@ -316,10 +316,14 @@ sub time_set_local_time
{
my ($time) = @_;
+ &xst_report_enter ();
+ &xst_report ("time_localtime_set", "%{$time}");
+
$command = sprintf ("date %02d%02d%02d%02d%04d.%02d", $$time{"month"}, $$time{"monthday"},
$$time{"hour"}, $$time{"minute"}, $$time{"year"}, $$time{"second"});
- $res = &xst_run ($command);
+ $res = &xst_file_run ($command);
+ &xst_report_leave ();
return -1 if $res;
return 0;
}
@@ -328,23 +332,28 @@ sub time_set_rh62_zone
{
my ($localtime, $zonebase, $timezone) = @_;
- &xst_report_info(10, "Setting timezone");
+ &xst_report_enter ();
+ &xst_report ("time_timezone_set", $timezone);
$tz = "$zonebase/$timezone";
if (stat($tz) ne "")
{
- $fd = &xst_open_write_from_names ($localtime);
+ $fd = &xst_file_open_write_from_names ($localtime);
+ &xst_report_leave ();
return -1 if !$fd;
close $fd;
unlink $localtime; # Important, since it might be a symlink.
- $res = &xst_run("cp $tz $localtime");
+ &xst_report_enter ();
+ $res = &xst_file_run("cp $tz $localtime");
+ &xst_report_leave ();
return -1 if $res;
return 0;
}
+ &xst_report_leave ();
return -1;
}
diff --git a/users-conf.in b/users-conf.in
index 4c7b8dc..7cbf657 100644
--- a/users-conf.in
+++ b/users-conf.in
@@ -77,13 +77,13 @@ $progress_max = 3;
# Where are the tools?
-$cmd_usermod = &xst_locate_tool ("usermod");
-$cmd_userdel = &xst_locate_tool ("userdel");
-$cmd_useradd = &xst_locate_tool ("useradd");
-$cmd_groupdel = &xst_locate_tool ("groupdel");
-$cmd_groupadd = &xst_locate_tool ("groupadd");
-$cmd_groupmod = &xst_locate_tool ("groupmod");
-$cmd_gpasswd = &xst_locate_tool ("gpasswd");
+$cmd_usermod = &xst_file_locate_tool ("usermod");
+$cmd_userdel = &xst_file_locate_tool ("userdel");
+$cmd_useradd = &xst_file_locate_tool ("useradd");
+$cmd_groupdel = &xst_file_locate_tool ("groupdel");
+$cmd_groupadd = &xst_file_locate_tool ("groupadd");
+$cmd_groupmod = &xst_file_locate_tool ("groupmod");
+$cmd_gpasswd = &xst_file_locate_tool ("gpasswd");
# --- Internal configuration variables --- #
@@ -211,7 +211,7 @@ sub read_login_defs
local *FILE;
my @line;
- $ifh = &xst_open_read_from_names(@login_defs_names);
+ $ifh = &xst_file_open_read_from_names(@login_defs_names);
if (not $ifh) { return; } # We didn't find it.
*FILE = $ifh;
@@ -237,7 +237,7 @@ sub read_passwd_shadow
# Find the passwd file.
- $ifh = &xst_open_read_from_names(@passwd_names);
+ $ifh = &xst_file_open_read_from_names(@passwd_names);
if (not $ifh) { return; } # We didn't find it.
*FILE = $ifh;
$passwd_last_modified = (stat (FILE))[9]; # &get the mtime.
@@ -264,7 +264,7 @@ sub read_passwd_shadow
# Find the shadow file.
- *FILE = &xst_open_read_from_names(@shadow_names);
+ *FILE = &xst_file_open_read_from_names(@shadow_names);
if (*FILE) {
my ($login, $passwd);
my $passwd_pos = $users_prop_map{"password"};
@@ -293,7 +293,7 @@ sub read_group
# Find the file.
- $ifh = &xst_open_read_from_names(@group_names);
+ $ifh = &xst_file_open_read_from_names(@group_names);
if (not $ifh) { return; } # We didn't find it.
*FILE = $ifh;
$group_last_modified = (stat (FILE))[9]; # &get the mtime.
@@ -325,7 +325,7 @@ sub read_profiles
my $path;
$path = &xst_file_get_data_path . "/users/profiles.xml";
- $profiles = &xst_buffer_load ($path);
+ $profiles = &xst_file_buffer_load ($path);
}
sub write_logindefs
@@ -555,7 +555,7 @@ sub save_profiles
my $path;
$path = &xst_file_get_data_path . "/users/profiles.xml";
- &xst_buffer_save ($1, $path);
+ &xst_file_buffer_save ($1, $path);
}
}
@@ -630,7 +630,7 @@ sub xml_parse_users
elsif ($$tree[0] eq "groupdb") { &xml_parse_groupdb ($$tree[1]); }
else
{
- &xst_report_warning(1, "Unexpected tag " . $$tree[0] . " while parsing users");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$tree;
@@ -652,7 +652,7 @@ sub xml_parse_login_defs
}
else
{
- &xst_report_warning(2, "Unexpected tag " . $$tree[0] . " while parsing logindefs");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$tree;
@@ -666,7 +666,7 @@ sub xml_parse_passwd_last_modified
shift @$tree; # Skip attributes.
- &xst_report_warning(3, "passwd_last_modified tag contents is not PCDATA only") if ($$tree[0] ne "0");
+ &xst_report ("xml_unexp_arg", "", "passwd_last_modified") if ($$tree[0] ne "0");
$passwd_last_modified = $$tree[1];
}
@@ -676,7 +676,7 @@ sub xml_parse_group_last_modified
shift @$tree; # Skip attributes.
- &xst_report_warning(4, "group_last_modified tag contents is not PCDATA only") if ($$tree[0] ne "0");
+ &xst_report ("xml_unexp_arg", "", "group_last_modified") if ($$tree[0] ne "0");
$group_last_modified = $$tree[1];
}
@@ -691,7 +691,7 @@ sub xml_parse_userdb
if ($$tree[0] eq "user") { &xml_parse_user ($$tree[1]); }
else
{
- &xst_report_warning(5, "Unexpected tag " . $$tree[0] . " while parsing userdb");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$tree;
@@ -714,7 +714,7 @@ sub xml_parse_user
}
else
{
- &xst_report_warning(6, "Unexpected tag " . $$tree[0] . " while parsing user");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$tree;
@@ -736,7 +736,7 @@ sub xml_parse_groupdb
if ($$tree[0] eq "group") { &xml_parse_group ($$tree[1]); }
else
{
- &xst_report_warning(7, "Unexpected tag " . $$tree[0] . " while parsing groupdb");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$tree;
@@ -760,7 +760,7 @@ sub xml_parse_group
}
else
{
- &xst_report_warning(9, "Unexpected tag " . $$tree[0] . " while parsing group");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$tree;
@@ -776,7 +776,7 @@ sub xml_parse_group
}
else
{
- &xst_report_warning(8, "Unexpected tag " . $$a[0] . " while parsing users");
+ &xst_report ("xml_unexp_tag", $$tree[0]);
}
shift @$a;
shift @$a;
@@ -958,7 +958,7 @@ sub xml_print
sub get
{
- &xst_report_info(1, "Getting user database");
+ &xst_report ("users_getting_db");
&read_login_defs (); &xst_print_progress ();
&read_group (); &xst_print_progress ();