|
| 1 | +# Hardware Probe (hw-probe) Runner |
| 2 | + |
| 3 | +Modular, POSIX-`sh` runner to install/update and execute **[hw-probe](https://github.com/linuxhw/hw-probe)** on **Debian/Ubuntu**, with optional **Docker** mode. |
| 4 | +Works offline (save locally) or online (upload to linux-hardware.org), and can auto-extract generated reports. |
| 5 | + |
| 6 | +- Uses your existing `functestlib.sh` for logging, `check_dependencies`, and `check_network_status`. |
| 7 | +- All helpers live in `Runner/utils/` and are shared across tools. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Folder layout |
| 12 | + |
| 13 | +``` |
| 14 | +Runner/ |
| 15 | +├─ utils/ |
| 16 | +│ ├─ lib_common.sh # tiny helpers (root/sudo, OS detect, ensure_dir, network check) |
| 17 | +│ ├─ lib_apt.sh # apt install/update/version helpers |
| 18 | +│ ├─ lib_docker.sh # docker presence/launch helpers |
| 19 | +│ └─ lib_hwprobe.sh # hw-probe install/update/run (local & docker) + extraction |
| 20 | +└─ tools/ |
| 21 | + └─ hw-probe/ |
| 22 | + ├─ run.sh # main CLI (sources init_env → functestlib → utils/*) |
| 23 | + └─ README.md # this file |
| 24 | +``` |
| 25 | + |
| 26 | +> `run.sh` auto-locates and sources your repo’s `init_env` → `${TOOLS}/functestlib.sh` so the libs can call `log_info`, `log_warn`, `log_error`, `log_fail`, `log_skip`, `check_dependencies`, `check_network_status`, etc. |
| 27 | +
|
| 28 | +--- |
| 29 | + |
| 30 | +## Requirements |
| 31 | + |
| 32 | +- **OS:** Debian/Ubuntu (checked by the script) |
| 33 | +- **Privileges:** root required to probe all devices |
| 34 | + - If not root, the runner uses `sudo -E` automatically. |
| 35 | +- **APT tools:** `apt-get`, `apt-cache`, `dpkg` |
| 36 | +- **Network:** only needed when: |
| 37 | + - Installing/updating packages or pulling Docker images |
| 38 | + - Using `--upload yes` |
| 39 | +- **Docker mode:** requires `docker` (the runner can install `docker.io` via apt) |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## What the runner does |
| 44 | + |
| 45 | +- Checks platform (Debian/Ubuntu) and basic tools |
| 46 | +- Optionally installs **hw-probe** (latest or pinned version) |
| 47 | +- Optionally updates **hw-probe** to latest |
| 48 | +- Ensures recommended dependencies (e.g., `lshw`, `smartmontools`, `nvme-cli`, `hdparm`, `pciutils`, `usbutils`, `dmidecode`, `ethtool`, `lsscsi`, `iproute2`) |
| 49 | +- Runs **locally** or via **Docker** |
| 50 | +- Saves output to a specified directory (default `./hw-probe_out`) using `hw-probe -save` |
| 51 | +- Optionally uploads probe to linux-hardware.org |
| 52 | +- Optionally auto-extracts `hw.info.txz` to `OUT/extracted-<timestamp>` |
| 53 | +- Prints: saved path, extraction hint, and (when uploaded) the Probe URL |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## Usage |
| 58 | + |
| 59 | +```sh |
| 60 | +cd Runner/tools/hw-probe |
| 61 | +./run.sh [OPTIONS] |
| 62 | +``` |
| 63 | + |
| 64 | +### Options |
| 65 | + |
| 66 | +| Option | Values | Default | Description | |
| 67 | +|---|---|---|---| |
| 68 | +| `--mode` | `local` \| `docker` | `local` | Run natively or inside the official `linuxhw/hw-probe` image. | |
| 69 | +| `--upload` | `yes` \| `no` | `no` | Upload probe to linux-hardware.org and print the URL. Auto-disabled if offline. | |
| 70 | +| `--out` | path | `./hw-probe_out` | Directory to save artifacts (`hw.info.txz`) and logs. Created if missing. | |
| 71 | +| `--extract` | `yes` \| `no` | `no` | Auto-extract the saved archive to `OUT/extracted-<ts>`. Requires `tar` (xz support preferred). | |
| 72 | +| `--install` | – | – | Ensure **hw-probe** is installed (latest) if missing. | |
| 73 | +| `--version` | string | – | Install a specific version (implies `--install`). | |
| 74 | +| `--update` | – | – | Update **hw-probe** to the latest available version. | |
| 75 | +| `--list-versions` | – | – | Show available versions from APT (policy/madison). | |
| 76 | +| `--deps-only` | – | – | Install recommended dependencies only (no hw-probe). | |
| 77 | +| `--probe-args` | quoted args | – | Extra args forwarded to `hw-probe` (both modes). | |
| 78 | +| `--dry-run` | – | – | Print intended actions without installing/running. | |
| 79 | +| `--verbose` | – | – | Increase logging verbosity (handled by functestlib). | |
| 80 | +| `-h`, `--help` | – | – | Show usage. | |
| 81 | + |
| 82 | +> The runner uses `check_network_status` before any download (APT/Docker). If offline and `--upload yes`, it downgrades to `--upload no` for that run. |
| 83 | +
|
| 84 | +--- |
| 85 | + |
| 86 | +## Quick starts |
| 87 | + |
| 88 | +### 1) Local run, save only (no upload), then auto-extract |
| 89 | +```sh |
| 90 | +./run.sh --mode local --upload no --extract yes |
| 91 | +``` |
| 92 | + |
| 93 | +### 2) Local run, upload + auto-extract |
| 94 | +```sh |
| 95 | +./run.sh --mode local --upload yes --extract yes |
| 96 | +``` |
| 97 | + |
| 98 | +### 3) Docker run, save only, custom output dir |
| 99 | +```sh |
| 100 | +./run.sh --mode docker --upload no --out ./out --extract yes |
| 101 | +``` |
| 102 | + |
| 103 | +### 4) Install/update workflows |
| 104 | +```sh |
| 105 | +# Ensure deps + latest hw-probe (if missing), then run |
| 106 | +./run.sh --install --mode local |
| 107 | + |
| 108 | +# Install a specific version |
| 109 | +./run.sh --install --version 1.6 |
| 110 | + |
| 111 | +# Update to latest |
| 112 | +./run.sh --update |
| 113 | +``` |
| 114 | + |
| 115 | +### 5) List available package versions |
| 116 | +```sh |
| 117 | +./run.sh --list-versions |
| 118 | +``` |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## Artifacts & Logs |
| 123 | + |
| 124 | +- **Saved report:** `OUT/hw.info.txz` (xz-compressed tar) |
| 125 | +- **Local run log:** `OUT/.hw-probe-run-<timestamp>.log` |
| 126 | +- **Docker run log:** `OUT/.hw-probe-docker-<timestamp>.log` |
| 127 | +- **Auto-extraction (if `--extract yes`):** `OUT/extracted-<timestamp>/` |
| 128 | + |
| 129 | +To manually inspect or extract: |
| 130 | + |
| 131 | +```sh |
| 132 | +# list |
| 133 | +tar -tJf OUT/hw.info.txz |
| 134 | + |
| 135 | +# extract |
| 136 | +mkdir -p OUT/extracted |
| 137 | +tar -xJf OUT/hw.info.txz -C OUT/extracted |
| 138 | + |
| 139 | +# fallbacks if your tar lacks -J: |
| 140 | +# bsdtar -xf OUT/hw.info.txz -C OUT/extracted |
| 141 | +# xz -dc OUT/hw.info.txz | tar -xf - -C OUT/extracted |
| 142 | +``` |
| 143 | + |
| 144 | +When `--upload yes`, the runner prints the **Probe URL** returned by hw-probe (e.g., `https://linux-hardware.org/?probe=<id>`). |
| 145 | + |
| 146 | +--- |
| 147 | + |
| 148 | +## Docker notes |
| 149 | + |
| 150 | +The runner: |
| 151 | +- Installs `docker.io` via APT if missing (Debian/Ubuntu) |
| 152 | +- Pulls `linuxhw/hw-probe` if online; if offline it requires the image to exist locally |
| 153 | +- Runs with: |
| 154 | + - `--privileged --net=host --pid=host` |
| 155 | + - Read-only binds: `/dev`, `/lib/modules`, `/etc/os-release`, `/var/log` |
| 156 | + - Output bind: `-v "$OUT":/out` so `-save /out` persists artifacts on the host |
| 157 | + |
| 158 | +Your original run line is respected, and the script captures container stdout to a host log for URL parsing. |
| 159 | + |
| 160 | +--- |
| 161 | + |
| 162 | +## Extra hw-probe arguments |
| 163 | + |
| 164 | +Pass through to `hw-probe` via `--probe-args`, e.g.: |
| 165 | + |
| 166 | +```sh |
| 167 | +# Quiet logging level (example) |
| 168 | +./run.sh --mode local --probe-args "-log-level minimal" |
| 169 | + |
| 170 | +# Add ACPI table dump & decode (requires acpica-tools) |
| 171 | +./run.sh --mode local --probe-args "-dump-acpi -decode-acpi" |
| 172 | +``` |
| 173 | + |
| 174 | +--- |
| 175 | + |
| 176 | +## X11 warning |
| 177 | + |
| 178 | +If you see: |
| 179 | +``` |
| 180 | +WARNING: X11-related logs are not collected (try to run 'sudo -E hw-probe ...') |
| 181 | +``` |
| 182 | +It usually means `DISPLAY`/`XAUTHORITY` aren’t accessible to root (common on servers). To include X11 logs: |
| 183 | + |
| 184 | +```sh |
| 185 | +xhost +local:root |
| 186 | +sudo -E env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" hw-probe -all -save ./hw-probe_out |
| 187 | +``` |
| 188 | + |
| 189 | +(Our runner already uses `sudo -E`; you just might need `xhost` on desktop systems.) |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +## Offline use |
| 194 | + |
| 195 | +- Use `--upload no` (default); artifacts are saved locally. |
| 196 | +- You can upload later when online: |
| 197 | + ```sh |
| 198 | + # Example: upload a saved probe |
| 199 | + sudo -E hw-probe -upload -src /path/to/hw.info.txz |
| 200 | + ``` |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## Security & privacy |
| 205 | + |
| 206 | +- `--upload yes` sends probe data to linux-hardware.org over HTTPS (see upstream privacy notes). |
| 207 | +- Docker mode uses `--privileged` to access host hardware; run only on trusted systems. |
| 208 | +- The runner uses `sudo -E` when needed to collect device info. |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +## Exit codes |
| 213 | + |
| 214 | +- `0` on success |
| 215 | +- Non-zero on failures (unsupported OS, missing critical tools, network required but offline, Docker not runnable, extraction failure ignored unless critical, etc.) |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +## Troubleshooting |
| 220 | + |
| 221 | +- **“Unknown option: dump”** → We use `-save`, not `-dump`. If you call `hw-probe` manually, be sure to use `-save`. |
| 222 | +- **“not in gzip format” when opening `hw.info.txz`** → It’s xz, not gzip. Use `tar -tJf` / `tar -xJf` (or `bsdtar`, or `xz -dc | tar -xf -`). |
| 223 | +- **Offline + Docker first-time** → Ensure the image `linuxhw/hw-probe` is already present locally or run once online. |
| 224 | +- **Network checks** → The runner calls `check_network_status` (from `functestlib.sh`) before any download; offline runs still work with `--upload no`. |
| 225 | + |
| 226 | +--- |
| 227 | + |
| 228 | +## Dev notes |
| 229 | + |
| 230 | +- All scripts are **POSIX `sh`**, shellcheck-friendly (only dynamic-source warnings suppressed). |
| 231 | +- No duplicated infra—logging and basic checks come from your **`functestlib.sh`**. |
| 232 | +- To extend behavior, prefer adding to `lib_hwprobe.sh` and surface flags via `run.sh`. |
0 commit comments