Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ bin:
# - Apostrophe handling fixes
.PHONY: manpages
manpages:
cargo xtask manpages
cargo run --release --package xtask -- manpages

# This gates CI by default. Note that for clippy, we gate on
# only the clippy correctness and suspicious lints, plus a select
Expand Down Expand Up @@ -50,10 +50,10 @@ makesudoinstall:
sudo make install

sync-manpages:
cargo xtask sync-manpages
cargo run --release --package xtask -- sync-manpages

update-manpages:
cargo xtask update-manpages
cargo run --release --package xtask -- update-manpages

update-generated: sync-manpages manpages

Expand Down
20 changes: 18 additions & 2 deletions crates/xtask/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use std::process::Command;

use camino::Utf8Path;
use color_eyre::eyre::{eyre, Context, Report};
use color_eyre::Result;
use xshell::Shell;
Expand All @@ -19,6 +20,9 @@ const TASKS: &[(&str, fn(&Shell) -> Result<()>)] = &[
("spec", spec),
];

/// File used to identify the bcvk source tree toplevel.
const TOPLEVEL_MARKER: &str = "contrib/packaging/bcvk.spec";

fn install_tracing() {
use tracing_error::ErrorLayer;
use tracing_subscriber::fmt;
Expand All @@ -37,11 +41,23 @@ fn install_tracing() {
.init();
}

/// Check if we're in a bcvk source tree by looking for [`TOPLEVEL_MARKER`].
fn in_bcvk_source_tree() -> Result<bool> {
Utf8Path::new(TOPLEVEL_MARKER)
.try_exists()
.context("Checking for toplevel")
}

fn main() -> Result<(), Report> {
install_tracing();
color_eyre::install()?;
// Ensure our working directory is the toplevel
{

// Ensure our working directory is the bcvk source toplevel.
// First check if we're already there (e.g. when invoked from extracted
// tarball during RPM build). Only try git if we're not already in the
// right place - this avoids issues when building inside a different
// git repository.
if !in_bcvk_source_tree()? {
let toplevel_path = Command::new("git")
.args(["rev-parse", "--show-toplevel"])
.output()
Expand Down