Page MenuHomeDevCentral

roles/freebsd-repo/ports/files/parse-portshaker-merged-ports.py

Authored By
dereckson
Oct 16 2024, 18:58
Size
1 KB
Referenced Files
None
Subscribers
None

roles/freebsd-repo/ports/files/parse-portshaker-merged-ports.py

#!/usr/bin/env python3
# -------------------------------------------------------------
# portshaker merged ports -> pkglist
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: Nasqueron
# Description: Read portshaker merged ports file
# Output a pkglist for Poudriere
# License: BSD-2-Clause
# -------------------------------------------------------------
import os
import sys
# -------------------------------------------------------------
# Poudriere helper methods
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POUDRIERE_CONFIG_ROOT="/usr/local/etc/poudriere.d"
def get_ports_tree_config_dir(name):
return POUDRIERE_CONFIG_ROOT + "/ports/" + name
def is_ports_tree_exists(name):
return os.path.exists(get_ports_tree_config_dir(name))
def get_ports_tree_path(name):
mnt_path = get_ports_tree_config_dir(name) + "/mnt"
with open(mnt_path) as fd:
return fd.readline().strip()
# -------------------------------------------------------------
# Portshaker helper methods
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def parse_port(line):
return line.strip().split(":")[1]
def get_portshaker_merged_ports(name):
try:
ports_path = get_ports_tree_path(name) + "/.portshaker-merged-ports"
except FileNotFoundError:
return []
return [parse_port(line) for line in open(ports_path)]
# -------------------------------------------------------------
# Application entry point
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def run(tree_name):
ports = get_portshaker_merged_ports(tree_name)
for port in ports:
print(port)
if __name__ == "__main__":
argc = len(sys.argv)
if argc < 2:
print(f"Usage: {sys.argv[0]} <ports tree name>", file=sys.stderr)
sys.exit(1)
run(sys.argv[1])

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2199386
Default Alt Text
roles/freebsd-repo/ports/files/parse-portshaker-merged-ports.py (1 KB)

Event Timeline