mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-18 19:10:31 +08:00
The main dependant of `radicle-git`, and its crates, is [`heartwood`]. It is licensed under MIT or Apache-2.0, which has been incompatible with the GPL-3.0 license. Since the intellectual property of this code base is with the Better Internet Foundation, it was decided to re-license code in this repository to make the upstream repository compatible. - Remove the license headers (and instructions to add them) - Add MIT and Apache-2.0 licenses - Remove the GPL-3.0 license - Change the license declarations in the `Cargo.toml` files [`heartwood`]: https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
64 lines
1.6 KiB
Rust
64 lines
1.6 KiB
Rust
use std::{
|
|
env, fs,
|
|
fs::File,
|
|
io,
|
|
path::{Path, PathBuf},
|
|
};
|
|
|
|
use anyhow::Context as _;
|
|
use flate2::read::GzDecoder;
|
|
use tar::Archive;
|
|
|
|
enum Command {
|
|
Build(PathBuf),
|
|
Publish(PathBuf),
|
|
}
|
|
|
|
impl Command {
|
|
fn new() -> io::Result<Self> {
|
|
let current = env::current_dir()?;
|
|
Ok(if current.ends_with("radicle-surf") {
|
|
Self::Build(current)
|
|
} else {
|
|
Self::Publish(PathBuf::from(
|
|
env::var("OUT_DIR").map_err(|err| io::Error::new(io::ErrorKind::Other, err))?,
|
|
))
|
|
})
|
|
}
|
|
|
|
fn target(&self) -> PathBuf {
|
|
match self {
|
|
Self::Build(path) => path.join("data"),
|
|
Self::Publish(path) => path.join("data"),
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let target = Command::new()
|
|
.expect("could not determine the cargo command")
|
|
.target();
|
|
let git_platinum_tarball = "./data/git-platinum.tgz";
|
|
|
|
unpack(git_platinum_tarball, target).expect("Failed to unpack git-platinum");
|
|
|
|
println!("cargo:rerun-if-changed={git_platinum_tarball}");
|
|
}
|
|
|
|
fn unpack(archive_path: impl AsRef<Path>, target: impl AsRef<Path>) -> anyhow::Result<()> {
|
|
let content = target.as_ref().join("git-platinum");
|
|
if content.exists() {
|
|
fs::remove_dir_all(content).context("attempting to remove git-platinum")?;
|
|
}
|
|
let archive_path = archive_path.as_ref();
|
|
let tar_gz = File::open(archive_path).context(format!(
|
|
"attempting to open file: {}",
|
|
archive_path.display()
|
|
))?;
|
|
let tar = GzDecoder::new(tar_gz);
|
|
let mut archive = Archive::new(tar);
|
|
archive.unpack(target).context("attempting to unpack")?;
|
|
|
|
Ok(())
|
|
}
|