Skip to content

Keep the desktop responsive during AUR source builds - #12778

Open
tedwardd wants to merge 5 commits into
omacom:quattrofrom
tedwardd:fix/aur-update-priority
Open

tedwardd wants to merge 5 commits into
omacom:quattrofrom
tedwardd:fix/aur-update-priority

Conversation

@tedwardd

@tedwardd tedwardd commented Sep 21, 2026 •

Copy link
Copy Markdown

Summary

omarchy-update runs AUR source builds (via yay/makepkg) at default process priority with unbounded build parallelism. A heavy source build — e.g. libsignal-client's cargo + cmake stack — can therefore compete head-to-head with foreground apps for the CPU while it compiles: observed on a 4-thread machine, load average reached ~10, PSI cpu some sat at ~56%, and interactive apps (editor, terminal, compositor) were effectively frozen until the build finished.

This change treats updates as background work: the AUR build step runs at lowered CPU and I/O priority — costless when the machine is otherwise idle — and offers build tools a default job count of half the machine's cores, so a source build stops elbowing interactive apps for the whole machine. The count is delivered through each tool's usual variable (Make, CMake, Cargo) as a default; tools that ignore those variables are not capped, so this is polite backgrounding rather than a hard guarantee.

Changes

  • bin/omarchy-update-aur-pkgs
    • yay now runs under nice -n 15 ionice -c 2 -n 7 (inherited by makepkg, rustc, cc, cmake and ninja)
    • CARGO_BUILD_JOBS and CMAKE_BUILD_PARALLEL_LEVEL default to nproc / 2 (floor 1) via the environment
    • Override the default with OMARCHY_AUR_BUILD_JOBS (validated as a positive integer; non-positive falls back to 1)
  • The selected Make job count is asserted after makepkg loads its configuration. makepkg sources its config after the environment, so the env value alone cannot enforce the cap; the updater hands yay a thin makepkg config (--makepkgconf) that sources the real configuration files from their own paths — $MAKEPKG_CONF (or /etc/makepkg.conf; a makepkgconf saved in yay's own configuration is honored by starting from yay's effective value, yay -Pg), its drop-ins, then the user file — and appends -jN just before any standalone -- (or last), where GNU Make reads the final job option as the effective one regardless of spelling (-jN, -j N, --jobs=N, --jobs N).
  • An exported MAKEFLAGS is preserved: the updater never replaces it, so flags and assignments such as CC=clang survive into makepkg and the cap is appended to whatever is effective after configuration loads. Unrelated Make flags stay intact, relative sources inside a config keep resolving from that file's own path, $MAKEPKG_CONF names the real config path while the real files are sourced, a config file that fails to source (including an unreadable drop-in) still aborts the build as it does without this file, and the temporary config is removed on every exit path.

