Commit c4bcd1cc authored by Mike Hibler's avatar Mike Hibler
Browse files

Temporary hacks to work around lack of GPT support in imagezip.

parent 88641ab7
......@@ -55,6 +55,7 @@ my $zipper = "/usr/local/bin/imagezip";
my $uploader = "/usr/local/bin/frisupload";
my $xenscript = "/usr/local/bin/create-xen-image";
my $slice = "";
my $slicenum = 0;
my $device;
my $filename;
......@@ -117,16 +118,16 @@ if (defined($options{"F"})) {
}
if (defined($options{"s"})) {
my $num = $options{"s"};
$slicenum = $options{"s"};
if ($num =~ /(\d)/) {
$num = $1;
if ($slicenum =~ /(\d)/) {
$slicenum = $1;
}
else {
die("Tainted slice number: $num");
die("Tainted slice number: $slicenum");
}
$slice = "-s $num";
$slice = "-s $slicenum";
# XXX for now we do not generate relocation info on slices
# XXX there are still some issues with LILO/GRUB
......@@ -184,10 +185,31 @@ if ($^O eq 'linux') {
$device = "/dev/sd$dunit";
}
#
# XXX we don't support GPT right now, so we can only do Linux partition
# images directly from the partition device.
#
my $isgpt = 0;
if ($^O eq 'linux' && -x "/sbin/sgdisk" &&
!system("/sbin/sgdisk $device >/dev/null 2>&1")) {
if ($slicenum == 0) {
print STDERR
"Cannot take whole disk image of GPT disk\n";
exit(3);
}
$isgpt = 1;
}
#
# If imageid is defined, we use the frisbee uploader.
#
my $cmd = "$sudo $zipper $slice $device $filename";
my $cmd = "$sudo $zipper";
if ($isgpt) {
# force imagezip to treat as an ext filesystem and use the slice device
$cmd .= " -S 131 $device$slicenum $filename";
} else {
$cmd .= " $slice $device $filename";
}
if (defined($imageid)) {
# use basic shell sleezy trick to capture exit status from imagezip
$cmd = "( $cmd || echo \$? > /tmp/imagezip.stat )";
......
......@@ -346,18 +346,18 @@ my $dofrisbee = 0;
foreach my $iid (sort keys %iinfo) {
if (!defined($iinfo{$iid}{'disk'})) {
print STDERR "Must specify disk\n";
exit(0);
exit(1);
}
if (!defined($iinfo{$iid}{'part'})) {
$iinfo{$iid}{'part'} = 0;
}
if (!defined($iinfo{$iid}{'iname'})) {
print STDERR "Must specify imagename\n";
exit(0);
exit(1);
}
if (!defined($iinfo{$iid}{'method'})) {
print STDERR "Must specify method\n";
exit(0);
exit(1);
}
if ($iinfo{$iid}{'method'} eq "frisbee") {
$dofrisbee++;
......@@ -573,6 +573,21 @@ sub process_image($)
exit(3);
}
#
# XXX we don't support GPT right now, so we can only do Linux partition
# images directly from the partition device.
#
my $isgpt = 0;
if ($^O eq 'linux' && -x "/sbin/sgdisk" &&
!mysystem("/sbin/sgdisk ".$iinfo{$iid}{'disk'}." >/dev/null 2>&1")) {
if ($iinfo{$iid}{'part'} == 0) {
print STDERR
"Cannot take whole disk image of GPT disk\n";
exit(3);
}
$isgpt = 1;
}
#
# Fire off the command:
#
......@@ -591,8 +606,13 @@ sub process_image($)
if (exists($iinfo{$iid}{'izopts'})) {
$cmd .= $iinfo{$iid}{'izopts'};
}
if ($iinfo{$iid}{'part'} != 0) {
$cmd .= " -s " . $iinfo{$iid}{'part'};
if ($isgpt) {
# force imagezip to treat as an ext filesystem
$cmd .= " -S 131";
} else {
if ($iinfo{$iid}{'part'} != 0) {
$cmd .= " -s " . $iinfo{$iid}{'part'};
}
}
if (exists($iinfo{$iid}{'sigfile'})) {
$cmd .= " -H $localdir/sigfile";
......@@ -601,6 +621,10 @@ sub process_image($)
$cmd .= " -U $localdir/nsigfile";
}
$cmd .= " " . $iinfo{$iid}{'disk'};
if ($isgpt) {
# use the slice device
$cmd .= $iinfo{$iid}{'part'};
}
my $image = $iinfo{$iid}{'iname'};
if ($iinfo{$iid}{'method'} eq "file") {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment