diff --git a/.gitignore b/.gitignore index e7fafc5..41a53bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /debian/*.debhelper /debian/*.substvars /debian/debhelper-build-stamp -/debian/blend \ No newline at end of file +/debian/blend +/debian/files diff --git a/README.md b/README.md index a768d01..359c6f4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/blend b/blend index 8ddb861..9b9cbe9 100755 --- a/blend +++ b/blend @@ -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() \ No newline at end of file + command() diff --git a/blend-pkgmngr-path.sh b/blend-pkgmngr-path.sh new file mode 100644 index 0000000..72901b4 --- /dev/null +++ b/blend-pkgmngr-path.sh @@ -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 + diff --git a/completions/blend b/completions/blend index 70bbdee..4e7ed05 100755 --- a/completions/blend +++ b/completions/blend @@ -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 \ No newline at end of file +complete -F _completions -- blend diff --git a/debian/blend.install b/debian/blend.install index 3888acc..4182e87 100644 --- a/debian/blend.install +++ b/debian/blend.install @@ -1,2 +1,4 @@ blend /usr/bin/ +pkgmanagers /blend/ +blend-pkgmngr-path.sh /etc/profile.d/ completions/blend /usr/share/bash-completion/completions/ \ No newline at end of file diff --git a/debian/changelog b/debian/changelog index e89874f..e418a57 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +blend (1.0.3) lunar; urgency=emergency + + * Sync with blend 1.0.3, which updates the completions + + -- Rudra Bali 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 Thu, 19 Jan 2023 00:00:01 +0530 + blend (1.0.1) lunar; urgency=medium * Sync with blend 1.0.1 diff --git a/pkgmanagers/apt b/pkgmanagers/apt new file mode 100755 index 0000000..b0f337f --- /dev/null +++ b/pkgmanagers/apt @@ -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 \ No newline at end of file diff --git a/pkgmanagers/apt-get b/pkgmanagers/apt-get new file mode 100755 index 0000000..c2f01ec --- /dev/null +++ b/pkgmanagers/apt-get @@ -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 \ No newline at end of file diff --git a/pkgmanagers/dnf b/pkgmanagers/dnf new file mode 100755 index 0000000..6767b5d --- /dev/null +++ b/pkgmanagers/dnf @@ -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 \ No newline at end of file diff --git a/pkgmanagers/pacman b/pkgmanagers/pacman new file mode 100755 index 0000000..fe89f03 --- /dev/null +++ b/pkgmanagers/pacman @@ -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 \ No newline at end of file diff --git a/pkgmanagers/yay b/pkgmanagers/yay new file mode 100755 index 0000000..0b4e061 --- /dev/null +++ b/pkgmanagers/yay @@ -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 \ No newline at end of file diff --git a/pkgmanagers/yum b/pkgmanagers/yum new file mode 100755 index 0000000..8a4fd06 --- /dev/null +++ b/pkgmanagers/yum @@ -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 \ No newline at end of file