diff options
author | hansp <hansp> | 2001-02-08 03:22:27 +0000 |
---|---|---|
committer | hansp <hansp> | 2001-02-08 03:22:27 +0000 |
commit | f5ecbd3ccbb82609372876d7083a4f51f37cc722 (patch) | |
tree | 1d4ecc130307e2b1fa0ab99289fb3c3d0596e4d2 /general.pl.in | |
parent | 7da4eba622373343b67004a8fb67f0ffd8a88d21 (diff) |
2001-02-07 Hans Petter Jansson <hpj@ximian.com>
* be.pl.in: Refactored into obsoletion.
* file.pl.in, general.pl.in, platform.pl.in, report.pl.in,
service.pl.in, util.pl.in, xml.pl.in: Added.
* boot-conf.in, disks-conf.in, memory-conf.in,
network-conf.in, shares-conf.in, time-conf.in, users-conf.in,
media.pl.in, network.pl.in, parse.pl.in, replace.pl.in:
Removed dependency on be.pl. Added new dependencies.
* Makefile.am: Removed be.pl from distribution (but not
build). Added new targets.
* removable-media.pl.in: Added an XML skeleton. This file will
go away later, though.
Diffstat (limited to 'general.pl.in')
-rw-r--r-- | general.pl.in | 229 |
1 files changed, 229 insertions, 0 deletions
diff --git a/general.pl.in b/general.pl.in new file mode 100644 index 0000000..dbecc6b --- /dev/null +++ b/general.pl.in @@ -0,0 +1,229 @@ +#!/usr/bin/env perl +#-*-perl-*- +#-*- Mode: perl; tab-width: 2; indent-tabs-mode: f; c-basic-offset: 2 -*- + +# Common stuff for the ximian-setup-tools backends. +# +# Copyright (C) 2000-2001 Ximian, Inc. +# +# Authors: Hans Petter Jansson <hpj@ximian.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library 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 Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + + +require "___scriptsdir___/report.pl"; +require "___scriptsdir___/platform.pl"; + + +# --- Operation modifying variables --- # + + +# Variables are set to their default value, which may be overridden by user. Note +# that a $prefix of "" will cause the configurator to use '/' as the base path, +# and disables creation of directories and writing of previously non-existent +# files. + +$be_name = ""; # Short name of tool. +$be_version = ""; # Version of tool - [major.minor.revision]. +$be_operation = ""; # Major operation user wants to perform - [get | set | filter]. + +$be_prefix = ""; +$be_verbose = 0; +$be_do_immediate = 1; + + +# --- Generic part of usage text --- # + + +my $be_usage_generic =<<"end_of_usage_generic;"; + Major operations (specify one of these): + + -g --get Prints the current configuration to standard output, as + a standalone XML document. The configuration is read from + the host\'s system config files. + + -s --set Updates the current configuration from a standalone XML + document read from standard input. The format is the same + as for the document generated with --get. + + -f --filter Reads XML configuration from standard input, parses it, + and writes the configurator\'s impression of it back to + standard output. Good for debugging and parsing tests. + + -h --help Prints this page to standard error. + + --version Prints version information to standard output. + + Modifiers (specify any combination of these): + + --platform <name-ver> Overrides the detection of your platform\'s + name and version, e.g. debian-2.3. Use with care. See the + documentation for a full list of supported platforms. + + --disable-immediate With --set, prevents the configurator from + running any commands that make immediate changes to + the system configuration. Use with --prefix to make a + dry run that won\'t affect your configuration. + + With --get, suppresses running of non-vital external + programs that might take a long time to finish. + + -p --prefix <location> Specifies a directory prefix where the + configuration is looked for or stored. When storing + (with --set), directories and files may be created. + + --progress Prints machine-readable progress information to standard + output, before any XML, consisting of three-digit + percentages always starting with \'0\'. + + --report Prints machine-readable diagnostic messages to standard + output, before any XML. Each message has a unique + three-digit ID. The report ends in a blank line. + + -v --verbose Prints human-readable diagnostic messages to standard + error. +end_of_usage_generic; + + +# --- Auto-informative printing --- # + + +sub be_print_usage +{ + my $i; + + print STDERR "Usage: $be_name-conf <--get | --set | --filter | --help | --version>\n"; + + for ($i = (length $be_name); $i > 0; $i--) { print STDERR " "; } + print STDERR " [--disable-immediate] [--prefix <location>]\n"; + + for ($i = (length $be_name); $i > 0; $i--) { print STDERR " "; } + print STDERR " [--progress] [--report] [--verbose]\n\n"; + + print STDERR $be_description . "\n"; + + print STDERR $be_usage_generic . "\n"; +} + + +sub be_print_version +{ + print "$be_name $be_version\n"; +} + + +# --- Initialization and finalization --- # + + +sub be_begin +{ + $| = 1; + &be_report_begin (); + &be_progress_begin (); + + if (!$be_dist) { &be_platform_guess (); } + + if ($be_dist) + { + &be_report_info (95, "Configuring for platform $be_dist"); + } + else + { + &be_report_fatal (95, "Unknown or unsupported platform"); + &be_end (); + exit (2); + } +} + + +sub be_end +{ + &be_progress_end (); + &be_report_end (); +} + + +sub be_set_operation +{ + if ($be_operation ne "") + { + print STDERR "Error: You may specify only one major operation.\n\n"; + print STDERR $Usage; + exit (1); + } + + $be_operation = $_[0]; +} + + +sub be_init +{ + my @args = @_; + + $be_name = @args[0]; + $be_version = @args[1]; + $be_description = @args[2]; + shift @args; shift @args; shift @args; + + while (@args) + { + if ($args[0] eq "--get" || $args[0] eq "-g") { &be_set_operation ("get"); } + elsif ($args[0] eq "--set" || $args[0] eq "-s") { &be_set_operation ("set"); } + elsif ($args[0] eq "--filter" || $args[0] eq "-f") { &be_set_operation ("filter"); } + elsif ($args[0] eq "--help" || $args[0] eq "-h") { &be_print_usage (); exit (0); } + elsif ($args[0] eq "--version") { &be_print_version (); exit (0); } + elsif ($args[0] eq "--prefix" || $args[0] eq "-p") + { + if ($be_prefix ne "") + { + print STDERR "Error: You may specify --prefix only once.\n\n"; + &be_print_usage (); exit (1); + } + + $be_prefix = $args[1]; + + if ($be_prefix eq "") + { + print STDERR "Error: You must specify an argument to the --prefix option.\n\n"; + &be_print_usage (); exit (1); + } + + shift @args; # For the argument. + } + elsif ($args[0] eq "--platform") { $be_dist = $args[1]; shift @args; } + elsif ($args[0] eq "--disable-immediate") { $be_do_immediate = 0; } + elsif ($args[0] eq "--verbose" || $args[0] eq "-v") { $be_verbose = 1; } + elsif ($args[0] eq "--progress") { $be_progress = 1; } + elsif ($args[0] eq "--report") { $be_reporting = 1; } + else + { + print STDERR "Error: Unrecognized option '$args[0]'.\n\n"; + &be_print_usage (); exit (1); + } + + shift @args; + } + + if ($be_operation eq "") + { + print STDERR "Error: No operation specified.\n\n"; + &be_print_usage (); + exit (1); + } + + &be_begin (); +} + +1; |