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,
|
a newline-separated list of packages to install,
|
||||||
enabling batching and the consolidation of interdependent packages into one unit.
|
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 (central) package repository containing package sources
|
||||||
- a package manager that can inspect or remove packages
|
- a package manager that can inspect or remove packages
|
||||||
|
|
||||||
## Planned
|
### Planned
|
||||||
- detection mechanism for handlers and features
|
- detection mechanism for handlers and features
|
||||||
(e.g. whether they support batching)
|
(e.g. whether they support batching)
|
||||||
- helper/hook for adding packages to groups upon install
|
- helper/hook for adding packages to groups upon install
|
||||||
(at least for `pacman`)
|
(at least for `pacman`)
|
||||||
|
|
||||||
## TODOs
|
### TODOs
|
||||||
- Debug corner cases
|
- Debug corner cases
|
||||||
- Implement Collections
|
|
||||||
- Handler preparation - update repos and cache last update time in /tmp
|
- Handler preparation - update repos and cache last update time in /tmp
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
arch
|
arch
|
||||||
aur
|
aur
|
||||||
snap
|
|
||||||
flatpak
|
|
||||||
script
|
script
|
||||||
make
|
|
||||||
zsh
|
zsh
|
||||||
linux
|
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"; }
|
getcontent() { test -x "$1" && "$1" || cat "$1"; }
|
||||||
|
|
||||||
# Get available package entries for given package
|
# Get available package entries for given package
|
||||||
get() {
|
getentries() {
|
||||||
cat "$home/handlers.available" | while read handler
|
cat "$home/handlers.available" | while read handler
|
||||||
do find "$home/packages/$1" -name "$handler*" 2>/dev/null
|
do find "$home/packages/$1" -name "$handler*" 2>/dev/null
|
||||||
done
|
done
|
||||||
|
@ -19,23 +19,31 @@ get() {
|
||||||
|
|
||||||
# Install a package by name
|
# Install a package by name
|
||||||
installpkg() {
|
installpkg() {
|
||||||
pkgs=$(get "$1")
|
test "$1" = "--quiet" && local quiet=true && shift
|
||||||
if test -z "$pkgs"
|
local pkgs=$(getentries "$1")
|
||||||
then
|
if test -z "$pkgs"; then
|
||||||
printf "No handler available for package '%s'\n" "$1" >&2
|
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
|
return 2
|
||||||
fi
|
fi
|
||||||
for pkg in $pkgs; do
|
for pkg in $pkgs
|
||||||
highlight "$pkg"
|
do highlight "$pkg"
|
||||||
name="$(basename $pkg)"
|
local name="$(basename $pkg)"
|
||||||
base="${name%_*}"
|
local base="${name%_*}"
|
||||||
|
|
||||||
ext="${name#$base}"
|
local ext="${name#$base}"
|
||||||
handler="$home/handlers/$base"
|
local handler="$home/handlers/$base"
|
||||||
if test -d "$handler"
|
if test -d "$handler"
|
||||||
then
|
then
|
||||||
args="$(getcontent "$pkg")"
|
local args="$(getcontent "$pkg" | grep . || echo "$1")"
|
||||||
install="$(find "$handler" -name "install$ext" | head -1)" &&
|
local install="$(find "$handler" -name "install$ext" | head -1)" &&
|
||||||
destress " $install $args" &&
|
destress " $install $args" &&
|
||||||
$install $args
|
$install $args
|
||||||
else
|
else
|
||||||
|
@ -72,6 +80,7 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
exitcode=0
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
groupfile="$home/groups/$1"
|
groupfile="$home/groups/$1"
|
||||||
if test -f "$groupfile"
|
if test -f "$groupfile"
|
||||||
|
@ -80,6 +89,8 @@ while test $# -gt 0; do
|
||||||
"$home/handlers/$(head -1 handlers.available)/install" "$pkg"
|
"$home/handlers/$(head -1 handlers.available)/install" "$pkg"
|
||||||
done
|
done
|
||||||
else installpkg "$1"
|
else installpkg "$1"
|
||||||
|
exitcode=$(expr $exitcode \| $?)
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
done
|
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