Skip to content

Commit

Permalink
Merge pull request #25 from kloptops/main
Browse files Browse the repository at this point in the history
Added PortMaster-Multiverse, added config upgrade code, updated default_theme, updated translations.
  • Loading branch information
kloptops authored Oct 29, 2023
2 parents be9bf09 + 412cfb7 commit 979796a
Show file tree
Hide file tree
Showing 17 changed files with 425 additions and 366 deletions.
2 changes: 1 addition & 1 deletion PortMaster/pugwash
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

## -- BEGIN PORTMASTER INFO --
PORTMASTER_VERSION = '8.4.22'
PORTMASTER_VERSION = '8.4.23'
PORTMASTER_RELEASE_CHANNEL = 'beta'
## -- END PORTMASTER INFO --

Expand Down
29 changes: 17 additions & 12 deletions PortMaster/pylibs/default_theme/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"comment": "Port image",
"parent": "port_info_area",
"area": [ 0.0, 0.1, 1.0, 0.4 ],
"area[4:3]": [ 0.0, 0.1, 1.0, 0.7 ],
"area[30:17|427:240]": [ 0.0, 0.1, 1.0, 0.75 ],
"area[16:9]": [ 0.0, 0.1, 1.0, 0.65 ]

Expand Down Expand Up @@ -301,7 +302,7 @@
"port_general_info": {
"parent": "port_info_text_area",
"area": [ 5, 5, -5, -5 ],
"area[4:3]": [ 5, 90, -5, -5 ],
"area[4:3]": [ 5, 70, -5, -5 ],
"area[1:1]": [ 5,88, -5, -5 ],
"area[16:9]": [ 5, 80, -5, -5 ],
"area[427:240]": [ 5, 80, -5, -5 ],
Expand All @@ -317,7 +318,7 @@
"port_desc": {
"parent": "port_info_text_area",
"area": [ 5, 65, -5, -45 ],
"area[4:3]": [ 5, 118, -5, -50 ],
"area[4:3]": [ 5, 130, -5, -50 ],
"area[1:1]": [ 5, 145, -5, -50 ],
"area[3:2]": [ 5, 65, -5, -25 ],
"area[16:9]": [ 5, 165, -5, -100 ],
Expand Down Expand Up @@ -800,18 +801,9 @@
"image": "{port_info.image}"
},

"featured_port_description": {
"text": "{featured_ports.description}",
"font-size": 16,
"font-color": "general_font",
"area": [ 0.0, 0.10, 0.3, 0.85 ],
"align": "topleft",
"text-wrap": true
},

"port_general_info": {
"parent": "left_pane_featured",
"area": [ 0.0, 0.6, 0.95, 0.8 ],
"area": [ 0.0, 0.70, 0.95, 0.85 ],
"border-x": 16,
"font-size": 16,
"font-size[1920x1152]": 11,
Expand All @@ -821,6 +813,19 @@
"text": "Genres: {port_info.genres}\n{if:port_info.install_size}Installed Size: {port_info.install_size}{else}Download Size: {port_info.download_size}{endif}{if:port_info.runtime}\nRuntime: {port_info.runtime} ({port_info.runtime_status}){endif}"
},

"featured_port_description": {
"text": "{featured_ports.description}",
"font-size": 16,
"font-color": "general_font",
"area": [ 0.0, 0.05, 0.3, 0.19 ],
"align": "topleft",
"autoscroll": "marquee",
"scroll-speed": 60,
"scroll-delay-start": 1500,
"scroll-delay-end": 1500,
"text-wrap": true
},


"#element:button_bar": {}

Expand Down
11 changes: 11 additions & 0 deletions PortMaster/pylibs/harbourmaster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@
"data": {}
}
"""),
"021_portmaster.multiverse.source.json": textwrap.dedent("""
{
"prefix": "pmmv",
"api": "PortMasterV2",
"name": "PortMaster Multiverse",
"url": "https://api.github.com/repos/PortsMaster-MV/PortMaster-Multiverse/releases/latest",
"last_checked": null,
"version": 4,
"data": {}
}
"""),
}


Expand Down
36 changes: 35 additions & 1 deletion PortMaster/pylibs/harbourmaster/harbour.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class HarbourMaster():
__PORTS_INFO = None
__PORTERS = None

CONFIG_VERSION = 1
CONFIG_VERSION = 2
DEFAULT_CONFIG = {
'version': CONFIG_VERSION,
'first-run': True,
Expand All @@ -49,6 +49,7 @@ class HarbourMaster():
PORTS_INFO_URL = PORT_INFO_URL + "ports_info.json"
FEATURED_PORTS_URL = PORT_INFO_URL + "featured_ports.json"
PORTERS_URL = PORT_INFO_URL + "porters.json"
SOURCES_URL = PORT_INFO_URL + "sources.json"

def __init__(self, config, *, tools_dir=None, ports_dir=None, temp_dir=None, callback=None):
"""
Expand Down Expand Up @@ -130,6 +131,10 @@ def __init__(self, config, *, tools_dir=None, ports_dir=None, temp_dir=None, cal
if 'theme' not in self.cfg_data:
self.cfg_data['theme'] = 'default_theme'

if self.cfg_data.get('version', 1) != self.CONFIG_VERSION:
self.update_config()
self.cfg_data['version'] = self.CONFIG_VERSION

self.load_info()

self.load_sources()
Expand All @@ -138,6 +143,35 @@ def __init__(self, config, *, tools_dir=None, ports_dir=None, temp_dir=None, cal

self.save_config()

def update_config(self):
version = self.cfg_data.get('version', 1)
if version:
# Upgrade from version 1 to 2
logger.debug(f"Upgrading PortMaster/config/config.json: 1 -> 2")

for image_dir in self.cfg_dir.glob("images_*"):
if not image_dir.is_dir():
continue

logger.debug(f"rmtree {image_dir}")
shutil.rmtree(str(image_dir))

for source_file in self.cfg_dir.glob("*portmaster*.source.json"):
if not source_file.is_file():
continue

logger.debug(f"unlink {source_file}")
source_file.unlink()

for source_name in HM_SOURCE_DEFAULTS:
with (self.cfg_dir / source_name).open('w') as fh:
fh.write(HM_SOURCE_DEFAULTS[source_name])

logger.debug(f"creating {source_name}")

version = 2


def save_config(self):
with open(self.cfg_file, 'w') as fh:
json.dump(self.cfg_data, fh, indent=4)
Expand Down
Loading

0 comments on commit 979796a

Please sign in to comment.