diff options
| author | Pavel Egorov <[email protected]> | 2026-07-29 03:30:49 +0300 |
|---|---|---|
| committer | Pavel Egorov <[email protected]> | 2026-07-29 03:30:49 +0300 |
| commit | 71034d171fe80d305d766e15ba894de78062cc11 (patch) | |
| tree | 1b0209f66d466d506065250b76f139706e0c63d1 /.config | |
| parent | 6252009efa60f83094318a91be2d627709b1af8d (diff) | |
| download | dotfiles-71034d171fe80d305d766e15ba894de78062cc11.tar.gz dotfiles-71034d171fe80d305d766e15ba894de78062cc11.zip | |
Diffstat (limited to '')
| -rw-r--r-- | .config/yay/hooks/install_log.lua | 30 | ||||
| -rw-r--r-- | .config/yay/hooks/maintainer_change.lua | 75 | ||||
| -rw-r--r-- | .config/yay/hooks/recently_modified.lua | 18 | ||||
| -rw-r--r-- | .config/yay/init.lua | 4 |
4 files changed, 127 insertions, 0 deletions
diff --git a/.config/yay/hooks/install_log.lua b/.config/yay/hooks/install_log.lua new file mode 100644 index 0000000..e07183e --- /dev/null +++ b/.config/yay/hooks/install_log.lua | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | -- Copypasted from https://github.com/Jguer/yay/blob/next/doc/examples/install_log.lua | ||
| 2 | |||
| 3 | |||
| 4 | local log_path = (os.getenv("XDG_STATE_HOME") or (os.getenv("HOME") .. "/.local/state")) .. "/yay/install.log" | ||
| 5 | local log_dir = log_path:match("^(.+)/[^/]+$") | ||
| 6 | |||
| 7 | yay.create_autocmd("PostInstall", { | ||
| 8 | desc = "append every installed/upgraded package to a persistent log", | ||
| 9 | callback = function(event) | ||
| 10 | yay.log.info("install_log: writing to ", log_path) | ||
| 11 | os.execute("mkdir -p " .. log_dir) | ||
| 12 | local f, err = io.open(log_path, "a") | ||
| 13 | if not f then | ||
| 14 | yay.log.warn("install_log: cannot open log file: ", err) | ||
| 15 | return | ||
| 16 | end | ||
| 17 | |||
| 18 | local ts = os.date("%Y-%m-%dT%H:%M:%S") | ||
| 19 | |||
| 20 | for _, pkg in ipairs(event.data.packages) do | ||
| 21 | local upgrade = pkg.local_version ~= "" | ||
| 22 | local action = upgrade and "upgrade" or "install" | ||
| 23 | local version_change = upgrade and (pkg.local_version .. " -> " .. pkg.version) or pkg.version | ||
| 24 | f:write(string.format("%s %-9s %-7s %-14s %-12s %s\n", | ||
| 25 | ts, action, pkg.source, pkg.reason, pkg.name, version_change)) | ||
| 26 | end | ||
| 27 | |||
| 28 | f:close() | ||
| 29 | end, | ||
| 30 | }) | ||
diff --git a/.config/yay/hooks/maintainer_change.lua b/.config/yay/hooks/maintainer_change.lua new file mode 100644 index 0000000..9f8be2d --- /dev/null +++ b/.config/yay/hooks/maintainer_change.lua | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | -- Copypasted from https://github.com/Jguer/yay/blob/next/doc/examples/maintainer_change.lua | ||
| 2 | -- | ||
| 3 | -- Warn when an AUR package's maintainer changes between upgrades. | ||
| 4 | -- | ||
| 5 | -- The known maintainer for each package is stored in a plain text cache file | ||
| 6 | -- inside the yay cache directory (build_dir). On the first upgrade for a | ||
| 7 | -- package the current maintainer is recorded without any warning. On | ||
| 8 | -- subsequent upgrades: | ||
| 9 | -- * same maintainer → debug "match correct" | ||
| 10 | -- * different maintainer → error "new maintainer, double check build files" | ||
| 11 | -- | ||
| 12 | -- The cache is updated whenever a new or changed maintainer is seen. | ||
| 13 | -- | ||
| 14 | -- Cache file location: <cache_dir>/maintainer_cache | ||
| 15 | -- Format: one "pkgname=maintainer" entry per line. | ||
| 16 | |||
| 17 | -- missing reliable cfg getter | ||
| 18 | local cache_dir = (os.getenv("XDG_CACHE_HOME") or (os.getenv("HOME") .. "/.cache")) .. "/yay" | ||
| 19 | local cache_file = cache_dir .. "/maintainer_cache" | ||
| 20 | |||
| 21 | local function load_cache() | ||
| 22 | local cache = {} | ||
| 23 | local f = io.open(cache_file, "r") | ||
| 24 | if not f then return cache end | ||
| 25 | for line in f:lines() do | ||
| 26 | local name, maintainer = line:match("^([^=]+)=(.*)$") | ||
| 27 | if name then | ||
| 28 | cache[name] = maintainer | ||
| 29 | end | ||
| 30 | end | ||
| 31 | f:close() | ||
| 32 | return cache | ||
| 33 | end | ||
| 34 | |||
| 35 | local function save_cache(cache) | ||
| 36 | local f = assert(io.open(cache_file, "w")) | ||
| 37 | for name, maintainer in pairs(cache) do | ||
| 38 | f:write(name .. "=" .. maintainer .. "\n") | ||
| 39 | end | ||
| 40 | f:close() | ||
| 41 | end | ||
| 42 | |||
| 43 | yay.create_autocmd("UpgradeSelect", { | ||
| 44 | desc = "warn on AUR maintainer changes", | ||
| 45 | callback = function(event) | ||
| 46 | yay.log.info("checking for AUR maintainer changes") | ||
| 47 | local cache = load_cache() | ||
| 48 | local dirty = false | ||
| 49 | |||
| 50 | for _, pkg in ipairs(event.data.upgrades) do | ||
| 51 | if pkg.repository == "aur" and pkg.maintainer ~= "" then | ||
| 52 | local cached = cache[pkg.name] | ||
| 53 | if cached == nil then | ||
| 54 | -- First time seeing this package: seed the cache silently. | ||
| 55 | cache[pkg.name] = pkg.maintainer | ||
| 56 | dirty = true | ||
| 57 | elseif cached == pkg.maintainer then | ||
| 58 | yay.log.debug("match correct: " .. pkg.name .. " " .. pkg.maintainer) | ||
| 59 | else | ||
| 60 | yay.log.error("new maintainer, double check build files: ", pkg.name, | ||
| 61 | "(was: " .. cached .. ", now: " .. pkg.maintainer .. ")") | ||
| 62 | cache[pkg.name] = pkg.maintainer | ||
| 63 | dirty = true | ||
| 64 | end | ||
| 65 | end | ||
| 66 | end | ||
| 67 | |||
| 68 | if dirty then | ||
| 69 | yay.log.info("saving maintainer cache:", cache_file) | ||
| 70 | save_cache(cache) | ||
| 71 | end | ||
| 72 | |||
| 73 | return { exclude = {}, skip_menu = false } | ||
| 74 | end, | ||
| 75 | }) | ||
diff --git a/.config/yay/hooks/recently_modified.lua b/.config/yay/hooks/recently_modified.lua new file mode 100644 index 0000000..561d87e --- /dev/null +++ b/.config/yay/hooks/recently_modified.lua | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | -- Copypasted from https://github.com/Jguer/yay/blob/next/doc/examples/recently_modified.lua | ||
| 2 | |||
| 3 | yay.create_autocmd("UpgradeSelect", { | ||
| 4 | desc = "skip recently modified AUR upgrades", | ||
| 5 | callback = function(event) | ||
| 6 | yay.log.info("pre-excluding AUR packages modified in the last 3 days") | ||
| 7 | local exclude = {} | ||
| 8 | local recent_cutoff = os.time() - (3 * 24 * 60 * 60) | ||
| 9 | for _, pkg in ipairs(event.data.upgrades) do | ||
| 10 | if pkg.repository == "aur" and pkg.last_modified >= recent_cutoff then | ||
| 11 | yay.log.warn("pre-excluding recently modified AUR package: ", pkg.name) | ||
| 12 | table.insert(exclude, pkg.name) | ||
| 13 | end | ||
| 14 | end | ||
| 15 | |||
| 16 | return { exclude = exclude, skip_menu = false } | ||
| 17 | end, | ||
| 18 | }) | ||
diff --git a/.config/yay/init.lua b/.config/yay/init.lua index 18c3b97..721762c 100644 --- a/.config/yay/init.lua +++ b/.config/yay/init.lua | |||
| @@ -5,3 +5,7 @@ yay.opt.sudo_loop = true -- Do not expire sudo prompt | |||
| 5 | yay.opt.answer_clean = "None" | 5 | yay.opt.answer_clean = "None" |
| 6 | yay.opt.answer_diff = "All" | 6 | yay.opt.answer_diff = "All" |
| 7 | yay.opt.remove_make = "no" | 7 | yay.opt.remove_make = "no" |
| 8 | |||
| 9 | require("hooks/install_log") | ||
| 10 | require("hooks/recently_modified") | ||
| 11 | require("hooks/maintainer_change") | ||
