summaryrefslogtreecommitdiffstats
path: root/src/watch
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
commit4304b0f336ddba7b4ec6780795059ff2066d105b (patch)
tree10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/watch
parente757979f1a2afdbe7146066345bb9acd19d3b151 (diff)
downloadaur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz
aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound.
Diffstat (limited to 'src/watch')
-rw-r--r--src/watch/detect.rs52
-rw-r--r--src/watch/digests.rs19
-rw-r--r--src/watch/mirror.rs18
-rw-r--r--src/watch/scheduler.rs3
-rw-r--r--src/watch/staleness.rs19
-rw-r--r--src/watch/upstream.rs40
6 files changed, 0 insertions, 151 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index de1285e..800c157 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -8,28 +8,16 @@ use crate::time;
use crate::watch::digests::resolve_sources;
use crate::watch::mirror::{read_tree, sync_mirror, Sync};
-/// What one check of one pkgbase resulted in.
-///
-/// Four variants mirror [`Upsert`] deliberately (n-2): `Upsert` answers the storage
-/// question, `Outcome` the watcher's. `outcome_of` is the only place that knows both.
#[derive(Debug, Clone)]
pub enum Outcome {
NoChange,
- /// The subscription is paused: we look at nothing and change nothing.
Paused,
- /// A new review was opened.
Candidate { id: i64, kind: String },
- /// The open review was updated in place (I7).
Collapsed { id: i64, revision: i64 },
- /// The seen-but-unresolved review was frozen and a new one opened.
Superseded { old: i64, new: i64 },
- /// Identical to something a human already rejected.
PreviouslyRejected,
- /// Something changed but nothing is publishable (I11).
Notice { kind: String, detail: serde_json::Value },
- /// The package vanished from AUR.
Gone,
- /// Detection could not complete; the watcher will back off.
Blocked(String),
}
@@ -40,12 +28,9 @@ pub struct CheckReport {
pub outcome: Outcome,
}
-/// One full detection pass for a subscribed pkgbase.
pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
let pb = get_pkgbase(db, name)?
.ok_or_else(|| crate::error::Error::not_found(format!("pkgbase {name}")))?;
- // A paused subscription is not observed at all: pausing must not keep opening
- // reviews nobody will act on, nor keep polling AUR.
let sub = db::get_subscription(db, name)?;;
let paused = sub.as_ref().map(|s| s.state == SubscriptionState::Paused).unwrap_or(false);
if paused {
@@ -64,8 +49,6 @@ pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
db::set_subscription_state(&db.writer, name, SubscriptionState::Orphaned)?;
return Ok(CheckReport { pkgbase: name.into(), head: String::new(), outcome: Outcome::Gone });
}
- // The cheap poll saved a fetch, but we still have to look: a source can
- // change its bytes without the recipe moving (§5.3).
Sync::Unchanged { head } => head.clone(),
Sync::Fetched { head, .. } | Sync::Cloned { head } => head.clone(),
};
@@ -74,24 +57,16 @@ pub fn check_pkgbase(cfg: &Config, db: &Db, name: &str) -> Result<CheckReport> {
r
}
-/// When to look at this pkgbase again: its own interval if the subscription
-/// carries one, otherwise the global default. The interval is an argument because
-/// the caller already read the subscription row (m-11).
fn schedule_next(db: &Db, name: &str, poll_interval: Option<i64>) {
let interval = poll_interval.unwrap_or_else(|| crate::db::setting_i64(db, "poll_interval", 86400));
let next = time::secs_ahead(interval);
- // Best-effort: a missed stamp means the scheduler looks again a tick early,
- // not that a change goes unnoticed.
let _ = db::note_check(&db.writer, name, &next, None);
}
-/// Everything after the mirror is up to date.
fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckReport> {
let mirror = cfg.mirror_path(&pb.name);
let report = |outcome: Outcome| CheckReport { pkgbase: pb.name.clone(), head: head.to_string(), outcome };
- // §16 mirror divergence: if the accepted pin has vanished from our own
- // mirror, hard-fail this pkgbase rather than silently re-pinning.
let accepted = crate::review::candidates::accepted_for(db, pb)?;
if let Some(a) = &accepted {
if !crate::git::has_commit(&mirror, &a.aur_commit) {
@@ -113,12 +88,8 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
let recipe = recipe_from_tree(&tree.files)?;
let recipe_hash = tree.recipe_hash();
- // §5.2, the two-stage funnel. Stage A is one `ls-remote` per VCS source and
- // costs no clone; if the tip set is what the accepted release was built from,
- // nothing can have changed and Stage B never runs.
let has_vcs = recipe.source_entries.iter().any(|e| e.is_vcs());
let accepted_pins: Vec<UpstreamPin> = accepted.as_ref().map(|a| a.pins()).unwrap_or_default();
- // A recipe with no VCS sources states its own version.
let stage_a = if has_vcs {
Some(crate::watch::upstream::probe(&recipe, &accepted_pins)?)
} else {
@@ -129,8 +100,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
} else if stage_a.as_ref().unwrap().needs_stage_b() {
crate::watch::upstream::resolve(cfg, db, pb, &recipe, &recipe_hash, stage_a.as_ref().unwrap())?
} else {
- // Upstream has not moved; reusing the accepted pins keeps the next pass
- // cheap too.
accepted.as_ref().map(|a| crate::watch::upstream::StageB {
epoch: a.epoch.clone(),
pkgver: a.pkgver.clone(),
@@ -139,8 +108,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
cached: true,
})
};
- // For a VCS package the literal `pkgver=` is frozen; the resolved one is the
- // only version a consumer could install.
let (epoch, pkgver, pkgrel, pins) = match &resolved {
Some(r) => (r.epoch.clone(), r.pkgver.clone(), r.pkgrel.clone(), r.pins.clone()),
None => (recipe.epoch.clone(), recipe.pkgver.clone(), recipe.pkgrel.clone(), Vec::new()),
@@ -176,13 +143,11 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
};
let Some(base) = accepted else {
- // §7.1b: nothing to diff against — this is a first introduction.
let up = upsert_candidate(db, pb, None, &nc)?;
score(db, cfg, pb, &recipe, &digests, None, candidate_id_of(&up));
return Ok(report(outcome_of(up)));
};
- // Same identity as what we already serve: nothing happened.
if base.aur_commit == head
&& base.epoch == nc.epoch
&& base.pkgver == nc.pkgver
@@ -197,8 +162,6 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
let publishable = pkgver::vercmp(&base.version(), &new_version) != std::cmp::Ordering::Equal;
if !publishable {
- // §5.2 / §5.3: nothing pacman could offer as an upgrade. Record it
- // loudly instead of inventing a pkgrel bump.
return Ok(report(non_publishable(db, pb, &base, &nc, &recipe)?));
}
@@ -224,8 +187,6 @@ fn candidate_id_of(up: &Upsert) -> Option<i64> {
}
}
-/// Advisory risk scoring (§6). Best-effort: a scoring failure must never lose a
-/// candidate, so this logs rather than propagates.
fn score(
db: &Db,
cfg: &Config,
@@ -239,13 +200,10 @@ fn score(
if let Ok(a) = crate::review::risk::assess(db, cfg, recipe, digests, accepted) {
let _ = crate::review::candidates::set_risk(db, id, &a.level, &a.signals);
}
- // Record now what would block the build later, using the same rule the plan
- // step uses, so a reviewer sees it before approving (§10.4).
let missing = missing_deps(db, pb, recipe);
let _ = crate::review::candidates::set_missing_deps(db, id, &missing);
}
-/// Dependencies that are ours to publish but are not in the index yet.
fn missing_deps(db: &Db, pb: &Pkgbase, recipe: &Recipe) -> Vec<String> {
let ours = match db::our_package_names(db) {
Ok(o) => o,
@@ -278,8 +236,6 @@ fn outcome_of(up: Upsert) -> Outcome {
}
}
-/// The version string did not move, so there is no review to open — but the change
-/// is recorded, because a silently drifting tarball must not be invisible (§5.3).
fn non_publishable(
db: &Db,
pb: &Pkgbase,
@@ -289,9 +245,6 @@ fn non_publishable(
) -> Result<Outcome> {
let old_digests: Vec<SourceDigest> = base.digests();
let new_digests: Vec<SourceDigest> = serde_json::from_str(&nc.source_digests_json).unwrap_or_default();
- // A local source is part of the recipe: when its bytes move, that *is* the
- // recipe drift. A VCS source's digest is its pin, so upstream moving shows up
- // there too, but that is ordinary drift (§5.3).
let vcs_indices: std::collections::BTreeSet<usize> = recipe
.source_entries
.iter()
@@ -312,9 +265,6 @@ fn non_publishable(
let pins_changed = old_pins != new_pins;
if digest_changed {
- // The single most valuable detection in the system: the artifact in the
- // index was built from bytes upstream no longer serves, and the version is
- // unchanged. An approval would be useless, so this is an alert.
let changed: Vec<serde_json::Value> = changed_remote
.iter()
.map(|n| {
@@ -350,8 +300,6 @@ fn non_publishable(
)?;
return Ok(Outcome::Notice { kind: notice_kind::PIN_DRIFT.into(), detail: serde_json::json!({}) });
}
- // The recipe drifted under a static version: the maintainer probably forgot
- // to bump pkgrel, and the user should know.
db::put_notice_once(
&db.writer,
pb.id,
diff --git a/src/watch/digests.rs b/src/watch/digests.rs
index d3119eb..b95bd6c 100644
--- a/src/watch/digests.rs
+++ b/src/watch/digests.rs
@@ -4,7 +4,6 @@ use crate::error::Result;
use crate::recipe::{declared_sums, is_hex_digest, SKIP};
use crate::watch::mirror::Tree;
-/// Resolve the digest of every `source=()` entry.
pub fn resolve_sources(
cfg: &Config,
db: &Db,
@@ -23,8 +22,6 @@ pub fn resolve_sources(
};
if entry.is_vcs() {
- // The resolved commit *is* the digest; captured during Stage B where
- // we clone anyway (§5.2), so near-free.
let pin = pins.iter().find(|p| p.index == entry.index);
let digest = pin
.map(|p| p.commit.clone())
@@ -36,10 +33,6 @@ pub fn resolve_sources(
kind: entry.vcs.clone().unwrap_or_else(|| "vcs".into()),
digest,
size: 0,
- // Computed from the recipe like every other entry (m-19), not
- // hardcoded: for a VCS source the answer is usually
- // yes-by-absence, so renderers must ask `is_vcs` before calling
- // it a missing checksum.
skip_declared: match declared_sums(recipe, entry.index) {
Some(d) => d == SKIP || !is_hex_digest(&d),
None => true,
@@ -61,8 +54,6 @@ pub fn resolve_sources(
let d = crate::hash::hex(&bytes);
(d, bytes.len() as u64)
}
- // A "local" file that is not in the tree is the recipe's bug;
- // record the absence rather than inventing a digest.
None => (String::new(), 0),
};
out.push(SourceDigest {
@@ -76,9 +67,7 @@ pub fn resolve_sources(
continue;
}
- // Static source.
if !skip_declared {
- // Trusted-as-declared: makepkg verifies it at build time.
out.push(SourceDigest {
index: entry.index,
url: entry.url.clone(),
@@ -90,8 +79,6 @@ pub fn resolve_sources(
continue;
}
- // The paid path: download and stream-hash into the cache, which the
- // build then reuses so the bytes are paid for once.
let (digest, size) = download_and_cache(cfg, db, &entry.url)?;
out.push(SourceDigest {
index: entry.index,
@@ -105,10 +92,6 @@ pub fn resolve_sources(
Ok(out)
}
-/// Download `url`, hashing as we go, and record it in `source_cache`.
-///
-/// This always goes to the network: the point of .5.3 is to notice that the bytes
-/// behind a `SKIP` source changed while the version did not.
pub fn download_and_cache(cfg: &Config, db: &Db, url: &str) -> Result<(String, u64)> {
let tmp = cfg.source_cache_dir().join(format!("tmp-{}", crate::hash::short(url.as_bytes(), 16)));
let (digest, size) = crate::fetch::fetch_to(url, &tmp)?;
@@ -126,8 +109,6 @@ pub fn download_and_cache(cfg: &Config, db: &Db, url: &str) -> Result<(String, u
Ok((digest, size))
}
-/// The cached file holding `digest`, if we still have it. The build uses this
-/// so the bytes it consumes are the bytes that were hashed at detection time.
pub fn cached_path(db: &Db, url: &str, digest: &str) -> Option<std::path::PathBuf> {
db::source_cache_path(db, url, digest)
.ok()
diff --git a/src/watch/mirror.rs b/src/watch/mirror.rs
index b6f9c47..89c175d 100644
--- a/src/watch/mirror.rs
+++ b/src/watch/mirror.rs
@@ -6,21 +6,14 @@ use crate::db::{self, Db};
use crate::error::{Error, Result};
use crate::git;
-/// Result of a cheap poll. `Unchanged` means we did **not** fetch — the poll is
-/// `git ls-remote`, one request per pkgbase (§5.1).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Sync {
- /// Remote is gone (deleted from AUR).
Gone,
- /// `ls-remote` matched the local tip; no fetch performed.
Unchanged { head: String },
- /// The tip moved; we fetched and now have `head`.
Fetched { head: String, previous: Option<String> },
- /// We had no local mirror yet.
Cloned { head: String },
}
-/// Ensure a mirror exists and is polled. Updates `pkgbase.aur_head`.
pub fn sync_mirror(cfg: &Config, db: &Db, name: &str, url: &str) -> Result<Sync> {
let mirror = cfg.mirror_path(name);
let known_head = db::get_pkgbase(db, name)?.and_then(|p| p.aur_head.clone());
@@ -52,15 +45,9 @@ fn record(db: &Db, name: &str, head: &str, mirror: &Path) -> Result<()> {
db::set_aur_head(&db.writer, pb.id, head, &mirror.display().to_string())
}
-/// A materialized snapshot tree: blob ids for hashing, text bodies for parsing
-/// and diffing.
#[derive(Debug, Clone)]
pub struct Tree {
- /// `(path, git blob id)` for every file in the tree — the input to
- /// `recipe_hash`, which covers shipped patches too (§3).
pub blobs: Vec<(String, String)>,
- /// Text bodies, keyed by path. Binary files are omitted here but still
- /// counted in `blobs`.
pub files: BTreeMap<String, String>,
}
@@ -79,10 +66,7 @@ impl Tree {
}
}
-/// Read a commit's tree out of the mirror without touching the network.
pub fn read_tree(mirror: &Path, commit: &str) -> Result<Tree> {
- // §16 mirror divergence: if a pin we are asked to read has vanished, that is
- // a hard failure, not a silent re-pin.
if !git::has_commit(mirror, commit) {
return Err(Error::fail_closed(format!(
"commit {commit} is missing from the local mirror; history was rewritten"
@@ -104,8 +88,6 @@ fn looks_textual(b: &[u8]) -> bool {
!b[..b.len().min(512)].contains(&0)
}
-/// Raw bytes of one file at a commit — used to hash sources shipped in the AUR
-/// repo (§5.3 "local file shipped in the AUR repo").
pub fn read_file(mirror: &Path, commit: &str, path: &str) -> Result<Vec<u8>> {
git::read_blob(mirror, commit, path)
}
diff --git a/src/watch/scheduler.rs b/src/watch/scheduler.rs
index 837a51a..eb79db0 100644
--- a/src/watch/scheduler.rs
+++ b/src/watch/scheduler.rs
@@ -6,7 +6,6 @@ use crate::config::Config;
use crate::db::{self, Db};
use crate::watch::detect::check_pkgbase;
-/// Spawn the watcher tick thread.
pub fn spawn_scheduler(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>) -> JoinHandle<()> {
std::thread::Builder::new()
.name("watcher".into())
@@ -14,7 +13,6 @@ pub fn spawn_scheduler(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>) -> JoinH
while !stop.load(Ordering::SeqCst) {
let tick = crate::db::setting_i64(&db, "poll_tick", 30);
sweep(&cfg, &db);
- // Sleep in small slices so shutdown is prompt.
let mut slept = 0;
while slept < tick && !stop.load(Ordering::SeqCst) {
std::thread::sleep(std::time::Duration::from_secs(1));
@@ -25,7 +23,6 @@ pub fn spawn_scheduler(cfg: Arc<Config>, db: Db, stop: Arc<AtomicBool>) -> JoinH
.expect("spawn watcher")
}
-/// One sweep over everything that is due.
pub fn sweep(cfg: &Config, db: &Db) -> usize {
let now = crate::time::now();
let due = match db::due_subscriptions(db, &now) {
diff --git a/src/watch/staleness.rs b/src/watch/staleness.rs
index 2631769..4e171a1 100644
--- a/src/watch/staleness.rs
+++ b/src/watch/staleness.rs
@@ -3,26 +3,19 @@ use crate::error::Result;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Kind {
- /// A dependency we publish has moved on.
Outdated,
- /// A dependency we publish has disappeared from the index.
Missing,
}
#[derive(Debug, Clone)]
pub struct Stale {
pub kind: Kind,
- /// The pkgbase that would need rebuilding.
pub pkgbase: String,
- /// The dependency, or the pkgbase itself for `Missing`.
pub dependency: String,
- /// Version it was built against.
pub built_with: String,
- /// Version the index serves now (empty when missing).
pub now: String,
}
-/// Every stale package, derived from world snapshots against the live index.
pub fn stale_rows(db: &Db) -> Result<Vec<Stale>> {
let rows = db::published_world_members(db)?;
@@ -30,7 +23,6 @@ pub fn stale_rows(db: &Db) -> Result<Vec<Stale>> {
for (pkgbase, members_json) in rows {
let members: Vec<db::WorldMember> = serde_json::from_str(&members_json).unwrap_or_default();
for m in members {
- // A package is not stale relative to itself.
if m.pkgbase == pkgbase {
continue;
}
@@ -57,15 +49,10 @@ pub fn stale_rows(db: &Db) -> Result<Vec<Stale>> {
Ok(out)
}
-/// Staleness for one pkgbase, rendered for the package page.
pub fn stale_for(db: &Db, pkgbase: &str) -> Result<Vec<Stale>> {
Ok(stale_rows(db)?.into_iter().filter(|s| s.pkgbase == pkgbase).collect())
}
-/// AUR now offers a **lower** version than we serve (§10.2). This is not a build
-/// request; it is an announcement that the mirror and upstream have disagreed.
-///
-/// Derived on read, so it disappears the moment either side moves.
pub fn downgrades(db: &Db) -> Result<Vec<Stale>> {
let rows = db::served_vs_offered_pkgvers(db)?;
let mut out = Vec::new();
@@ -84,18 +71,12 @@ pub fn downgrades(db: &Db) -> Result<Vec<Stale>> {
Ok(out)
}
-/// "If I approve this, what goes stale?" — the dependents question (§10.3).
-/// A package depends on `name` if `name` appears in its recorded world or in
-/// its recipe dependencies.
pub fn dependents_of(db: &Db, name: &str) -> Result<Vec<String>> {
let mut out: Vec<String> = Vec::new();
for (pkgname, json) in db::index_recipes(db)? {
if pkgname == name {
continue;
}
- // A recipe we cannot read is not a recipe that does not depend on
- // `name`: treat the unreadable as a reason to look, so a malformed
- // srcinfo cannot silently hide a dependent package from staleness.
let depends = match serde_json::from_str::<crate::db::model::Recipe>(&json) {
Ok(r) => crate::pkgver::dep_names(&r.depends)
.into_iter()
diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs
index 507d734..2b89238 100644
--- a/src/watch/upstream.rs
+++ b/src/watch/upstream.rs
@@ -9,34 +9,24 @@ use crate::db::{self, model::*, Db, Pkgbase};
use crate::error::{Error, Result};
use crate::git;
-/// What Stage A found.
#[derive(Debug, Clone)]
pub struct StageA {
- /// One pin per VCS source, in `source=()` order.
pub pins: Vec<UpstreamPin>,
- /// URLs we could not probe cheaply (svn, hg, or a dead remote). Treated as
- /// "assume it moved" — we would rather run Stage B than miss a release.
pub unprobed: Vec<String>,
- /// True when the tip set differs from the accepted release's pins.
pub moved: bool,
}
impl StageA {
- /// Stage B is worth running: something upstream moved, or we cannot prove
- /// that nothing did.
pub fn needs_stage_b(&self) -> bool {
self.moved || !self.unprobed.is_empty()
}
}
-/// Probe every VCS source in the recipe. **Every** one, not just the first: a
-/// pkgbase can build from two upstream repos and either can move alone.
pub fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
let mut pins = Vec::new();
let mut unprobed = Vec::new();
for entry in recipe.source_entries.iter().filter(|e| e.is_vcs()) {
let want = if let Some(c) = &entry.commit {
- // Pinned to a commit by the recipe itself: it cannot move.
pins.push(UpstreamPin {
index: entry.index,
url: entry.url.clone(),
@@ -67,13 +57,9 @@ pub fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
branch: entry.branch.clone(),
commit: sha,
}),
- // The remote is gone or the ref vanished: that is movement
- // we must not swallow, and Stage B will report it properly.
None => unprobed.push(entry.url.clone()),
}
}
- // svn/hg/bzr: no cheap universal probe. Be honest about it and let
- // Stage B decide, rather than claiming nothing moved.
Some(other) => {
unprobed.push(format!("{other}:{}", entry.url));
pins.push(UpstreamPin {
@@ -91,15 +77,12 @@ pub fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> {
Ok(StageA { pins, unprobed, moved: now != then })
}
-/// What Stage B produced: the authoritative version plus the pins it was
-/// computed from.
#[derive(Debug, Clone)]
pub struct StageB {
pub epoch: String,
pub pkgver: String,
pub pkgrel: String,
pub pins: Vec<UpstreamPin>,
- /// True when the answer came from the cache instead of a fresh resolution.
pub cached: bool,
}
@@ -108,8 +91,6 @@ impl StageB {
crate::pkgver::full_version(&self.epoch, &self.pkgver, &self.pkgrel)
}
- /// Rebuild an answer from its cache row. The `cached` flag is ours to set:
- /// the row says nothing about how this call got its answer (§6 M-6).
fn from_cache(row: StageBCacheRow) -> Self {
StageB {
epoch: row.epoch,
@@ -120,7 +101,6 @@ impl StageB {
}
}
- /// The row this answer occupies in `stage_b_cache`.
fn as_row(&self) -> StageBCacheRow {
StageBCacheRow {
epoch: self.epoch.clone(),
@@ -131,8 +111,6 @@ impl StageB {
}
}
-/// A process-wide cap on concurrent Stage B resolutions (§5.2). Each one clones
-/// repositories and runs a chroot-less makepkg.
static RUNNING: AtomicUsize = AtomicUsize::new(0);
static SLOT_FREE: Condvar = Condvar::new();
static SLOT_LOCK: Mutex<()> = Mutex::new(());
@@ -140,7 +118,6 @@ static SLOT_LOCK: Mutex<()> = Mutex::new(());
pub struct StageBSlot(());
impl StageBSlot {
- /// Take a Stage B slot, blocking until one is free.
pub fn acquire(cap: usize) -> Self {
let cap = cap.max(1);
let guard = SLOT_LOCK.lock().unwrap_or_else(|e| e.into_inner());
@@ -164,10 +141,6 @@ impl Drop for StageBSlot {
}
}
-/// Stage B: resolve the real `pkgver` for a VCS pkgbase.
-///
-/// `None` means "there is nothing to resolve" — the recipe has no VCS sources,
-/// so the literal `pkgver=` is already the answer.
pub fn resolve(
cfg: &Config,
db: &Db,
@@ -181,15 +154,10 @@ pub fn resolve(
}
let tip_hash = tip_hash(&stage_a.pins);
- // Cache hit: same recipe, same upstream tips. Keyed on
- // (pkgbase, recipe_hash, upstream_tip) exactly as §5.2 asks.
if let Some(hit) = db::stage_b_cache_get(db, pb.id, recipe_hash, &tip_hash)? {
return Ok(Some(StageB::from_cache(hit)));
}
- // Per-pkgbase cooldown: even if the tips moved again, we do not re-resolve the
- // same pkgbase more than once per window, so a chatty upstream cannot turn
- // detection into a build loop.
let cooldown = db::setting_i64(db, "stage_b_cooldown", 86400);
if let Some(recent) = db::stage_b_recent(db, pb.id, cooldown)? {
return Ok(Some(StageB::from_cache(recent)));
@@ -201,7 +169,6 @@ pub fn resolve(
Ok(Some(resolved))
}
-/// The actual work: warm the clone cache, then ask `makepkg` what it computes.
fn run(
cfg: &Config,
pb: &Pkgbase,
@@ -210,8 +177,6 @@ fn run(
tip_hash: &str,
stage_a: &StageA,
) -> Result<StageB> {
- // Clone reuse: fetch into a persistent bare cache rather than re-cloning a
- // multi-gigabyte upstream every day (§5.2).
let mut pins = stage_a.pins.clone();
for pin in &mut pins {
if pin.commit.is_empty() {
@@ -224,8 +189,6 @@ fn run(
} else {
let _ = git::fetch_and_head(&cache);
}
- // The clone is here anyway, so confirm the tip locally: that also proves
- // the commit we probed actually exists and is reachable.
if let Ok(local) = git::head(&cache) {
if !local.is_empty() && git::has_commit(&cache, &pin.commit) {
pin.branch = pin.branch.clone().or_else(|| default_branch(&cache));
@@ -233,8 +196,6 @@ fn run(
}
}
- // Run `makepkg --vercheck` against the recipe in a scratch directory. The
- // real tool clones the sources itself; the shim reports the fixture value.
let scratch = scratch_dir(cfg, &pb.name, recipe_hash, tip_hash);
let _ = std::fs::remove_dir_all(&scratch);
std::fs::create_dir_all(&scratch)?;
@@ -277,7 +238,6 @@ fn default_branch(cache: &std::path::Path) -> Option<String> {
.filter(|s| !s.is_empty())
}
-/// A stable hash of the upstream tip set — the cache key's third component.
pub fn tip_hash(pins: &[UpstreamPin]) -> String {
let mut v: Vec<String> = pins
.iter()