* feat: `soar` module * fix(soar): Inverted `unlock-repos` logic * chore(soar): Add `soar` to modules.json * fix(soar): Logic for detecting if `unlock-repos` is disabled * fix(docs): Wrong `/usr/` systemd path reference * chore(soar): Add log for `unlock_repos` * chore(soar): Add `finished=false` at the beggining of `soar` shell profile * fix(soar): `/root` being `$HOME` in config * fix(soar): Wrong `PATH` I forgot to add `bin` directory * docs(soar): Clarify that `PATH` needs to be exported only outside of standard config dir * chore(soar): Unlock extra repos if `unlock-repos` is enabled * docs(soar): Mention of external repos * chore(soar): Simplify getting `XDG` directories * chore(soar): Add removing config in uninstallation script * chore(soar): Remove whole config directory instead of file in uninstallation script * fix(soar): Missing quote in uninstallation script * chore(soar): Make uninstallation script POSIX * fix(soar): Bad syntax for `soar-upgrade-packages` service `exec` It's `ExecStart`, not `Exec`. * fix(soar): Set `auto-upgrade` timer as `--user` instead of `--system` * chore(soar): Shorten the boot delay & randomize it for `auto-upgrades` * chore(soar): Add `network-online.target` in `Wants` to systemd service for `auto-upgrades` * chore(soar): Remove `upgrade-wait-after-boot`, as good defaults are set with no need for changing * chore(soar): Add option for unlocking the `PATH` in all conditions * chore(soar): Add `unlock-path` option to typespec * docs(soar): Add `unlock-path` to `module.yml` example * chore(soar): Remove condition for checking the `soar.sh` file If another `soar` module overwrites the previous one, it should be able to overwrite `soar.sh` shell profile too with custom option if set. * chore(soar): Remove `unlock-path`, as it's too dangerous * chore(soar): Don't copy update timer & service if `auto-upgrade` is false * chore(soar): Style fix * chore(soar): Don't execute `upgrade` when soar is already running * chore(soar): Use environment variable for `SOAR_CONFIG` to simplify things * docs(sour): Fix typo * chore(soar): Use native `soar` command for setting `bincache` repo only * fix(soar): Make `soar` condition check for auto-upgrades more reliable * chore(soar): Some more improvements to auto-update condition check False positive can happen if some text editor edits some file like `soar-something.txt` or similar. This assures more that only executed binary is detected. * chore(soar): Remove duplicate code for setting config * docs(soar): Add full example of options in `module.yml` * chore(soar): Rename `unlock-repos` to `additional-repos` & add docs about repo info * chore(soar): Enable `pkforge-cargo` & `pkgforge-go` repos * docs: rewordings, run through languagetool * chore(soar): Add condition in shell profile to check if `soar` PATH already exists * chore(soar): Disable redundant shellcheck SC2076 in shell profile * docs: final reword --------- Co-authored-by: xyny <git@xyny.anonaddy.me> Co-authored-by: xyny <60004820+xynydev@users.noreply.github.com>
61 lines
2.9 KiB
Bash
61 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
# Install 'soar'
|
|
echo "Downloading & installing 'soar' package manager"
|
|
REPO="pkgforge/soar"
|
|
LATEST_VER="$(basename $(curl -Ls -o /dev/null -w %{url_effective} https://github.com/${REPO}/releases/latest))"
|
|
# Assuming that ARM64 custom images will be built from ARM64 runners for this working detection
|
|
ARCH="$(uname -m)"
|
|
curl -fLs --create-dirs "https://github.com/${REPO}/releases/download/${LATEST_VER}/soar-${ARCH}-linux" -o "/usr/bin/soar"
|
|
chmod +x "/usr/bin/soar"
|
|
|
|
# Configuration values for package auto-upgrades (using upgrade term here from brew)
|
|
AUTO_UPGRADE=$(echo "${1}" | jq -r 'try .["auto-upgrade"]')
|
|
if [[ -z "${AUTO_UPGRADE}" || "${AUTO_UPGRADE}" == "null" ]]; then
|
|
AUTO_UPGRADE=true
|
|
fi
|
|
|
|
UPGRADE_INTERVAL=$(echo "${1}" | jq -r 'try .["upgrade-interval"]')
|
|
if [[ -z "${UPGRADE_INTERVAL}" || "${UPGRADE_INTERVAL}" == "null" ]]; then
|
|
UPGRADE_INTERVAL="8h"
|
|
fi
|
|
|
|
# Configuration for enabling additional repos (outside of 'bincache')
|
|
ADDITIONAL_REPOS=$(echo "${1}" | jq -r 'try .["additional-repos"]')
|
|
mkdir -p "/usr/share/bluebuild/soar"
|
|
if [[ "${ADDITIONAL_REPOS}" == "true" ]]; then
|
|
echo "Enabling all additional 'soar' repos in config, including external ones"
|
|
soar defconfig --external -c "/usr/share/bluebuild/soar/config.toml"
|
|
else
|
|
echo "Using the default 'bincache', 'pkgforge-cargo' & 'pkgforge-go' repositories in config"
|
|
soar -c /usr/share/bluebuild/soar/config.toml defconfig -r bincache -r pkgforge-cargo -r pkgforge-go
|
|
fi
|
|
# Fix /root being ${HOME}
|
|
sed -i 's|/root|~|g' "/usr/share/bluebuild/soar/config.toml"
|
|
# Add soar config to environment
|
|
echo "SOAR_CONFIG=/usr/share/bluebuild/soar/config.toml" >> /etc/environment
|
|
|
|
if [[ "${AUTO_UPGRADE}" == true ]]; then
|
|
echo "Configuring auto-upgrades of 'soar' packages"
|
|
echo "Copying soar-upgrade-packages service"
|
|
cp "${MODULE_DIRECTORY}/soar/soar-upgrade-packages.service" "/usr/lib/systemd/user/soar-upgrade-packages.service"
|
|
if [[ -n "${UPGRADE_INTERVAL}" ]] && [[ "${UPGRADE_INTERVAL}" != "8h" ]]; then
|
|
echo "Applying custom 'upgrade-interval' value in '${UPGRADE_INTERVAL}' time interval for soar-upgrade-packages timer"
|
|
sed -i "s/^OnUnitInactiveSec=.*/OnUnitInactiveSec=${UPGRADE_INTERVAL}/" "${MODULE_DIRECTORY}/soar/soar-upgrade-packages.timer"
|
|
fi
|
|
echo "Copying soar-upgrade-packages timer"
|
|
cp "${MODULE_DIRECTORY}/soar/soar-upgrade-packages.timer" "/usr/lib/systemd/user/soar-upgrade-packages.timer"
|
|
echo "Enabling auto-upgrades for 'soar' packages"
|
|
systemctl --global enable soar-upgrade-packages.timer
|
|
else
|
|
echo "Auto-upgrades for 'soar' packages are disabled"
|
|
fi
|
|
|
|
# Add 'soar' packages to path only when it's interactive terminal session & non-root user, similar to brew
|
|
if [[ ! -d "/etc/profile.d/" ]]; then
|
|
mkdir -p "/etc/profile.d/"
|
|
fi
|
|
echo "Applying shell profile for exporting 'soar' packages directory to PATH"
|
|
cp "${MODULE_DIRECTORY}/soar/soar-profile.sh" "/etc/profile.d/soar.sh"
|