Debian Codegraph @

auxdata/wscript

raw ◀ ▶
1 Debian patch touch this file
•1 #! /usr/bin/python3
2 import os
3
4 from waflib import Options, Utils, Logs
5
6
7 def options(opt):
8 opt.add_option(
9 "--no-hooks",
10 action="store_true",
11 default=False,
12 help="Don't run any mime, icon cache or similar update hooks [Default:False]",
13 )
14 opt.add_option(
15 "--no-update-mime",
16 action="store_true",
17 default=False,
18 help="Do not update mime and desktop databases [Default:Update]",
19 )
20 opt.add_option(
21 "--no-update-icon-cache",
22 action="store_true",
23 default=False,
24 help="Do not update icon cache [Default:Update]",
25 )
26
27
28 def configure(conf):
29 if not Options.options.no_update_mime and not Options.options.no_hooks:
30 conf.env["AUXDATA_MIME"] = 1
31 if (
32 not Options.options.no_update_icon_cache
33 and not Options.options.no_hooks
34 ):
35 conf.env["UPDATE_ICON_CACHE"] = 1
36
37
38 def build(bld):
39 # merge translations into the .desktop file
40 # and set it up to be installed
41 def install_desktop_file(desktop_subst_file):
42 return bld(
43 features="intltool_in",
44 podir="../po",
45 flags=("-d", "-q", "-u"),
46 source=desktop_subst_file + ".in",
47 target=desktop_subst_file,
48 install_path="${DATADIR}/applications",
49 chmod=0o755,
50 )
51
52 k_desktop = install_desktop_file("kupfer.desktop")
53 _x_desktop = install_desktop_file("kupfer-exec.desktop")
54
55 ## install kupfer.desktop as a Thunar sendto object
56 kd_install = os.path.join(
57 Utils.subst_vars(k_desktop.install_path, bld.env), "kupfer.desktop"
58 )
59 symlink_location = Utils.subst_vars(
60 "${DATADIR}/Thunar/sendto/kupfer.desktop", bld.env
61 )
62 symlink_target = os.path.relpath(
63 kd_install, os.path.dirname(symlink_location)
64 )
65 bld.symlink_as(symlink_location, symlink_target)
66
67 ## install mimetype descriptions
68
69 mimetypes_file = "kupfer-mimetypes.xml"
70 bld(
71 features="intltool_in",
72 podir="../po",
73 flags=("-x", "-q", "-u"),
74 source=mimetypes_file + ".in",
75 target=mimetypes_file,
76 install_path="${DATADIR}/mime/packages/",
77 )
78
79 def update_mime(bld):
80 Logs.pprint("GREEN", "Updating mime database")
81 bld.exec_command(
82 [
83 "update-mime-database",
84 Utils.subst_vars("${DATADIR}/mime", bld.env),
85 ]
86 )
87 bld.exec_command(
88 [
89 "update-desktop-database",
90 Utils.subst_vars("${DATADIR}/applications", bld.env),
91 ]
92 )
93
94 if bld.is_install and bld.env["AUXDATA_MIME"]:
95 bld.add_post_fun(update_mime)
96
97 ## install kupfer icon
98 icons_inst = bld.install_files(
99 "${DATADIR}/icons/hicolor",
100 bld.path.ant_glob("hicolor/**"),
101 cwd=bld.path.find_dir("hicolor"),
102 relative_trick=True,
103 )
104
105 def update_icon_cache(bld):
106 icon_dir = Utils.subst_vars("${DATADIR}/icons/hicolor", bld.env)
107 if not Options.options.destdir:
108 Logs.pprint("GREEN", "Updating Gtk icon cache.")
109 command = f"gtk-update-icon-cache -q -f -t {icon_dir}"
110 bld.exec_command(command)
111 else:
112 Logs.pprint(
113 "YELLOW", "Icon cache not updated. After install, run this:"
114 )
115 Logs.pprint("YELLOW", f"gtk-update-icon-cache -q -f -t {icon_dir}")
116
117 if icons_inst and bld.is_install and bld.env["UPDATE_ICON_CACHE"]:
118 bld.add_post_fun(update_icon_cache)