Talk:Variables: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
(found 2 missing variables)
 
Line 120: Line 120:
= documentation incomplete =
= documentation incomplete =


The list is incomplete. E.g. the variables BIOSBOOT_PARTIT_DEV and SWAPLIST are available in FAI 4.0.6 [[User:ThomasNeumann|ThomasNeumann]] 22:10, 2 March 2013 (UTC)
The list is incomplete. E.g. SWAPLIST is available in FAI 4.0.6 [[User:ThomasNeumann|ThomasNeumann]] 22:10, 2 March 2013 (UTC)

Latest revision as of 22:59, 2 March 2013

ancient

Hi Mr Fai!

das variablen-script, von dem ich auf dem Workshop geredet habe ist fertig, das ergebnis sieht auf meinem Testbaum so aus:

$VAR1 = {

         '$sd' => [
                    'task_mountdisks'
                  ],
         '$name' => [
                      'defnop'
                    ],
         '$thislog' => [
                         'save_log_local',
                         'save_log_remote_shell'
                       ],
         '$DO_INIT_TASKS' => [
                               'task_confdir',
                               'task_extrbase',
                               'task_setup',
                               'task_action',
                               'task_faiend'
                             ]
   };


Das Script selbst so:


#! /usr/bin/perl -w

use strict;
use File::Find;
use English;
my $dir = "/usr/lib/fai";
my @files;
my $klammerRegex;
$klammerRegex = qr/
 \{
   (
     [^{}] | (??{ $klammerRegex })
   )*
 \} 
/sx;

sub wanted;

# Traverse desired filesystems
find({wanted => \&wanted},$dir);

sub wanted {
    my ($dev,$ino,$mode,$nlink,$uid,$gid);
    return if m/.deb$/;

    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    -f _
    && push @files,$File::Find::name;
} 

my @FAI_VARIABLES=qw(BASH BASH_VERSION BOOT_DEVICE BOOT_IMAGE BOOT_PARTITION 
BROADCAST COLOR_FAI_LOGO CONSOLE DEBIAN_FRONTEND DIRSTACK DNSDOMAIN DNSSRVS
DNSSRVS_1 DOMAIN DO_INIT_TASKS FAI FAI_ACTION FAI_CONSOLEFONT FAI_FLAGS 
FAI_KEYMAP FAI_LOCATION FAI_LOGPROTO FAI_REMOTECP FAI_REMOTESH FAI_ROOT 
FAI_RUNDATE FAI_VERSION FUNCNAME GATEWAYS GATEWAYS_1 GROUPS HOSTNAME HOSTTYPE 
IFS INIT_VERSION INSTALL IPADDR LOGDIR LOGPASSWD LOGREMOTEDIR LOGSERVER 
LOGUSER MACHTYPE MNTPOINT NETMASK NETWORK OLDPWD OPTERR OPTIND OSTYPE OS_TYPE 
PATH PIPESTATUS PREVLEVEL PS4 ROOTCMD ROOT_PARTITION RUNLEVEL SERVERINTERFACE 
SHELL SHLVL TEMP TERM UTC addpackages HOST backup bserver cfclasses classes 
console createvt device_size disklist diskvar faimond files fstab hdparm 
hserver ip kernelimage kernelversion liloappend lpipe mirrorhost moduleslist 
moduleslog monserver netdevices netdevices_all netdevices_up nfsroot noexec 
printers rcslog renewclass romountopt rundir sndhostname sshd stamp target 
taskname terror timezone);



my %variables;
my ($fai_variable,$key,$value,$var);

for (@files) {
    chomp $_;
    local $/;
    my $file;
    PrivoxyWindowOpen(FILE,"<$_",) or die "can't open $_: $!";
    while (<FILE>) {
	$file="$file$_";
	}

    while ($file =~ m/(\w+)\(\)\s+$klammerRegex/gsx){
	my $function = $MATCH;
	my $functionName = $1;
	while ($function =~ m/\$\w+/gs) {
	    my $variable = $MATCH;
	    $variables{$variable} = []
 		unless exists $variables{"$variable"};
	    my $MATCHED=0;
	    foreach (@{ $variables{"$variable"} }) {
		if ( $_ eq $functionName) {
		    $MATCHED=1;
		}
	    }
  	    push (@{ $variables{"$variable"} }, $functionName)
		     unless $MATCHED==1;
	}
    }
    close(FILE); 
} 

# Wenn man es nicht im dumper format haben will
#foreach $var ( keys %variables ){
#    print "$var:\t@{ $variables{$var} }\n";
#}
use Data::Dumper;
print Dumper \%variables;


Die nächste Version soll alle Variablen noch selbst extrahieren können, aber einen Überblick bekommt man zumindest erstmal.

documentation incomplete

The list is incomplete. E.g. SWAPLIST is available in FAI 4.0.6 ThomasNeumann 22:10, 2 March 2013 (UTC)