aggiornamenti installazione e README

master
Guido Longoni 2026-01-22 14:04:47 +01:00
parent 1a4423ed0d
commit 6bd9f6427b
7 changed files with 140 additions and 12 deletions

41
AGENTS.md 100644
View File

@ -0,0 +1,41 @@
# Repository Guidelines
## Project Structure & Module Organization
- `grezzo.sh` is the core library with shared helpers (e.g., `feat_needed`, `feat_missing`).
- `featlib/` contains feature installers, one tool per file (`pip.sh`, `docker.sh`, `npm.sh`, `rustup.sh`, `curl.sh`).
- `featlib/poetry/` holds Poetry-specific feature scripts (e.g., `django.sh`).
- Entry-point scripts live at the repo root (e.g., `python.sh`, `node_pip_docker_rust.sh`).
## Build, Test, and Development Commands
There is no build system; scripts are executed directly from the repo root.
- `bash python.sh` installs Python tooling via `pip`/`pyenv`.
- `bash node_pip_docker_rust.sh` installs Node, Pip/Poetry, Docker, and Rust tooling.
- `bash grezzo.sh` can be sourced by other scripts; it is not meant to be run standalone.
These scripts may call `sudo` and can modify shell configuration files (e.g., `$HOME/.bashrc.before`).
## Coding Style & Naming Conventions
- Language: Bash; keep the `#! /bin/bash --` shebang.
- Indentation: prefer 4 spaces (match existing files).
- Functions follow the pattern `feat_add_*`, `feat_needed`, and `*_feat_needed`.
- Use `this_script_path` to resolve relative includes and avoid `cd` assumptions.
## Testing Guidelines
No automated tests are present. Validate changes by running the relevant script end-to-end on a test machine and confirming installed tools are available (e.g., `docker --version`, `python --version`).
## Commit & Pull Request Guidelines
- Commit messages are short, descriptive, and currently in Italian (see `git log` examples like “aggiornamenti …”, “piccola modifica”).
- Do not add signatures or personal tags in commit messages.
- PRs should describe the target platforms (apt/pacman/apk/yum/zypper) and any system changes made (packages installed, files edited, required restarts).
- Include repro commands and any manual verification performed.
## Security & Configuration Tips
- Scripts can install packages system-wide and add APT repositories/keys; review changes carefully.
- Prefer testing in a VM or container and document any OS-specific behavior.

57
README.md 100755 → 100644
View File

