Path: blob/main/sys/contrib/device-tree/scripts/rewrite-index.pl
48254 views
#!/usr/bin/perl1use strict;2use warnings;3use IPC::Open2;4my $pid;56open(my $lsfiles, "-|", "git ls-files -s") or die "fork lsfiles: $!";78while (<$lsfiles>) {9if ($_ =~ m/^120000 ([0-9a-f]{40}) (.*)\t(.*)/) {10my ($obj, $stage, $path) = ($1,$2,$3);11if (!defined $pid) {12$pid = open2(*Rderef, *Wderef, "git cat-file --batch-check='deref-ok %(objectname)' --follow-symlinks")13or die "open git cat-file: $!";14}15print Wderef "$ENV{GIT_COMMIT}:$path\n" or die "write Wderef: $!";16my $deref = <Rderef>;17if ($deref =~ m/^deref-ok ([0-9a-f]{40})$/) {18$_ = "100644 $1 $stage\t$path\n"19} elsif ($deref =~ /^dangling /) {20# Skip next line21my $dummy = <Rderef>;22} else {23die "Failed to parse symlink $ENV{GIT_COMMIT}:$path $deref";24}25}2627my $m = 0;2829# Keep the copyright. Also ensures we never have a completely empty commit.30$m++ if m/\tCOPYING$/;3132# A few architectures have dts files at non standard paths. Massage those into33# a standard arch/ARCH/boot/dts first.3435# symlink: arch/microblaze/boot/dts/system.dts -> ../../platform/generic/system.dts36next if m,\tarch/microblaze/boot/dts/system.dts$,;37$m++ if s,\tarch/microblaze/platform/generic/(system.dts)$,\tarch/microblaze/boot/dts/$1,;3839# arch/mips/lantiq/dts/easy50712.dts40# arch/mips/lantiq/dts/danube.dtsi41# arch/mips/netlogic/dts/xlp_evp.dts42# arch/mips/ralink/dts/rt3050.dtsi43# arch/mips/ralink/dts/rt3052_eval.dts44$m++ if s,\tarch/mips/([^/]*)/dts/(.*\.dts.?)$,\tarch/mips/boot/dts/$2,;4546# arch/mips/cavium-octeon/octeon_68xx.dts47# arch/mips/cavium-octeon/octeon_3xxx.dts48# arch/mips/mti-sead3/sead3.dts49$m++ if s,\tarch/mips/([^/]*)/([^/]*\.dts.?)$,\tarch/mips/boot/dts/$2,;5051# arch/x86/platform/ce4100/falconfalls.dts52$m++ if s,\tarch/x86/platform/ce4100/falconfalls.dts,\tarch/x86/boot/dts/falconfalls.dts,;5354# test cases55$m++ if s,\tdrivers/of/testcase-data/,\ttestcase-data/,;5657# Now rewrite generic DTS paths58$m++ if s,\tarch/([^/]*)/boot/dts/(.*\.dts.?)$,\tsrc/$1/$2,;59$m++ if s,\tarch/([^/]*)/boot/dts/(.*\.h)$,\tsrc/$1/$2,;6061# Also rewrite the DTS include paths for dtc+cpp support62$m++ if s,\tarch/([^/]*)/include/dts/,\tsrc/$1/include/,;63$m++ if s,\tinclude/dt-bindings/,\tinclude/dt-bindings/,;6465# Rewrite the bindings subdirectory66$m++ if s,\tDocumentation/devicetree/bindings/,\tBindings/,;6768print if $m > 0;69}70kill $pid if $pid;71exit 0;727374