Testing

  • bash -n syntax check clean.
  • test/shell.d/aur-update-jobs-test.sh (new): mocked-PATH harness with stubbed pacman, omarchy-pkg-aur-accessible, yay and nproc, host-independent by construction (sandboxed user configs override the system file in the merged config's own resolution order; custom MAKEPKG_CONFs fully replace it; default-count checks assert only the appended count). Covers the priority drop (niceness 15 asserted), the env caps (nproc 8 → 4 jobs, floor 1, OMARCHY_AUR_BUILD_JOBS=2 → 2), the one-job override beating every MAKEFLAGS spelling (incl. -j 4, --jobs=4 and a standalone -- section, each smoke-built with real Make), an exported MAKEFLAGS preserved at the yay boundary and capped in the merged config, a non-positive override falling back to one job, an alternate MAKEPKG_CONF file keeping its settings (user file not read on top), a yay-saved makepkgconf honored, relative config includes, $MAKEPKG_CONF companion references, config-error propagation, an unreadable drop-in aborting the load, and the unreachable-AUR skip path.
  • test/shell.d/update-hook-security-test.sh (base): all checks pass — the sudo_options wrapper and || exit 1 coexist with the new invocation.
  • Full ./test/shell and ./test/cli failure sets are identical to the quattro base control on the same machine.
  • Read-only yay -Sua run on a current system reported "there is nothing to do" — no system changes.

@tedwardd
tedwardd force-pushed the fix/aur-update-priority branch from d215af0 to 47a2cc1 Compare September 21, 2026 13:09
@llstrk

llstrk commented Sep 21, 2026

Copy link
Copy Markdown

The advertised Make job cap can be replaced by makepkg configuration.

Verified: starting from niceness 0, the updated invocation and its tested build children run at niceness 15 and best-effort I/O priority 7. Job defaults, the one-job floor, explicit overrides, yay arguments, and skip paths behaved as intended at the yay boundary.

makepkg configuration can override the selected Make job count

At omarchy-update-aur-pkgs:17-21, MAKEFLAGS is supplied only through the environment. Real makepkg 7.1.0 subsequently sources its configuration, which can replace that value:

Synthetic config: MAKEFLAGS="-j4"
OMARCHY_AUR_BUILD_JOBS=1
  updater passes MAKEFLAGS=-j1
    makepkg loads config: MAKEFLAGS=-j4
      Make runs 4 concurrent test jobs, not 1

Impact: users with a configured Make job count do not receive the selected per-update cap, even with an explicit one-job override. Lower priority still applies. This is incomplete parallelism control, not newly introduced oversubscription or a reproduced desktop freeze. With no configured MAKEFLAGS, the new value survives.

Suggested change: apply the selected Make job count after makepkg configuration is loaded, preserving unrelated Make flags, or explicitly document that makepkg configuration takes precedence over this override. A replacement implementation was not tested.

Scope correction: describe these as job-count defaults for cooperating tools, not a guarantee that foreground work retains half the CPU. With all three environment values set for two jobs, the same four-task synthetic workload reached two concurrent jobs through cmake --build, but four through direct Ninja. The priority settings still applied in both cases.


Review information

Test scope: head 47a2cc14e65e0a8bf68bb1f7eab701d3f2d0502c against merge-base 8f324c90b82790d31ab33565441e07cbdb8d2308. Production updater, mocked package/network gates and yay orchestration, real makepkg/Make/CMake/Ninja, and small synthetic jobs. No real AUR compilation or installation, Cargo build, desktop-responsiveness benchmark, or disk-scheduler performance test. Setting priorities does not establish their effect across CPU task groups or storage schedulers.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra initial inspection, independent Fable 5.1 and separate Astra reviews, followed by coordinator verification of claims against source and targeted saved evidence.

@tedwardd

Copy link
Copy Markdown
Author

Resolution of review comment (issuecomment-5768750538)

Both points from the review are addressed in commit a873e0a3 (pushed on top of 47a2cc14).

makepkg configuration overriding the Make job count: omarchy-update-aur-pkgs now hands yay a merged makepkg.conf via --makepkgconf (yay v13 passes this through as makepkg --config). The merged file mirrors makepkg's own resolution order — /etc/makepkg.conf, its makepkg.conf.d drop-ins, then the user file — with the selected MAKEFLAGS= asserted last, so the job count is applied after configuration is loaded instead of being replaced by it. Unrelated make flags are preserved: the effective post-config MAKEFLAGS is computed (env + configs, same ordering makepkg uses) and only the -j token is rewritten, e.g. -j4 --output-sync=recurse → -j1 --output-sync=recurse. The environment values at the yay boundary (MAKEFLAGS, CARGO_BUILD_JOBS, CMAKE_BUILD_PARALLEL_LEVEL) are unchanged.

Verified with the review's exact scenario (user config MAKEFLAGS="-j4", OMARCHY_AUR_BUILD_JOBS=1): running real makepkg with the merged config, a probe PKGBUILD's prepare() recorded MAKEFLAGS=-j1.

Scope correction: the inline comment now describes the count as a job-count default offered to cooperating build tools (Make, Cargo, CMake), not a guarantee that foreground work retains half the CPU.

Tests: new test/shell.d/aur-update-jobs-test.sh — explicit override beats a configured MAKEFLAGS while keeping its flags, half-core default, one-job floor, explicit override, unreachable-AUR skip path. Full ./test/shell failure set is unchanged from the merge base (pre-existing environment-dependent GUI-shell checks); ./test/cli is clean.

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up at head a873e0a3 to the earlier review and the author's reply. Verified: the merged makepkg.conf fixes the reported MAKEFLAGS="-j4" case.

The cap still misses the --jobs=N spelling. Copying the config text into one temporary file also introduces new build failures and hides config errors. The branch now conflicts with quattro.

Earlier claim Status at a873e0a3
Verified priority and job-count behavior Still holds
makepkg configuration can override the Make job count Resolved for -jN configs, still present for --jobs=N and --jobs N
Scope correction (job-count defaults, not a CPU guarantee) Resolved in the code comment; the PR description still makes the old claim (see the note below)

Verified: with real makepkg 7.1.0 and GNU Make 4.4.1, the reported case (user config MAKEFLAGS="-j4", OMARCHY_AUR_BUILD_JOBS=1) now reaches prepare() and build() as -j1 and runs 1 concurrent job. -j4 --output-sync=recurse becomes -j1 --output-sync=recurse. The ~/.makepkg.conf fallback and an unset XDG_CONFIG_HOME also resolve to -j1. yay 13.0.1, the version Omarchy ships, passes --makepkgconf to every makepkg call as --config. yay and the build still run at niceness 15 and best-effort I/O priority 7, the environment values at the yay boundary are unchanged, and the temporary file is removed on exit. The new test passes at this head and fails against both earlier updaters.

The cap only recognizes the -jN spelling

At omarchy-update-aur-pkgs:43-50, only words matching ^-j[0-9]*$ are removed, and the selected -jN is placed first. GNU Make uses the last job option it sees. Measured with OMARCHY_AUR_BUILD_JOBS=1 and a synthetic four-job Makefile:

User config MAKEFLAGS Merge base This head
"-j4" 4 jobs -j1: 1 job
"--jobs=4" 4 jobs -j1 --jobs=4: 4 jobs
"--jobs 4" not run -j1 --jobs 4: 4 jobs
"-j 4" 4 jobs, build succeeds -j1 4: Make stops with No rule to make target '4', makepkg exits 4

Impact: --jobs=$(nproc) is the form the Arch Wiki makepkg page suggests, so users who followed it still get their configured job count, even with an explicit override. A -j 4 config, which built before this PR, now makes Make-based AUR builds fail, because Make treats the leftover 4 as a target.

Suggested change: append the selected option after the retained flags instead of before them. At Make level, -j 4 -j1, --jobs=4 -j1, --jobs 4 -j1 and -j4 --output-sync=recurse -j1 each ran 1 job with exit 0. Alternatively, also strip --jobs[=N] and a separate number after -j or --jobs. A patched updater was not run.

Copying config text into one temporary file changes how makepkg loads it

makepkg sources each config file separately from its own path. At omarchy-update-aur-pkgs:52-66, the files are joined with cat into a mktemp file ending in the MAKEFLAGS= line, and makepkg sources that file instead. Measured with real makepkg 7.1.0, comparing the merge base and this head:

User config Merge base This head
Last line MAKEFLAGS="-j4", no final newline builds, 4 jobs merged value -j4MAKEFLAGS=-j1: Make rejects the -j argument, makepkg exits 4
MAKEFLAGS="-j4", then a last-line comment with no final newline builds, 4 jobs appended MAKEFLAGS becomes part of the comment: 4 jobs, cap not applied
source "$(dirname "${BASH_SOURCE[0]}")/other.conf" included settings present BASH_SOURCE names the temp file, the include is not found, the build runs without its settings
Last line source /missing/path.conf Failed to source error, makepkg exits 6 makepkg exits 0 and builds

In the last two rows the failure does not stop makepkg: it aborts only when sourcing a config file returns non-zero, and the merged file always ends with a successful assignment. A config file that failed to source and stopped the build before is now accepted.

Impact: valid user configs can now fail to build or lose settings, and config errors no longer stop the build. The same joining applies between /etc/makepkg.conf, each drop-in and the user file. That boundary was confirmed from source only.

Suggested change: write the merged file as source '<path>' || return lines for the system file, each drop-in and the user file, followed by the MAKEFLAGS= line. Each file then keeps its own path and line boundaries, and a config file that fails to source still aborts makepkg, as it does today. This approach was not run.

A custom makepkg config is replaced

The merged file always starts from /etc/makepkg.conf and the default user file. makepkg otherwise honors MAKEPKG_CONF, and --config overrides it. With MAKEPKG_CONF pointing to a custom file that sets -j2 and a marker variable, the merge base built with that file (2 jobs, marker set). This head ignored it (-j1, marker unset). yay reads its own config before the command line, so a makepkgconf saved in yay's settings is also replaced by --makepkgconf. The yay part was confirmed from yay 13.0.1 source only.

Impact: users who keep build settings in an alternate makepkg config lose them during omarchy update.

Suggested change: skip the merged config when MAKEPKG_CONF or a yay makepkgconf is set (or start from that file), or note the limitation in the updater comment.

Other notes

Base conflict: the branch conflicts with quattro in bin/omarchy-update-aur-pkgs. #9467, merged after this commit was pushed, changed the same line to yay "${sudo_options[@]}" -Sua ... || exit 1, with a no-update sudo wrapper. A resolution needs to keep both the sudo options and || exit 1, as well as this PR's nice/ionice, environment values and --makepkgconf. One such resolution passed this PR's new test and the base's update-hook-security-test.sh (all 23 checks, matching the base control).

Optional test improvement: in test/shell.d/aur-update-jobs-test.sh:9, skip only prints a line, so the test keeps running. With /etc/makepkg.conf absent (simulated in copies of the updater and test), it printed the SKIP line, then failed the updater hands yay a merged makepkg.conf, and the harness listed the file as both skipped and failed. Other whole-file skips in the repository follow skip with exit 0.

Documentation note: the updated code comment addresses the earlier scope correction, but the PR description still says the change caps parallelism "so foreground work always keeps half the CPU". Its Testing section also says "unchanged yay arguments", which no longer holds now that --makepkgconf is added.


Review information

Test scope: head a873e0a374534c0b012276f7424196a2a22aaefd, compared with the first commit 47a2cc14 and merge base 8f324c90, and checked for conflicts against quattro at 7e8d35ef. Real makepkg 7.1.0 and GNU Make 4.4.1 ran synthetic PKGBUILDs through the unmodified updater. yay was replaced by a stub that passes the config to makepkg as yay 13.0.1's source does. Source was read for pacman 7.1.0 and yay 13.0.1. No real AUR package, Cargo, CMake or Ninja build, and no desktop-responsiveness measurement. The full ./test/shell suite was not re-run.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
AUR source builds like libsignal-client fully saturate small laptops at
default priority. Lower their scheduling (nice 15, ionice best-effort-low)
and cap cargo/cmake parallelism so interactive apps win mid-update.
makepkg sources its configuration after the environment, so a MAKEFLAGS set
in /etc/makepkg.conf or the user makepkg.conf silently replaced the updater's
per-update job cap. Hand yay a merged makepkg.conf that mirrors the system
config, its drop-ins, and the user config, then asserts the selected job
count last while keeping any unrelated make flags. Add shell tests covering
the override, default, one-job floor, and skip paths.
@tedwardd
tedwardd force-pushed the fix/aur-update-priority branch from a873e0a to 9a2d3e4 Compare September 28, 2026 12:42
@tedwardd

Copy link
Copy Markdown
Author

Resolution of the follow-up review (issuecomment-5856697923)

Thanks — the -j 4 break and the config-sourcing regressions were real. Both are fixed on top of a rebase onto quattro (head 9a2d3e46, 2 commits, no conflict). All points, in order:

Cap misses --jobs=N / -j N spellings; -j 4 breaks. Confirmed with GNU Make 4.4.1 (last job option wins: -j4 -j1 → 1 job, exit 0). The merge/replace logic is gone: the merged config now appends -jN last and touches nothing else, so every spelling caps and -j 4 (with its separate 4 argument) survives verbatim. Verified: -j4 --output-sync=recurse -j1, --jobs=4 -j1, -j 4 -j1 each ran 1 job with a four-sleep Makefile and exit 0.

Cat-joining changed how makepkg loads configs; masked errors. The merged config is now a list of source '<real path>' || return lines (system file, its drop-ins, then the user file), each sourced from its own path, followed by the MAKEFLAGS=... append. The no-final-newline garbage, trailing-comment swallowing, and BASH_SOURCE-relative include cases all resolve to their merge-base behavior, and a config file that fails to source still aborts the config load (source ... || return propagates — covered by a test asserting the merged config exits non-zero with a failing user config).

Custom MAKEPKG_CONF / yay makepkgconf replaced. The merged config now honors $MAKEPKG_CONF — it sources that file plus its .d, and only reads the user file when the default /etc/makepkg.conf path is in play, exactly like makepkg's own resolution (test asserts the custom file's settings are kept and its count capped). A makepkgconf saved in yay's own config still takes precedence over the override; that limitation is documented in the updater comment.

