Coverage for src/build_xfce.py: 30.43%
55 statements
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-02 08:58 -0700
« prev ^ index » next coverage.py v7.16.0, created at 2026-09-02 08:58 -0700
1#!/usr/bin/env python
3"""
4Name: build.py
5Purpose: Clean local Xfce repository directories
7source: https://gitlab.com/kevinbowen/xfrepos
8version: 0.8.7
9updated: 20260827
10@author: kevin.bowen@gmail.com
11"""
13import argparse
14import os
15import sys
16import time
17from pathlib import Path
19from cappdata import component_list
21parser = argparse.ArgumentParser(description="Build groups of Xfce components locally.")
22parser.add_argument(
23 "-c",
24 "--component",
25 action="store",
26 choices=[
27 "apps",
28 "bindings",
29 "panel-plugins",
30 "thunar-plugins",
31 "www",
32 "xfce",
33 "all_components",
34 ],
35 help="Specify an Xfce component group to build locally.",
36)
37parser.add_argument("--version", action="version", version="%(prog)s 0.8.7")
38args = parser.parse_args()
39if args.component is None: 39 ↛ 46line 39 didn't jump to line 46 because the condition on line 39 was always true
40 print(
41 "No component was specified. Default to building"
42 " the 'apps' components locally...."
43 )
44 args.component = "apps"
46line_rule = "\u2248" * 16
47path = Path(__file__).parent.resolve()
48os.chdir(path)
51def build_xfce(component, comp_list):
52 """Run autogen.sh and make on selected components."""
53 print(f"Building the Xfce {component} group...")
55 def get_path(comp_group):
56 # grandparent directory (../../) relative to script.
57 installpath = Path.cwd().parent.parent.joinpath(comp_group)
59 return installpath
61 repopath = get_path(component)
62 os.environ["PKG_CONFIG_PATH"] = "/usr/lib/pkgconfig:/usr"
64 if Path.is_dir(repopath):
65 os.chdir(repopath)
66 for item in component_list(comp_list):
67 p = Path(item)
68 if p.is_dir():
69 os.chdir(item)
70 print(f"\nRunning autogen.sh for {item} ...\n")
71 os.system("./autogen.sh --prefix=/usr") # ruff: ignore[start-process-with-a-shell]
72 print(f"\nRunning make for {item} ...\n")
73 time.sleep(1.5)
74 # ruff: ignore[start-process-with-a-shell]
75 os.system("make") # ruff: ignore[start-process-with-partial-path]
76 os.chdir("..")
77 else:
78 print("\nNothing to do...\n")
79 print(
80 f"The '{item}' repository does not exist.\n\n"
81 "Perhaps you need to clone it first.\n"
82 )
83 print(line_rule)
85 else:
86 print("Nothing to do...\n")
87 print(
88 f"The '{component}' repositories do not exist.\n\n"
89 "Perhaps you need to clone the directory first.\n"
90 )
91 print(line_rule)
94def main(component_group_name):
95 """Build arguments to pass to build_xfce() with a call to
96 cappdata for component name list.
97 command format:
98 build_xfce(component='apps',
99 comp_list='apps')
100 """
101 cgroup_listname = component_list(component_group_name)
102 # All cgroup_listnames will return a string, except 'all'
103 if isinstance(cgroup_listname, dict):
104 for comp, cglist in cgroup_listname.items():
105 build_xfce(component=comp, comp_list=cglist)
106 else:
107 build_xfce(component=component_group_name, comp_list=component_group_name)
110if __name__ == "__main__": 110 ↛ 111line 110 didn't jump to line 111 because the condition on line 110 was never true
111 try:
112 component_group = args.component
113 main(component_group)
114 except KeyboardInterrupt:
115 print()
116 print("Stopped xfrepos. Exiting...")
117 sys.exit()