Browse Source

Now gbootroot is functioning well as either a GUI or CLI in relation to whether or not arguments are added. Options.pm allows things to be checked before interpreting so that a determination can be made what mode to go in.

master
freesource 22 years ago
parent
commit
830a1c109a
  1. 64
      BootRoot/BootRoot.pm
  2. 56
      BootRoot/Options.pm
  3. 4
      BootRoot/Yard.pm
  4. 46
      gbootroot

64
BootRoot/BootRoot.pm

@ -31,13 +31,13 @@ use Exporter;
use strict;
use POSIX;
use Getopt::Long; # only here for convenience
use BootRoot::Yard;
use BootRoot::YardBox;
use BootRoot::Error;
use File::Basename;
use File::Find;
use File::Path;
use BootRoot::Options;
$SIG{__WARN__} =
sub { warn @_ unless $_[0] =~ /Subroutine [\w:]+ redefined/io
@ -349,13 +349,16 @@ my $verbosity = 1; # info & sys use this as Global
$verbosefn = "$tmp/verbose"; # All verbosity
#my $verbosefn = "/tmp/verbose"; # Yard - always logged, but 0&1 = STDOUT
# Need this before everything.
Gtk::Rc->parse("/etc/gbootroot/gbootrootrc");
if ( !%option ) {
if ( !$::commandline ) {
# Need this before everything.
Gtk::Rc->parse("/etc/gbootroot/gbootrootrc");
verbosity_box();
start_logging_output($verbosefn,$verbosity); # Yard "tmp dir name"
# "verbosity level"
}
if ( !$::commandline ) {
verbosity_box();
start_logging_output($verbosefn,$verbosity); # Yard "tmp dir name"
# "verbosity level"
}
#-------------------------------
@ -436,27 +439,30 @@ if ( -d $global_yard_replacements_arch_dep ) {
#-------------------------------
if ( !$::commandline ) {
if ( !%option ) {
if ( !$::commandline ) {
# Gtk::check_version expects different arguments than .7004 so will have
# to check for the version instead.
# Right now >= 0.7002 is o.k.
#if (Gtk::check_version(undef,"1","0","7") =~ /too old/) {
if (Gtk->major_version < 1) {
et();
}
elsif (Gtk->micro_version < 7) {
et();
}
elsif (Gtk->minor_version < 2) {
et();
if (Gtk->major_version < 1) {
et();
}
elsif (Gtk->micro_version < 7) {
et();
}
elsif (Gtk->minor_version < 2) {
et();
}
}
}
my $window;
if ( !$::commandline ) {
if ( !%option ) {
if ( !$::commandline ) {
$window = Gtk::Window->new("toplevel");
# special policy
@ -721,6 +727,7 @@ $box2->show();
$window->show();
}
}
# Here we put the logic if the program is going to be run from the commandline.
@ -792,31 +799,16 @@ else {
# Let's read in the ARGV
my %option;
Getopt::Long::config("bundling","no_auto_abbrev");
GetOptions (
%option,
"root-filename=s",
"uml-kernel=s",
"method=s",
"template=s", # The only required argument
"filesystem-size=s",
"filesytem-type=s",
"uml-exclusively=s",
"preserve-ownership=s",
"kernel-version=s",
);
start_logging_output($verbosefn,$verbosity); # Yard "tmp dir name"
# "verbosity level"
info(1, "hello there\n");
#info(1, "hello there\n");
my $it = kernel_version_check();
print $it;
# read_contents_file( "$template_dir$template", $tmp,
# $filesystem_size, \%uml_expect );

56
BootRoot/Options.pm

@ -0,0 +1,56 @@
############################################################################
##
## Options.pm
## Copyright (C) 2000, 2001, 2002 by Jonathan Rosenbaum
## <freesource@users.sourceforge.net>
##
## This program is free software; you may 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; if not, write to the Free Software
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
##############################################################################
package BootRoot::Options;
use vars qw(@ISA @EXPORT %EXPORT_TAGS);
use Exporter;
use Getopt::Long;
@ISA = qw(Exporter);
@EXPORT = qw(option %option);
sub option {
Getopt::Long::config("bundling","no_auto_abbrev");
GetOptions (
\%option,
"root-filename=s",
"uml-kernel=s",
"method=s",
"template=s", # The only required argument
"filesystem-size=s",
"filesytem-type=s",
"uml-exclusively=s",
"preserve-ownership=s",
"kernel-version=s",
"stdout"
);
}
1;

4
BootRoot/Yard.pm

@ -50,6 +50,7 @@ use English; # I think this can be ditched for portability
use File::Find; # used by check_root_fs
use BootRoot::BootRoot;
use BootRoot::Error;
use BootRoot::Options;
my (%Included, %replaced_by, %links_to, %is_module, %hardlinked,
%strippable, %lib_needed_by, @Libs, %user_defined_link);
@ -1826,11 +1827,10 @@ sub info {
}
if ( $::commandline ) {
if ( %option ) {
print @msgs;
}
}
## This will produce red.

46
gbootroot

@ -231,39 +231,65 @@ BEGIN {
$ENV{'PATH'} = "/usr/sbin:" . $ENV{'PATH'};
}
if ( !$ARGV[0] ) {
use Gtk;
init Gtk;
set_locale Gtk;
use BootRoot::Options;
option();
$::commandline = \%option if %option;
$::commandline = $ARGV[0] if $ARGV[0];
if ( $Getopt::Long::error > 0 ) {
exit;
}
else {
$::commandline = $ARGV[0];
if ( !%option ) {
if ( !$::commandline ) {
use Gtk;
init Gtk;
set_locale Gtk;
}
}
}
use strict;
use BootRoot::BootRoot;
#use BootRoot::Options;
#use Getopt::Long;
$main::editor = "emacs --font 6x13";
$main::makefs = "mke2fs -F -m0 -i8192"; # Root Disk
$main::sudo = "sudo";
#print $option{"stdout"};
#print %option;
start();
if ( !$ARGV[0] ) {
main Gtk;
exit( 0 );
if ( !%option ) {
if ( !$::commandline ) {
main Gtk;
exit( 0 );
}
}

Loading…
Cancel
Save