summaryrefslogtreecommitdiff
path: root/dh_makeshlibs
blob: 41bf161419e397756f35401eda818ad0cb754200 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl -w
#
# Automatically generate shlibs files.

BEGIN { push @INC, "debian", "/usr/share/debhelper" }
use Dh_Lib;
init();

foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
	$TMP=tmpdir($PACKAGE);

	if (-e "$TMP/DEBIAN/shlibs") {
		error("$TMP/DEBIAN/shlibs already exists.");
	}

	open (FIND, "find $TMP -type f -name '*.so.*' |");
	while (<FIND>) {
		chomp;
		($library, $major)=m#.*/(.*)\.so\.(\d*)\.?#;
		if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
			$major=$dh{M_PARAMS};
		}
		if (! -d "$TMP/DEBIAN") {
			doit("install","-d","$TMP/DEBIAN");
		}
		$deps=$PACKAGE;
		if ($dh{V_FLAG_SET}) {
			if ($dh{V_FLAG} ne '') {
				$deps=$dh{V_FLAG};
			}	
			else {
				# Call isnative becuase it sets $dh{VERSION}
				# as a side effect.
				isnative($PACKAGE);
				$deps="$PACKAGE (>= $dh{VERSION})";
			}
		}
		if (defined($library) && defined($major) && defined($deps) && 
		    $library ne '' && $major ne '' && $deps ne '') {
			complex_doit("echo '$library $major $deps' >>$TMP/DEBIAN/shlibs");
		}
	}
	close FIND;

	if (-e "$TMP/DEBIAN/shlibs") {
		doit("chmod",644,"$TMP/DEBIAN/shlibs");
		doit("chown","root.root","$TMP/DEBIAN/shlibs");
	}
}