File: wscript

package info (click to toggle)
kupfer 329-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,352 kB
  • sloc: python: 37,681; makefile: 88; sh: 78; xml: 3
file content (118 lines) | stat: -rw-r--r-- 3,580 bytes parent folder | download | duplicates (3)
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
#! /usr/bin/python3
import os

from waflib import Options, Utils, Logs


def options(opt):
    opt.add_option(
        "--no-hooks",
        action="store_true",
        default=False,
        help="Don't run any mime, icon cache or similar update hooks [Default:False]",
    )
    opt.add_option(
        "--no-update-mime",
        action="store_true",
        default=False,
        help="Do not update mime and desktop databases [Default:Update]",
    )
    opt.add_option(
        "--no-update-icon-cache",
        action="store_true",
        default=False,
        help="Do not update icon cache [Default:Update]",
    )


def configure(conf):
    if not Options.options.no_update_mime and not Options.options.no_hooks:
        conf.env["AUXDATA_MIME"] = 1
    if (
        not Options.options.no_update_icon_cache
        and not Options.options.no_hooks
    ):
        conf.env["UPDATE_ICON_CACHE"] = 1


def build(bld):
    # merge translations into the .desktop file
    # and set it up to be installed
    def install_desktop_file(desktop_subst_file):
        return bld(
            features="intltool_in",
            podir="../po",
            flags=("-d", "-q", "-u"),
            source=desktop_subst_file + ".in",
            target=desktop_subst_file,
            install_path="${DATADIR}/applications",
            chmod=0o755,
        )

    k_desktop = install_desktop_file("kupfer.desktop")
    _x_desktop = install_desktop_file("kupfer-exec.desktop")

    ## install kupfer.desktop as a Thunar sendto object
    kd_install = os.path.join(
        Utils.subst_vars(k_desktop.install_path, bld.env), "kupfer.desktop"
    )
    symlink_location = Utils.subst_vars(
        "${DATADIR}/Thunar/sendto/kupfer.desktop", bld.env
    )
    symlink_target = os.path.relpath(
        kd_install, os.path.dirname(symlink_location)
    )
    bld.symlink_as(symlink_location, symlink_target)

    ## install mimetype descriptions

    mimetypes_file = "kupfer-mimetypes.xml"
    bld(
        features="intltool_in",
        podir="../po",
        flags=("-x", "-q", "-u"),
        source=mimetypes_file + ".in",
        target=mimetypes_file,
        install_path="${DATADIR}/mime/packages/",
    )

    def update_mime(bld):
        Logs.pprint("GREEN", "Updating mime database")
        bld.exec_command(
            [
                "update-mime-database",
                Utils.subst_vars("${DATADIR}/mime", bld.env),
            ]
        )
        bld.exec_command(
            [
                "update-desktop-database",
                Utils.subst_vars("${DATADIR}/applications", bld.env),
            ]
        )

    if bld.is_install and bld.env["AUXDATA_MIME"]:
        bld.add_post_fun(update_mime)

    ## install kupfer icon
    icons_inst = bld.install_files(
        "${DATADIR}/icons/hicolor",
        bld.path.ant_glob("hicolor/**"),
        cwd=bld.path.find_dir("hicolor"),
        relative_trick=True,
    )

    def update_icon_cache(bld):
        icon_dir = Utils.subst_vars("${DATADIR}/icons/hicolor", bld.env)
        if not Options.options.destdir:
            Logs.pprint("GREEN", "Updating Gtk icon cache.")
            command = f"gtk-update-icon-cache -q -f -t {icon_dir}"
            bld.exec_command(command)
        else:
            Logs.pprint(
                "YELLOW", "Icon cache not updated. After install, run this:"
            )
            Logs.pprint("YELLOW", f"gtk-update-icon-cache -q -f -t {icon_dir}")

    if icons_inst and bld.is_install and bld.env["UPDATE_ICON_CACHE"]:
        bld.add_post_fun(update_icon_cache)