Changeset 3663


Ignore:
Timestamp:
May 3, 2017, 11:27:14 AM (4 weeks ago)
Author:
bruno
Message:

Better handling of -s option for parted2fdisk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi/mr-parted2fdisk

    r3647 r3663  
    173173# whatever the option used.
    174174$device = $ARGV[0] if (defined $opts{'l'});
    175 $device = $opts{'s'} if (defined $opts{'s'});
    176175$device = $ARGV[0] if (defined $ARGV[0]);
    177 $device = "" if ((not defined $device) || ($device =~ /^-/));
    178176
    179177# -s takes a partition as arg
    180178# so create a correct device from that
    181179if (defined $opts{'s'}) {
     180    $device = $opts{'s'};
    182181    $wpart = $device;
    183182    # To support dev like cciss/c0d0p1
     
    194193}
    195194
    196 pb_log(1,"Called with device: $device\n");
     195# util-linux/fdisk version
     196my $fdisk = pb_check_req("fdisk",0);
     197open(CMD,"$fdisk -v |") || die "Unable to execute $fdisk";
     198my $version = <CMD>;
     199close(CMD);
     200chomp($version);
     201# RHEL 5 has fdisk from util-linux 2.13-pre7
     202# Mageia 4 has fdisk from util-linux 2.24.2
     203$version =~ s/[^0-9\.]*([0-9a-z\.-]+)[\)]*$/$1/;
     204my ($v,$maj,$min) = split(/\./,$version);
     205
     206# Consider pre version the same as the following for formats
     207if ((defined $maj) && ($maj =~ /-pre/)) {
     208    $maj =~ s/-pre.*$//;
     209    $maj++;
     210}
     211# Remove potential remaining letters
     212$maj =~ s/[a-z]+//;
     213
     214if ((defined $min) && ($min =~ /-pre/)) {
     215    $min =~ s/-pre.*$//;
     216    $min++;
     217}
     218$min =~ s/[a-z]+// if (defined $min);
    197219
    198220my %pid = ( "FAT" => "6",
     
    217239    $pnum{$l} = $i;
    218240}
    219 
    220 # util-linux/fdisk version
    221 my $fdisk = pb_check_req("fdisk",0);
    222 open(CMD,"$fdisk -v |") || die "Unable to execute $fdisk";
    223 my $version = <CMD>;
    224 close(CMD);
    225 chomp($version);
    226 # RHEL 5 has fdisk from util-linux 2.13-pre7
    227 # Mageia 4 has fdisk from util-linux 2.24.2
    228 $version =~ s/[^0-9\.]*([0-9a-z\.-]+)[\)]*$/$1/;
    229 my ($v,$maj,$min) = split(/\./,$version);
    230 
    231 # Consider pre version the same as the following for formats
    232 if ((defined $maj) && ($maj =~ /-pre/)) {
    233     $maj =~ s/-pre.*$//;
    234     $maj++;
    235 }
    236 # Remove potential remaining letters
    237 $maj =~ s/[a-z]+//;
    238 
    239 if ((defined $min) && ($min =~ /-pre/)) {
    240     $min =~ s/-pre.*$//;
    241     $min++;
    242 }
    243 $min =~ s/[a-z]+// if (defined $min);
    244241
    245242# fdisk has a bug when handling more than 1024 disks, seen on RHEL
Note: See TracChangeset for help on using the changeset viewer.