|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 |
|
3 | | - |
4 | 3 | # This file is part of PrawnOS (https://www.prawnos.com) |
5 | | -# Copyright (c) 2022 Hal Emmerich <hal@halemmerich.com> |
| 4 | +# Copyright (c) 2023 Eva Emmerich <eva@evaemmerich.com> |
6 | 5 |
|
7 | 6 | # PrawnOS is free software: you can redistribute it and/or modify |
8 | 7 | # it under the terms of the GNU General Public License version 2 |
|
19 | 18 |
|
20 | 19 | import click |
21 | 20 | from prompt_toolkit.shortcuts import button_dialog |
22 | | -from tools import get_device_model |
23 | | - |
24 | | -# option helpers |
25 | | -def validate_res(res, expected): |
26 | | - if res not in expected: |
27 | | - raise ValueError(f"{res} is not a valid option, expected one of {expected}") |
| 21 | +import libinstall |
| 22 | +import package_lists as pl |
| 23 | +import constants |
28 | 24 |
|
29 | 25 | # option handlers |
30 | | -de_answers = ["xfce", "gnome"] |
31 | | -de_hint ="Choose a desktop envorionment to install. If you are unsure, pick Xfce" |
32 | | -def ask_de(options): |
33 | | - result = None |
34 | | - if (opt := options.get("de", None)): |
35 | | - result = opt |
36 | | - else: |
37 | | - result = button_dialog( |
| 26 | +all_handlers = {} |
| 27 | + |
| 28 | +DE_OPT = "de" |
| 29 | +DE_XFCE = "xfce" |
| 30 | +DE_GNOME = "gnome" |
| 31 | +DE_ANSWERS = [DE_XFCE, DE_GNOME] |
| 32 | +DE_DIALOG = button_dialog( |
38 | 33 | title='Install Desktop Environment', |
39 | | - text=de_hint, |
| 34 | + text="Choose a desktop envorionment to install. If you are unsure, pick Xfce", |
40 | 35 | buttons=[ |
41 | | - ('Xfce', "xfce"), |
42 | | - ('Gnome', "gnome"), |
| 36 | + ('Xfce', DE_XFCE), |
| 37 | + ('Gnome', DE_GNOME), |
43 | 38 | ], |
44 | | - ).run() |
45 | | - validate_res(result, de_answers) |
46 | | - return result |
47 | | - |
48 | | - |
49 | | -#TODO ensure all options end up in the all_answers map |
50 | | -all_answers = {"de" : de_answers} |
51 | | -def ask_all(options): |
52 | | - answers = all_answers |
53 | | - answers["de"] = ask_de(options) |
54 | | - |
55 | | - return answers |
| 39 | + ) |
56 | 40 |
|
| 41 | +libinstall.register_opt(all_handlers, DE_OPT, DE_ANSWERS, DE_DIALOG) |
57 | 42 |
|
58 | 43 |
|
59 | 44 |
|
60 | 45 | def main(options): |
61 | 46 | #TODO take map of user prompted options to skip prompting |
62 | | - answers = ask_all(options) |
| 47 | + answers = libinstall.ask_all(all_handlers, options) |
63 | 48 |
|
64 | | - model = get_device_model() |
| 49 | + model = libinstall.get_device_model() |
65 | 50 | print(model) |
66 | 51 | print(answers) |
67 | 52 |
|
| 53 | + |
| 54 | + #TODO set the timezone, and the time |
| 55 | + packages = [] |
| 56 | + ## General packages |
| 57 | + packages += pl.base_debs_download |
| 58 | + packages += pl.prawnos_base_debs_prebuilt_download |
| 59 | + |
| 60 | + ## Device Specific packages |
| 61 | + if "veyron" in model: |
| 62 | + packages += prawnos-veyron-config |
| 63 | + elif "gru" in model: |
| 64 | + packages += prawnos-gru-config |
| 65 | + |
| 66 | + ## DE Specific packages |
| 67 | + if answers[DE_OPT] == DE_GNOME: |
| 68 | + packages += gnome_debs_download |
| 69 | + packages += prawnos_gnome_debs_prebuilt_download |
| 70 | + |
| 71 | + elif answers[DE_OPT] = DE_XFCE: |
| 72 | + packages += xfce_debs_download |
| 73 | + packages += prawnos_xfce_debs_prebuilt_download |
| 74 | + |
| 75 | + libinstall.apt_install(packages) |
| 76 | + |
| 77 | + # clean up some broken packages, and some not necessary |
| 78 | + purge_packages = [] |
| 79 | + # TODO figure out what packages are pulling these in |
| 80 | + purge_packages += gnome-software |
| 81 | + purge_packages += lilyterm |
| 82 | + # TODO debug why rotation is flipped |
| 83 | + # work around issue #234 |
| 84 | + purge_packages += iio-sensor-proxy |
| 85 | + # remove light-locker, as it is broken see issue #56 |
| 86 | + purge_packages += light-locker |
| 87 | + |
| 88 | + libinstall.apt_purge(purge_packages) |
| 89 | + |
| 90 | + #TODO need to wrap the following commands |
| 91 | + |
| 92 | + #$ apt clean -y |
| 93 | + #$ apt autoremove --purge -y |
| 94 | + |
| 95 | + # reload the CA certificate symlinks |
| 96 | + #$ update-ca-certificates --fresh |
| 97 | + |
| 98 | + #enable periodic TRIM |
| 99 | + #$ cp /lib/systemd/system/fstrim.{service,timer} /etc/systemd/system |
| 100 | + # systemctl enable fstrim.timer |
| 101 | + |
| 102 | + |
| 103 | + |
68 | 104 | @click.command() |
69 | 105 | @click.option('--options_file', default=None) |
70 | 106 | def cli(options_file): |
|
0 commit comments