feat: handle package groups
This commit is contained in:
parent
14c9d58ebd
commit
471c321caa
6 changed files with 56 additions and 37 deletions
18
README.md
18
README.md
|
@ -30,7 +30,7 @@ Keep the following in mind when configuring instalee:
|
||||||
for sensible syncing across many different machines
|
for sensible syncing across many different machines
|
||||||
a mechanism such as [yasm alternate files](https://yadm.io/docs/alternates)
|
a mechanism such as [yasm alternate files](https://yadm.io/docs/alternates)
|
||||||
can prove useful.
|
can prove useful.
|
||||||
- `collections` are usually personal, but system-agnostic
|
- `groups` are usually personal, but system-agnostic
|
||||||
- `handlers` and `packages` need to be attuned,
|
- `handlers` and `packages` need to be attuned,
|
||||||
as the package entry format needs to fit the handler definitions.
|
as the package entry format needs to fit the handler definitions.
|
||||||
These may be obtained from a trusted source
|
These may be obtained from a trusted source
|
||||||
|
@ -44,12 +44,14 @@ See the [man page](instalee.1) for more details.
|
||||||
|
|
||||||
`instalee <target>`
|
`instalee <target>`
|
||||||
|
|
||||||
A _target_ may either be a _package_ or a _collection_.
|
A _target_ may either be a _package_ or a _group_.
|
||||||
*Instalee* first checks for a `collections/<target>` file.
|
*Instalee* first checks for a `groups/<target>` file.
|
||||||
A _collection_ is a newline-separated list of packages to install,
|
A _group_ is a newline-separated list of packages to install,
|
||||||
which *instalee* then resolves individually.
|
which *instalee* then resolves individually.
|
||||||
|
One difference here is that it will try the first handler for the package
|
||||||
|
if it has no associated definition.
|
||||||
|
|
||||||
When there is no corresponding _collection_,
|
When there is no corresponding _group_,
|
||||||
*instalee* searches for the first available _handler_
|
*instalee* searches for the first available _handler_
|
||||||
with a corresponding entry at `packages/<target>/<handler>`,
|
with a corresponding entry at `packages/<target>/<handler>`,
|
||||||
piping it into the _handler_ to install the package.
|
piping it into the _handler_ to install the package.
|
||||||
|
@ -57,14 +59,12 @@ The package definition may be an empty file
|
||||||
(thus simply indicating the availability of a package for a _handler_),
|
(thus simply indicating the availability of a package for a _handler_),
|
||||||
in which case the name of the package is passed to the _handler_.
|
in which case the name of the package is passed to the _handler_.
|
||||||
|
|
||||||
Note that both _collections_ and package entries can be executable files,
|
Note that both _groups_ and package entries can be executable files,
|
||||||
in which case *instalee* will execute them and use their output instead,
|
in which case *instalee* will execute them and use their output instead,
|
||||||
so watch the file permissions!
|
so watch the file permissions!
|
||||||
If an available _handler_ has no definition in `handlers`,
|
If an available _handler_ has no definition in `handlers`,
|
||||||
the package file _has to be_ executable,
|
the package file _has to be_ executable,
|
||||||
as *instalee* will then simply execute it.
|
as *instalee* will then simply execute it.
|
||||||
This _handler_ is usually named `custom`,
|
|
||||||
though that is no requirement.
|
|
||||||
|
|
||||||
### Handlers
|
### Handlers
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ enabling batching and the consolidation of interdependent packages into one unit
|
||||||
## 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 collections upon install
|
- helper/hook for adding packages to groups upon install
|
||||||
(at least for `pacman`)
|
(at least for `pacman`)
|
||||||
|
|
||||||
## TODOs
|
## TODOs
|
||||||
|
|
5
groups/music
Normal file
5
groups/music
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
mpd
|
||||||
|
mpc
|
||||||
|
ncmpc
|
||||||
|
mpdris
|
||||||
|
vlc
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
yay -S --needed --noconfirm "$@"
|
yay -S --batchinstall --needed --noconfirm "$@"
|
||||||
|
|
65
instalee
65
instalee
|
@ -17,17 +17,46 @@ get() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Install a package by name
|
||||||
|
installpkg() {
|
||||||
|
pkgs=$(get "$1")
|
||||||
|
if test -z "$pkgs"
|
||||||
|
then
|
||||||
|
printf "No handler available for package '%s'\n" "$1" >&2
|
||||||
|
return 2
|
||||||
|
fi
|
||||||
|
for pkg in $pkgs; do
|
||||||
|
highlight "$pkg"
|
||||||
|
name="$(basename $pkg)"
|
||||||
|
base="${name%_*}"
|
||||||
|
|
||||||
|
ext="${name#$base}"
|
||||||
|
handler="$home/handlers/$base"
|
||||||
|
if test -d "$handler"
|
||||||
|
then
|
||||||
|
args="$(getcontent "$pkg")"
|
||||||
|
install="$(find "$handler" -name "install$ext" | head -1)" &&
|
||||||
|
destress " $install $args" &&
|
||||||
|
$install $args
|
||||||
|
else
|
||||||
|
destress " running unhandled $pkg"
|
||||||
|
$pkg
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
## EXECUTION
|
## EXECUTION
|
||||||
chmod +rx "$home/handlers" -R
|
chmod +rx "$home/handlers" -R
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
(-v|--version|"")
|
(-V|--version|"")
|
||||||
printf "$0 r%s.%s\n" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
printf "$0 r%s.%s\n" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||||
echo "Try '$0 --help' or 'man $name' for usage info"
|
echo "Try '$0 --help' or 'man $name' for usage info"
|
||||||
# TODO license https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion
|
# TODO license https://www.gnu.org/prep/standards/html_node/_002d_002dversion.html#g_t_002d_002dversion
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
(-?|-h|--help)
|
(-h|--help)
|
||||||
man $name 2>/dev/null || man "$home/$name.1"
|
man $name 2>/dev/null || man "$home/$name.1"
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
|
@ -44,31 +73,13 @@ case "$1" in
|
||||||
esac
|
esac
|
||||||
|
|
||||||
while test $# -gt 0; do
|
while test $# -gt 0; do
|
||||||
pkgs=$(get "$1")
|
groupfile="$home/groups/$1"
|
||||||
if test -z "$pkgs"
|
if test -f "$groupfile"
|
||||||
then
|
then for pkg in $(getcontent "$groupfile")
|
||||||
printf "No handler available for package '%s'\n" "$1" >&2
|
do installpkg "$pkg" ||
|
||||||
exit 2
|
"$home/handlers/$(head -1 handlers.available)/install" "$pkg"
|
||||||
|
done
|
||||||
|
else installpkg "$1"
|
||||||
fi
|
fi
|
||||||
for pkg in $pkgs; do
|
|
||||||
highlight "$pkg"
|
|
||||||
name="$(basename $pkg)"
|
|
||||||
base="${name%_*}"
|
|
||||||
test "$base" = "custom" && $pkg && exit 0
|
|
||||||
|
|
||||||
ext="${name#$base}"
|
|
||||||
mgr="$home/handlers/$base"
|
|
||||||
if test -d "$mgr"
|
|
||||||
then
|
|
||||||
args="$(getcontent "$pkg")"
|
|
||||||
install="$(find "$mgr" -name "install$ext" | head -1)" &&
|
|
||||||
destress " $install $args" &&
|
|
||||||
$install $args
|
|
||||||
else
|
|
||||||
destress " running unhandled $pkg"
|
|
||||||
$pkg
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
done
|
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
1
packages/mpdris/aur
Normal file
1
packages/mpdris/aur
Normal file
|
@ -0,0 +1 @@
|
||||||
|
mpdris2-git
|
2
packages/vlc/arch
Normal file
2
packages/vlc/arch
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
vlc
|
||||||
|
phonon-qt5-vlc
|
Loading…
Add table
Reference in a new issue