summaryrefslogtreecommitdiffstats
path: root/src/watch/upstream.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch/upstream.rs')
-rw-r--r--src/watch/upstream.rs40
1 files changed, 0 insertions, 40 deletions
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()