<commit_before>#!/bin/sh

set -e

# shellcheck source=_lib.sh
. "${XDG_DATA_HOME:-~/.local/share}/replicator/_lib.sh"

case $(uname) in
  Darwin)
    section "System (Homebrew)"

    important "Upgrading packages with Homebrew..."
    brew upgrade
    important "Installing packages with Homebrew Bundle..."
    brew bundle
    ;;
  FreeBSD)
    [ "$(id -u)" -eq 0 ] || exec su root -c "sh $0"

    section "System (ports)"

    important "Upgrading ports with pkg..."
    pkg upgrade -y
    important "Installing ports with pkg..."
    sed 's/[[:space:]]*#.*//;/^[[:space:]]*$/d' \
      "$XDG_CONFIG_HOME/replicator/freebsd-ports.txt" | \
    xargs pkg install -y

    if ! grep -Eq '^CONSERVATIVE_UPGRADE' /usr/local/etc/pkg.conf; then
      important "Configuring pkg to upgrade aggressively..."
      printf '\n%s' 'CONSERVATIVE_UPGRADE: false;' >>/usr/local/etc/pkg.conf
    fi

    if ! grep -Eq '^PKG_ENABLE_PLUGINS' /usr/local/etc/pkg.conf; then
      important "Enabling pkg-provides..."
      sed -e '/PKG_PLUGINS_DIR/s/^#//' -e '/PKG_ENABLE_PLUGINS/s/^#//' \
        -e 's/#PLUGINS \[/PLUGINS [ provides ]/' -i '' /usr/local/etc/pkg.conf
    fi
    ;;
  Linux)
    section "System (pacman)"

    # bootstrap yay
    if ! command -v yay >/dev/null; then
      (
        important "Bootstrapping yay..."

        YAY="${TMPDIR:-/tmp}/yay"
        trap 'rm -rf $YAY' EXIT

        git clone https://aur.archlinux.org/yay.git "$YAY"
        cd "$YAY"
        makepkg -si --noconfirm
      )
    fi

    # pass through language managers
    export GOENV_VERSION=system NODENV_VERSION=system PYENV_VERSION=system RBENV_VERSION=system

    important "Upgrading packages with Yay..."
    yay -Syu
    important "Installing packages with Yay..."
    sed 's/[[:space:]]*#.*//;/^[[:space:]]*$/d' \
      "$XDG_CONFIG_HOME/replicator/arch-packages.txt" | \
    yay -S --needed
    important "Updating pacman file database..."
    yay -Fy
    ;;
esac

# vi: ft=sh<commit_msg>replicator: add missing --noconfirm<commit_after>#!/bin/sh

set -e

# shellcheck source=_lib.sh
. "${XDG_DATA_HOME:-~/.local/share}/replicator/_lib.sh"

case $(uname) in
  Darwin)
    section "System (Homebrew)"

    important "Upgrading packages with Homebrew..."
    brew upgrade
    important "Installing packages with Homebrew Bundle..."
    brew bundle
    ;;
  FreeBSD)
    [ "$(id -u)" -eq 0 ] || exec su root -c "sh $0"

    section "System (ports)"

    important "Upgrading ports with pkg..."
    pkg upgrade -y
    important "Installing ports with pkg..."
    sed 's/[[:space:]]*#.*//;/^[[:space:]]*$/d' \
      "$XDG_CONFIG_HOME/replicator/freebsd-ports.txt" | \
    xargs pkg install -y

    if ! grep -Eq '^CONSERVATIVE_UPGRADE' /usr/local/etc/pkg.conf; then
      important "Configuring pkg to upgrade aggressively..."
      printf '\n%s' 'CONSERVATIVE_UPGRADE: false;' >>/usr/local/etc/pkg.conf
    fi

    if ! grep -Eq '^PKG_ENABLE_PLUGINS' /usr/local/etc/pkg.conf; then
      important "Enabling pkg-provides..."
      sed -e '/PKG_PLUGINS_DIR/s/^#//' -e '/PKG_ENABLE_PLUGINS/s/^#//' \
        -e 's/#PLUGINS \[/PLUGINS [ provides ]/' -i '' /usr/local/etc/pkg.conf
    fi
    ;;
  Linux)
    section "System (pacman)"

    # bootstrap yay
    if ! command -v yay >/dev/null; then
      (
        important "Bootstrapping yay..."

        YAY="${TMPDIR:-/tmp}/yay"
        trap 'rm -rf $YAY' EXIT

        git clone https://aur.archlinux.org/yay.git "$YAY"
        cd "$YAY"
        makepkg -si --noconfirm
      )
    fi

    # pass through language managers
    export GOENV_VERSION=system NODENV_VERSION=system PYENV_VERSION=system RBENV_VERSION=system

    important "Upgrading packages with Yay..."
    yay -Syu --noconfirm
    important "Installing packages with Yay..."
    sed 's/[[:space:]]*#.*//;/^[[:space:]]*$/d' \
      "$XDG_CONFIG_HOME/replicator/arch-packages.txt" | \
    yay -S --needed --noconfirm
    important "Updating pacman file database..."
    yay -Fy
    ;;
esac

# vi: ft=sh
{'fraction_non_alphanumeric': 0.16249374061091637, 'fraction_numerical': 0.00100150225338007, 'mean_word_length': 2.4028960817717206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7059064', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1423, 'n_words': 342}