feat: resolve handler packages
This commit is contained in:
parent
471c321caa
commit
24ddc01d95
8 changed files with 37 additions and 20 deletions
13
README.md
13
README.md
|
@ -73,19 +73,24 @@ a typical handler will accept
|
|||
a newline-separated list of packages to install,
|
||||
enabling batching and the consolidation of interdependent packages into one unit.
|
||||
|
||||
## What instalee is not
|
||||
When installing a package and there is no handler available,
|
||||
but a package with the name of a handler of the package has an installable candidate,
|
||||
the handler will be installed, made available and used.
|
||||
|
||||
## Features
|
||||
|
||||
### What instalee is not
|
||||
- a (central) package repository containing package sources
|
||||
- a package manager that can inspect or remove packages
|
||||
|
||||
## Planned
|
||||
### Planned
|
||||
- detection mechanism for handlers and features
|
||||
(e.g. whether they support batching)
|
||||
- helper/hook for adding packages to groups upon install
|
||||
(at least for `pacman`)
|
||||
|
||||
## TODOs
|
||||
### TODOs
|
||||
- Debug corner cases
|
||||
- Implement Collections
|
||||
- Handler preparation - update repos and cache last update time in /tmp
|
||||
|
||||
### Windows
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
arch
|
||||
aur
|
||||
snap
|
||||
flatpak
|
||||
script
|
||||
make
|
||||
zsh
|
||||
linux
|
||||
cargo
|
||||
|
|
2
handlers/cargo/install
Executable file
2
handlers/cargo/install
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/sh
|
||||
cargo install "$@"
|
37
instalee
37
instalee
|
@ -11,7 +11,7 @@ destress() { echo "[2m$1[0m"; }
|
|||
getcontent() { test -x "$1" && "$1" || cat "$1"; }
|
||||
|
||||
# Get available package entries for given package
|
||||
get() {
|
||||
getentries() {
|
||||
cat "$home/handlers.available" | while read handler
|
||||
do find "$home/packages/$1" -name "$handler*" 2>/dev/null
|
||||
done
|
||||
|
@ -19,23 +19,31 @@ get() {
|
|||
|
||||
# Install a package by name
|
||||
installpkg() {
|
||||
pkgs=$(get "$1")
|
||||
if test -z "$pkgs"
|
||||
then
|
||||
printf "No handler available for package '%s'\n" "$1" >&2
|
||||
test "$1" = "--quiet" && local quiet=true && shift
|
||||
local pkgs=$(getentries "$1")
|
||||
if test -z "$pkgs"; then
|
||||
local handlers=$(find "$home/packages/$1" -type f -printf "%f\n" 2>/dev/null)
|
||||
for handler in $handlers
|
||||
do installpkg --quiet "$handler" &&
|
||||
echo "$handler" >> "$home/handlers.available" &&
|
||||
installpkg "$1" &&
|
||||
return $?
|
||||
done
|
||||
test "$quiet" ||
|
||||
echo "No handler available for package '$1'" >&2
|
||||
return 2
|
||||
fi
|
||||
for pkg in $pkgs; do
|
||||
highlight "$pkg"
|
||||
name="$(basename $pkg)"
|
||||
base="${name%_*}"
|
||||
for pkg in $pkgs
|
||||
do highlight "$pkg"
|
||||
local name="$(basename $pkg)"
|
||||
local base="${name%_*}"
|
||||
|
||||
ext="${name#$base}"
|
||||
handler="$home/handlers/$base"
|
||||
local ext="${name#$base}"
|
||||
local handler="$home/handlers/$base"
|
||||
if test -d "$handler"
|
||||
then
|
||||
args="$(getcontent "$pkg")"
|
||||
install="$(find "$handler" -name "install$ext" | head -1)" &&
|
||||
local args="$(getcontent "$pkg" | grep . || echo "$1")"
|
||||
local install="$(find "$handler" -name "install$ext" | head -1)" &&
|
||||
destress " $install $args" &&
|
||||
$install $args
|
||||
else
|
||||
|
@ -72,6 +80,7 @@ case "$1" in
|
|||
;;
|
||||
esac
|
||||
|
||||
exitcode=0
|
||||
while test $# -gt 0; do
|
||||
groupfile="$home/groups/$1"
|
||||
if test -f "$groupfile"
|
||||
|
@ -80,6 +89,8 @@ while test $# -gt 0; do
|
|||
"$home/handlers/$(head -1 handlers.available)/install" "$pkg"
|
||||
done
|
||||
else installpkg "$1"
|
||||
exitcode=$(expr $exitcode \| $?)
|
||||
fi
|
||||
shift
|
||||
done
|
||||
exit $exitcode
|
||||
|
|
0
packages/cargo/apt
Normal file
0
packages/cargo/apt
Normal file
1
packages/cargo/arch
Normal file
1
packages/cargo/arch
Normal file
|
@ -0,0 +1 @@
|
|||
rust
|
0
packages/diffr/aur
Normal file
0
packages/diffr/aur
Normal file
0
packages/diffr/cargo
Normal file
0
packages/diffr/cargo
Normal file
Loading…
Add table
Reference in a new issue