/usr/bin/lr_report_cfg2xml is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | #! /usr/bin/perl -w
# vim:syntax=perl
use strict;
use lib '/usr/share/perl5';
use Locale::TextDomain qw/lire/;
use Lire::Logger qw/lr_err/;
use Lire::Config;
use Lire::Error qw/ an_error_occured invalid_superservice /;
use Lire::DlfSchema;
use Lire::ReportConfig;
use Lire::I18N qw/set_fh_encoding/;
use Getopt::Long;
sub usage {
lr_err( @_,
__(
"Usage: lr_report_cfg2xml <superservice> <name> <report_cfg_file>\n" ) );
}
sub setup_cfg_paths {
my $specdir = $_[0];
# Clear the spec path
foreach my $dir ( Lire::Config->config_spec_path() ) {
Lire::Config->del_config_spec_path_dir( $dir );
}
Lire::Config->add_config_spec_path_dir( $specdir );
Lire::Config->init();
return;
}
sub setup_cfg_var {
my ( $listname, $varname, $dirs ) = @_;
return unless defined $dirs;
my $path = Lire::Config->get_var( $listname );
my $dir_spec = $path->spec()->get( $varname );
# Clear the path
while ( $path->elements() ) {
$path->remove(0);
}
# Adds the new dirs
foreach my $dir ( @$dirs ) {
$path->append( $dir_spec->instance( 'value' => $dir ) );
}
return;
}
my %opts = ();
my $success = GetOptions( \%opts, 'cfgspecdir=s', 'reportsdir=s@',
'filtersdir=s@', 'schemasdir=s@' );
setup_cfg_paths( $opts{'cfgspecdir'} )
if ( defined $opts{'cfgspecdir'} );
usage() unless $success;
usage() unless @ARGV == 3;
my ( $super, $name, $file ) = @ARGV;
# Since this script is used from the source tree before any Lire installation
# exists, we cannot 'use' Lire::Program. Otherwise it will try to parse the
# not-yet installed configuration files.
require Lire::Program;
eval {
setup_cfg_var( 'lr_schemas_path', 'schemas', $opts{'schemasdir'} );
setup_cfg_var( 'lr_reports_path', 'reports', $opts{'reportsdir'} );
setup_cfg_var( 'lr_filters_path', 'filters', $opts{'filtersdir'} );
};
lr_err( an_error_occured( $@ ) ) if $@;
lr_err( invalid_superservice( $super ) )
unless Lire::DlfSchema->has_superservice( $super );
eval {
my $report_cfg = new_from_file Lire::ReportConfig( $super, $file );
my $cfg = $report_cfg->as_config_value( $name );
set_fh_encoding( \*STDOUT, 'utf-8' );
print <<EOF;
<?xml version="1.0"?>
<!DOCTYPE lrcsml:config-spec PUBLIC
"-//LogReport.ORG//DTD Lire Report Configuration Specification Markup Language V1.0//EN"
"http://www.logreport.org/LRCSML/1.0/lrcsml.dtd">
<lrcsml:config-spec xmlns="http://www.logreport.org/LRCML/"
xmlns:lrcsml="http://www.logreport.org/LRCSML/">
<lrcsml:report-config name="$name">
EOF
$cfg->save_xml( \*STDOUT, 2 );
print <<EOF;
</lrcsml:report-config>
</lrcsml:config-spec>
EOF
};
lr_err( an_error_occured( $@ ) ) if $@;
# Local Variables:
# mode: cperl
# End:
__END__
=pod
=head1 NAME
lr_report_cfg2xml - Convert old style report configuration to XML
=head1 SYNOPSIS
lr_report_cfg2xml I<supservice> I<name> I<report_cfg_file> > I<xml_spec_file>
=head1 DESCRIPTION
The B<lr_report_cfg2xml> command converts a report configuration file
as used with Lire version 1.5 and below to a report configuration
template.
The script takes three mandatory arguments:
=over 4
=item superservice
The superservice used by the report configuration file.
=item name
The name of the template that will be generated.
=item report_cfg_file
The report configuration file to convert.
=back
It writes on STDOUT a Lire Configuration Specification file. This
specification file contains one report-config element named I<name>.
Its default value will be identical to the content of the report
configuration file. If you install that file in the
I<sharedir>/lire/templates, you will be able to instantiate report
configuration using that template from the lire(1) interface.
=head1 VERSION
$Id: lr_report_cfg2xml.in,v 1.4 2006/07/23 13:16:33 vanbaal Exp $
=head1 AUTHOR
Francis J. Lacoste <flacoste@logreport.org>
=head1 COPYRIGHT
Copyright (C) 2004 Stichting LogReport Foundation LogReport@LogReport.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
|