Implement basic package list comparison

This commit is contained in:
Juno Takano 2024-06-26 16:43:54 -03:00
parent 0079047ab6
commit ef963da8e5
3 changed files with 52 additions and 8 deletions

41
check
View file

@ -1,14 +1,22 @@
#! /usr/bin/env sh
# user-configured settings
# state
## user-configured settings
TORI_ROOT="$HOME/.config/tori"
# global state
files=
## global constants
OS="$(uname -s)"
## global state
base_files=
bkp_files=
user_packages=
system_packages=
# application logic
# behavior
## utility functions
log() {
local level="$1" # unimplemented
@ -19,6 +27,7 @@ log() {
fi
}
## configuration processing functions
scan_directory() {
local target="$1"
@ -36,8 +45,32 @@ scan_directory() {
echo "$files"
}
scan_packages() {
local package_manager
local args__get_manually_installed
local system_packages_eval
if [ $OS = "FreeBSD" ]; then
package_manager="pkg"
args__get_manually_installed='query -e "%a = 0" "%n"'
fi
system_packages=$(eval "$package_manager $args__get_manually_installed")
user_packages="$(cat $TORI_ROOT/packages | sort | uniq)"
if [ "$system_packages" = "$user_packages" ]; then
log debug "packages match"
else
log debug "packages mismatch"
log debug "system: $system_packages"
log debug "user: $user_packages"
fi
}
base_files="$(scan_directory "$TORI_ROOT/base")"
bkp_files="$(scan_directory "$TORI_ROOT/bkp")"
log debug "collected base files:\n$base_files"
log debug "collected bkp files:\n$bkp_files"
scan_packages

View file

@ -1,16 +1,19 @@
tori is designed to be portable so that its features allow transfering your configuration between different versions of an operating system or even between different operating systems depending on the presently supported ones.
`tori`'s role is to manage your configuration files and installed packages, allowing you to transfer this configuration between different versions of an operating system or even between different Unix and Unix-like operating systems, provided they are presently supported.
To aid this portability and ability to run in different systems, it is also designed to have minimal dependencies since it is meant to run on brand new systems where very few packages have been installed.
Because the application is meant to manage the installation of packages for you, it would defeat its purpose for it to require any packages to already be installed in order to function. It must be a portable application with minimal dependencies, so it can perform its functions on brand new systems where very few packages have been installed and little to no configuration has been done.
Despite this, some assumptions are still made about what your system supports:
To achieve this portability and independence, it is meant to run on a POSIX-compatible shell where POSIX utilities are available. If your system does not provide this, it is very unlikely `tori` will function.
Below is a list of assumptions made about what your system supports:
- shell
- `local` keyword
- executables
- `find`
- `sed`
- `date` with nanoseconds as `%N`
- `env` at `/usr/bin/env`
- While this may be an issue from a portability standpoint, hardcoding the path where `sh` is also poses another portability issue. A more robust way to find it would be desirable.
tori is implemented as a set of shell scripts. These are currently only tested on the `sh` Almquist shell as shipped by FreeBSD and the `dash` Almquist shell as shipped by Void Linux.
`tori` is currently only tested on the `sh` Almquist shell as shipped by FreeBSD and the `dash` Almquist shell as shipped by Void Linux.

8
docs/user-packages.md Normal file
View file

@ -0,0 +1,8 @@
In order to take advantage of all the features offered by `tori` for package management, the operating system's package manager must provide a way to:
- install and uninstall packages from a command-line interface
- query manually installed packages
The `packages` file is located at the root of the configuration directory and contains a list of package names, one per line. Blank lines and lines beginning with `#` are ignored.
When processing the package list, `tori` will compare the list of installed packages to the list in the configuration and ask the user for what action to take in order to conciliate them, unless a default action has been specified.