Compare commits

...

2 commits

5 changed files with 76 additions and 17 deletions

66
check
View file

@ -1,12 +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)"
# application logic
## global state
base_files=
bkp_files=
user_packages=
system_packages=
# behavior
## utility functions
log() {
local level="$1" # unimplemented
@ -17,20 +27,50 @@ log() {
fi
}
## configuration processing functions
traverse() {
scan_directory() {
local target="$1"
local files=
local escaped_config_root="$(echo $TORI_ROOT | sed 's/\//\\\//g')"
log debug "traversing $target"
if [ -d "$target" ]; then
log debug "found dir: $target"
files="$(find "$target" -type f)\n$files"
scan="$(find "$target" -type f)"
for line in $scan; do
line="$(echo $line | sed "s/$escaped_config_root\///")"
files="$line\n$files"
done
fi
log debug "collected files:\n$files"
echo "$files"
}
cd "$TORI_ROOT"
for item in $TORI_ROOT/*; do
traverse "$item"
done
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.

View file

@ -26,3 +26,4 @@ Both of these directories mimic the file structure found from the root of the fi
└── .shrc
```
`tori` will look only for regular files inside your configuration directory and currently will ignore symbolic link and any other filetype when scanning it.

7
docs/user-files.md Normal file
View file

@ -0,0 +1,7 @@
`tori` can track if a given file in the configuration directory is present and matches the content of the corresponding file on the system level.
However, if a file changed on the system level is not in the configuration directory, `tori` can only alert you to that if the operating system provides some way to compare the present state of the system to the original one prior to user intervention.
One example would be FreeBSD's intrusion detection system, which provides a way to know which files have been changed. Another way would be by relying on a file system that provides the ability to compare differences between snapshots, such as ZFS. A third way would be if the operating system's package manager provides a command line interface to read the contents of packages and has packages that correspond to the core system, such as Void Linux's package manager, `xbps`.
The resource-intensiveness of each of these methods will vary greatly and therefore checking the whole system for changes can be time-consuming or provide overwhelming output. For this reason, `tori` by default operates in a more minimal fashion where you take responsibility for adding the files you would like to track to your configuration and only get warnings of untracked files when explicitly asked.

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.