From e47c5d7df79c3da42f19d2fe3776079fe1223e88 Mon Sep 17 00:00:00 2001 From: ALPERDURUKAN Date: Mon, 7 Oct 2024 21:15:48 +0300 Subject: [PATCH 01/11] Update blend Added Ubuntu 24.04 LTS to containers --- blend | 1 + 1 file changed, 1 insertion(+) diff --git a/blend b/blend index 570a068..0bc2eb5 100755 --- a/blend +++ b/blend @@ -92,6 +92,7 @@ distro_map = { 'fedora-39': 'registry.fedoraproject.org/fedora-toolbox:39', 'centos': 'quay.io/toolbx-images/centos-toolbox:latest', 'ubuntu-22.04': 'quay.io/toolbx/ubuntu-toolbox:22.04', + 'ubuntu-24.04-lts': 'quay.io/toolbx/ubuntu-toolbox:24.04', } default_distro = 'arch-linux' From a890b119d7ec01f8f6ad8f7ba83110a6d7fb7efd Mon Sep 17 00:00:00 2001 From: ALPERDURUKAN Date: Mon, 7 Oct 2024 21:18:50 +0300 Subject: [PATCH 02/11] Update containers.html Added Ubuntu 24.04 LTS container support --- blend-settings/src/pages/containers.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/blend-settings/src/pages/containers.html b/blend-settings/src/pages/containers.html index 54806c2..935a85a 100644 --- a/blend-settings/src/pages/containers.html +++ b/blend-settings/src/pages/containers.html @@ -15,6 +15,7 @@ +
@@ -66,4 +67,4 @@ - \ No newline at end of file + From 463cdf64fc62f281d6741796d27b063cd1e9d958 Mon Sep 17 00:00:00 2001 From: askiiart Date: Tue, 1 Oct 2024 12:02:25 -0500 Subject: [PATCH 03/11] allow arguments for commands running in containers --- user | 1 + 1 file changed, 1 insertion(+) diff --git a/user b/user index b6624f0..ed8d6a4 100755 --- a/user +++ b/user @@ -208,6 +208,7 @@ def exec_c(container, cmds): exit(1) creation_env = os.environ.copy() creation_env['BLEND_NO_CHECK'] = 'true' + cmds = [ cmd.replace('\\-', '-') for cmd in cmds] subprocess.run(['blend', 'enter', '-cn', container, '--', *cmds], env=creation_env) From 321f9d9399f961749b7507ddda87ed6edf8e93f5 Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 15:37:43 -0600 Subject: [PATCH 04/11] fix old distro map terms being referenced --- blend | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/blend b/blend index 0bc2eb5..908c93e 100755 --- a/blend +++ b/blend @@ -248,12 +248,12 @@ def core_run_container(cmd): def core_install_pkg(pkg): - if args.distro == 'fedora-rawhide': + if args.distro.startswith('fedora-'): if args.noconfirm == True: core_run_container(f'sudo dnf -y install {pkg}') else: core_run_container(f'sudo dnf install {pkg}') - elif args.distro == 'arch': + elif args.distro == 'arch-linux': if core_get_retcode('[ -f /usr/bin/yay ]') != 0: core_run_container('sudo pacman -Sy') core_run_container( @@ -274,12 +274,12 @@ def core_install_pkg(pkg): def core_remove_pkg(pkg): - if args.distro == 'fedora-rawhide': + if args.distro.startswith('fedora-'): if args.noconfirm == True: core_run_container(f'sudo dnf -y remove {pkg}') else: core_run_container(f'sudo dnf remove {pkg}') - elif args.distro == 'arch': + elif args.distro == 'arch-linux': if args.noconfirm == True: core_run_container(f'sudo pacman --noconfirm -Rcns {pkg}') else: @@ -293,9 +293,9 @@ def core_remove_pkg(pkg): def core_search_pkg(pkg): - if args.distro == 'fedora-rawhide': + if args.distro.startswith('fedora-'): core_run_container(f'dnf search {pkg}') - elif args.distro == 'arch': + elif args.distro == 'arch-linux': core_run_container(f'yay -Sy') core_run_container(f'yay {pkg}') elif args.distro.startswith('ubuntu-'): @@ -304,9 +304,9 @@ def core_search_pkg(pkg): def core_show_pkg(pkg): - if args.distro == 'fedora-rawhide': + if args.distro.startswith('fedora-'): core_run_container(f'dnf info {pkg}') - elif args.distro == 'arch': + elif args.distro == 'arch-linux': core_run_container(f'yay -Sy') core_run_container(f'yay -Si {pkg}') elif args.distro.startswith('ubuntu-'): @@ -358,21 +358,21 @@ def show_blend(): def sync_blends(): - if args.distro == 'fedora-rawhide': + if args.distro.startswith('fedora-'): core_run_container(f'dnf makecache') - elif args.distro == 'arch': + elif args.distro == 'arch-linux': core_run_container(f'yay -Syy') elif args.distro.startswith('ubuntu-'): core_run_container(f'sudo apt-get update') def update_blends(): - if args.distro == 'fedora-rawhide': + if args.distro.startswith('fedora-'): if args.noconfirm == True: core_run_container(f'sudo dnf -y upgrade') else: core_run_container(f'sudo dnf upgrade') - elif args.distro == 'arch': + elif args.distro == 'arch-linux': if args.noconfirm == True: core_run_container(f'yay --noconfirm') else: From 58004461229c283f083ad319dc2a8664479f1d20 Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 16:31:46 -0600 Subject: [PATCH 05/11] code cleanup and minor bug fixes --- blend | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/blend b/blend index 908c93e..d6df431 100755 --- a/blend +++ b/blend @@ -19,7 +19,6 @@ import os import sys -import glob import time import shutil import socket @@ -129,7 +128,7 @@ def check_container(name): def check_container_status(name): - if os.environ.get('SUDO_USER') == None: + if os.environ.get('SUDO_USER'): return host_get_output("podman inspect --type container " + name + " --format \"{{.State.Status}}\"") else: return host_get_output(f"sudo -u {os.environ.get('SUDO_USER')} podman inspect --type container " + name + " --format \"{{.State.Status}}\"") @@ -137,7 +136,7 @@ def check_container_status(name): def core_start_container(name, new_container=False): sudo = [] - if os.environ.get('SUDO_USER') != None: + if os.environ.get('SUDO_USER'): sudo = ['sudo', '-u', os.environ.get('SUDO_USER')] subprocess.call([*sudo, 'podman', 'start', name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) @@ -150,7 +149,7 @@ def core_start_container(name, new_container=False): subprocess.call(['podman', 'logs', '--since', str(start_time), name]) exit(1) - if os.environ.get('SUDO_USER') == None: + if not os.environ.get('SUDO_USER'): logproc = pexpect.spawn( 'podman', args=['logs', '-f', '--since', str(start_time), name], timeout=3600) else: @@ -393,7 +392,7 @@ def enter_container(): podman_args = ['--env', 'LC_ALL=C.UTF-8'] sudo = [] - if os.environ.get('SUDO_USER') == None: + if not os.environ.get('SUDO_USER'): podman_args = ['--user', getpass.getuser()] else: sudo = ['sudo', '-u', os.environ.get( @@ -402,7 +401,7 @@ def enter_container(): if name not in ['LANG', 'LC_CTYPE', 'LC_ALL', 'PATH', 'HOST', 'HOSTNAME', 'SHELL'] and not name.startswith('_'): podman_args.append('--env') podman_args.append(name + '=' + val) - if os.environ.get('BLEND_COMMAND') == None or os.environ.get('BLEND_COMMAND') == '': + if not os.environ.get('BLEND_COMMAND'): if args.pkg == []: if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'): exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, From 3d888de5e132dca65481131a1a86a161ff7bda6f Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 13:57:11 -0600 Subject: [PATCH 06/11] removes user's distro checking (done in blend) and adds exit code (which is then returned by user) --- blend | 2 +- user | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/blend b/blend index d6df431..bc50db5 100755 --- a/blend +++ b/blend @@ -102,7 +102,7 @@ def get_distro(): return distro_map[args.distro] except: error(f"{args.distro} isn't supported by blend.") - exit() + exit(1) def list_containers(): diff --git a/user b/user index ed8d6a4..2b519c6 100755 --- a/user +++ b/user @@ -161,14 +161,10 @@ def create_container(container_name, distro): ''' Create a container ''' - if distro not in ('arch', 'almalinux-9', 'crystal-linux', 'debian', 'fedora-38', 'kali-linux', 'neurodebian-bookworm', 'rocky-linux', 'ubuntu-22.04', 'ubuntu-23.04'): - error( - f'distro {colors.bold}{distro}{colors.reset} not supported') if subprocess.run(['podman', 'container', 'exists', container_name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: error(f'container {colors.bold}{container_name}{colors.reset} already exists') exit(1) - subprocess.run(['blend', 'create-container', '-cn', container_name, '-d', distro]) - + exit(subprocess.run(['blend', 'create-container', '-cn', container_name, '-d', distro]).returncode) @cli.command("delete-container") @click.argument('container') From 3eaf53104acd083e087f7958a3ef020d16a36904 Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 15:05:30 -0600 Subject: [PATCH 07/11] Fix user's default distro (arch -> arch-linux) --- user | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user b/user index 2b519c6..3be3832 100755 --- a/user +++ b/user @@ -156,7 +156,7 @@ def associate_binary(association): @cli.command("create-container") @click.argument('container_name') -@click.argument('distro', default='arch') +@click.argument('distro', default='arch-linux') def create_container(container_name, distro): ''' Create a container From 77e9293295e4606b32c261512b0ef3e32a2d674c Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 15:18:52 -0600 Subject: [PATCH 08/11] have blend handle no distro being specified itself --- user | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/user b/user index 3be3832..c6cef81 100755 --- a/user +++ b/user @@ -164,7 +164,11 @@ def create_container(container_name, distro): if subprocess.run(['podman', 'container', 'exists', container_name], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode == 0: error(f'container {colors.bold}{container_name}{colors.reset} already exists') exit(1) - exit(subprocess.run(['blend', 'create-container', '-cn', container_name, '-d', distro]).returncode) + args = ['blend', 'create-container', '-cn', container_name] + # blend handles no distro being specified already + if distro: + args.extend(['-d', distro]) + exit(subprocess.run(args).returncode) @cli.command("delete-container") @click.argument('container') From 4569521785a919efbcb82f454d39a35880117276 Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 15:22:29 -0600 Subject: [PATCH 09/11] a distro arg is now *optional* with no default, since blend handles it --- user | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user b/user index c6cef81..0936619 100755 --- a/user +++ b/user @@ -156,7 +156,7 @@ def associate_binary(association): @cli.command("create-container") @click.argument('container_name') -@click.argument('distro', default='arch-linux') +@click.argument('distro', required=False) def create_container(container_name, distro): ''' Create a container From a6ec69a1f615c8e4f1cc11592eaa49d2cec49285 Mon Sep 17 00:00:00 2001 From: askiiart Date: Thu, 7 Nov 2024 13:42:51 -0600 Subject: [PATCH 10/11] remove unused imports cuz why not --- user | 4 ---- 1 file changed, 4 deletions(-) diff --git a/user b/user index 0936619..92e36ca 100755 --- a/user +++ b/user @@ -1,13 +1,9 @@ #!/usr/bin/python3 import os -import yaml import click import subprocess -from urllib.request import urlopen - - class colors: reset = '\033[0m' bold = '\033[01m' From 09f31200483e87df0d2afd401cad3a48c897b344 Mon Sep 17 00:00:00 2001 From: askiiart Date: Sun, 10 Nov 2024 10:33:00 -0600 Subject: [PATCH 11/11] forgot to fix the function name oops --- user | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user b/user index 92e36ca..1f78050 100755 --- a/user +++ b/user @@ -134,7 +134,7 @@ def associate_binary(association, container): @cli.command("dissociate") @click.argument('association') -def associate_binary(association): +def dissociate_binary(association): ''' Remove an association '''