Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Remove native deps: openssl-sys, git2-sys, libssh2-sys (#14302)
Browse files Browse the repository at this point in the history
* Remove native deps: openssl-sys, git2-sys, libssh2-sys

Enables substrate master compiles first time on more machines.
(E.g. not needing
OPENSSL_DEV_LIB to be correctly configured.)

* cargo fmt

* Remove newline

* Update utils/frame/generate-bags/src/lib.rs

Co-authored-by: Bastian Köcher <[email protected]>

* remove trailing new line

---------

Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
gilescope and bkchr authored Jun 7, 2023
1 parent bc4055b commit aeb8c31
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 73 deletions.
58 changes: 0 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scripts/ci/node-template-release/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ targets = ["x86_64-unknown-linux-gnu"]
clap = { version = "4.2.5", features = ["derive"] }
flate2 = "1.0"
fs_extra = "1.3"
git2 = "0.16"
glob = "0.3"
tar = "0.4"
tempfile = "3"
Expand Down
24 changes: 13 additions & 11 deletions scripts/ci/node-template-release/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use std::{
use clap::Parser;
use flate2::{write::GzEncoder, Compression};
use fs_extra::dir::{self, CopyOptions};
use git2;
use glob;
use itertools::Itertools;
use tar;
Expand Down Expand Up @@ -79,17 +78,20 @@ fn write_cargo_toml(path: &Path, cargo_toml: CargoToml) {

/// Gets the latest commit id of the repository given by `path`.
fn get_git_commit_id(path: &Path) -> String {
let repo = git2::Repository::discover(path)
.expect(&format!("Node template ({}) should be in a git repository.", path.display()));

let commit_id = repo
.head()
.expect("Repository should have a head")
.peel_to_commit()
.expect("Head references a commit")
.id();
let mut dir = path;
while !dir.join(".git").exists() {
dir = dir
.parent()
.expect(&format!("Node template ({}) should be in a git repository.", path.display()));
}

format!("{}", commit_id)
let git = dir.join(".git");
let head = git.join("HEAD");
let head_contents = fs::read_to_string(head).expect("Repository should have a HEAD");
let branch = head_contents.strip_prefix("ref: ").expect(".git/HEAD to start 'ref: '").trim();
let mut commit = fs::read_to_string(git.join(branch)).expect("Head references a commit");
commit.truncate(commit.trim_end().len());
commit
}

/// Rewrites git dependencies:
Expand Down
1 change: 0 additions & 1 deletion utils/frame/generate-bags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ pallet-staking = { version = "4.0.0-dev", path = "../../../frame/staking" }

# third party
chrono = { version = "0.4.19" }
git2 = { version = "0.16.0", default-features = false }
num-format = "0.4.3"
7 changes: 5 additions & 2 deletions utils/frame/generate-bags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ fn existential_weight<T: pallet_staking::Config>(
/// Just searches the git working directory root for files matching certain patterns; it's
/// pretty naive.
fn path_to_header_file() -> Option<PathBuf> {
let repo = git2::Repository::open_from_env().ok()?;
let workdir = repo.workdir()?;
let mut workdir: &Path = &std::env::current_dir().ok()?;
while !workdir.join(".git").exists() {
workdir = workdir.parent()?;
}

for file_name in &["HEADER-APACHE2", "HEADER-GPL3", "HEADER", "file_header.txt"] {
let path = workdir.join(file_name);
if path.exists() {
Expand Down

0 comments on commit aeb8c31

Please sign in to comment.