/usr/bin/ocs-devsort is in clonezilla 3.10.11-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | #!/usr/bin/perl
# This function is provided by Miracle Linux.
# Now since the sort program on CentOS/RHEL 5 does not support the option "-V", we use this function.
# In the future we should use "sort -V" only. It's easier.
sub usage_details{
die "".
"Sort lines from stdin, based on the version number sorting\n".
"-h, --help Show this help message\n".
";"
} # end of usage_details
#
while ( $_ = shift ) {
if(/-h$|--help$/) {
usage_details();
}
}
sub split_devname {
my $dev = $_[0];
my ($h, $m, $t);
$dev =~ m!(?:(?:((?:i2o/)*[hsv]d)([a-z]+))|(?:(cciss)/(c[0-9]d[0-9])p*))([0-9]*)!;
if ($1 ne "") {
$h = $1; $m = $2; $t = $5;
}
else {
$h = $3; $m = $4; $t = $5;
}
return ($h, $m, $t);
}
sub subsort {
my ($a_h, $a_m, $a_t) = split_devname($a);
my ($b_h, $b_m, $b_t) = split_devname($b);
if ($a_h ne $b_h) {
return $a_h cmp $b_h;
}
elsif (length($a_m) == length($b_m)) {
return $a_m cmp $b_m || $a_t <=> $b_t;
}
else {
return length($a_m) <=> length($b_m);
}
}
@input = <STDIN>;
@devnames = sort subsort @input;
print @devnames;
|