summaryrefslogtreecommitdiffstats
path: root/debian/update-control-files.py
blob: ec428d786aa798582640dc205db81d2900421f45 (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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/python3

# Add all languages which should build a binary package
languages = {
    "cs": "Czech",
    "da": "Danish",
    "de": "German",
    "el": "Greek",
    "es": "Spanish",
    "fi": "Finnish",
    "fr": "French",
    "hu": "Hungarian",
    "id": "Indonesian",
    "it": "Italian",
    "mk": "Macedonian",
    "nb": "Norwegian",
    "nl": "Dutch",
    "pl": "Polish",
    "pt-br": "Brazilian Portuguese",
    "ro": "Romanian",
    "ru": "Russian",
    "sr": "Serbian",
    "sv": "Swedish",
    "uk": "Ukrainian",
    "vi": "Vietnamese",
}

# Add all languages which should *not* build a -dev binary package,
# because there are no translations yet
no_dev_packages = {
    "el",
    "fi",
    "hu",
    "id",
    "mk",
    "nb",
    "ro",
    "ru",
    "sv",
    "sr",
    "vi",
}

def locale(code):
    locale = code
    parts = code.split("-")
    if len(parts) > 1:
        locale = parts[0] + "_" + parts[1].upper()
    return locale

# Generate helper control files
for code, name in languages.items():
    with open("manpages-{}.docs".format(code), "w") as out:
        out.write("README.md\n")

    if code not in no_dev_packages:
        with open("manpages-{}-dev.docs".format(code), "w") as out:
            out.write("README.md\n")

    with open("manpages-{}.install".format(code), "w") as out:
        out.write("usr/share/man/{}/man1/*\n".format(locale(code)))
        out.write("usr/share/man/{}/man2/intro.2.gz\n".format(locale(code)))
        out.write("usr/share/man/{}/man3/intro.3.gz\n".format(locale(code)))
        out.write("usr/share/man/{}/man4/*\n".format(locale(code)))
        out.write("usr/share/man/{}/man5/*\n".format(locale(code)))
        out.write("usr/share/man/{}/man6/*\n".format(locale(code)))
        out.write("usr/share/man/{}/man7/*\n".format(locale(code)))
        out.write("usr/share/man/{}/man8/*\n".format(locale(code)))

    if code not in no_dev_packages:
        with open("manpages-{}-dev.install".format(code), "w") as out:
            out.write("usr/share/man/{}/man2/*\n".format(locale(code)))
            out.write("usr/share/man/{}/man3/*\n".format(locale(code)))

# FIXME Should write out .links files as well?

with open("rules", "w") as out:
    out.write("#! /usr/bin/make -f\n\n")
    out.write("include /usr/share/dpkg/pkg-info.mk\n\n")
    out.write("%:\n")
    out.write("\tdh $@\n\n")
    out.write("override_dh_installman:\n")
    out.write("\tdh_installman\n")
    out.write("\t# Prevent broken symlinks, see https://bugs.debian.org/876047\n")
    out.write("\t# and https://bugs.debian.org/875419\n")
    for code, language in languages.items():
        out.write("\tif [ -L $(CURDIR)/debian/manpages-{}/usr/share/man/{}/man4/console_ioctl.4.gz ]; then \\\n".format(code, locale(code)))
        out.write("\t\tmkdir -p $(CURDIR)/debian/manpages-{}-dev/usr/share/man/{}/man4 ; \\\n".format(code, locale(code)))
        out.write("\t\tmv $(CURDIR)/debian/manpages-{}/usr/share/man/{}/man4/console_ioctl.4.gz \\\n".format(code, locale(code)))
        out.write("\t\t  $(CURDIR)/debian/manpages-{}-dev/usr/share/man/{}/man4 ; \\\n".format(code, locale(code)))
        out.write("\tfi\n")
        out.write("\tif [ -L $(CURDIR)/debian/manpages-{}/usr/share/man/{}/man4/tty_ioctl.4.gz ]; then \\\n".format(code, locale(code)))
        out.write("\t\tmkdir -p $(CURDIR)/debian/manpages-{}-dev/usr/share/man/{}/man4 ; \\\n".format(code, locale(code)))
        out.write("\t\tmv $(CURDIR)/debian/manpages-{}/usr/share/man/{}/man4/tty_ioctl.4.gz \\\n".format(code, locale(code)))
        out.write("\t\t  $(CURDIR)/debian/manpages-{}-dev/usr/share/man/{}/man4 ; \\\n".format(code, locale(code)))
        out.write("\tfi\n")
    out.write("\t# Remove intro.{2,3} manpages from manpages-LANGUAGE-dev,\n")
    out.write("\t# they are included in manpages-LANGUAGE\n")
    for code, language in languages.items():
        out.write("\trm -f debian/manpages-{}-dev/usr/share/man/{}/man2/intro.2\n".format(code, locale(code)))
        out.write("\trm -f debian/manpages-{}-dev/usr/share/man/{}/man3/intro.3\n".format(code, locale(code)))

with open("control", "w") as out:
    out.write("""Source: manpages-l10n
Maintainer: Dr. Helge Kreutzmann <debian@helgefjell.de>
Uploaders: Dr. Tobias Quathamer <toddy@debian.org>
Section: doc
Priority: optional
Build-Depends: debhelper-compat (= 12)
Build-Depends-Indep: po4a
Rules-Requires-Root: no
Standards-Version: 4.6.2
Vcs-Browser: https://salsa.debian.org/debian/manpages-l10n
Vcs-Git: https://salsa.debian.org/debian/manpages-l10n.git
Homepage: https://manpages-l10n-team.pages.debian.net/manpages-l10n/
""")

    for code, language in languages.items():
        out.write("\nPackage: manpages-{}\n".format(code))
        out.write("""Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}
Suggests: man-browser,
          manpages
""")
        out.write("Description: {} man pages\n".format(language))
        out.write(" This package contains manual pages translated into {},\n".format(language))
        out.write(""" originating from a large number of projects which do not ship
 translated man pages themselves, including the traditional Linux
 manpages. The exact projects and man pages might change from
 release to release, so please look at the actually shipped files
 for the current set.
 .
 The following sections are included:
  * 1 = User programs (e.g. ls, ln)
  * 4 = Devices (e.g. hd, sd).
  * 5 = File formats and protocols, syntaxes of several system
        files (e.g. wtmp, /etc/passwd, nfs).
  * 6 = Games etc.
  * 7 = Conventions and standards, macro packages, etc.
        (e.g. nroff, ascii).
  * 8 = System administration commands.
 .
 The original (software) packages contain additional manual pages
 which have not been translated yet.

""")

        if code not in no_dev_packages:
            out.write("Package: manpages-{}-dev\n".format(code))
            out.write("""Architecture: all
Multi-Arch: foreign
Depends: ${misc:Depends}
Suggests: man-browser,
          manpages-dev,
          glibc-doc
""")
            out.write("Description: {} development manpages\n".format(language))
            out.write(" This package contains the Linux development manual pages\n")
            out.write(" translated into {}.\n".format(language))
            out.write(""" .
 The following sections are included:
  * 2 = Linux system calls.
  * 3 = Libc calls (note that a more comprehensive source of
        information may be found in one of the libc-doc packages).
 .
 The English package manpages-dev contains additional manual pages
 which have not been translated yet.
""")