@ -1,3 +1,58 @@
# grezzo
Vedremo man mano che cos'è... Per ora è un tool di supporto all'installazione di librerie e al deployment di software
Tool Bash per installare e garantire la presenza di tooling di sviluppo in modo dichiarativo:
tu dici cosa vuoi, grezzo si occupa di farlo comparire, includendo dipendenze e policy opinionated.
## Idee chiave
- Dichiarativo “al top”, imperativo “sotto al cofano”: si usano `feat_needed` e gli installer `feat_add_*`.
- Include-once: ogni script in `featlib/` si carica una sola volta.
- Policy opinionated: priorita' su Mint, Debian, Ubuntu, Arch; poi altri Linux.
## Struttura
- `grezzo.sh`: core (helper comuni e `feat_needed`).
- `featlib/`: installer per singole feature (es. `pip.sh`, `docker.sh`, `npm.sh`).
- `featlib/poetry/`: estensioni Poetry (es. `django.sh`).
- Script di esempio nella root (es. `python.sh`, `node_pip_docker_rust.sh`).
## Come si usa
Scrivi uno script dichiarativo con le feature che vuoi garantire:
```bash
#! /bin/bash --
. "grezzo.sh"
. "featlib/npm.sh"
. "featlib/pip.sh"
. "featlib/docker.sh"
. "featlib/rustup.sh"
npm-g_feat_needed "node-red"
pip_feat_needed "poetry"
feat_needed "docker"
feat_needed "rustup"
```
Esegui lo script dalla root del repository:
```bash
bash my-setup.sh
```
## Convenzioni
- `feat_needed <cmd>`: se il comando non esiste, invoca `feat_add_<cmd>`.
- `feat_add_<cmd>`: implementa linstallazione (puo' includere dipendenze imperative).
- `*_feat_needed <pkg>`: wrapper per package manager specifici (pip, npm, poetry).
## Note importanti
- Alcuni installer modificano `$HOME/.bashrc.before` e lo includono in `~/.bashrc`.
- Molti installer usano `sudo` e possono aggiungere repository ufficiali (es. Docker).
- Per coerenza con le policy, si preferiscono i repo ufficiali e gli install script upstream.
## Stato del progetto
Il progetto e' in evoluzione. Se vuoi aggiungere una nuova feature, crea un nuovo
`featlib/<nome>.sh` con `feat_add_<nome>` e aggiornalo secondo le policy correnti.

View File

@ -3,15 +3,19 @@
function feat_addpacks_curl() {
if ! feat_missing "apt-get"; then
sudo apt-get install -y curl
sudo apt-get update
sudo apt-get install -y bash curl
elif ! feat_missing "pacman"; then
sudo pacman -S --needed curl
sudo pacman -S --needed bash curl
elif ! feat_missing "apk"; then
sudo apk add --no-cache curl
sudo apk add --no-cache bash curl
elif ! feat_missing "yum"; then
sudo yum install bash curl
elif ! feat_missing "zypper"; then
sudo zypper in bash curl
fi
}
function feat_add_curl() {
feat_addpacks_curl
}

View File

@ -17,16 +17,16 @@ function feat_addpacks_docker() {
sudo rm -rf /etc/apt/keyrings/docker.gpg >/dev/null 2>&1
if [[ "$DISTRIB_ID" == "LinuxMint" ]]; then
. /etc/upstream-release/lsb-release
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$DISTRIB_CODENAME stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
elif [[ "$DISTRIB_ID" == "Ubuntu" ]]; then
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
else
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
@ -42,7 +42,7 @@ function feat_addpacks_docker() {
}
function feat_add_docker() {
if feat_missing "dockerd"; then
if feat_missing "docker"; then
feat_addpacks_docker
fi
}

View File

@ -3,6 +3,7 @@
function feat_addpacks_npm_dev() {
if ! feat_missing "apt-get"; then
sudo apt-get update
sudo apt-get install -y wget curl tar
elif ! feat_missing "pacman"; then
sudo pacman -S --needed base-devel wget curl tar
@ -17,11 +18,13 @@ function feat_addpacks_npm_dev() {
function feat_add_npm() {
feat_addpacks_npm_dev
[ -f "$HOME/.bashrc.before" ] || touch "$HOME/.bashrc.before"
cat - "$HOME/.bashrc.before" <<- EOF > "$HOME/.bashrc.before.tmp"
export N_PREFIX="\$HOME/.local"
export PATH="\$N_PREFIX/bin:\$PATH"
EOF
mv "$HOME/.bashrc.before.tmp" "$HOME/.bashrc.before"
feat_bashrc_before_needed
. "$HOME/.bashrc.before"
mkdir -p "$N_PREFIX"
curl -L https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s latest

View File

@ -5,6 +5,7 @@
function feat_addpacks_pip_dev() {
if ! feat_missing "apt-get"; then
sudo apt-get update
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev git
@ -30,11 +31,13 @@ function feat_add_pip() {
feat_needed curl
feat_addpacks_pip_dev
curl https://pyenv.run | bash 2>&1
[ -f "$HOME/.bashrc.before" ] || touch "$HOME/.bashrc.before"
{ echo "export PYENV_ROOT=\"\$HOME/.pyenv\"
export PATH=\"\$PYENV_ROOT/bin:\$PATH\"
eval \"\$(pyenv init -)\"" ;
cat "$HOME/.bashrc.before"; } > "$HOME/.bashrc.before.tmp"
mv "$HOME/.bashrc.before.tmp" "$HOME/.bashrc.before"
feat_bashrc_before_needed
. "$HOME/.bashrc.before"
LATESTPYTHON="$(pyenv install -l | grep '^[0-9\. ]*$' | sed -ne '$s|\s*||gp')"
pyenv install "$LATESTPYTHON"

View File

@ -6,6 +6,23 @@ function this_script_path() {
echo "$(cd "$(dirname "$(readlink -f -- "${BASH_SOURCE[1]}")")" > /dev/null && pwd -P)"
}
function feat_bashrc_before_needed() {
local bashrc="$HOME/.bashrc"
local include_line='. "$HOME/.bashrc.before"'
if [ ! -f "$bashrc" ]; then
printf 'HOME="%s"\n%s\n' "$HOME" "$include_line" > "$bashrc"
return
fi
if grep -Fqs "$include_line" "$bashrc" || grep -Fqs "$HOME/.bashrc.before" "$bashrc"; then
return
fi
{
printf 'HOME="%s"\n%s\n' "$HOME" "$include_line"
cat "$bashrc"
} > "$bashrc.tmp"
mv "$bashrc.tmp" "$bashrc"
}
function feat_missing() {
! command -v "$1" >/dev/null 2>&1
}
@ -13,6 +30,11 @@ function feat_missing() {
function feat_needed() {
FEAT="$1"
if feat_missing "$FEAT"; then
eval "feat_add_$FEAT"
if type "feat_add_$FEAT" >/dev/null 2>&1; then
eval "feat_add_$FEAT"
else
echo "Missing function: feat_add_$FEAT" >&2
return 1
fi
fi
}