summaryrefslogtreecommitdiff
path: root/scripts/dpkg-safefilelist.pl
blob: 65210150430d9e13dc08640f9f59efe0b0c3de80 (plain)
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
#!/usr/bin/perl
open(FILES, "find -mindepth 1|");
sub myprint {
	print "@_\n";
}
while (<FILES>) {
	chomp;
	$file = $_;
	if( ! -l $file ) {
		print "$file\n" if(!$targets{$file});
	}
	$newfile = $file;
	$oldfile = $newfile;

	while (-l $newfile) {
		push @symlinks, $newfile;
		$oldfile = $newfile;
		$link = readlink($newfile);
		$newfile = $_;
		$newfile =~ s,.*/,,;
		$path = $_;
		$path =~ s,[^/]*$,,;
		$newfile = $path . $link;
		break if("$oldfile" == "$newfile");
	}
	if(-e $newfile) {
		push @symlinks, $newfile;
		while($file = pop @symlinks) {
			if(!$targets{$file}) {
				$targets{$file} = 1;
				print "$file\n";
			}
		}
	}
}