Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/contrib/device-tree/scripts/rewrite-index.pl
48254 views
1
#!/usr/bin/perl
2
use strict;
3
use warnings;
4
use IPC::Open2;
5
my $pid;
6
7
open(my $lsfiles, "-|", "git ls-files -s") or die "fork lsfiles: $!";
8
9
while (<$lsfiles>) {
10
if ($_ =~ m/^120000 ([0-9a-f]{40}) (.*)\t(.*)/) {
11
my ($obj, $stage, $path) = ($1,$2,$3);
12
if (!defined $pid) {
13
$pid = open2(*Rderef, *Wderef, "git cat-file --batch-check='deref-ok %(objectname)' --follow-symlinks")
14
or die "open git cat-file: $!";
15
}
16
print Wderef "$ENV{GIT_COMMIT}:$path\n" or die "write Wderef: $!";
17
my $deref = <Rderef>;
18
if ($deref =~ m/^deref-ok ([0-9a-f]{40})$/) {
19
$_ = "100644 $1 $stage\t$path\n"
20
} elsif ($deref =~ /^dangling /) {
21
# Skip next line
22
my $dummy = <Rderef>;
23
} else {
24
die "Failed to parse symlink $ENV{GIT_COMMIT}:$path $deref";
25
}
26
}
27
28
my $m = 0;
29
30
# Keep the copyright. Also ensures we never have a completely empty commit.
31
$m++ if m/\tCOPYING$/;
32
33
# A few architectures have dts files at non standard paths. Massage those into
34
# a standard arch/ARCH/boot/dts first.
35
36
# symlink: arch/microblaze/boot/dts/system.dts -> ../../platform/generic/system.dts
37
next if m,\tarch/microblaze/boot/dts/system.dts$,;
38
$m++ if s,\tarch/microblaze/platform/generic/(system.dts)$,\tarch/microblaze/boot/dts/$1,;
39
40
# arch/mips/lantiq/dts/easy50712.dts
41
# arch/mips/lantiq/dts/danube.dtsi
42
# arch/mips/netlogic/dts/xlp_evp.dts
43
# arch/mips/ralink/dts/rt3050.dtsi
44
# arch/mips/ralink/dts/rt3052_eval.dts
45
$m++ if s,\tarch/mips/([^/]*)/dts/(.*\.dts.?)$,\tarch/mips/boot/dts/$2,;
46
47
# arch/mips/cavium-octeon/octeon_68xx.dts
48
# arch/mips/cavium-octeon/octeon_3xxx.dts
49
# arch/mips/mti-sead3/sead3.dts
50
$m++ if s,\tarch/mips/([^/]*)/([^/]*\.dts.?)$,\tarch/mips/boot/dts/$2,;
51
52
# arch/x86/platform/ce4100/falconfalls.dts
53
$m++ if s,\tarch/x86/platform/ce4100/falconfalls.dts,\tarch/x86/boot/dts/falconfalls.dts,;
54
55
# test cases
56
$m++ if s,\tdrivers/of/testcase-data/,\ttestcase-data/,;
57
58
# Now rewrite generic DTS paths
59
$m++ if s,\tarch/([^/]*)/boot/dts/(.*\.dts.?)$,\tsrc/$1/$2,;
60
$m++ if s,\tarch/([^/]*)/boot/dts/(.*\.h)$,\tsrc/$1/$2,;
61
62
# Also rewrite the DTS include paths for dtc+cpp support
63
$m++ if s,\tarch/([^/]*)/include/dts/,\tsrc/$1/include/,;
64
$m++ if s,\tinclude/dt-bindings/,\tinclude/dt-bindings/,;
65
66
# Rewrite the bindings subdirectory
67
$m++ if s,\tDocumentation/devicetree/bindings/,\tBindings/,;
68
69
print if $m > 0;
70
}
71
kill $pid if $pid;
72
exit 0;
73
74