mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-24 12:06:17 +01:00
Compare commits
No commits in common. "47371ac9a11d0d8ec2c1ca38ea87f3b7e3121f99" and "a97ad66e1fb21bebd72b5f82e7ffc86529db8db0" have entirely different histories.
47371ac9a1
...
a97ad66e1f
@ -1,34 +0,0 @@
|
||||
{
|
||||
"intent": "Fix pacman_wrapper.sh so whitelist/blocklist matching works for `pacman -U <file>.pkg.tar.zst` installs, which yay always uses — previously a whitelisted package installed via -U could be misidentified because the check compared raw filenames instead of bare package names.",
|
||||
"scope": [
|
||||
"linux_configuration/scripts/periodic_background/digital_wellbeing/pacman/pacman_wrapper.sh",
|
||||
"linux_configuration/scripts/periodic_background/digital_wellbeing/pacman/pacman_whitelist.txt",
|
||||
"linux_configuration/tests/test_pacman_wrapper_security.sh",
|
||||
"Non-goal: no change to blocklist policy content beyond the ungoogled-chromium/plain-chromium swap needed for the browser migration"
|
||||
],
|
||||
"changes": [
|
||||
"Added strip_pkgfile_suffix() to pacman_wrapper.sh to derive a bare package name from a -U <file>.pkg.tar.zst argument before whitelist/blocklist matching",
|
||||
"Updated pacman_whitelist.txt: added ungoogled-chromium, ungoogled-chromium-bin, ungoogled-chromium-bin-debug; removed stale chromium/ublock-origin entries (Chromium 151 dropped MV2, package was uninstalled)",
|
||||
"Added a regression test to test_pacman_wrapper_security.sh covering strip_pkgfile_suffix + is_blocked_package_name against -U package-file arguments"
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "bash tests/test_pacman_wrapper_security.sh",
|
||||
"result": "pass",
|
||||
"evidence": "=== All Tests Passed! === including new TEST: 'Verifying strip_pkgfile_suffix + is_blocked_package_name handle -U package-file arguments' -> strip_pkgfile_suffix bares -U filenames; whitelisted packages are allowed via -U, non-whitelisted blocked keywords still blocked"
|
||||
},
|
||||
{
|
||||
"command": "shellcheck pacman/pacman_wrapper.sh && shfmt -d pacman/pacman_wrapper.sh",
|
||||
"result": "pass",
|
||||
"evidence": "shellcheck exit 0, shfmt reported no diff"
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"strip_pkgfile_suffix uses a regex/glob to strip the pkg.tar.zst suffix and arch/version fields — a package name containing unusual characters could in theory mismatch, but the whitelist only contains conventional pacman package names",
|
||||
"Whitelist changes remove blanket chromium/ublock-origin entries — any script still assuming those names are whitelisted will now be blocked by the wrapper until updated"
|
||||
],
|
||||
"rollback": [
|
||||
"git revert this commit",
|
||||
"Re-run bash tests/test_pacman_wrapper_security.sh after rollback to confirm no residual state from the new test"
|
||||
]
|
||||
}
|
||||
@ -1,56 +0,0 @@
|
||||
{
|
||||
"intent": "Make full/classic uBlock Origin load on every real Chromium-family browser launch on Arch (alongside LeechBlockNG, already wired by install_leechblock.sh), and fix the same integration for the Ubuntu/Debian install script so both distros work end to end.",
|
||||
"scope": [
|
||||
"linux_configuration/scripts/periodic_background/digital_wellbeing/install_ublock.sh (new)",
|
||||
"linux_configuration/scripts/periodic_background/digital_wellbeing/seed_ublock_storage.js",
|
||||
"linux_configuration/scripts/single_use/install_ungoogled_chromium_ubuntu.sh",
|
||||
"Non-goal: no changes to LeechBlockNG's own installer or defaults"
|
||||
],
|
||||
"changes": [
|
||||
"seed_ublock_storage.js: fixed extension-ID discovery for --load-extension (unpacked) deployments. Chromium assigns a synthetic, install-path-derived ID rather than the CWS ID for unpacked loads; the seeder now reads extensions.settings[*].path back out of the profile's own Preferences file to find the right LevelDB storage dir, falling back to the CWS ID only for real Chrome-Web-Store installs. Verified empirically: /usr/lib/ublock-origin resolves to id bnpeoafekllpappgoakfpagjghdaicfb on this machine.",
|
||||
"seed_ublock_storage.js: added --ext-path=<path> CLI override so non-Arch installers (different package path) can point the ID-discovery step at their own unpacked install location instead of relying on a hardcoded Arch path.",
|
||||
"install_ublock.sh (new): wires uBlock Origin into the same Chromium-family wrapper install_leechblock.sh already patches, using a comma-joined single --load-extension flag rather than a second, separate flag occurrence.",
|
||||
"install_ungoogled_chromium_ubuntu.sh: corrected UBLOCK_EXT_PATH from the unverified guess /usr/share/webext/ublock-origin-chromium to the actual Debian/Ubuntu package path /usr/share/chromium/extensions/ublock-origin, confirmed via packages.ubuntu.com's noble file listing for webext-ublock-origin-chromium (manifest.json present at that path). Also passes --ext-path to the seeder so ID discovery works on Ubuntu too."
|
||||
],
|
||||
"verification": [
|
||||
{
|
||||
"command": "Empirical: launched real /usr/bin/chromium headless with --load-extension=/usr/lib/ublock-origin, inspected Preferences",
|
||||
"result": "pass",
|
||||
"evidence": "extensions.settings['bnpeoafekllpappgoakfpagjghdaicfb'].path == '/usr/lib/ublock-origin', confirming the synthetic-ID mechanism the seeder fix relies on"
|
||||
},
|
||||
{
|
||||
"command": "Empirical: tested a single comma-joined --load-extension=pathA,pathB flag vs. two separate --load-extension= flags",
|
||||
"result": "pass / critical finding",
|
||||
"evidence": "Comma-joined: both extensions register with disable_reasons: []. Two separate flags: LAST-WINS, the first extension is silently dropped. install_ublock.sh and the Ubuntu script were written to always comma-join into any existing flag rather than append a second one."
|
||||
},
|
||||
{
|
||||
"command": "node ./seed_ublock_storage.js --force run against a scratch profile pre-seeded via a real headless chromium launch",
|
||||
"result": "pass",
|
||||
"evidence": "Correctly discovered synthetic ID from Preferences, wrote selectedFilterLists (71 entries) to the matching LevelDB dir; read back and confirmed persisted"
|
||||
},
|
||||
{
|
||||
"command": "node ./seed_ublock_storage.js --ext-path=/usr/share/chromium/extensions/ublock-origin --force run against a synthetic Preferences entry using the Debian path",
|
||||
"result": "pass",
|
||||
"evidence": "Correctly matched the override path and seeded the corresponding LevelDB dir, confirming the Ubuntu installer's fixed invocation will work"
|
||||
},
|
||||
{
|
||||
"command": "bash install_ublock.sh run for real against the live system (user-approved)",
|
||||
"result": "pass",
|
||||
"evidence": "Patched /usr/local/bin/browser-preexec-wrapper's exec line to a comma-joined --load-extension flag; launched real chromium afterward and confirmed both bnpeoafekllpappgoakfpagjghdaicfb (uBO) and kbkikbljacklcgphimabcdnifabmhfjn (LeechBlock) present with disable_reasons: [] in the live profile's Preferences"
|
||||
},
|
||||
{
|
||||
"command": "shellcheck install_ublock.sh scripts/single_use/install_ungoogled_chromium_ubuntu.sh && shfmt -d (both)",
|
||||
"result": "pass",
|
||||
"evidence": "shellcheck exit 0 for both; shfmt reported no diff for either file"
|
||||
}
|
||||
],
|
||||
"risks": [
|
||||
"install_ublock.sh's idempotency check greps for the uBO path already present inside a --load-extension=\"...\" flag; if a future manual edit changes flag quoting style it could double-patch on re-run (mitigated: it also backs up to .orig before any patch, same pattern as install_leechblock.sh)",
|
||||
"UBLOCK_EXT_PATH for Ubuntu is now sourced from a live packages.ubuntu.com listing rather than execution on real Ubuntu hardware — the Ubuntu install script itself (download/apt install steps) remains unexecuted/unverified on this session, only the seeder+path logic was verified",
|
||||
"The deployed /usr/local/bin/browser-preexec-wrapper is a stale (pre-crash-logging) revision vs. the repo's current system-maintenance/bin/browser-preexec-wrapper.sh source — install_ublock.sh patched the deployed file as-is; the crash-logging feature drift is a separate, unaddressed issue"
|
||||
],
|
||||
"rollback": [
|
||||
"git revert this commit",
|
||||
"On the live machine: restore /usr/local/bin/browser-preexec-wrapper from /usr/local/bin/browser-preexec-wrapper.orig (sudo cp -a) to undo the real system patch made this session"
|
||||
]
|
||||
}
|
||||
@ -1,225 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# uBlock Origin installer/wirer for Arch Linux (and derivatives)
|
||||
# - Uses the ublock-origin pacman package already unpacked at /usr/lib/ublock-origin
|
||||
# (install via `sudo pacman -S ublock-origin` if missing)
|
||||
# - Wires Chromium-based browsers to auto-load it via --load-extension, alongside
|
||||
# any extension a previous installer (e.g. install_leechblock.sh) already wired in
|
||||
# - Seeds every selectable filter list into the extension's storage so uBO runs in
|
||||
# full/classic mode with everything enabled, not just the shipped defaults
|
||||
#
|
||||
# IMPORTANT: --load-extension is last-wins across *separate* occurrences of the
|
||||
# flag — Chromium silently drops every extension but the last one specified this
|
||||
# way. Only a single, comma-joined "--load-extension=pathA,pathB" loads both.
|
||||
# This script therefore never appends a second --load-extension flag: it always
|
||||
# rewrites the existing flag (if any) into a comma-joined one.
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
SCRIPT_NAME=${0##*/}
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
info() { printf "\033[1;34m[INFO]\033[0m %s\n" "$*"; }
|
||||
warn() { printf "\033[1;33m[WARN]\033[0m %s\n" "$*"; }
|
||||
err() { printf "\033[1;31m[ERR ]\033[0m %s\n" "$*"; }
|
||||
|
||||
require_cmd() {
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
err "Missing dependency: $1"
|
||||
MISSING=1
|
||||
fi
|
||||
}
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
${SCRIPT_NAME} — Wire up uBlock Origin (pacman package) for Chromium-based browsers
|
||||
|
||||
Usage: ${SCRIPT_NAME}
|
||||
|
||||
Notes:
|
||||
- Requires the 'ublock-origin' pacman package (sudo pacman -S ublock-origin).
|
||||
- Chromium-based browsers are integrated via the same wrapper pattern used by
|
||||
install_leechblock.sh; running both installers preserves both extensions in
|
||||
a single comma-joined --load-extension flag.
|
||||
- Firefox-based browsers are out of scope here — install uBlock Origin from
|
||||
addons.mozilla.org instead, permanent installs work there unlike LeechBlock.
|
||||
EOF
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
"") ;;
|
||||
*)
|
||||
err "Unrecognized option: $1"
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
MISSING=0
|
||||
require_cmd sed
|
||||
require_cmd find
|
||||
[[ $MISSING -eq 1 ]] && {
|
||||
err "Please install missing tools and re-run."
|
||||
exit 1
|
||||
}
|
||||
|
||||
EXT_PATH="/usr/lib/ublock-origin"
|
||||
if [[ ! -f "$EXT_PATH/manifest.json" ]]; then
|
||||
err "uBlock Origin not found at $EXT_PATH (manifest.json missing)."
|
||||
err "Install it first: sudo pacman -S ublock-origin"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── Seed default filter-list selection (all lists enabled) ────────────
|
||||
if [[ ! -d "$SCRIPT_DIR/node_modules/classic-level" ]]; then
|
||||
info "Installing classic-level npm package into $SCRIPT_DIR ..."
|
||||
npm install --prefix "$SCRIPT_DIR" 2>&1 | grep -v '^npm warn' || true
|
||||
fi
|
||||
|
||||
# Chrome locks its LevelDB files while running — close all Chromium browsers
|
||||
# so the write succeeds.
|
||||
pkill -f 'google-chrome|chromium|brave-browser|vivaldi|thorium' 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
if node "$SCRIPT_DIR/seed_ublock_storage.js"; then
|
||||
info "Seeded uBlock Origin filter-list selection into browser storage"
|
||||
else
|
||||
warn "Could not seed uBlock Origin defaults — run manually after install:"
|
||||
warn " node $SCRIPT_DIR/seed_ublock_storage.js"
|
||||
fi
|
||||
|
||||
# ── Detect browsers ─────────────────────────────────────────────────────
|
||||
declare -A BROWSERS
|
||||
BROWSERS=(
|
||||
[chromium]="Chromium"
|
||||
[google-chrome-stable]="Google Chrome"
|
||||
[google-chrome]="Google Chrome"
|
||||
[brave-browser]="Brave"
|
||||
[vivaldi-stable]="Vivaldi"
|
||||
[vivaldi]="Vivaldi"
|
||||
[opera]="Opera"
|
||||
[thorium-browser]="Thorium"
|
||||
)
|
||||
|
||||
found_any=0
|
||||
|
||||
# Add uBO to a browser launcher's --load-extension flag without dropping any
|
||||
# extension a previous installer (LeechBlock) already wired in. Handles the
|
||||
# same two cases as install_leechblock.sh's replace_browser_in_place:
|
||||
# 1) The binary is a shell script with an "exec" line — patch it in-place.
|
||||
# 2) The binary is a compiled ELF — wrap it with a shell script.
|
||||
# Follows symlinks only one level, same as install_leechblock.sh, so shared
|
||||
# wrapper scripts (e.g. browser-preexec-wrapper used by multiple symlinks)
|
||||
# only get patched once regardless of which browser name triggered it.
|
||||
wire_browser_in_place() {
|
||||
local bin="$1"
|
||||
shift
|
||||
local pretty="$1"
|
||||
shift
|
||||
|
||||
local bin_path
|
||||
bin_path=$(command -v "$bin" || true)
|
||||
[[ -z $bin_path ]] && return
|
||||
|
||||
local real_bin
|
||||
real_bin=$(readlink -f "$bin_path")
|
||||
|
||||
# Already comma-joined in: nothing to do.
|
||||
if grep -qE -- "--load-extension=\"[^\"]*${EXT_PATH//\//\\/}[^\"]*\"" "$real_bin" 2>/dev/null; then
|
||||
info "$pretty ($bin) already has uBlock Origin in --load-extension — skipping"
|
||||
found_any=1
|
||||
return
|
||||
fi
|
||||
|
||||
# Case 1: Shell script with an exec line carrying an existing
|
||||
# --load-extension="..." flag (most likely from install_leechblock.sh) —
|
||||
# rewrite it in-place into a comma-joined flag so both extensions load.
|
||||
if file "$real_bin" 2>/dev/null | grep -qi 'text\|script'; then
|
||||
if grep -qE -- '--load-extension="[^"]*"' "$real_bin" 2>/dev/null; then
|
||||
info "Adding uBlock Origin to existing --load-extension flag in $real_bin…"
|
||||
pkill -f "$real_bin" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
local orig_backup="${real_bin}.orig"
|
||||
if [[ ! -f $orig_backup ]]; then
|
||||
info "Backing up $real_bin → $orig_backup"
|
||||
sudo cp -a "$real_bin" "$orig_backup"
|
||||
fi
|
||||
|
||||
sudo sed -i -E "s|--load-extension=\"([^\"]*)\"|--load-extension=\"\1,${EXT_PATH}\"|" "$real_bin"
|
||||
|
||||
info "✓ $pretty --load-extension flag now includes uBlock Origin"
|
||||
found_any=1
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -qE '^exec ' "$real_bin"; then
|
||||
info "Patching exec line in $real_bin to add uBlock Origin…"
|
||||
pkill -f "$real_bin" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
local orig_backup="${real_bin}.orig"
|
||||
if [[ ! -f $orig_backup ]]; then
|
||||
info "Backing up $real_bin → $orig_backup"
|
||||
sudo cp -a "$real_bin" "$orig_backup"
|
||||
fi
|
||||
|
||||
sudo sed -i "s|^exec \(.*\) \"\\\$@\"|exec \1 --load-extension=\"$EXT_PATH\" \"\\\$@\"|" "$real_bin"
|
||||
|
||||
info "✓ $pretty exec line patched with uBlock Origin"
|
||||
found_any=1
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Case 2: Binary or script without a recognisable exec/--load-extension
|
||||
# line — wrap it directly (no prior LeechBlock installer has run here).
|
||||
local orig_backup="${real_bin}.orig"
|
||||
|
||||
info "Killing running $pretty instances…"
|
||||
pkill -f "$real_bin" 2>/dev/null || true
|
||||
pkill -f "$(basename "$real_bin")" 2>/dev/null || true
|
||||
sleep 1
|
||||
|
||||
if [[ ! -f $orig_backup ]]; then
|
||||
info "Backing up $real_bin → $orig_backup"
|
||||
sudo cp -a "$real_bin" "$orig_backup"
|
||||
else
|
||||
info "Backup already exists: $orig_backup"
|
||||
fi
|
||||
|
||||
info "Replacing $real_bin with uBlock Origin wrapper…"
|
||||
sudo tee "$real_bin" >/dev/null <<WRAP
|
||||
#!/usr/bin/env bash
|
||||
# __UBLOCK_WRAPPER__ — auto-generated by install_ublock.sh
|
||||
# Original backed up at: $orig_backup
|
||||
exec "$orig_backup" --load-extension="$EXT_PATH" "\$@"
|
||||
WRAP
|
||||
sudo chmod +x "$real_bin"
|
||||
|
||||
info "✓ $pretty now always launches with uBlock Origin"
|
||||
found_any=1
|
||||
}
|
||||
|
||||
info "Detecting installed browsers…"
|
||||
for bin in "${!BROWSERS[@]}"; do
|
||||
if command -v "$bin" >/dev/null 2>&1; then
|
||||
wire_browser_in_place "$bin" "${BROWSERS[$bin]}"
|
||||
fi
|
||||
done
|
||||
|
||||
echo
|
||||
if [[ $found_any -eq 1 ]]; then
|
||||
info "uBlock Origin integration complete."
|
||||
warn "Chromium will mark it as a developer extension; this is expected for unpacked installs."
|
||||
else
|
||||
warn "No supported browsers detected. uBlock Origin package is present at: $EXT_PATH"
|
||||
echo "Supported (auto-wired): ${!BROWSERS[*]}."
|
||||
fi
|
||||
|
||||
echo
|
||||
info "Done."
|
||||
@ -1,34 +1,5 @@
|
||||
# Exact package names that should bypass the block even if matching a keyword.
|
||||
thorium-browser-bin
|
||||
# Allowed 2026-08-12: Thorium (thorium-browser-bin) has a recurring, deterministic
|
||||
# internal crash (identical stack offsets across 7 coredumps, root cause an
|
||||
# unresolved CHECK/assertion in a stripped binary at its latest available
|
||||
# version — see session notes). Tried plain `chromium` (extra/chromium)
|
||||
# first, but that package is already past Chromium's Manifest V2 removal
|
||||
# (151.0.7922.108 — MV2 code paths gone as of Chromium 151, per upstream
|
||||
# changelog), so full uBlock Origin (MV2) cannot load and it was removed.
|
||||
# ungoogled-chromium is the V8/Chromium browser that still ships the MV2
|
||||
# extension runtime as a maintainer-patched stopgap (NOT a permanent
|
||||
# guarantee — could disappear in any future ungoogled-chromium release with
|
||||
# no warning; re-check this if uBO stops loading after a pacman/yay update).
|
||||
# The `chromium` KEYWORD stays blocked, so plain chromium/chromium-dev/etc.
|
||||
# remain barred — only the exact `ungoogled-chromium` package name is allowed.
|
||||
ungoogled-chromium
|
||||
# Also allow the prebuilt -bin variant: a from-source ungoogled-chromium
|
||||
# build via yay takes ~14h+ even throttled to half the machine's cores (full
|
||||
# Chromium compile, 56000+ ninja steps) — completely impractical for same-day
|
||||
# use. ungoogled-chromium-bin trails the source package by about one version
|
||||
# (150.x vs 151.x measured 2026-08-12) since it's a separately-maintained
|
||||
# prebuilt, but that lag is normal and acceptable; it is NOT a security
|
||||
# downgrade rationale, just a build-time one.
|
||||
ungoogled-chromium-bin
|
||||
# makepkg.conf's global OPTIONS has `debug` enabled, so building
|
||||
# ungoogled-chromium-bin also produces a companion
|
||||
# ungoogled-chromium-bin-debug package (debug symbols only — not loaded or
|
||||
# shipped by default). `yay -S` always installs both via one `pacman -U`
|
||||
# call; whitelisting only the main package still blocks the whole
|
||||
# transaction on the -debug package's name matching the `chromium` keyword.
|
||||
ungoogled-chromium-bin-debug
|
||||
# Allowed 2026-08-09 as a LeechBlock-enforced browser, same footing as Thorium:
|
||||
# install_leechblock.sh already policy-installs the blocker into LibreWolf via
|
||||
# /etc/librewolf/policies, so this is not an unfiltered escape hatch. Needed
|
||||
|
||||
@ -346,34 +346,14 @@ function display_operation() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Helper: strip a pacman package-file suffix (-<pkgver>-<pkgrel>-<arch>.pkg.tar.<ext>)
|
||||
# down to the bare package name, if present. `pacman -U <path>` (what `yay`
|
||||
# always uses to install a package it just built locally) passes a filename
|
||||
# like "ungoogled-chromium-bin-150.0.7871.186-1-x86_64.pkg.tar.zst", not the
|
||||
# bare name — without this, an exact-match whitelist entry for
|
||||
# "ungoogled-chromium-bin" could never match a `-U` install and would always
|
||||
# fall through to the (correctly still-substring) blocked-keywords check.
|
||||
# Leaves package names without this suffix (the `-S` case) untouched.
|
||||
# shellcheck disable=SC2329 # invoked indirectly by name (is_blocked_package_name)
|
||||
function strip_pkgfile_suffix() {
|
||||
local name="$1"
|
||||
if [[ $name =~ ^(.+)-[^-]+-[0-9]+-(x86_64|any|i686|aarch64)\.pkg\.tar\.(zst|xz|gz|bz2|lrz|lzo|Z)$ ]]; then
|
||||
printf '%s' "${BASH_REMATCH[1]}"
|
||||
else
|
||||
printf '%s' "$name"
|
||||
fi
|
||||
}
|
||||
|
||||
# Helper: return 0 if the given package name is blocked by policy
|
||||
# shellcheck disable=SC2329 # invoked indirectly by name (remove_installed_packages_matching, check_install_for)
|
||||
function is_blocked_package_name() {
|
||||
load_policy_lists
|
||||
local normalized="${1,,}"
|
||||
local bare_name
|
||||
bare_name="$(strip_pkgfile_suffix "$normalized")"
|
||||
|
||||
for allowed in "${WHITELISTED_NAMES_LIST[@]}"; do
|
||||
if [[ $normalized == "$allowed" || $bare_name == "$allowed" ]]; then
|
||||
if [[ $normalized == "$allowed" ]]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
@ -1,179 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* seed_ublock_storage.js
|
||||
*
|
||||
* Writes a uBlock Origin `selectedFilterLists` entry directly into Chrome's
|
||||
* extension LevelDB storage, enabling every filter list uBO ships (not just
|
||||
* the defaults that are on out of the box). Same mechanism as
|
||||
* seed_leechblock_storage.js: chrome.storage.local is a LevelDB store under
|
||||
* "Local Extension Settings/<extension-id>/", writable while the browser is
|
||||
* closed.
|
||||
*
|
||||
* uBO downloads/compiles the content of any newly-enabled 3rd-party list on
|
||||
* its own update cycle after the extension's first real launch (~105s), so
|
||||
* newly-selected lists need one browser launch with network access before
|
||||
* they're actually enforced — this only sets which lists are selected.
|
||||
*
|
||||
* Usage:
|
||||
* node seed_ublock_storage.js [--force] [--ext-path=/path/to/unpacked/ublock]
|
||||
*
|
||||
* --ext-path overrides the unpacked install path to match against (defaults
|
||||
* to Arch's /usr/lib/ublock-origin). Pass this on non-Arch installers whose
|
||||
* package path differs, e.g. Debian/Ubuntu's
|
||||
* /usr/share/chromium/extensions/ublock-origin.
|
||||
*
|
||||
* Must be run while the browser is NOT open.
|
||||
*
|
||||
* Requires: classic-level (npm install classic-level)
|
||||
*/
|
||||
|
||||
import { ClassicLevel } from "classic-level";
|
||||
import { existsSync, readdirSync, readFileSync } from "fs";
|
||||
import path from "path";
|
||||
import os from "os";
|
||||
import https from "https";
|
||||
|
||||
// ── CLI args ─────────────────────────────────────────────────────────
|
||||
const args = process.argv.slice(2);
|
||||
const force = args.includes("--force");
|
||||
const extPathArg = args.find((a) => a.startsWith("--ext-path="));
|
||||
const customExtPath = extPathArg ? extPathArg.slice("--ext-path=".length) : null;
|
||||
|
||||
// ── Known CWS extension ID for uBlock Origin (MV2) ────────────────────
|
||||
const CWS_EXT_ID = "cjpalhdlnbpafiamejdnhcphjbkeiagm";
|
||||
|
||||
// uBO's package install path(s), used with --load-extension deployments.
|
||||
// Chromium derives a synthetic, install-specific extension ID from the
|
||||
// unpacked path rather than using the CWS ID — read it back out of the
|
||||
// profile's own Preferences file instead of guessing it. Includes both
|
||||
// known distro package paths so this script works unmodified whether it
|
||||
// was seeded via --ext-path (e.g. from the Ubuntu installer) or run bare
|
||||
// (Arch's ublock-origin package).
|
||||
const UNPACKED_EXT_PATHS = customExtPath
|
||||
? [customExtPath]
|
||||
: ["/usr/lib/ublock-origin", "/usr/share/chromium/extensions/ublock-origin"];
|
||||
|
||||
// Find the extension ID Chromium assigned to an unpacked extension loaded via
|
||||
// --load-extension, by matching extensions.settings[*].path against known
|
||||
// install paths. Returns null if the profile has no Preferences file yet
|
||||
// (i.e. the browser has never been launched with this profile).
|
||||
function findUnpackedExtensionId(configDir, profile) {
|
||||
const prefsPath = path.join(configDir, profile, "Preferences");
|
||||
if (!existsSync(prefsPath)) return null;
|
||||
let prefs;
|
||||
try {
|
||||
prefs = JSON.parse(readFileSync(prefsPath, "utf8"));
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
const settings = prefs?.extensions?.settings ?? {};
|
||||
for (const [id, entry] of Object.entries(settings)) {
|
||||
if (UNPACKED_EXT_PATHS.includes(entry?.path)) return id;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ── Fetch uBO's own filter-list catalog and select every filter list ──
|
||||
function fetchAssetsJson() {
|
||||
return new Promise((resolve, reject) => {
|
||||
https
|
||||
.get(
|
||||
"https://raw.githubusercontent.com/gorhill/uBlock/master/assets/assets.json",
|
||||
(res) => {
|
||||
if (res.statusCode !== 200) {
|
||||
reject(new Error(`HTTP ${res.statusCode} fetching assets.json`));
|
||||
return;
|
||||
}
|
||||
let body = "";
|
||||
res.on("data", (chunk) => (body += chunk));
|
||||
res.on("end", () => {
|
||||
try {
|
||||
resolve(JSON.parse(body));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
},
|
||||
)
|
||||
.on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
function selectAllFilterListKeys(assets) {
|
||||
// Every entry with content === "filters" is a filter list (as opposed to
|
||||
// uBO's own resource/scriptlet/redirect assets, which use other content
|
||||
// types). "off: true" only means "not selected by default" — it is still
|
||||
// a valid, selectable list, which is exactly what we want to force on.
|
||||
return Object.entries(assets)
|
||||
.filter(([, v]) => v.content === "filters")
|
||||
.map(([key]) => key);
|
||||
}
|
||||
|
||||
// ── Find all Chrome/Chromium profile dirs with this extension ────────
|
||||
const configDirs = [
|
||||
path.join(os.homedir(), ".config/google-chrome"),
|
||||
path.join(os.homedir(), ".config/chromium"),
|
||||
path.join(os.homedir(), ".config/BraveSoftware/Brave-Browser"),
|
||||
path.join(os.homedir(), ".config/vivaldi"),
|
||||
path.join(os.homedir(), ".config/thorium"),
|
||||
path.join(os.homedir(), ".config/ungoogled-chromium"),
|
||||
];
|
||||
|
||||
async function seedProfile(storageDir, selectedFilterLists) {
|
||||
const db = new ClassicLevel(storageDir, { createIfMissing: true });
|
||||
try {
|
||||
if (!force) {
|
||||
try {
|
||||
const existing = await db.get("selectedFilterLists");
|
||||
if (existing && JSON.parse(existing).length > 0) {
|
||||
console.log(` Skipping ${storageDir} — filter lists already configured (use --force to override).`);
|
||||
return;
|
||||
}
|
||||
} catch (_) {
|
||||
/* key doesn't exist — fine, proceed to seed */
|
||||
}
|
||||
}
|
||||
|
||||
await db.put("selectedFilterLists", JSON.stringify(selectedFilterLists));
|
||||
console.log(` ✓ Selected ${selectedFilterLists.length} filter lists in ${storageDir}`);
|
||||
} finally {
|
||||
await db.close();
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Fetching uBlock Origin's filter-list catalog...");
|
||||
const assets = await fetchAssetsJson();
|
||||
const selectedFilterLists = selectAllFilterListKeys(assets);
|
||||
console.log(`Found ${selectedFilterLists.length} selectable filter lists (enabling all of them).`);
|
||||
|
||||
let found = false;
|
||||
for (const configDir of configDirs) {
|
||||
if (!existsSync(configDir)) continue;
|
||||
for (const profile of readdirSync(configDir)) {
|
||||
// --load-extension deployments (this repo's normal case): Chromium
|
||||
// assigns a synthetic ID derived from the unpacked path, discoverable
|
||||
// only via the profile's own Preferences file.
|
||||
const unpackedId = findUnpackedExtensionId(configDir, profile);
|
||||
// Real CWS installs (e.g. Brave's Chrome Web Store install): fixed ID.
|
||||
const cwsExtDir = path.join(configDir, profile, "Extensions", CWS_EXT_ID);
|
||||
const cwsStorageDir = path.join(configDir, profile, "Local Extension Settings", CWS_EXT_ID);
|
||||
const cwsInstalled = existsSync(cwsExtDir) || existsSync(cwsStorageDir);
|
||||
|
||||
const extId = unpackedId ?? (cwsInstalled ? CWS_EXT_ID : null);
|
||||
if (!extId) continue;
|
||||
|
||||
const storageDir = path.join(configDir, profile, "Local Extension Settings", extId);
|
||||
console.log(`Seeding ${configDir}/${profile} (extension id ${extId})...`);
|
||||
try {
|
||||
await seedProfile(storageDir, selectedFilterLists);
|
||||
found = true;
|
||||
} catch (e) {
|
||||
console.warn(` ⚠ Failed to seed ${storageDir}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
console.log("No uBlock Origin installations found.");
|
||||
process.exit(0);
|
||||
}
|
||||
@ -1,218 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install ungoogled-chromium on Ubuntu/Debian with full uBlock Origin (MV2,
|
||||
# all filter lists pre-enabled) loaded on every launch.
|
||||
#
|
||||
# Why ungoogled-chromium instead of plain chromium/google-chrome: Chromium
|
||||
# removed Manifest V2 extension support starting with Chromium 138 (the last
|
||||
# MV2 code paths are gone as of Chromium 151), which breaks full uBlock
|
||||
# Origin (uBO's full/classic build is MV2-only; the MV3 "uBO Lite" that
|
||||
# survives the cutoff drops dynamic filter lists and most cosmetic
|
||||
# filtering). ungoogled-chromium is a Chromium fork whose maintainers
|
||||
# currently patch the MV2 extension runtime back in — a maintainer-patched
|
||||
# stopgap, not a permanent guarantee. Re-run this script's uBO seeding step
|
||||
# (or check the ungoogled-chromium changelog) if a future release drops that
|
||||
# patch and uBO stops loading.
|
||||
#
|
||||
# What this script does:
|
||||
# 1. Installs ungoogled-chromium from a .deb release (no official Debian/
|
||||
# Ubuntu package exists upstream; berkley4/ungoogled-chromium-debian is
|
||||
# the community-maintained binary build referenced from
|
||||
# ungoogled-software's own binaries index).
|
||||
# 2. Installs uBlock Origin unpacked via apt (webext-ublock-origin-chromium,
|
||||
# Debian/Ubuntu universe) and wires --load-extension so it's always
|
||||
# loaded, matching the Arch pacman_wrapper.sh + install_leechblock.sh
|
||||
# pattern in this repo (but standalone: no digital-wellbeing blocking
|
||||
# layer, no LeechBlock — just the browser + full ad blocker).
|
||||
# 3. Pre-enables every uBO filter list (not just the out-of-the-box
|
||||
# defaults) via seed_ublock_storage.js, the same LevelDB-seeding
|
||||
# mechanism seed_leechblock_storage.js already uses in this repo.
|
||||
#
|
||||
# Usage:
|
||||
# ./install_ungoogled_chromium_ubuntu.sh [--force]
|
||||
#
|
||||
# --force re-seeds uBO's filter-list selection even if it looks configured.
|
||||
#
|
||||
# Requires: Ubuntu/Debian with apt, sudo, curl, node+npm (for the seeder).
|
||||
# Must be run while ungoogled-chromium is NOT open (the seeder writes to its
|
||||
# LevelDB storage directly and a running browser holds it locked).
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
SCRIPT_NAME=${0##*/}
|
||||
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
|
||||
DIGITAL_WELLBEING_DIR="$SCRIPT_DIR/../periodic_background/digital_wellbeing"
|
||||
SEEDER_SCRIPT="$DIGITAL_WELLBEING_DIR/seed_ublock_storage.js"
|
||||
|
||||
UBLOCK_EXT_PATH="/usr/share/chromium/extensions/ublock-origin"
|
||||
DEB_RELEASE_REPO="berkley4/ungoogled-chromium-debian"
|
||||
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m'
|
||||
|
||||
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
|
||||
warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
|
||||
error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
||||
|
||||
FORCE=0
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--force) FORCE=1 ;;
|
||||
--help | -h)
|
||||
echo "Usage: $SCRIPT_NAME [--force]"
|
||||
echo ""
|
||||
echo " --force Re-seed uBO's filter-list selection even if already configured."
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
error "Unknown option: $arg"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$(id -u)" -eq 0 ]]; then
|
||||
error "Don't run this as root. It calls sudo itself where needed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v apt-get >/dev/null 2>&1; then
|
||||
error "apt-get not found — this script targets Ubuntu/Debian."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if pgrep -x chrome >/dev/null 2>&1 || pgrep -f "ungoogled-chromium" >/dev/null 2>&1; then
|
||||
error "ungoogled-chromium appears to be running. Close it first — the uBO seeding step writes to its LevelDB storage directly and a running browser holds it locked."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── 1. Install ungoogled-chromium from the community .deb release ──────
|
||||
if command -v ungoogled-chromium >/dev/null 2>&1; then
|
||||
info "ungoogled-chromium already installed ($(ungoogled-chromium --version 2>/dev/null || echo 'version unknown')) — skipping install."
|
||||
else
|
||||
info "Fetching latest ungoogled-chromium .deb release info from ${DEB_RELEASE_REPO}..."
|
||||
RELEASE_JSON=$(curl -fsSL "https://api.github.com/repos/${DEB_RELEASE_REPO}/releases/latest")
|
||||
DEB_URL=$(echo "$RELEASE_JSON" | grep -oP '"browser_download_url":\s*"\K[^"]+ungoogled-chromium_[^"]+_amd64\.deb(?=")' | grep -v dbgsym | head -1)
|
||||
SANDBOX_URL=$(echo "$RELEASE_JSON" | grep -oP '"browser_download_url":\s*"\K[^"]+ungoogled-chromium-sandbox_[^"]+_amd64\.deb(?=")' | grep -v dbgsym | head -1)
|
||||
|
||||
if [[ -z "$DEB_URL" || -z "$SANDBOX_URL" ]]; then
|
||||
error "Could not find expected .deb assets in the latest ${DEB_RELEASE_REPO} release."
|
||||
error "Check https://github.com/${DEB_RELEASE_REPO}/releases manually."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||
|
||||
info "Downloading $(basename "$DEB_URL")..."
|
||||
curl -fsSL -o "$TMP_DIR/chromium.deb" "$DEB_URL"
|
||||
info "Downloading $(basename "$SANDBOX_URL")..."
|
||||
curl -fsSL -o "$TMP_DIR/sandbox.deb" "$SANDBOX_URL"
|
||||
|
||||
info "Installing via apt (resolves runtime deps automatically)..."
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y "$TMP_DIR/sandbox.deb" "$TMP_DIR/chromium.deb"
|
||||
|
||||
if ! command -v ungoogled-chromium >/dev/null 2>&1; then
|
||||
error "Install finished but 'ungoogled-chromium' is not on PATH — check apt output above."
|
||||
exit 1
|
||||
fi
|
||||
info "✓ ungoogled-chromium installed: $(ungoogled-chromium --version 2>/dev/null || echo 'installed')"
|
||||
fi
|
||||
|
||||
# ── 2. Install uBlock Origin (unpacked, MV2) and wire --load-extension ──
|
||||
if [[ ! -d "$UBLOCK_EXT_PATH" ]]; then
|
||||
info "Installing webext-ublock-origin-chromium (unpacked uBO)..."
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y webext-ublock-origin-chromium
|
||||
fi
|
||||
|
||||
if [[ ! -d "$UBLOCK_EXT_PATH" ]]; then
|
||||
error "webext-ublock-origin-chromium installed but $UBLOCK_EXT_PATH is missing."
|
||||
error "Check 'dpkg -L webext-ublock-origin-chromium' for the actual install path and update UBLOCK_EXT_PATH in this script."
|
||||
exit 1
|
||||
fi
|
||||
info "✓ uBlock Origin unpacked at $UBLOCK_EXT_PATH"
|
||||
|
||||
REAL_BIN="$(command -v ungoogled-chromium)"
|
||||
LOAD_EXT_FLAG="--load-extension=\"$UBLOCK_EXT_PATH\""
|
||||
|
||||
if grep -q -- "$LOAD_EXT_FLAG" "$REAL_BIN" 2>/dev/null; then
|
||||
info "ungoogled-chromium already wired to load uBlock Origin — skipping."
|
||||
else
|
||||
ORIG_BACKUP="${REAL_BIN}.orig"
|
||||
if file "$REAL_BIN" 2>/dev/null | grep -qi 'text\|script'; then
|
||||
# Real launcher is a shell script (typical for the chromium-launcher
|
||||
# package this .deb depends on) — patch its exec line in place so any
|
||||
# custom flags it already applies (GPU workarounds, profile dir, etc.)
|
||||
# are preserved rather than bypassed by a wrapper.
|
||||
if grep -qE '^exec ' "$REAL_BIN"; then
|
||||
info "Patching exec line in $REAL_BIN to add uBlock Origin..."
|
||||
if [[ ! -f "$ORIG_BACKUP" ]]; then
|
||||
info "Backing up $REAL_BIN → $ORIG_BACKUP"
|
||||
sudo cp -a "$REAL_BIN" "$ORIG_BACKUP"
|
||||
fi
|
||||
sudo sed -i "s|^exec \(.*\) \"\\\$@\"|exec \1 $LOAD_EXT_FLAG \"\\\$@\"|" "$REAL_BIN"
|
||||
info "✓ ungoogled-chromium exec line patched with uBlock Origin"
|
||||
else
|
||||
error "Launcher at $REAL_BIN is a script but has no recognisable 'exec' line — patch it manually."
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# Real launcher is a compiled binary — wrap it instead of patching.
|
||||
info "Wrapping $REAL_BIN with a uBlock Origin loader..."
|
||||
if [[ ! -f "$ORIG_BACKUP" ]]; then
|
||||
sudo cp -a "$REAL_BIN" "$ORIG_BACKUP"
|
||||
fi
|
||||
sudo tee "$REAL_BIN" >/dev/null <<WRAP
|
||||
#!/usr/bin/env bash
|
||||
# __UBLOCK_WRAPPER__ — auto-generated by install_ungoogled_chromium_ubuntu.sh
|
||||
# Original backed up at: $ORIG_BACKUP
|
||||
exec "$ORIG_BACKUP" --load-extension="$UBLOCK_EXT_PATH" "\$@"
|
||||
WRAP
|
||||
sudo chmod +x "$REAL_BIN"
|
||||
info "✓ ungoogled-chromium now always launches with uBlock Origin"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── 3. Pre-enable every uBO filter list ─────────────────────────────────
|
||||
if ! command -v node >/dev/null 2>&1; then
|
||||
warn "node not found — installing via apt (needed for the filter-list seeder)."
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y nodejs npm
|
||||
fi
|
||||
|
||||
if [[ ! -f "$SEEDER_SCRIPT" ]]; then
|
||||
error "Seeder script not found at $SEEDER_SCRIPT — is this repo checkout complete?"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$DIGITAL_WELLBEING_DIR/node_modules/classic-level" ]]; then
|
||||
info "Installing Node deps for the seeder (classic-level)..."
|
||||
npm install --prefix "$DIGITAL_WELLBEING_DIR" 2>&1 | grep -v '^npm warn' || true
|
||||
fi
|
||||
|
||||
info "Launching ungoogled-chromium once to create its profile/extension storage dirs..."
|
||||
"$REAL_BIN" --headless=new --disable-gpu about:blank >/dev/null 2>&1 &
|
||||
BROWSER_PID=$!
|
||||
sleep 4
|
||||
kill "$BROWSER_PID" 2>/dev/null || true
|
||||
wait "$BROWSER_PID" 2>/dev/null || true
|
||||
|
||||
SEED_ARGS=("--ext-path=$UBLOCK_EXT_PATH")
|
||||
[[ "$FORCE" -eq 1 ]] && SEED_ARGS+=(--force)
|
||||
info "Seeding uBlock Origin filter-list selection (all lists)..."
|
||||
node "$SEEDER_SCRIPT" "${SEED_ARGS[@]}"
|
||||
|
||||
cat <<EOF
|
||||
|
||||
${GREEN}Done.${NC} ungoogled-chromium is installed with uBlock Origin always loaded
|
||||
and every filter list selected.
|
||||
|
||||
Note: newly-selected 3rd-party filter lists are only marked *selected* by
|
||||
this seeding step — uBO downloads and compiles their actual content on its
|
||||
own update cycle (~105s) after the next real launch with network access.
|
||||
Launch ungoogled-chromium normally once and give it a couple of minutes
|
||||
before expecting every list to be actively blocking.
|
||||
EOF
|
||||
@ -221,57 +221,6 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test: strip_pkgfile_suffix + is_blocked_package_name correctly recognise a
|
||||
# whitelisted package even when passed as a full `-U <path>.pkg.tar.zst`
|
||||
# argument. Regression test for the 2026-08-12 bug: `yay` always installs a
|
||||
# package it just built via `pacman -U <path>/<pkg>-<ver>-<rel>-<arch>.pkg.tar.zst`,
|
||||
# not the bare name — an exact-match whitelist entry could never match that
|
||||
# filename, silently blocking every AUR package the whitelist was meant to
|
||||
# allow the moment it went through a real `-U` install rather than `-S`.
|
||||
echo "[TEST] Verifying strip_pkgfile_suffix + is_blocked_package_name handle -U package-file arguments..."
|
||||
PACMAN_WRAPPER_FUNC_TEST_SCRIPT="$(mktemp)"
|
||||
FIXTURE_DIR="$(mktemp -d)"
|
||||
trap 'rm -f "$PACMAN_WRAPPER_FUNC_TEST_SCRIPT"; rm -rf "$FIXTURE_DIR"' EXIT
|
||||
|
||||
printf 'chromium\n' >"$FIXTURE_DIR/pacman_blocked_keywords.txt"
|
||||
printf 'ungoogled-chromium-bin\n' >"$FIXTURE_DIR/pacman_whitelist.txt"
|
||||
printf '\n' >"$FIXTURE_DIR/pacman_greylist.txt"
|
||||
|
||||
{
|
||||
cat <<'HEADER'
|
||||
#!/bin/bash
|
||||
set -u
|
||||
load_policy_lists() { :; } # is_blocked_package_name calls this; arrays are pre-seeded below instead
|
||||
HEADER
|
||||
sed -n '/^function strip_pkgfile_suffix/,/^}/p' "$WRAPPER_DIR/pacman_wrapper.sh"
|
||||
sed -n '/^function is_blocked_package_name/,/^}/p' "$WRAPPER_DIR/pacman_wrapper.sh"
|
||||
printf 'BLOCKED_KEYWORDS_LIST=(%s)\n' "$(printf "'%s' " "$(cat "$FIXTURE_DIR/pacman_blocked_keywords.txt")")"
|
||||
printf 'WHITELISTED_NAMES_LIST=(%s)\n' "$(printf "'%s' " "$(cat "$FIXTURE_DIR/pacman_whitelist.txt")")"
|
||||
printf 'GREYLISTED_KEYWORDS_LIST=()\n'
|
||||
cat <<'BODY'
|
||||
echo "$(strip_pkgfile_suffix "ungoogled-chromium-bin-150.0.7871.186-1-x86_64.pkg.tar.zst")"
|
||||
if is_blocked_package_name "ungoogled-chromium-bin-150.0.7871.186-1-x86_64.pkg.tar.zst"; then echo BLOCKED; else echo ALLOWED; fi
|
||||
if is_blocked_package_name "chromium-151.0.7922.108-1-x86_64.pkg.tar.zst"; then echo BLOCKED; else echo ALLOWED; fi
|
||||
BODY
|
||||
} >"$PACMAN_WRAPPER_FUNC_TEST_SCRIPT"
|
||||
|
||||
FUNC_TEST_OUTPUT="$(bash "$PACMAN_WRAPPER_FUNC_TEST_SCRIPT")"
|
||||
EXPECTED_FUNC_TEST_OUTPUT="ungoogled-chromium-bin
|
||||
ALLOWED
|
||||
BLOCKED"
|
||||
|
||||
if [[ "$FUNC_TEST_OUTPUT" == "$EXPECTED_FUNC_TEST_OUTPUT" ]]; then
|
||||
echo "✓ strip_pkgfile_suffix bares -U filenames; whitelisted packages are allowed via -U, non-whitelisted blocked keywords still blocked"
|
||||
else
|
||||
echo "✗ Mismatch:"
|
||||
echo " expected: $EXPECTED_FUNC_TEST_OUTPUT"
|
||||
echo " got: $FUNC_TEST_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
rm -f "$PACMAN_WRAPPER_FUNC_TEST_SCRIPT"
|
||||
rm -rf "$FIXTURE_DIR"
|
||||
trap - EXIT
|
||||
|
||||
echo ""
|
||||
echo "=== All Tests Passed! ==="
|
||||
echo ""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user