summaryrefslogtreecommitdiffstats
path: root/src/pipeline/publish.rs
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/pipeline/publish.rs
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/pipeline/publish.rs')
-rw-r--r--src/pipeline/publish.rs61
1 files changed, 0 insertions, 61 deletions
diff --git a/src/pipeline/publish.rs b/src/pipeline/publish.rs
index 7340e53..dc9f918 100644
--- a/src/pipeline/publish.rs
+++ b/src/pipeline/publish.rs
@@ -9,15 +9,6 @@ use crate::error::{Error, Result};
use crate::pipeline::{Collect, Ctx};
use crate::time;
-/// One writer to the served repo at a time — *the* serialization guarantee for
-/// the index (§8.2, §9, I4). A publish renders a new database in scratch space,
-/// commits the DB, then renames over the live one; a second writer interleaving
-/// anywhere in that sequence produces an index matching neither DB state. Held by
-/// [`publish`] and [`withdraw_package`] for the whole sequence; [`reconcile`] skips
-/// it because it runs before the dispatcher exists.
-///
-/// A panic while holding it is recovered rather than propagated: atomic publish
-/// means a poisoned lock cannot have left a half-written database.
static REPO_LOCK: Mutex<()> = Mutex::new(());
fn lock_repo() -> std::sync::MutexGuard<'static, ()> {
@@ -27,7 +18,6 @@ fn lock_repo() -> std::sync::MutexGuard<'static, ()> {
}
}
-/// The world a build is admitted against: every pkgbase's accepted version.
pub fn index_world(db: &Db) -> Result<Vec<WorldMember>> {
let rels = db::all_published_releases(db)?;
let mut out = Vec::new();
@@ -40,8 +30,6 @@ pub fn index_world(db: &Db) -> Result<Vec<WorldMember>> {
Ok(out)
}
-/// Package files that belong in the served index right now, plus the extra ones
-/// being published (not in the DB yet when the new index is rendered).
fn index_artifacts(db: &Db, extra: &[PathBuf]) -> Result<Vec<PathBuf>> {
let mut out: Vec<PathBuf> = Vec::new();
for p in db::index_packages(db)? {
@@ -55,9 +43,6 @@ fn index_artifacts(db: &Db, extra: &[PathBuf]) -> Result<Vec<PathBuf>> {
Ok(out)
}
-/// Publish the collected artifacts of a build. Returns the new release id.
-///
-/// Serialized against every other writer of the index by [`REPO_LOCK`].
pub fn publish(ctx: &Ctx) -> Result<i64> {
let _guard = lock_repo();
let collect = Collect::load(&ctx.collect_path)?;
@@ -68,13 +53,8 @@ pub fn publish(ctx: &Ctx) -> Result<i64> {
let arch_dir = ctx.cfg.repo_arch_dir();
std::fs::create_dir_all(&arch_dir)?;
- // Artifacts are copied into the served tree under their real filenames.
let mut staged: Vec<(PathBuf, PathBuf)> = Vec::new();
- // Set once the render starts, so the failure path can sweep the scratch
- // directory even if the publish died after repo-add returned.
let mut scratch_dir: Option<PathBuf> = None;
- // Files this publish created that were not there before: if the publish does
- // not land they are orphans no index names (§6 m-16).
let mut fresh: Vec<PathBuf> = Vec::new();
for p in &collect.packages {
let from = PathBuf::from(&p.path);
@@ -106,7 +86,6 @@ pub fn publish(ctx: &Ctx) -> Result<i64> {
pkgs = dedupe_by_name(pkgs);
let rendered = render_db(&ctx.cfg, &arch_dir, "publish", &pkgs, &mut scratch_dir)?;
- // Fault injection so I4 can be tested for real (§6 M-9).
#[cfg(feature = "test-support")]
if ctx.cfg.hooks.publish_fault.as_deref() == Some("before-rename") {
return Err(Error::other("injected fault: before-rename"));
@@ -141,8 +120,6 @@ pub fn publish(ctx: &Ctx) -> Result<i64> {
})();
if outcome.is_err() {
- // Nothing in the served tree may look like a publish that did not land
- // (m-16); files already there belong to the release still served.
for p in &fresh {
let _ = std::fs::remove_file(p);
}
@@ -158,7 +135,6 @@ fn repo_for(db: &Db) -> Result<String> {
Ok(id.to_string())
}
-/// Insert the release and its package rows, and move the accepted pointer.
fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> {
let at = time::now();
let pkgbase_id = ctx.pb.id;
@@ -167,8 +143,6 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> {
Some(cid) => crate::review::approve::approval_for(&ctx.db, cid)?.map(|(id, _)| id),
None => None,
};
- // I1: nothing publishes without an approval. A manual rebuild inherits the
- // approval of the release it rebuilds.
let inherited = match ctx.build.kind.as_str() {
"manual_rebuild" => ctx
.build
@@ -193,8 +167,6 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> {
.flatten()
.and_then(|b| b.world_snapshot_id);
let repo_id = db::repo_id(&ctx.db)?;
- // The compare-and-swap baseline is the release the *approval* was taken
- // against, not whatever the pointer says now.
let expected_base: Option<i64> = match ctx.build.kind.as_str() {
"manual_rebuild" => ctx.build.release_id,
_ => ctx
@@ -205,15 +177,12 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> {
};
ctx.db.writer.tx(move |tx| {
- // Compare-and-swap inside the write transaction (I4).
let actual_base = db::accepted_pointer_in(tx, pkgbase_id)?;
if actual_base != expected_base {
return Err(Error::conflict(
"accepted pointer moved while this build was running; refusing to publish",
));
}
- // The index holds exactly the accepted pointer, so what it held for these
- // names goes before the new rows go in.
db::remove_index_packages_in(tx, &names)?;
let release_id = db::insert_release_in(
tx,
@@ -249,8 +218,6 @@ fn commit_release(ctx: &Ctx, collect: &Collect) -> Result<i64> {
})
}
-/// Remove scratch directories a crash left behind: the leading dot means nothing
-/// a consumer asks for, and only a render creates one.
pub fn sweep_render_dirs(arch_dir: &Path) {
let Ok(entries) = std::fs::read_dir(arch_dir) else {
return;
@@ -262,7 +229,6 @@ pub fn sweep_render_dirs(arch_dir: &Path) {
}
}
-/// A database repo-add has rendered, and the scratch directory it rendered into.
struct Rendered {
db: PathBuf,
dir: PathBuf,
@@ -270,8 +236,6 @@ struct Rendered {
}
impl Rendered {
- /// The publish point: rename over the live database, fsync the directory
- /// entry, then drop the scratch directory.
fn swap_into(self, final_db: &Path) -> Result<()> {
std::fs::rename(&self.db, final_db)?;
fsync_dir(&self.arch_dir)?;
@@ -280,15 +244,6 @@ impl Rendered {
}
}
-/// Render a fresh database with repo-add, ready to be renamed into place.
-///
-/// repo-add refuses any database argument that is not a name pacman itself would
-/// accept, so the render happens in a scratch directory *under* the served
-/// directory, under the exact name a consumer will download. Same filesystem, so
-/// the caller's `rename` is still the atomic swap I4 requires.
-///
-/// `scratch` is filled in as soon as the directory exists, so the caller can sweep
-/// it even if this function is never reached again.
fn render_db(
cfg: &Config,
arch_dir: &Path,
@@ -316,8 +271,6 @@ fn render_db(
Ok(rendered)
}
-/// `repo-add -R <db> <pkgs...>`, deliberately *not* `-s`: repo-add would sign into
-/// scratch space that gets deleted. The hub signs the live file itself in [`sign`].
fn run_repo_add(cfg: &Config, db_path: &Path, pkgs: &[PathBuf]) -> Result<()> {
let mut cmd = Command::new(&cfg.repo_add_bin);
cmd.arg("-R");
@@ -344,8 +297,6 @@ fn sign(cfg: &Config, path: &Path) -> Result<()> {
sign_to(cfg, path, Path::new(&sig))
}
-/// `gpg --detach-sign` over `path`, written to `sig_out` atomically. The key never
-/// leaves the hub — a build sandbox signs nothing (§8).
pub(crate) fn sign_to(cfg: &Config, path: &Path, sig_out: &Path) -> Result<()> {
if cfg.signing_key_id.is_empty() {
return Ok(());
@@ -368,8 +319,6 @@ pub(crate) fn sign_to(cfg: &Config, path: &Path, sig_out: &Path) -> Result<()> {
Ok(())
}
-/// fsync, and *say so* when it fails (m-7). Swallowing the error would make the
-/// write-scratch-fsync-rename promise a comment rather than a guarantee.
fn fsync_file(p: &Path) -> Result<()> {
let f = std::fs::File::open(p)
.map_err(|e| Error::other(format!("open {} for fsync: {e}", p.display())))?;
@@ -386,9 +335,6 @@ fn fsync_dir(p: &Path) -> Result<()> {
Ok(())
}
-
-/// Keep one entry per package name; the newest file wins. The name comes from
-/// `.PKGINFO`, not the filename, because package names contain dashes.
fn dedupe_by_name(paths: Vec<PathBuf>) -> Vec<PathBuf> {
let mut seen: BTreeSet<String> = BTreeSet::new();
let mut out: Vec<PathBuf> = Vec::new();
@@ -406,10 +352,6 @@ fn dedupe_by_name(paths: Vec<PathBuf>) -> Vec<PathBuf> {
out
}
-/// The package name a built artifact declares, read from its own `.PKGINFO`.
-///
-/// The name that goes into the index must come from the same read of the bytes the
-/// pipeline signs, so this uses the real parser (§6 M-4).
fn package_name(path: &Path) -> Option<String> {
let bytes = std::fs::read(path).ok()?;
let info = crate::pkginfo::pkginfo_text(&bytes).ok()?;
@@ -421,8 +363,6 @@ fn package_name(path: &Path) -> Option<String> {
}
}
-/// Re-materialize the served index from the DB. Run at startup: if a crash left
-/// the DB ahead of the file, this closes the gap without inventing anything.
pub fn reconcile(cfg: &Config, db: &Db) -> Result<usize> {
let pkgs = db::index_packages(db)?;
let mut files = Vec::new();
@@ -450,7 +390,6 @@ pub fn reconcile(cfg: &Config, db: &Db) -> Result<usize> {
Ok(files.len())
}
-/// Remove a package from the served index (§9 withdrawal path).
pub fn withdraw_package(cfg: &Config, db: &Db, name: &str) -> Result<()> {
let _guard = lock_repo();
let rid = db::repo_id(db)?;