This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
forked from marcinbojko/linux_mint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
patch.py
153 lines (131 loc) · 4.15 KB
/
patch.py
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
"""
This module create overrides yaml files
"""
import yaml
def add(content, name, items=None):
"""
Content to add in overrides
"""
return_content = {name: content}
if items:
for item in items:
return_content[name].append(item)
return return_content
def remove(targets, remove_items):
"""
Remove unwanted items from the list
"""
# for item in remove_items:
# targets.remove(item)
for item in remove_items:
if isinstance(item, dict):
targets.remove(item)
else:
for i, target in enumerate(targets):
if item in target:
targets.pop(i)
def create_filename(name):
"""
Creates output filenames
"""
filename = "mint20_override_" + name + ".yaml"
return filename
def write_yaml_file(filename, output):
"""
Write yaml content to disk
"""
with open(filename, "w") as file:
yaml.dump(
output,
file,
explicit_start=True,
explicit_end=True,
sort_keys=False
)
def main():
"""
I'm main :)
"""
# names of sections to work on.
name_deb = "deb"
name_downloads = "downloads"
name_files = "files"
name_flatpak = "flatpak"
name_pip = "pip"
name_startup = "startup"
# Content to add
add_deb = [
"https://github.com/BoostIO/BoostNote.next-local/releases/download/v0.21.1/boost-note-local-linux.deb",
"https://github.com/bitwarden/desktop/releases/download/v1.27.1/Bitwarden-1.27.1-amd64.deb",
"https://download.teamviewer.com/download/linux/teamviewer_amd64.deb"
]
add_downloads = [
{
"url": "https://github.com/bitwarden/cli/releases/download/v1.17.1/bw-linux-1.17.1.zip",
"destination": "bw",
"skip_tree": False
}
]
add_files = [
{
"url": "https://github.com/ytmdesktop/ytmdesktop/releases/download/v1.13.0/YouTube-Music-Desktop-App-1.13.0.AppImage",
"destination": "youtubemusic",
"desktop_file": "./files/apps/youtubemusic/youtubemusic.desktop"
},
{
"url": "https://developers.yubico.com/yubikey-manager-qt/Releases/yubikey-manager-qt-1.2.2-linux.AppImage",
"destination": "yubikeymanager",
"desktop_file": "./files/apps/yubikeymanager/yubikeymanager.desktop"
}
]
add_flatpak = [
{"name": "https://flathub.org/repo/appstream/org.telegram.desktop.flatpakref"},
{"name": "https://flathub.org/repo/appstream/org.signal.Signal.flatpakref"},
{"name": "https://flathub.org/repo/appstream/us.zoom.Zoom.flatpakref"}
]
add_pip = [
"pylint",
"pycodestyle"
]
# Content to remove in overrides
remove_startup = [
{"filename": "dropbox.desktop", "source": "./files/apps/dropbox/dropbox.desktop"},
{"filename": "synapse.desktop", "source": "./files/apps/synapse/synapse.desktop"},
{"filename": "DockX.desktop", "source": "./files/apps/dockbarx/DockX.desktop"}
]
remove_deb = [
"wpsoffice"
]
# Assign content we care about to variables
with open("mint20.yaml") as file:
content = yaml.load(file, Loader=yaml.FullLoader)
# Remove content before creating output.
remove(content["deb"], remove_deb)
remove(content["startup"], remove_startup)
write_yaml_file(
create_filename(name_deb),
add(content["deb"], name_deb, add_deb)
)
write_yaml_file(
create_filename(name_downloads),
add(content["downloads"], name_downloads, add_downloads)
)
write_yaml_file(
create_filename(name_files),
add(content["files"], name_files, add_files)
)
write_yaml_file(
create_filename(name_flatpak),
add(content["flatpak"], name_flatpak, add_flatpak)
)
write_yaml_file(
create_filename(name_pip),
add(content["pip"], name_pip, add_pip)
)
write_yaml_file(
create_filename(name_startup),
add(content["startup"], name_startup)
)
if __name__ == "__main__":
# execute only if run as a script
main()