File: move_links_to_correct_package

package info (click to toggle)
manpages 6.15-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 20,184 kB
  • sloc: sh: 575; python: 222; perl: 190; makefile: 29; lisp: 22
file content (73 lines) | stat: -rw-r--r-- 3,055 bytes parent folder | download
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
#!/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="
    man/man3/queue.3
    man/man3/S_ISBLK.3
    man/man3/S_ISCHR.3
    man/man3/S_ISDIR.3
    man/man3/S_ISFIFO.3
    man/man3/S_ISLNK.3
    man/man3/S_ISREG.3
    man/man3/S_ISSOCK.3
    man/man3type/siginfo_t.3type
    man/man3type/sigset_t.3type
    man/man4/console_ioctl.4
    man/man4/tty_ioctl.4
    man/man7/sigevent.7"
    file_is_known="no"
    for file in $known_files; do
        if [ "$1" = "$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/man*; do
    src_section_strip=$(echo "$src_section" | cut -c 5-8)
    for file in "$src_section"/*; do
        destination=$(grep "^\.so " "$file")
        file_strip=$(echo "$file" | xargs basename)
        if [ -n "$destination" ]; then
            dest_section=$(echo "$destination" | sed -e "s/.*\(man.\).*/\1/")
            if [ "$dest_section" != "$src_section_strip" ]; then
                # The destination is in the package manpages
                if [ "$dest_section" != "man2" ] && [ "$dest_section" != "man3" ]; then
                    # Ensure the source link is not in package manpages-dev
                    if [ "$src_section_strip" = "man2" ] || [ "$src_section_strip" = "man3" ]; then
                        echo "Moving $file to package manpages."
                        mkdir -p "debian/manpages/usr/share/man/$src_section_strip"
                        mv "debian/manpages-dev/usr/share/man/$src_section_strip/$file_strip" "debian/manpages/usr/share/man/$src_section_strip/$file_strip"
                        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_strip" != "man2" ] && [ "$src_section_strip" != "man3" ]; then
                        echo "Moving $file to package manpages-dev."
                        mkdir -p "debian/manpages-dev/usr/share/man/$src_section_strip"
                        mv "debian/manpages/usr/share/man/$src_section_strip/$file_strip" "debian/manpages-dev/usr/share/man/$src_section_strip/$file_strip"
                        check_breaks_replaces "$file"
                    fi
                fi
            fi
        fi
    done
done