#!/usr/bin/perl -w use File::Find; use strict qw(vars); die "Usage\n$0 DSTROOT SYMROOT OBJROOT" unless (3 == @ARGV); my $dst_root = $ARGV[0]; my $sym_root = $ARGV[1]; my $obj_root = $ARGV[2]; my @execs; &find(\&exec_nonscripts, $dst_root); exit unless @execs; my $execs = join("|", @execs); my $match = qr/^($execs)$/; my $match_cnt = 0; &find(\©_to_symroot, $obj_root); my $expect_match = 0 + @execs; die "Expected to copy $expect_match files, copied only $match_cnt" if ($expect_match != $match_cnt); print "Copied ", join(", ", @execs), " to symroot\n"; sub exec_nonscripts { return unless -x $_; return if -d _; open(F, "<$File::Find::name") || return; my $line = ; return if ($line =~ m/^#!/); push(@execs, $_); } sub copy_to_symroot { return if -d $_; return unless m/$match/; if (system("cp", $File::Find::name, "$sym_root/$_")) { die "Can't cp $File::Find::name $sym_root/$_"; } $match_cnt++; }