summaryrefslogtreecommitdiffstats
path: root/debian/move_links_to_correct_package
blob: 32fbb3aaaf41b1c26d02a79bc441d80010b9d675 (plain) (blame)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
#
# In order to not ship broken symlinks, every manpage needs
# to be checked for a link. If there is a link, ensure
# that the destination file exists in the Debian
# package. See bug #876047 for an example.

# Ensure that the given file is alread handled.
# After the necessery Breaks/Replaces are added
# to debian/control, the file needs to be added
# manually to the list of known files.
check_breaks_replaces () {
  known_files="man3/FILE.3
    man3/aiocb.3
    man3/clock_t.3
    man3/clockid_t.3
    man3/dev_t.3
    man3/div_t.3
    man3/double_t.3
    man3/fenv_t.3
    man3/fexcept_t.3
    man3/float_t.3
    man3/gid_t.3
    man3/id_t.3
    man3/imaxdiv_t.3
    man3/int16_t.3
    man3/int32_t.3
    man3/int64_t.3
    man3/int8_t.3
    man3/intN_t.3
    man3/intmax_t.3
    man3/intptr_t.3
    man3/lconv.3
    man3/ldiv_t.3
    man3/lldiv_t.3
    man3/off_t.3
    man3/pid_t.3
    man3/ptrdiff_t.3
    man3/queue.3
    man3/regex_t.3
    man3/regmatch_t.3
    man3/regoff_t.3
    man3/siginfo_t.3
    man3/sigset_t.3
    man3/sigval.3
    man3/size_t.3
    man3/ssize_t.3
    man3/suseconds_t.3
    man3/time_t.3
    man3/timer_t.3
    man3/timespec.3
    man3/timeval.3
    man3/uid_t.3
    man3/uint16_t.3
    man3/uint32_t.3
    man3/uint64_t.3
    man3/uint8_t.3
    man3/uintN_t.3
    man3/uintmax_t.3
    man3/uintptr_t.3
    man3/va_list.3
    man3/void.3
    man4/console_ioctl.4
    man4/tty_ioctl.4"
  file_is_known="no"
  for file in $known_files; do
    if [ "x$1" = "x$file" ]; then
     file_is_known="yes"
    fi
  done
  if [ $file_is_known = "no" ]; then
    echo
    echo "Error: The file $1 is not in the list of known files."
    echo "Probably you need to add Breaks/Replaces for the packages."
    echo "Afterwards, please add the file to the list of known files."
    echo
    exit 1
  fi
}

for src_section in man?; do
  for file in $src_section/*; do
    destination=`grep "^\.so " $file`
    if [ -n "$destination" ]; then
      dest_section=`echo "$destination" | sed -e "s/.*\(man.\).*/\1/"`
      if [ "$dest_section" != "$src_section" ]; then
        # The destination is in the package manpages
        if [ "$dest_section" != "man2" -a "$dest_section" != "man3" ]; then
          # Ensure the source link is not in package manpages-dev
          if [ "$src_section" = "man2" -o "$src_section" = "man3" ]; then
            echo "Moving $file to package manpages."
            mkdir -p "debian/manpages/usr/share/man/$src_section"
            mv "debian/manpages-dev/usr/share/man/$file" "debian/manpages/usr/share/man/$file"
            check_breaks_replaces "$file"
          fi
        else
          # The destination is in the package manpages-dev
          # Ensure the source link is not in package manpages
          if [ "$src_section" != "man2" -a "$src_section" != "man3" ]; then
            echo "Moving $file to package manpages-dev."
            mkdir -p "debian/manpages-dev/usr/share/man/$src_section"
            mv "debian/manpages/usr/share/man/$file" "debian/manpages-dev/usr/share/man/$file"
            check_breaks_replaces "$file"
          fi
        fi
      fi
    fi
  done
done