summaryrefslogtreecommitdiff
path: root/dh_installdirs
blob: 1ecf907e1d057365385bdf1417e7b7b1a4c02dc5 (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
#!/usr/bin/perl -w
#
# Reads debian/dirs, creates the directories listed there

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

foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
	$TMP=tmpdir($PACKAGE);
	$file=pkgfile($PACKAGE,"dirs");

	if (! -e $TMP) {
		doit("install","-d",$TMP);
	}

	undef @dirs;

	if ($file) {
		@dirs=filearray($file)
	}

	if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
		push @dirs, @ARGV;
	}	

	if (@dirs) {
		# Stick the $TMP onto the front of all the dirs.
		# This is necessary, for 2 reasons, one to make them 
		# be in the right directory, but more importantly, it 
		# protects against the danger of absolute dirs being
		# specified.
		@dirs=map {
				$_="$TMP/$_";
				tr:/:/:s; # just beautification.
				$_
			  } @dirs;

		# Create dirs.
		doit("install","-d",@dirs);
	}
}