mirror of
				https://github.com/fspc/gbootroot.git
				synced 2025-10-30 15:25:34 -04:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									8db50ec6ac
								
							
						
					
					
						commit
						830a1c109a
					
				| @ -31,13 +31,13 @@ use Exporter; | |||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use POSIX; | use POSIX; | ||||||
| use Getopt::Long;  # only here for convenience |  | ||||||
| use BootRoot::Yard; | use BootRoot::Yard; | ||||||
| use BootRoot::YardBox; | use BootRoot::YardBox; | ||||||
| use BootRoot::Error; | use BootRoot::Error; | ||||||
| use File::Basename; | use File::Basename; | ||||||
| use File::Find; | use File::Find; | ||||||
| use File::Path; | use File::Path; | ||||||
|  | use BootRoot::Options; | ||||||
| 
 | 
 | ||||||
| $SIG{__WARN__} =  | $SIG{__WARN__} =  | ||||||
|     sub { warn @_ unless $_[0] =~ /Subroutine [\w:]+ redefined/io  |     sub { warn @_ unless $_[0] =~ /Subroutine [\w:]+ redefined/io  | ||||||
| @ -349,15 +349,18 @@ my $verbosity = 1; # info & sys use this as Global | |||||||
| $verbosefn = "$tmp/verbose"; # All verbosity | $verbosefn = "$tmp/verbose"; # All verbosity | ||||||
| #my $verbosefn = "/tmp/verbose";  # Yard - always logged, but 0&1 = STDOUT | #my $verbosefn = "/tmp/verbose";  # Yard - always logged, but 0&1 = STDOUT | ||||||
| 
 | 
 | ||||||
|  | if ( !%option ) { | ||||||
|  |     if ( !$::commandline ) { | ||||||
|  | 
 | ||||||
| 	# Need this before everything. | 	# Need this before everything. | ||||||
|       Gtk::Rc->parse("/etc/gbootroot/gbootrootrc"); |       Gtk::Rc->parse("/etc/gbootroot/gbootrootrc"); | ||||||
| 
 |  | ||||||
| if ( !$::commandline ) { |  | ||||||
| 	verbosity_box();  | 	verbosity_box();  | ||||||
| 	start_logging_output($verbosefn,$verbosity); # Yard "tmp dir name"  | 	start_logging_output($verbosefn,$verbosity); # Yard "tmp dir name"  | ||||||
| 	                                             # "verbosity level" | 	                                             # "verbosity level" | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #------------------------------- | #------------------------------- | ||||||
| # USER DIRECTORIES | # USER DIRECTORIES | ||||||
| # /tmp | # /tmp | ||||||
| @ -436,6 +439,7 @@ if ( -d $global_yard_replacements_arch_dep ) { | |||||||
| 
 | 
 | ||||||
| #------------------------------- | #------------------------------- | ||||||
| 
 | 
 | ||||||
|  | if ( !%option ) { | ||||||
|     if ( !$::commandline ) { |     if ( !$::commandline ) { | ||||||
| 
 | 
 | ||||||
| # Gtk::check_version expects different arguments than .7004 so will have | # Gtk::check_version expects different arguments than .7004 so will have | ||||||
| @ -453,9 +457,11 @@ if ( !$::commandline ) { | |||||||
| 	    et(); | 	    et(); | ||||||
| 	} | 	} | ||||||
|     } |     } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| my $window; | my $window; | ||||||
| 
 | 
 | ||||||
|  | if ( !%option ) { | ||||||
|     if ( !$::commandline  ) { |     if ( !$::commandline  ) { | ||||||
| 
 | 
 | ||||||
| $window = Gtk::Window->new("toplevel"); | $window = Gtk::Window->new("toplevel"); | ||||||
| @ -721,6 +727,7 @@ $box2->show(); | |||||||
| 
 | 
 | ||||||
| $window->show(); | $window->show(); | ||||||
| 
 | 
 | ||||||
|  | } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| # Here we put the logic if the program is going to be run from the commandline. | # Here we put the logic if the program is going to be run from the commandline. | ||||||
| @ -792,32 +799,17 @@ else { | |||||||
| 
 | 
 | ||||||
| # Let's read in the ARGV | # 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"  | start_logging_output($verbosefn,$verbosity); # Yard "tmp dir name"  | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|                                              # "verbosity level" |                                              # "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, | #    read_contents_file( "$template_dir$template", $tmp, | ||||||
| #			    $filesystem_size, \%uml_expect ); | #			    $filesystem_size, \%uml_expect ); | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										56
									
								
								BootRoot/Options.pm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								BootRoot/Options.pm
									
									
									
									
									
										Normal file
									
								
							| @ -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; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| @ -50,6 +50,7 @@ use English;  # I think this can be ditched for portability | |||||||
| use File::Find; # used by check_root_fs | use File::Find; # used by check_root_fs | ||||||
| use BootRoot::BootRoot; | use BootRoot::BootRoot; | ||||||
| use BootRoot::Error;  | use BootRoot::Error;  | ||||||
|  | use BootRoot::Options; | ||||||
| 
 | 
 | ||||||
| my (%Included, %replaced_by, %links_to, %is_module, %hardlinked,  | my (%Included, %replaced_by, %links_to, %is_module, %hardlinked,  | ||||||
|     %strippable, %lib_needed_by, @Libs, %user_defined_link); |     %strippable, %lib_needed_by, @Libs, %user_defined_link); | ||||||
| @ -1826,11 +1827,10 @@ sub info { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|   if ( $::commandline ) { |   if ( %option ) { | ||||||
|       print @msgs; |       print @msgs; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ## This will produce red. | ## This will produce red. | ||||||
|  | |||||||
							
								
								
									
										36
									
								
								gbootroot
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								gbootroot
									
									
									
									
									
								
							| @ -231,37 +231,63 @@ BEGIN { | |||||||
| 	$ENV{'PATH'} = "/usr/sbin:" . $ENV{'PATH'}; | 	$ENV{'PATH'} = "/usr/sbin:" . $ENV{'PATH'}; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if ( !$ARGV[0] ) { | 
 | ||||||
|  |     use BootRoot::Options; | ||||||
|  |     option(); | ||||||
|  | 
 | ||||||
|  |     $::commandline = \%option if %option; | ||||||
|  |     $::commandline = $ARGV[0] if $ARGV[0]; | ||||||
|  | 
 | ||||||
|  |     if ( $Getopt::Long::error > 0 ) { | ||||||
|  | 	 | ||||||
|  | 	exit; | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     if ( !%option ) { | ||||||
|  | 	if ( !$::commandline  ) { | ||||||
| 
 | 
 | ||||||
| 	    use Gtk; | 	    use Gtk; | ||||||
| 	    init Gtk; | 	    init Gtk; | ||||||
| 	    set_locale Gtk;  | 	    set_locale Gtk;  | ||||||
| 
 | 
 | ||||||
| 	}	 | 	}	 | ||||||
|     else { |  | ||||||
|   |  | ||||||
| 	$::commandline = $ARGV[0]; |  | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| use strict; | use strict; | ||||||
| use BootRoot::BootRoot; | use BootRoot::BootRoot; | ||||||
|  | #use BootRoot::Options; | ||||||
|  | #use Getopt::Long; | ||||||
| 
 | 
 | ||||||
| $main::editor = "emacs --font 6x13"; | $main::editor = "emacs --font 6x13"; | ||||||
| $main::makefs = "mke2fs -F -m0 -i8192"; # Root Disk | $main::makefs = "mke2fs -F -m0 -i8192"; # Root Disk | ||||||
| $main::sudo = "sudo"; | $main::sudo = "sudo"; | ||||||
| 
 | 
 | ||||||
|  | #print $option{"stdout"}; | ||||||
|  | #print %option; | ||||||
|  | 
 | ||||||
| start(); | start(); | ||||||
| 
 | 
 | ||||||
| if ( !$ARGV[0] ) { | 
 | ||||||
|  | if ( !%option ) { | ||||||
|  |     if ( !$::commandline  ) { | ||||||
| 
 | 
 | ||||||
| 	main Gtk; | 	main Gtk; | ||||||
| 	exit( 0 ); | 	exit( 0 ); | ||||||
|   |   | ||||||
|     } |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user