bump up to 1.0.3

This commit is contained in:
Rudra Bali 2023-01-19 14:31:12 +05:30
parent e2eee152ac
commit 6eff7a1c09
13 changed files with 139 additions and 29 deletions

3
.gitignore vendored
View file

@ -1,4 +1,5 @@
/debian/*.debhelper
/debian/*.substvars
/debian/debhelper-build-stamp
/debian/blend
/debian/blend
/debian/files

View file

@ -15,7 +15,7 @@ This was originally developed by VanillaOS.
Usage:
blend [command] [options] [arguments]
Version: 1.0.1
Version: 1.0.3
blend is a package manager for blendOS, which includes support for Arch, Ubuntu and Fedora packages.
@ -32,6 +32,8 @@ You can use any of these distros by passing the option --distro=[NAME OF THE DIS
You can even install a supported desktop environment in a blend container (run `blend install-de [DESKTOP ENVIRONMENT NAME]` to install your favorite desktop environment).
However, this feature is still somewhat experimental, and some apps might be buggy.
Here's a list of the supported desktop environments:
1. gnome
2. mate
@ -43,8 +45,10 @@ available commands:
help Show this help message and exit.
version Show version information and exit.
enter Enter the container shell.
export Export the desktop entry for an installed blend.
unexport Unexport the desktop entry for a blend.
install Install packages inside a container.
install-de Install a desktop environment inside a container.
install-de Install a desktop environment inside a container. (EXPERIMENTAL)
remove Remove packages inside a managed container.
create-container Create a container managed by blend.
remove-container Remove a container managed by blend.

69
blend
View file

@ -5,7 +5,7 @@ import shutil
import argparse
import subprocess
__version = '1.0.1'
__version = '1.0.3'
### Colors
class colors:
@ -77,6 +77,8 @@ def distrobox_list_containers():
'{{.Names}}:{{.Mounts}}'], stdout=subprocess.PIPE).stdout.decode('utf-8').strip()
if len(_list) == 0:
info('No containers. Create one by installing a package (`blend install hello`), or manually create one (`blend create-container arch`).')
else:
info('List of containers:')
for container in _list.splitlines(keepends=False):
if 'distrobox' in container.split(':')[1]:
print(container.split(':')[0])
@ -107,7 +109,7 @@ def distrobox_create_container():
distrobox_run_container('cd ~; git clone https://aur.archlinux.org/yay.git')
distrobox_run_container('cd ~/yay; makepkg --noconfirm -si')
distrobox_get_output = lambda cmd: subprocess.run(['distrobox-enter', '-nw', '-n', args.container_name, '--', cmd],
distrobox_get_output = lambda cmd: subprocess.run(['distrobox-enter', '-nw', '-n', args.container_name, '--', 'sh', '-c', cmd],
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
def distrobox_run_container(cmd):
@ -275,20 +277,37 @@ def install_de():
distrobox_run_container(f'sudo apt-get purge -y gnome-terminal')
distrobox_run_container(f'sudo apt-get purge -y --auto-remove')
subprocess.run(f'echo "[Desktop Entry]" | sudo tee /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Name=GNOME on Wayland ({args.container_name})" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Name=GNOME on Wayland ({args.container_name})" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Comment=This session logs you into GNOME" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Exec=distrobox-enter -n {args.container_name} -- gnome-session --builtin" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Type=Application" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "DesktopNames=GNOME" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "X-GDM-SessionRegisters=true" | sudo tee -a /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "[Desktop Entry]" | sudo tee /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Name=GNOME on Xorg ({args.container_name})" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Comment=This session logs you into GNOME" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Exec=distrobox-enter -n {args.container_name} -- gnome-session --builtin" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "Type=Application" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "DesktopNames=GNOME" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'echo "X-GDM-SessionRegisters=true" | sudo tee -a /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'sudo chmod 755 /usr/share/wayland-sessions/gnome-wayland-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
subprocess.run(f'sudo chmod 755 /usr/share/xsessions/gnome-xorg-{args.container_name}.desktop', stdout=subprocess.DEVNULL, shell=True)
distrobox_run_container('sudo mkdir -p /usr/share/applications /usr/local/share/applications')
distrobox_run_container('''echo 'for dir in /usr/share/applications /usr/local/share/applications; do sudo find $dir -type f -exec sed -i -e '"'s/DBusActivatable=.*//g'"' {} '"';'"'; done' | sudo bash''')
def copy_desktop_files(pkg):
distrobox_run_container('sudo mkdir -p /usr/share/applications')
desktop_files = distrobox_get_output("find /usr/share/applications -type f -printf '%f\\n'").split('\r\n')
desktop_files[:] = [f.removesuffix('.desktop') for f in desktop_files if '.desktop' in f]
for f in desktop_files:
distrobox_run_container(f'CONTAINER_ID={args.container_name} distrobox-export --app {f}')
distrobox_run_container(f'CONTAINER_ID={args.container_name} distrobox-export --app {pkg} &>/dev/null')
def del_desktop_files(pkg):
distrobox_run_container(f'CONTAINER_ID={args.container_name} distrobox-export --app {pkg} --delete &>/dev/null')
def export_blend():
for pkg in args.pkg:
copy_desktop_files(pkg)
def unexport_blend():
for pkg in args.pkg:
del_desktop_files(pkg)
def install_blend():
if len(args.pkg) != 0:
@ -314,7 +333,7 @@ def remove_blend():
if not distrobox_check_container(args.container_name):
error(f"container {args.container_name} doesn't exist")
distrobox_remove_pkg(pkg)
subprocess.run(f'rm -f ~/.local/share/applications/{args.container_name}-*{pkg}*.desktop', shell=True)
del_desktop_files(pkg)
def search_blend():
if len(args.pkg) == 0:
@ -364,13 +383,12 @@ def update_blends():
error(f'distribution {args.distro} is not supported')
def enter_container():
if len(args.pkg) == 0:
error(f'you need to specify a container (run `blend list-container` to list all the containers)')
exit()
container = args.pkg[0]
info(f'entering container {container}')
args.container_name = container
subprocess.call(['distrobox-enter', '-n', args.container_name])
if not distrobox_check_container(args.container_name):
distrobox_create_container()
if os.environ.get('BLEND_COMMAND') == None or os.environ.get('BLEND_COMMAND') == '':
exit(subprocess.call(['distrobox-enter', '-n', args.container_name]))
else:
exit(subprocess.call(['distrobox-enter', '-n', args.container_name, '-e', os.environ['BLEND_COMMAND']]))
def create_container():
for container in args.pkg:
@ -381,7 +399,7 @@ def create_container():
def remove_container():
for container in args.pkg:
info(f'removing container {container}')
subprocess.run(['podman', 'stop', container], stdout=subprocess.DEVNULL)
subprocess.run(['podman', 'stop', container], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL)
subprocess.run(['distrobox-rm', container, '--force'], stdout=subprocess.DEVNULL)
def start_containers():
@ -423,6 +441,8 @@ You can use any of these distros by passing the option {colors.bold}--distro=[NA
You can even install a supported desktop environment in a blend container (run `blend install-de [DESKTOP ENVIRONMENT NAME]` to install your favorite desktop environment).
However, this feature is still somewhat experimental, and some apps might be buggy.
Here's a list of the supported desktop environments:
{colors.bold}1.{colors.reset} gnome
{colors.bold}2.{colors.reset} mate
@ -434,8 +454,10 @@ Here's a list of the supported desktop environments:
{colors.bold}help{colors.reset} Show this help message and exit.
{colors.bold}version{colors.reset} Show version information and exit.
{colors.bold}enter{colors.reset} Enter the container shell.
{colors.bold}export{colors.reset} Export the desktop entry for an installed blend.
{colors.bold}unexport{colors.reset} Unexport the desktop entry for a blend.
{colors.bold}install{colors.reset} Install packages inside a container.
{colors.bold}install-de{colors.reset} Install a desktop environment inside a container.
{colors.bold}install-de{colors.reset} Install a desktop environment inside a container. {colors.bold}(EXPERIMENTAL){colors.reset}
{colors.bold}remove{colors.reset} Remove packages inside a managed container.
{colors.bold}create-container{colors.reset} Create a container managed by blend.
{colors.bold}remove-container{colors.reset} Remove a container managed by blend.
@ -471,6 +493,8 @@ command_map = { 'install': install_blend,
'start-containers': start_containers,
'sync': sync_blends,
'update': update_blends,
'export': export_blend,
'unexport': unexport_blend,
'search': search_blend,
'show': show_blend,
'help': 'help',
@ -488,19 +512,16 @@ if len(sys.argv) == 1:
args = parser.parse_intermixed_args()
command = command_map[args.command]
distro_input = args.distro
args.distro = default_distro if args.distro == None else args.distro[0]
cn_input = args.container_name
args.container_name = args.distro if args.container_name == None else args.container_name[0]
if args.container_name in distro_map and not args.distro == args.container_name and distro_input == None:
args.distro = args.container_name
info(f'assuming you meant to use {args.distro} as the distro')
command = command_map[args.command]
if command == 'help':
parser.print_help()
elif command == 'version':
parser.parse_args(['--version'])
else:
command()
command()

9
blend-pkgmngr-path.sh Normal file
View file

@ -0,0 +1,9 @@
# shellcheck shell=sh
# Expand $PATH to include the directory where blend's package manager shortcuts
# are located.
blend_pkgmanager_bin_path="/blend/pkgmanagers"
if [ -n "${PATH##*${blend_pkgmanager_bin_path}}" ] && [ -n "${PATH##*${blend_pkgmanager_bin_path}:*}" ]; then
export PATH="${blend_pkgmanager_bin_path}:${PATH}"
fi

View file

@ -7,10 +7,11 @@ _completions() {
if [[ "$COMP_CWORD" == 1 ]]; then
SUGGESTIONS=('install' 'remove' 'update' 'show' 'search' 'enter' 'create-container' 'remove-container' \
'install-de' 'list-container' 'start-containers' 'sync' 'help' 'version' )
'install-de' 'list-containers' 'start-containers' 'sync' 'help' 'version' 'export' 'unexport',
'--container-name=' '--distro=' '--noconfirm' '--version')
fi
COMPREPLY=($(compgen -W "${SUGGESTIONS[*]}" "${COMP_WORDS[$COMP_CWORD]}"))
}
complete -F _completions -- blend
complete -F _completions -- blend

View file

@ -1,2 +1,4 @@
blend /usr/bin/
pkgmanagers /blend/
blend-pkgmngr-path.sh /etc/profile.d/
completions/blend /usr/share/bash-completion/completions/

12
debian/changelog vendored
View file

@ -1,3 +1,15 @@
blend (1.0.3) lunar; urgency=emergency
* Sync with blend 1.0.3, which updates the completions
-- Rudra Bali <rs2009@ubuntu.com> Thu, 19 Jan 2023 14:27:17 +0530
blend (1.0.2) lunar; urgency=emergency
* Sync with blend 1.0.2, which fixes many critical bugs
-- Rudra Bali <rs2009@ubuntu.com> Thu, 19 Jan 2023 00:00:01 +0530
blend (1.0.1) lunar; urgency=medium
* Sync with blend 1.0.1

10
pkgmanagers/apt Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
BLEND_COMMAND="sudo apt $@" blend enter ubuntu-22.10 --distro ubuntu-22.10
ret=$?
echo
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mapps installed this way will need to be exported manually using `blend export [pkg]`,\033[0m'
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mor you can run them by opening the Ubuntu-22.10 terminal (or running `blend enter -cn ubuntu-22.10`)\033[0m'
exit $ret

10
pkgmanagers/apt-get Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
BLEND_COMMAND="sudo apt-get $@" blend enter ubuntu-22.10 --distro ubuntu-22.10
ret=$?
echo
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mapps installed this way will need to be exported manually using `blend export [pkg]`,\033[0m'
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mor you can run them by opening the Ubuntu-22.10 terminal (or running `blend enter -cn ubuntu-22.10`)\033[0m'
exit $ret

10
pkgmanagers/dnf Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
BLEND_COMMAND="sudo dnf $@" blend enter fedora-rawhide --distro fedora-rawhide
ret=$?
echo
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mapps installed this way will need to be exported manually using `blend export [pkg]`,\033[0m'
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mor you can run them by opening the Fedora-rawhide terminal (or running `blend enter -cn fedora-rawhide`)\033[0m'
exit $ret

10
pkgmanagers/pacman Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
BLEND_COMMAND="sudo pacman $@" blend enter arch
ret=$?
echo
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mapps installed this way will need to be exported manually using `blend export [pkg]`,\033[0m'
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mor you can run them by opening the Arch terminal (or running `blend enter -cn arch`)\033[0m'
exit $ret

10
pkgmanagers/yay Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
BLEND_COMMAND="yay $@" blend enter arch
ret=$?
echo
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mapps installed this way will need to be exported manually using `blend export [pkg]`,\033[0m'
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mor you can run them by opening the Arch terminal (or running `blend enter -cn arch`)\033[0m'
exit $ret

10
pkgmanagers/yum Executable file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env bash
BLEND_COMMAND="sudo yum $@" blend enter fedora-rawhide --distro fedora-rawhide
ret=$?
echo
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mapps installed this way will need to be exported manually using `blend export [pkg]`,\033[0m'
echo -e '\033[01m\033[36m>> i: \033[0m\033[01mor you can run them by opening the Fedora-rawhide terminal (or running `blend enter -cn fedora-rawhide`)\033[0m'
exit $ret