Compare commits

..

13 commits

Author SHA1 Message Date
askiiart
eacb3aa470
Okay I don't know what's going on but Git seems to be working after like
40 rebase things so yeah I'm gonna do this all now
2024-11-10 10:35:56 -06:00
askiiart
09f3120048
forgot to fix the function name oops 2024-11-10 10:35:18 -06:00
askiiart
a6ec69a1f6
remove unused imports cuz why not 2024-11-10 10:35:15 -06:00
askiiart
4569521785
a distro arg is now *optional* with no default, since blend handles it 2024-11-10 10:35:13 -06:00
askiiart
77e9293295
have blend handle no distro being specified itself 2024-11-10 10:35:11 -06:00
askiiart
3eaf53104a
Fix user's default distro (arch -> arch-linux) 2024-11-10 10:35:08 -06:00
askiiart
3d888de5e1
removes user's distro checking (done in blend) and adds exit code (which is then returned by user) 2024-11-10 10:35:05 -06:00
askiiart
5800446122
code cleanup and minor bug fixes 2024-11-10 10:35:02 -06:00
askiiart
321f9d9399
fix old distro map terms being referenced 2024-11-10 10:34:59 -06:00
askiiart
463cdf64fc
allow arguments for commands running in containers 2024-11-10 10:34:56 -06:00
Rudra Saraswat
c8dafc0826
Merge pull request #11 from ALPERDURUKAN/main
Added Ubuntu 24.04 LTS Container Support
2024-10-07 22:25:25 +01:00
ALPERDURUKAN
a890b119d7
Update containers.html
Added Ubuntu 24.04 LTS container support
2024-10-07 21:18:50 +03:00
ALPERDURUKAN
e47c5d7df7
Update blend
Added Ubuntu 24.04 LTS to containers
2024-10-07 21:15:48 +03:00
3 changed files with 28 additions and 31 deletions

38
blend
View file

@ -19,7 +19,6 @@
import os
import sys
import glob
import time
import shutil
import socket
@ -92,6 +91,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'
@ -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():
@ -128,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}}\"")
@ -136,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)
@ -149,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:
@ -247,12 +247,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(
@ -273,12 +273,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:
@ -292,9 +292,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-'):
@ -303,9 +303,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-'):
@ -357,21 +357,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:
@ -392,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(
@ -401,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,

View file

@ -15,6 +15,7 @@
<option>CentOS</option>
<option>Fedora 39</option>
<option>Ubuntu 22.04</option>
<option>Ubuntu 24.04 LTS</option>
</select>
</div>
<div class="col-sm-1">
@ -66,4 +67,4 @@
<script src="internal/js/generic_page.js"></script>
<!-- Import containers JS. -->
<script src="internal/js/containers.js"></script>
<script src="internal/js/containers.js"></script>

18
user
View file

@ -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'
@ -138,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
'''
@ -156,19 +152,19 @@ def associate_binary(association):
@cli.command("create-container")
@click.argument('container_name')
@click.argument('distro', default='arch')
@click.argument('distro', required=False)
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])
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')