summaryrefslogtreecommitdiff
path: root/dh_makeshlibs
blob: 8f3e7a7ae0a411ecba24267b9e0aff92d35ea413 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/perl -w
#
# Automatically generate shlibs files.

use Debian::Debhelper::Dh_Lib;
init();

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

	my %seen;
	my $need_ldconfig = 0;

	doit("rm", "-f", "$TMP/DEBIAN/shlibs");

	open (FIND, "find $TMP -xtype f -name '*.so*' |");
	while (<FIND>) {
		chomp;
		$need_ldconfig=1;
		# The second evil regexp is for db3, whose author should
		# be shot.
		if (m#.*/([^/]*)\.so\.(\d*)\.?# || m#.*/([^/]*)-([^\s/]+)\.so$#) {
			$library = $1;
			$major = $2;
		}
		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 '') {
		    	# Prevent duplicate lines from entering the file.
		    	my $line="$library $major $deps";
			if (! $seen{$line}) {
				$seen{$line}=1;
				complex_doit("echo '$line' >>$TMP/DEBIAN/shlibs");
			}
		}
	}
	close FIND;

	# New as of dh_v3.
	if (! Debian::Debhelper::Dh_Lib::compat(2) && 
	    ! $dh{NOSCRIPTS} && $need_ldconfig) {
		autoscript($PACKAGE,"postinst","postinst-makeshlibs");
		autoscript($PACKAGE,"postrm","postrm-makeshlibs");
	}

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