Upgrade releasetools/sort_set
- retire the old shell script - import perl script The perl scripts has the following advantages: - The sorting should be more stable, even accross different OSes. - The sorted output is automatically formatted into columns - It is much faster, even on large inputs. Change-Id: I1068b21fda981b4cf9eeea4af83165ec2968280b
This commit is contained in:
parent
94a0fb49a5
commit
c2106076f4
50
releasetools/sort_set.pl
Executable file
50
releasetools/sort_set.pl
Executable file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/perl -T -t -w -W
|
||||||
|
|
||||||
|
print <<HEADER;
|
||||||
|
#
|
||||||
|
# Sorted using sort_set.pl in releasetools.
|
||||||
|
# to add an entry simply add it at the end of the
|
||||||
|
# file and run
|
||||||
|
# ../../../../releasetools/sort_set.pl < mi > out
|
||||||
|
# mv out mi
|
||||||
|
#
|
||||||
|
HEADER
|
||||||
|
|
||||||
|
while(<STDIN>) {
|
||||||
|
if ($_ =~ m/#.*/) {
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_ =~ m/(\S+)\s+(\S+)\s+(\S+)/) {
|
||||||
|
my ($f, $s, $c) = ($1, $2, $3);
|
||||||
|
$sets{"$f"} = $s;
|
||||||
|
$conditions{"$f"} = $c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_ =~ m/(\S+)\s+(\S+)/) {
|
||||||
|
my ($f, $s) = ($1, $2);
|
||||||
|
$sets{"$f"} = $s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach $file (sort keys %sets) {
|
||||||
|
$set = $sets{$file};
|
||||||
|
|
||||||
|
if (length($file) < 56) {
|
||||||
|
printf("%-55s ", $file);
|
||||||
|
} else {
|
||||||
|
printf("%s ", $file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$last = $set;
|
||||||
|
if (exists($conditions{$file})) {
|
||||||
|
$last = $conditions{$file};
|
||||||
|
if (length($set) < 16) {
|
||||||
|
printf("%-15s ", $set);
|
||||||
|
} else {
|
||||||
|
printf("%s ", $set);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%s\n", $last);
|
||||||
|
}
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
#
|
|
||||||
# kinda natural sorting for sets
|
|
||||||
# prepend every line with a modified path where
|
|
||||||
# slashes are replaced by "1" and "0" is added
|
|
||||||
# at the end of the string.
|
|
||||||
#
|
|
||||||
# entry
|
|
||||||
# ./bin/cat minix-sys
|
|
||||||
# becomes
|
|
||||||
#.1bin1cat0 ./bin/cat minix-sys
|
|
||||||
#
|
|
||||||
# This entry gets sorted after wich the key is removed using
|
|
||||||
# cut
|
|
||||||
#
|
|
||||||
# Additionally all lines starting with "#" are put on
|
|
||||||
# top in the order they where put in the file. this is done
|
|
||||||
# by creating a "key" with the value COUNTER
|
|
||||||
#
|
|
||||||
COUNTER=10000
|
|
||||||
while read i
|
|
||||||
do
|
|
||||||
A=$(echo $i | cut -f 1 -d ' ' | sed "s,^#,00$COUNTER,g" | sed 's,/,1,g' )
|
|
||||||
echo "${A}0 $i"
|
|
||||||
COUNTER=$(($COUNTER +1))
|
|
||||||
done | sort | cut -d ' ' -f 2-
|
|
||||||
Loading…
Reference in New Issue
Block a user