add aliases and redo the format a bunch

This commit is contained in:
askiiart 2025-04-25 10:39:14 -05:00
parent 021d2f0aa5
commit b771df150e
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
3 changed files with 60 additions and 18 deletions

51
blend
View file

@ -93,20 +93,53 @@ def podman_it_remover(cmd: list):
# END
# TODO: fix temp paths before committing
distro_map = yaml.safe_load(open('/usr/share/blend/images.yaml'))
if os.path.exists(f'/etc/blend/images.yaml'):
distro_map += yaml.safe_load(
open(f'{os.getenv('XDG_CONFIG_HOME')}/blend/images.yaml'))
if os.path.exists(f'{os.getenv('XDG_CONFIG_HOME')}/blend/images.yaml'):
distro_map += yaml.safe_load(
open(f'{os.getenv('XDG_CONFIG_HOME')}/blend/images.yaml'))
def image_data_from_dict(dictionary):
'''
Returns a distro map and aliases from a dict in this format:
```
{'arch-linux': {'image': 'quay.io/toolbx/arch-toolbox:latest', 'aliases': ['arch']}}
```
which is loaded in from yaml config files in this format:
```yaml
arch-linux:
image: "quay.io/toolbx/arch-toolbox:latest"
aliases:
- arch
```
'''
distro_map = {}
aliases = {}
for distro in dictionary.keys():
distro_map[distro] = dictionary[distro]['image']
try:
aliases[distro] = dictionary[distro]['aliases']
except KeyError:
pass
return (distro_map, aliases)
distro_map, aliases = image_data_from_dict(
yaml.safe_load(open('/usr/share/blend/images.yaml')))
tmp = image_data_from_dict(yaml.safe_load(open('system.yaml'))['images'])
distro_map += tmp[0]
aliases += tmp[1]
tmp += image_data_from_dict(yaml.safe_load(
open(f'{os.getenv('XDG_CONFIG_HOME')}/blend/images.yaml')))
distro_map += tmp[0]
aliases += tmp[1]
default_distro = 'arch-linux'
def get_distro():
def get_image():
try:
return distro_map[args.distro]
except:
@ -222,7 +255,7 @@ def core_create_container():
'--userns', 'keep-id',
'--annotation', 'run.oci.keep_original_groups=1'])
podman_command.extend([get_distro()])
podman_command.extend([get_image()])
# User (for init-blend)
podman_command.extend(['--uid', str(os.geteuid())])

View file

@ -1,3 +0,0 @@
# Here you can put custom images to be used for blend
# for example:
# opensuse: quay.io/exampleauthor/opensuse:15

View file

@ -1,6 +1,18 @@
arch-linux: quay.io/toolbx/arch-toolbox:latest
debian: quay.io/toolbx-images/debian-toolbox:testing
fedora-42: quay.io/fedora/fedora-toolbox:42
centos: quay.io/toolbx-images/centos-toolbox:latest
ubuntu-22.04: quay.io/toolbx/ubuntu-toolbox:22.04
ubuntu-24.04: quay.io/toolbx/ubuntu-toolbox:24.04
arch-linux:
image: quay.io/toolbx/arch-toolbox:latest
aliases:
- arch
debian:
image: quay.io/toolbx-images/debian-toolbox:testing
fedora-42:
image: quay.io/fedora/fedora-toolbox:42
aliases:
- fedora
centos:
image: quay.io/toolbx-images/centos-toolbox:latest
ubuntu-22.04:
image: quay.io/toolbx/ubuntu-toolbox:22.04
ubuntu-24.04:
image: quay.io/toolbx/ubuntu-toolbox:24.04
aliases:
- ubuntu