File: fix-paths

package info (click to toggle)
fml 4.0.3.dfsg-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,528 kB
  • ctags: 5
  • sloc: perl: 711; sh: 95; makefile: 88
file content (39 lines) | stat: -rw-r--r-- 909 bytes parent folder | download
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
36
37
38
39
#!/usr/bin/perl

$file = $ARGV[0];
$pwd = `/bin/pwd`;
chop($pwd);
$pwd = quotemeta($pwd);
$scriptp = 0;

# print "file: $file\n";
open(F, "$file") or die "cannot open $file, $!";
open(NF, ">$file.new") or die "cannot open $file.new, $!";
select(NF);
$_ = <F>;
if ($file =~ m,(usr/bin|usr/lib/fml|usr/share/fml), && $file !~ m,/doc/,) {
	if ($file =~ /(.pl|.cgi)$/ && !/^#!/) {
		print "#!/usr/bin/perl\n";
		$scriptp = 1;
	}
	if ($file =~ /.sh$/ && !/^#!/) {
		print "#!/bin/sh -e\n";
		$scriptp = 1;
	}
	if (/^#!/) {
		$scriptp = 1;
		s,#!(.*)/perl,#!/usr/bin/perl,;
	}
}
print; 
while (<F>) {
	s,^#!(.*)/perl,#!/usr/bin/perl,;
	s,exec /.*/perl,exec /usr/bin/perl,;
	s,$pwd/debian/[^/]+,,;
	print;
}
close(NF) or die "close failed: $file.new, $!" ;
close(F) or die "close failed: $file, $!";
rename("$file.new", "$file") or die "rename filed $file.new to $file, $!";
chmod 0755, $file if $scriptp;
exit (0);