Bernard,
my feedback and 3 comments:
1) I think it's better to pass the image name instead of the image
directory to --image option (see the changes in the attached patch)
2) in my image server for a suse10 image it gets the xen kernel and
prints a lot of warning (empty strings, etc), since the running kernel
is not the same kernel that is in the image; I've fixed this problem
calling _choose_kernel_file( '', "$image_dir/$image" ), as discussed on
IRC, and choosing the kernel as following:
+ # If cannot find kernel with name matching running version,
return the first good one
+ if (@kernels) {
+ foreach my $file (@kernels) {
+ my $kernel_release = _get_kernel_release($file);
+ if (defined($kernel_release) and (-d
"$image_dir/lib/modules/$kernel_release")) {
+ return $file;
}
+ }
}
3) in si_prepareclient --my-modules conflicts with --image
Then all seems good, if you've not other comments I think you can check
it in the trunk.
Cheers,
-Andrea
Bernard Li wrote:
> The attached patch will add a new function to si_prepareclient where you
> can pass it the location of the image you want to search for appropriate
> kernel and modules-dir and generate UYOK boot binaries from - handy to
> run on image server where all your images are.
>
> Thanks,
>
> Bernard
Index: lib/SystemImager/Config.pm
===================================================================
--- lib/SystemImager/Config.pm (revision 3704)
+++ lib/SystemImager/Config.pm (working copy)
@@ -12,8 +12,17 @@
use strict;
use AppConfig;
+BEGIN {
+ use Exporter();
-my $config = AppConfig->new(
+ @SystemImager::Config::ISA = qw(Exporter);
+ @SystemImager::Config::EXPORT = qw();
+ @SystemImager::Config::EXPORT_OK = qw($config);
+
+}
+use vars qw($config);
+
+$config = AppConfig->new(
'default_image_dir' => { ARGCOUNT => 1 },
'default_override_dir' => { ARGCOUNT => 1 },
'autoinstall_script_dir' => { ARGCOUNT => 1 },
Index: lib/SystemImager/UseYourOwnKernel.pm
===================================================================
--- lib/SystemImager/UseYourOwnKernel.pm (revision 3704)
+++ lib/SystemImager/UseYourOwnKernel.pm (working copy)
@@ -22,6 +22,8 @@
package SystemImager::UseYourOwnKernel;
use strict;
+use SystemImager::Config qw($config);
+
our $verbose;
our $is_mounted = 0;
@@ -29,7 +31,7 @@
#
# Usage:
-# SystemImager::UseYourOwnKernel->create_uyok_initrd($arch, $my_modules, $custom_kernel, $custom_mod_dir, $verbose);
+# SystemImager::UseYourOwnKernel->create_uyok_initrd($arch, $my_modules, $custom_kernel, $custom_mod_dir, $image, $verbose);
#
sub create_uyok_initrd() {
@@ -38,6 +40,7 @@
my $my_modules = shift;
my $custom_kernel = shift;
my $custom_mod_dir = shift;
+ my $image = shift;
$verbose = shift;
use File::Copy;
@@ -81,6 +84,21 @@
}
my $uname_r = get_uname_r();
+
+ if ($image) {
+ # Get SystemImager directories.
+ my $image_dir = $config->default_image_dir;
+
+ unless (-d "$image_dir/$image") {
+ die "error: $image is not a valid image! use si_lsimage to see the list of available images.\n";
+ }
+
+ # Autodetect custom kernel and modules directory in the image.
+ $custom_kernel = _choose_kernel_file( '', "$image_dir/$image" );
+ my $kernel_release = _get_kernel_release($custom_kernel);
+ $custom_mod_dir = "$image_dir/$image/lib/modules/$kernel_release";
+ }
+
my $module_dir;
if ($custom_mod_dir) {
$module_dir = $custom_mod_dir;
@@ -267,7 +285,10 @@
my ($input) = (<INPUT>);
#
# eliminate vmlinux files on RH
- if( $input =~ m/ELF 32-bit LSB executable,/ ) { return undef; }
+ if( $input =~ m/ELF 32-bit LSB executable,/ ) { return undef; }
+ #
+ # eliminate compressed data (eg. ramdisk)
+ if( $input =~ m/gzip compressed data,/ ) { return undef; }
close(INPUT);
#
@@ -277,12 +298,14 @@
#
# Usage:
-# my $kernel_file = _choose_kernel_file( $uname_r );
+# my $kernel_file = _choose_kernel_file( $uname_r, $image_dir );
#
sub _choose_kernel_file($) {
my $uname_r = shift;
- my @dirs = ('/boot', '/');
+ my $image_dir = shift;
+ $image_dir = '' if !($image_dir);
+ my @dirs = ("$image_dir/boot", "$image_dir/");
my @kernels;
foreach my $dir (@dirs) {
@@ -307,11 +330,15 @@
}
}
}
-
- # If cannot find kernel with name matching running version, return the first good one
- if (@kernels) {
- return pop(@kernels);
+ }
+ # If cannot find kernel with name matching running version, return the first good one
+ if (@kernels) {
+ foreach my $file (@kernels) {
+ my $kernel_release = _get_kernel_release($file);
+ if (defined($kernel_release) and (-d "$image_dir/lib/modules/$kernel_release")) {
+ return $file;
}
+ }
}
return undef;
Index: sbin/si_prepareclient
===================================================================
--- sbin/si_prepareclient (revision 3704)
+++ sbin/si_prepareclient (working copy)
@@ -183,6 +183,11 @@
Use this parameter only with --kernel and only if you use UYOK
feature.
+ --image DIR
+ Get kernel and kernel modules automatically from the image location
+ specified in DIR to use with UYOK (if executed on image server).
+ Use this parameter only if you use UYOK feature.
+
Download, report bugs, and make suggestions at:
http://systemimager.org/
@@ -200,6 +205,7 @@
"my-modules" => \my $my_modules,
"kernel=s" => \my $custom_kernel,
"modules-dir=s" => \my $modules_dir,
+ "image=s" => \my $image,
"version" => \my $version,
"server=s" => \my $server,
"yes" => \my $yes
@@ -255,6 +261,24 @@
exit 1;
}
+if($no_uyok and $image) {
+ print "FATAL: --no-uyok option conflicts with --image DIR!\n";
+ print qq(Try "$progname --help" for more info.\n);
+ exit 1;
+}
+
+if($custom_kernel and $image) {
+ print "FATAL: --kernel KERNEL option conflicts with --image DIR!\n";
+ print qq(Try "$progname --help" for more info.\n);
+ exit 1;
+}
+
+if($my_modules and $image) {
+ print "FATAL: --my-modules option conflicts with --image DIR!\n";
+ print qq(Try "$progname --help" for more info.\n);
+ exit 1;
+}
+
# Make sure we have certain tools that we need.
which('rsync') or croak("'rsync' is required for $progname to function properly. Please see http://systemimager.org for more details.");
which('systemconfigurator') or croak("'systemconfigurator' is required for $progname to function properly. Please see http://systemimager.org for more details.");
@@ -703,7 +727,7 @@
my $arch = get_arch();
my $verbose;
unless($quiet) { $verbose = 1; }
- SystemImager::UseYourOwnKernel->create_uyok_initrd( $arch, $my_modules, $custom_kernel, $modules_dir, $verbose );
+ SystemImager::UseYourOwnKernel->create_uyok_initrd( $arch, $my_modules, $custom_kernel, $modules_dir, $image, $verbose );
}
SystemImager::Common->write_auto_install_script_conf_footer($file);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sisuite-devel mailing list
Sisuite-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sisuite-devel