Base conflict with quattro (#9467). Branch rebased onto omacom/quattro; resolution keeps the sudo_options wrapper (with the no-update sudo under OMARCHY_SUDO_NO_UPDATE) and || exit 1 alongside the nice/ionice/env values and --makepkgconf. update-hook-security-test.sh passes all checks.

Test skip. skip in the new test now exits 0, matching the repository convention.

PR description. Reworded: the count is a job-count default for cooperating tools, not a guarantee that foreground work keeps half the CPU; the Testing section notes the --makepkgconf adder.

Verification: test/shell.d/aur-update-jobs-test.sh (10 checks — every spelling, MAKEPKG_CONF, relative includes, error propagation, skip path) passes; full ./test/shell + ./test/cli failure sets are byte-identical to the quattro base control on the same machine.

@llstrk

llstrk commented Sep 30, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: a yay-saved makepkgconf is replaced, although the new comment says it takes precedence.

Follow-up at 9a2d3e46 to the earlier review. All earlier findings are resolved except the yay-saved makepkgconf part.

A yay-saved makepkgconf is replaced

yay 13.0.1 reads its saved settings before the command line, so the added --makepkgconf overrides a saved value; lines 36-38 and the PR description say the opposite. Impact: omarchy update builds ignore a saved config.

Suggested change: start from yay's effective value (yay -Pg | jq -r '.makepkgconf // empty', not run) or skip --makepkgconf when one is saved; at minimum, fix both texts.

Reproducer (yay 13.0.1)

A makepkgconf saved in yay's configuration is replaced, not preferred

The updater comment (bin/omarchy-update-aur-pkgs, lines 36-38 at 9a2d3e4) and the PR description say a makepkgconf saved in yay's own configuration "takes precedence over this override, so those builds keep yay's settings". yay 13.0.1 (the version in the Omarchy stable repository) does the opposite: the command-line --makepkgconf the updater adds replaces the saved value, and yay then passes the updater's file to makepkg as --config.

Source (yay v13.0.1): main.go loads config.json (settings.NewConfig, line 70) and init.lua (lua.Load, line 88) before cfg.ParseCommandLine (line 101); pkg/settings/args.go:133-134 sets c.MakepkgConf = value for --makepkgconf; pkg/settings/exe/cmd_builder.go:145-147 passes c.MakepkgConfPath as makepkg --config.

Reproducer

Needs yay 13.0.1. Uses a throwaway XDG_CONFIG_HOME and pacman.conf; yay -Pg only prints the effective configuration and runs no package operation.

#!/bin/bash
set -eu
t=$(mktemp -d)
mkdir -p "$t/db/local" "$t/db/sync" "$t/xdg/yay"
printf '[options]\nRootDir = %s/\nDBPath = %s/db/\nArchitecture = x86_64\nSigLevel = Never\n' "$t" "$t" >"$t/pacman.conf"
printf '{"makepkgconf": "/home/user/my-makepkg.conf"}\n' >"$t/xdg/yay/config.json"
yay -V
show() { XDG_CONFIG_HOME="$t/xdg" yay --config "$t/pacman.conf" -Pg "$@" | grep '"makepkgconf"'; }
echo "saved in config.json:"
show
echo "saved in config.json, plus --makepkgconf as omarchy-update-aur-pkgs passes it:"
show --makepkgconf /tmp/tmp.updater-config
rm -rf "$t"

Actual output

yay v13.0.1 - libalpm v16.0.1
saved in config.json:
	"makepkgconf": "/home/user/my-makepkg.conf",
saved in config.json, plus --makepkgconf as omarchy-update-aur-pkgs passes it:
	"makepkgconf": "/tmp/tmp.updater-config",
exit status: 0

The same happened when the value was saved with yay --makepkgconf <file> --save and when it was set in init.lua (yay.opt.makepkg_conf): with the command-line flag, the effective makepkgconf was the flag's file in every case.

More findings (lower impact, reproduced at 9a2d3e4)

An unreadable drop-in no longer stops makepkg

Lines 46-48 write a source line only for drop-ins that pass [[ -r ]]. makepkg sources every *.conf in the .d directory and stops with Failed to source (exit 6) when one cannot be read. With a mode 000 drop-in, the merge base exited 6; this head built without the drop-in's settings. This contradicts the comment at lines 35-37. It is rare, since package drop-ins are normally 0644.

Suggested change: test [[ -e "$dropin" ]] instead, so makepkg reports the unreadable file as before (a review-only patch did this and kept the PR's 10 checks passing).

A MAKEFLAGS with a -- section now breaks Make builds

Line 57 appends -jN at the very end. For a configured MAKEFLAGS="-j4 -- V=1" (or "-j4 --"), Make reads the appended -j1 as a target and stops with No rule to make target '-j1'. The merge base built with 4 jobs and a873e0a3 with 1. Probably a rare spelling.

Suggested change: insert the job option before the first standalone -- when there is one, and append it otherwise (a review-only patch built every tested spelling with 1 job).

Configs that reference $MAKEPKG_CONF now see the temporary file

makepkg sets MAKEPKG_CONF from --config, so while the real system or custom config, its drop-ins and the user file are sourced, $MAKEPKG_CONF names the updater's temporary file. A custom config ending in source "$MAKEPKG_CONF.local" built at the merge base but made makepkg exit 6 at this head. This is the same class as the BASH_SOURCE case that was fixed. Neither Arch's stock configs nor any makepkg.conf in a GitHub code search uses this form, so it is a low-severity note.

Suggested change: set MAKEPKG_CONF to the real path before the source lines and back to the generated file's path before the MAKEFLAGS line (setting it only at the top makes makepkg re-read the drop-ins and user file after the cap); a review-only patch doing both kept the cap and found the companion file. Or note the limitation in the comment.

The new test fails when the host or caller already sets MAKEFLAGS

The test builds its merged config from the host's /etc/makepkg.conf and drop-ins, and merged_makeflags inherits the caller's environment. When the system config or a drop-in sets MAKEFLAGS="-j8", the merged config correctly yields -j8 -j4, but the test expects -j4 and fails. An exported MAKEFLAGS=-j8 in the shell running the test fails the same way, through the test's own evaluation only.

Suggested change: run merged_makeflags with MAKEFLAGS unset and expect the host's configured value as a prefix, or assert the generated file's structure.

Reproducer: unreadable drop-in

An unreadable drop-in no longer stops makepkg

makepkg 7.1.0 (libmakepkg/util/config.sh, source_makepkg_config) sources every *.conf in $MAKEPKG_CONF.d through source_safe, which stops with Failed to source (exit 6) when a file cannot be read. At 9a2d3e4, bin/omarchy-update-aur-pkgs:46-48 writes a source line only for drop-ins that pass [[ -r "$dropin" ]], so an unreadable drop-in is left out and the build continues without its settings. The updater comment (lines 35-37) says files that fail to source still abort makepkg as they would without this config.

Reproducer (PR test style)

Append to test/shell.d/aur-update-jobs-test.sh and run bash test/shell.d/aur-update-jobs-test.sh as a non-root user (root can read a mode 000 file):

# makepkg sources every *.conf drop-in and stops with "Failed to source" when
# one cannot be read; the merged config should keep that behavior.
write_stub omarchy-pkg-aur-accessible 'exit 0'
dropin_conf="$test_tmp/dropin-makepkg.conf"
cp "$custom_conf" "$dropin_conf"
mkdir -p "$dropin_conf.d"
printf 'OMARCHY_PROBE_DROPIN=1\n' >"$dropin_conf.d/10-private.conf"
chmod 000 "$dropin_conf.d/10-private.conf"
run_updater 1 8 "$dropin_conf"
set +e
bash --noprofile --norc -c 'source "$1" || exit 7' _ "$merged_config"
dropin_status=$?
set -e
chmod 644 "$dropin_conf.d/10-private.conf"
(( dropin_status == 7 )) || fail "an unreadable drop-in still aborts the config load" "got: $dropin_status"
pass "an unreadable drop-in still aborts the config load"

Actual output at 9a2d3e4

Run with a stock pacman 7.1.0 makepkg.conf (no MAKEFLAGS) standing in for /etc/makepkg.conf; stdout and stderr combined.

ok - explicit one-job override beats a configured MAKEFLAGS while keeping its flags
ok - a --jobs=N configuration is capped by the appended count
ok - a spaced -j N configuration is capped without breaking its argument
ok - default job count caps at half the cores
ok - job count floors at one job on a single-core machine
ok - OMARCHY_AUR_BUILD_JOBS overrides the default half-core count
ok - an alternate MAKEPKG_CONF file keeps its settings and is capped
ok - relative sources inside a user config keep resolving from that file
/tmp/tmp.JTwINeMhey/config/pacman/makepkg.conf: line 1: /missing/path.conf: No such file or directory
ok - a failing user config still aborts the build config load
ok - AUR updates are skipped when the AUR is unreachable
got: 0
not ok - an unreadable drop-in still aborts the config load
exit status: 1

End to end with real makepkg 7.1.0

Setup: a drop-in makepkg.conf.d/30-private.conf with mode 000, OMARCHY_AUR_BUILD_JOBS=1, and yay replaced by a stub that runs makepkg as yay 13.0.1 does. At the merge base 97a9fce, makepkg printed these two lines and exited 6, and the updater exited 1:

/tmp/work/mp/lib/util/util.sh: line 108: /tmp/work/sys/makepkg.conf.d/30-private.conf: Permission denied
==> ERROR: Failed to source /tmp/work/sys/makepkg.conf.d/30-private.conf

At 9a2d3e4 the generated config had no line for the drop-in. build() ran, makepkg exited 0, and the drop-in's settings were absent.

With [[ -r "$dropin" ]] changed to [[ -e "$dropin" ]] (not part of the PR; review-only patch), makepkg again exited 6 in the same setup, and the PR's 10 checks plus this block passed.

Reproducer: -- section in MAKEFLAGS

A MAKEFLAGS with a -- section now breaks Make builds

GNU Make reads the words after a standalone -- in MAKEFLAGS as variable definitions or targets. At 9a2d3e4, bin/omarchy-update-aur-pkgs:57 appends the job option at the very end, so for a configured MAKEFLAGS="-j4 -- V=1" (or "-j4 --") the appended -j1 lands after the --, and Make treats it as a target. The same configs built at the merge base and at the earlier head a873e0a.

Reproducer (PR test style)

Append to test/shell.d/aur-update-jobs-test.sh and run bash test/shell.d/aur-update-jobs-test.sh:

# GNU Make treats words after "--" in MAKEFLAGS as variable definitions or
# targets, so a job option appended after them is not read as an option.
write_stub omarchy-pkg-aur-accessible 'exit 0'
cat >"$config_home/pacman/makepkg.conf" <<'CONF'
MAKEFLAGS="-j4 -- V=1"
CONF
run_updater 1 8
makeflags=$(merged_makeflags "$merged_config")
printf 'all:\n\t@echo built\n' >"$test_tmp/Makefile"
make_output=$(MAKEFLAGS="$makeflags" make -f "$test_tmp/Makefile" 2>&1) ||
  fail "a MAKEFLAGS with a -- section still builds" "MAKEFLAGS=$makeflags"$'\n'"$make_output"
pass "a MAKEFLAGS with a -- section still builds"

Actual output at 9a2d3e4

Run with a stock pacman 7.1.0 makepkg.conf (no MAKEFLAGS) standing in for /etc/makepkg.conf; GNU Make 4.4.1; stdout and stderr combined.

ok - explicit one-job override beats a configured MAKEFLAGS while keeping its flags
ok - a --jobs=N configuration is capped by the appended count
ok - a spaced -j N configuration is capped without breaking its argument
ok - default job count caps at half the cores
ok - job count floors at one job on a single-core machine
ok - OMARCHY_AUR_BUILD_JOBS overrides the default half-core count
ok - an alternate MAKEPKG_CONF file keeps its settings and is capped
ok - relative sources inside a user config keep resolving from that file
/tmp/tmp.XpCguwPozH/config/pacman/makepkg.conf: line 1: /missing/path.conf: No such file or directory
ok - a failing user config still aborts the build config load
ok - AUR updates are skipped when the AUR is unreachable
MAKEFLAGS=-j4 -- V=1 -j1
make: *** No rule to make target '-j1'.  Stop.
not ok - a MAKEFLAGS with a -- section still builds
exit status: 1

End to end with real makepkg 7.1.0 and GNU Make 4.4.1

User config MAKEFLAGS="-j4 -- OMARCHY_MAKEVAR=1", OMARCHY_AUR_BUILD_JOBS=1, six-target Makefile run from build():

Revision MAKEFLAGS in build() Make result
merge base 97a9fce -j4 -- OMARCHY_MAKEVAR=1 4 concurrent jobs, exit 0
earlier head a873e0a -j1 -- OMARCHY_MAKEVAR=1 1 job, exit 0
head 9a2d3e4 -j4 -- OMARCHY_MAKEVAR=1 -j1 No rule to make target '-j1', exit 2

MAKEFLAGS="-j4 --" gave the same exit 2 at the head. MAKEFLAGS="-j4 OMARCHY_MAKEVAR=1" (no --) was capped to 1 job and built.

A review-only patch that inserts the job option before the first standalone -- when there is one (and appends it otherwise) built every spelling tested (-j4, --jobs=4, --jobs 4, -j 4, -j4 --output-sync=recurse, --jobs, -j4 -- V=1, -j4 --) with 1 job, and the PR's 10 checks plus this block passed.

Reproducer: $MAKEPKG_CONF reference

Inside the generated config, $MAKEPKG_CONF names the temporary file

makepkg 7.1.0 sets MAKEPKG_CONF from --config (makepkg.sh.in:994) and sources the config with that variable in scope (libmakepkg/util/config.sh.in:35-39, 68-78). At 9a2d3e4 the updater passes its temporary file as --config. So while the real system or custom config, its drop-ins and the user file are sourced from that file, $MAKEPKG_CONF is the temporary path, not the real config path. A config that finds a companion file through the variable now looks next to the temporary file.

Reproducer (PR test style)

Append to test/shell.d/aur-update-jobs-test.sh and run bash test/shell.d/aur-update-jobs-test.sh. The MAKEPKG_CONF="$merged_config" prefix models what makepkg does with --config.

# makepkg sets MAKEPKG_CONF to its --config file before sourcing it, and a
# config can locate a companion file through that variable.
write_stub omarchy-pkg-aur-accessible 'exit 0'
companion_conf="$test_tmp/companion-makepkg.conf"
printf 'source "$MAKEPKG_CONF.local"\n' >"$companion_conf"
printf 'OMARCHY_PROBE_COMPANION=1\n' >"$companion_conf.local"
run_updater 1 8 "$companion_conf"
companion_seen=$(MAKEPKG_CONF="$merged_config" bash --noprofile --norc -c \
  'source "$1" && printf "%s" "${OMARCHY_PROBE_COMPANION-}"' _ "$merged_config" 2>&1) || true
[[ $companion_seen == "1" ]] || fail "a config that finds files through \$MAKEPKG_CONF still finds them" "got: $companion_seen"
pass "a config that finds files through \$MAKEPKG_CONF still finds them"

Actual output at 9a2d3e4

Run with a stock pacman 7.1.0 makepkg.conf (no MAKEFLAGS) standing in for /etc/makepkg.conf; stdout and stderr combined.

ok - explicit one-job override beats a configured MAKEFLAGS while keeping its flags
ok - a --jobs=N configuration is capped by the appended count
ok - a spaced -j N configuration is capped without breaking its argument
ok - default job count caps at half the cores
ok - job count floors at one job on a single-core machine
ok - OMARCHY_AUR_BUILD_JOBS overrides the default half-core count
ok - an alternate MAKEPKG_CONF file keeps its settings and is capped
ok - relative sources inside a user config keep resolving from that file
/tmp/tmp.gyfxFuwpSW/config/pacman/makepkg.conf: line 1: /missing/path.conf: No such file or directory
ok - a failing user config still aborts the build config load
ok - AUR updates are skipped when the AUR is unreachable
got: /tmp/tmp.gyfxFuwpSW/companion-makepkg.conf: line 1: /tmp/tmp.gyfxFuwpSW/merged-makepkg.conf.local: No such file or directory
not ok - a config that finds files through $MAKEPKG_CONF still finds them
exit status: 1

(In the real updater the temporary file is a mktemp name such as /tmp/tmp.XXXXXXXXXX; the test copies it to merged-makepkg.conf.)

End to end with real makepkg 7.1.0

yay replaced by a stub that runs makepkg as yay 13.0.1 does; OMARCHY_AUR_BUILD_JOBS=1.

Setup Merge base 97a9fce Head 9a2d3e4
Custom MAKEPKG_CONF whose last line is source "$MAKEPKG_CONF.local" (.local sets a marker and MAKEFLAGS="-j2") builds, marker set, 2 jobs makepkg exit 6 (log below), updater exit 1
Same line followed by another setting builds, marker set, 2 jobs the same No such file or directory line, then builds without the .local settings (marker unset, -j1 -j1, 1 job)
System config ending if [[ -r $MAKEPKG_CONF.local ]]; then source "$MAKEPKG_CONF.local"; fi marker set silently skipped, marker unset
Recorded $MAKEPKG_CONF while system file, drop-in and user file are sourced /etc/makepkg.conf stand-in for all three the temporary file for all three
Exported custom MAKEPKG_CONF, value seen by a child process of build() the custom file the temporary file

makepkg log lines at the head for the first row (sandbox paths from the run):

/tmp/work/cases/head/Q1a/custom/c.conf: line 163: /tmp/work/tmp/tmp.YlRFrx9T5Z.local: No such file or directory
==> ERROR: Failed to source /tmp/work/tmp/tmp.YlRFrx9T5Z
Reproducer: test with host MAKEFLAGS

The new test fails when the host or caller already sets MAKEFLAGS

test/shell.d/aur-update-jobs-test.sh builds its merged config from the host's /etc/makepkg.conf and /etc/makepkg.conf.d/*.conf, and merged_makeflags (lines 75-77) evaluates it in a shell that inherits the caller's environment. The default-count checks (lines 110-127) expect exactly -j4, -j1 and -j2. When the system config, a drop-in or the caller's environment sets MAKEFLAGS (the Arch Wiki's makepkg page suggests setting it in makepkg.conf), the appended count follows that value and the file fails, although the updater behaves correctly.

Reproducer

On a machine whose /etc/makepkg.conf sets no MAKEFLAGS:

MAKEFLAGS=-j8 bash test/shell.d/aur-update-jobs-test.sh

Actual output at 9a2d3e4

Run with a stock pacman 7.1.0 makepkg.conf (no MAKEFLAGS) standing in for /etc/makepkg.conf; stdout and stderr combined.

ok - explicit one-job override beats a configured MAKEFLAGS while keeping its flags
ok - a --jobs=N configuration is capped by the appended count
ok - a spaced -j N configuration is capped without breaking its argument
got: -j8 -j4
not ok - default job count is half the cores
exit status: 1

The same two failing lines appeared, with an empty environment, when the stand-in system config ended with MAKEFLAGS="-j8", and when a drop-in in its .d directory set MAKEFLAGS="-j8". For the updater, -j8 -j4 is the correct result (Make uses the last job option); only the test's expectation is host-dependent.

Details

Verified at 9a2d3e46 with real makepkg 7.1.0 and GNU Make 4.4.1 (yay replaced by a stub that calls makepkg as yay 13.0.1 does, synthetic system config):

  • With OMARCHY_AUR_BUILD_JOBS=1, user configs -j4, --jobs=4, --jobs 4, -j 4, -j4 --output-sync=recurse and bare --jobs each ran 1 job; -j 4 builds again.
  • A last line without a final newline, a trailing comment, a BASH_SOURCE-relative include and a failing source on the last line behave as at the merge base (the failing source again makes makepkg exit 6 and the updater exit 1).
  • A custom MAKEPKG_CONF keeps its settings and drop-ins, the user file is not read on top of it, and the job count is capped.
  • yay and build() run at niceness 15 and best-effort I/O priority 7; the temporary file is removed after success, a yay failure, and TERM, INT or HUP.
  • sudo_options and || exit 1 are kept after the rebase; update-hook-security-test.sh passes 23/23 at head and base. The new test fails against the a873e0a3 updater.

Optional notes:

  • OMARCHY_AUR_BUILD_JOBS=0 produces -j0, which Make rejects (the '-j' option requires a positive integer argument); validating a positive integer would avoid it.
  • The test does not check nice/ionice (a mutant without them passes all 10 checks), although the PR's Testing section lists "the priority drop". The comment at test lines 131-132 says the user file is not read with a custom MAKEPKG_CONF, but the user file is empty at that point, so a mutant that reads it also passes.
  • bin/omarchy-update-aur-pkgs loses its final newline and the new test has none; every file in bin/ on the base branch quattro ends with one.

Review information

Test scope: source and sandbox runs at 9a2d3e46 with real makepkg 7.1.0 and GNU Make 4.4.1; no real AUR build.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

A makepkgconf saved in yay's own configuration was silently replaced by the
merge config, contradicting the comment. Start it from yay's effective value
(yay -Pg) when one is saved. Restore  to the real config path
while the real files are sourced so companion-file references keep working,
and to the generated path afterwards. Emit source lines for drop-ins by
existence so an unreadable one still aborts the load as makepkg does, insert
the job option before a standalone -- section instead of appending after it
(Make reads post--- words as targets), fall back to one job for a
non-positive OMARCHY_AUR_BUILD_JOBS, and harden the tests (niceness check,
yay -Pg stub, make smoke tests, host-independent MAKEFLAGS assertions).
@tedwardd

tedwardd commented Oct 1, 2026

Copy link
Copy Markdown
Author

Resolution of review 5920132399

All findings addressed in commit e08a7dbb (pushed on top of 9a2d3e46), with tests for each.

yay-saved makepkgconf replaced (the main finding). Correct — yay 13.0.1 merges config.json/init.lua before the command line, so --makepkgconf replaced a saved value, and my comment/description had it backwards. The updater now starts from yay's effective value — yay -Pg | jq -r '.makepkgconf // empty' — and uses that file as the configuration base (source it + its drop-ins, no user file on top, cap appended last), mirroring yay's own precedence. Test: a saved config with its own -j2 + marker is sourced, capped (-j2 -j1) and the marker is set. The comment and PR description now describe honoring rather than precedence.

Unreadable drop-in no longer stops makepkg. The merged config now emits source lines by existence ([[ -e ]]) rather than readability, so a mode-000 drop-in fails the load exactly as makepkg's source_safe does (exit 6, updater exit 1). Test asserts the merged config exits non-zero (unprivileged; skip under root, which can read such files).

MAKEFLAGS with a -- section. The job option is now inserted before the first standalone -- (-j4 -- V=1 → -j4 -j1 -- V=1), so Make never reads -j1 as a target, and the append order is unchanged otherwise. Covered by a unit assertion plus a real-Make smoke build of the merged value.

Configs that reference $MAKEPKG_CONF. The merged config sets MAKEPKG_CONF to the real config path before the source lines and back to the generated file's path before the cap, so source "$MAKEPKG_CONF.local" companions resolve as at the merge base while makepkg's later reads keep seeing the file it was handed. Test included.

Optional notes. OMARCHY_AUR_BUILD_JOBS is now validated as a positive integer (0 or non-numeric falls back to 1). The test asserts niceness 15 at the yay boundary, and the custom-MAKEPKG_CONF case now plants a user config with a marker to prove it is not read on top. MAKEFLAGS assertions in the test clear the caller's environment and match the trailing count so host-configured MAKEFLAGS (system file or drop-in) cannot flip the result. Both files end with a trailing newline.

Verification: 16/16 checks in aur-update-jobs-test.sh pass (run as this machine's unprivileged user, which also exercises the unreadable-drop-in branch); update-hook-security-test.sh passes 23/23 with the yay -Pg probe in place; full ./test/shell failure set is byte-identical to the quattro base control; ./test/cli matches the base's exit status.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Changes how AUR package builds are scheduled on the system.

The PR appears safe to merge based on the findings eligible for this review.

Summary

The PR lowers the scheduling priority of AUR updates and supplies default build-job counts to cooperating tools.

  • It generates a temporary makepkg configuration to apply the Make job count after existing configuration loads.
  • The latest revision removes a production test hook and changes the test fixture to exercise exported Make flags through a custom configuration.

Reviews (3) · Last reviewed commit: "Keep test hooks out of the production up..."

Comment thread bin/omarchy-update-aur-pkgs Resolved
Comment thread test/shell.d/aur-update-jobs-test.sh Resolved
The updater replaced an exported MAKEFLAGS with -jN at the yay boundary,
even when no makepkg config assigns one, dropping flags and variable
assignments such as CC=clang. Stop setting MAKEFLAGS on the invocation: the
merged config already appends the cap to whatever survives into makepkg
(exported value, then any config assignment), so an export is preserved and
still capped. Point the system makepkg config at TEST_MAKEPKG_CONF when set
so the tests run from a sandbox config instead of skipping on hosts without
a readable /etc/makepkg.conf, and add a test asserting the exported value
reaches the yay boundary and the merged config unchanged.
Comment thread bin/omarchy-update-aur-pkgs Resolved
A TEST_MAKEPKG_CONF honored by the updater could leak into real updates when
inherited: a readable test path would load the wrong configuration, and an
unreadable one would skip the cap even when /etc/makepkg.conf is usable.
Drop the hook; the test suite is hermetic by construction instead, with
sandboxed user configs overriding the system file in the merged config's own
resolution order and a custom MAKEPKG_CONF driving the exported-flags case,
so nothing test-only exists in production code paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants