Changeset 1413


Ignore:
Timestamp:
Feb 23, 2012, 8:43:53 PM (7 years ago)
Author:
bruno
Message:

r4399@localhost: bruno | 2012-02-20 20:47:28 +0100

  • Start coding kernel and keyboard detection for pbmkbm
Location:
devel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf

    r1408 r1413  
    551551ospathcmd-busybox default = /usr/lib/mindi/rootfs/bin/busybox
    552552
     553# Where is the keyboard config file
     554ospathcmd-keyfile default = /etc/rc.config
     555ospathcmd-keyfile rpm = /etc/sysconfig/keyboard
     556ospathcmd-keyfile slackware = /etc/rc.d/rc.keymap
     557ospathcmd-keyfile debian = /etc/rc.config,/etc/console/boottime.kmap.gz
     558ospathcmd-keyfile ubuntu = /etc/console-setup/boottime.kmap.gz,/etc/console-setup/cached.kmap.gz
     559ospathcmd-keyfile arch = /etc/rc.conf
     560ospathcmd-keyfile gentoo = /etc/conf.d/keymaps
     561# Where is the keyboard directory
     562ospathcmd-keymapdir default = /usr/lib/kbd/keymaps
     563# ???
     564ospathcmd-keymapdir slackware = /usr/share/kbd/keymaps
     565
    553566# Some path for commands may defer from one system to another
    554567ospathcmd-halt default = /sbin/halt
  • devel/pbmkbm/bin/pbmkbm

    r1408 r1413  
    138138=item B<-s|--script script>
    139139
    140 Name of the script you want to execute on the related boot media at the end o the build.
     140Name of the script you want to execute on the related boot media at the end of the build.
    141141
    142142=item B<-a|--add pkg1[,pkg2,...]>
     
    437437# BootLoader and its configuration
    438438# Additional data files coming from a potential caller (MondoRescue/Mindi e.g. with fstab, LVM, mountlist, ...)
     439pb_log(1,"End of boot media creation\n");
    439440}
    440441
     
    443444my $tgtree = shift;
    444445
     446pb_log(1,"Analyzing your busybox's configuration\n");
    445447# First, check which are the supported command in that version of busybox
    446448# and create the links for it in the target VE
     
    476478pb_log(2,"Target Tree is now: ".Dumper($tgtree)."\n");
    477479close(BUSY);
     480pb_log(1,"End of busybox analysis\n");
     481}
     482
     483sub pb_mkbm_find_keyboard {
     484
     485pb_log(1,"Analyzing your keyboard's configuration\n");
     486my $keyfile = pb_distro_get_param($pbos,pb_conf_get("ospathcmd-keyfile"));
     487die "Unable to read the keyfile $keyfile" if (! -r $keyfile);
     488my $keymapdir = pb_distro_get_param($pbos,pb_conf_get("ospathcmd-keymapdir"));
     489die "Unable to read the keymapdir $keymapdir" if (! -d $keymapdir);
     490
     491pb_log(1,"End of keyboard analysis\n");
    478492}
    479493
     
    482496my $kernel = shift;
    483497
    484 $kernel->is_xen = undef;
     498pb_log(1,"Analyzing your kernel's configuration\n");
     499$kernel->{"is_xen"} = undef;
    485500# See if we're booted from a Xen kernel
    486501# From http://wiki.xensource.com/xenwiki/XenCommonProblems#head-26434581604cc8357d9762aaaf040e8d87b37752
     
    488503    # It's a Xen kernel
    489504    pb_log(2,"INFO: We found a Xen Kernel running\n");
    490 }
     505    $kernel->{"is_xen"} = 1;
     506}
     507$kernel->{"release"} = pb_get_osrelease();
    491508
    492509my $kfile = pb_distro_get_param($pbos,pb_conf_get_if("mkbmkernelfile"));
    493510if ((defined $kfile) && ($kfile ne "")) {
    494511    pb_log(1,"INFO: You specified your kernel as $kfile, so using it\n");
    495     $kernel->file = $kfile;
     512    $kernel->{"file"} = $kfile;
    496513} else {
    497     $kernel->dir = pb_distro_get_param($pbos,pb_conf_get("mkbmkerneldir"));
    498     die "ERROR: The mkbmkerneldir content ($kernel->dir) doesn't refer to a directory\n"if (! -d $kernel->dir);
    499     pb_log(1,"INFO: Analyzing directory $kernel->dir to find your kernel");
    500     $kernel->namere = pb_distro_get_param($pbos,pb_conf_get("mkbmkernelnamere"));
    501 }
    502 
    503 # TODO: Look at a better way to find the name of the kernel we run
    504 # look at /proc/sys/kernel/bootloader_type /proc/sys/kernel/bootloader_version
    505 # to have a better guess
    506 my $dh;
    507 die "ERROR: Unable to open the mkbmkerneldir content ($kernel->dir)" if (! opendir($dh,$kernel->dir));
    508 while (readdir $dh) {
    509     # Skip non-files
    510     next if ((! -f $_) && (! -l $_));
    511     # Skip files not correpsonding to the RE planned
    512     next if ($_ !~ /$kernel->namere/);
    513     #my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$f/$_");
    514 }
    515 closedir($dh);
    516 $kernel->release = pb_get_osrelase();
     514    $kernel->{"dir"} = pb_distro_get_param($pbos,pb_conf_get("mkbmkerneldir"));
     515    die "ERROR: The mkbmkerneldir content ($kernel->{'dir'}) doesn't refer to a directory\n" if (! -d $kernel->{"dir"});
     516    pb_log(1,"INFO: Analyzing directory $kernel->{'dir'} to find your kernel\n");
     517    $kernel->{"namere"} = pb_distro_get_param($pbos,pb_conf_get("mkbmkernelnamere"));
     518
     519    # TODO: Look at a better way to find the name of the kernel we run
     520    # look at /proc/sys/kernel/bootloader_type /proc/sys/kernel/bootloader_version
     521    # to have a better guess
     522    my $dh;
     523    die "ERROR: Unable to open the mkbmkerneldir content ($kernel->{'dir'})\n" if (! opendir($dh,$kernel->{"dir"}));
     524    while (readdir $dh) {
     525        pb_log(3,"Potential kernel file: $_\n");
     526        # Skip non-files
     527        next if (! -f "$kernel->{'dir'}/$_");
     528        # Skip files not correpsonding to the RE planned
     529        next if ($_ !~ /$kernel->{"namere"}/);
     530        # We now have a candidate. Analyze further
     531        pb_log(3,"Potential kernel file 2: $_\n");
     532        eval
     533        {
     534            require File::MimeInfo;
     535            File::MimeInfo->import();
     536        };
     537        if ($@) {
     538            # File::MimeInfo not found
     539            die("ERROR: Install File::MimeInfo to handle kernel file detection\n");
     540        }
     541        my $mm = mimetype("$kernel->{'dir'}/$_");
     542        # Skip symlinks
     543        next if ($mm =~ /inode\/symlink/);
     544        pb_log(2,"file $_ mimetype: $mm\n");
     545        if ($mm =~ /\/x-gzip/) {
     546            # on ia64 kernel are gzip compressed
     547        }
     548        next if (pb_get_content("$kernel->{'dir'}/$_") !~ /$kernel->{"release"}/);
     549        pb_log(3,"Potential kernel file 3: $_\n");
     550        $kernel->{"file"} = "$kernel->{'dir'}/$_";
     551        #my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat("$f/$_");
     552    }
     553    closedir($dh);
     554}
     555pb_log(1,"INFO: kernel is ".Dumper($kernel)."\n");
     556pb_log(1,"End of kernel analysis\n");
    517557}
    518558
Note: See TracChangeset for help on using the changeset viewer.