3 # Generate symlinks in debian packages, reading debian/links. The
4 # file contains pairs of files and symlinks.
6 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
10 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
11 $TMP=tmpdir($PACKAGE);
12 $file=pkgfile($PACKAGE,"links");
16 @links=filearray($file);
19 # Make sure it has pairs of symlinks and destinations. If it
20 # doesn't, $#links will be _odd_ (not even, -- it's zero-based).
21 if (int($#links/2) eq $#links/2) {
22 error("$file lists a link without a destination.");
25 if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
29 # Same test as above, including arguments this time.
30 if (int($#links/2) eq $#links/2) {
31 error("parameters list a link without a destination.");
38 # Relivatize src and dest.
42 # Make sure the directory the link will be in exists.
43 $basedir=Dh_Lib::dirname("$TMP/$dest");
45 doit("install","-d",$basedir);
48 # Policy says that if the link is all within one toplevel
49 # directory, it should be relative. If it's between
50 # top level directories, leave it absolute.
51 @src_dirs=split(m:/+:,$src);
52 @dest_dirs=split(m:/+:,$dest);
53 if ($src_dirs[0] eq $dest_dirs[0]) {
54 # Figure out how much of a path $src and $dest
56 for ($x=0; $x<$#src_dirs && $src_dirs[$x] eq $dest_dirs[$x]; $x++) {}
57 # Build up the new src.
59 for (1..$#dest_dirs - $x) {
62 for ($x .. $#src_dirs) {
63 $src.=$src_dirs[$_]."/";
68 # Make sure it's properly absolute.
72 doit("ln","-sf",$src,"$TMP/$dest");