Skip to content

Commit aeb8c31

Browse files
gilescopebkchr
andauthored
Remove native deps: openssl-sys, git2-sys, libssh2-sys (paritytech#14302)
* 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]>
1 parent bc4055b commit aeb8c31

File tree

5 files changed

+18
-73
lines changed

5 files changed

+18
-73
lines changed

Cargo.lock

Lines changed: 0 additions & 58 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/ci/node-template-release/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ targets = ["x86_64-unknown-linux-gnu"]
1414
clap = { version = "4.2.5", features = ["derive"] }
1515
flate2 = "1.0"
1616
fs_extra = "1.3"
17-
git2 = "0.16"
1817
glob = "0.3"
1918
tar = "0.4"
2019
tempfile = "3"

scripts/ci/node-template-release/src/main.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::{
88
use clap::Parser;
99
use flate2::{write::GzEncoder, Compression};
1010
use fs_extra::dir::{self, CopyOptions};
11-
use git2;
1211
use glob;
1312
use itertools::Itertools;
1413
use tar;
@@ -79,17 +78,20 @@ fn write_cargo_toml(path: &Path, cargo_toml: CargoToml) {
7978

8079
/// Gets the latest commit id of the repository given by `path`.
8180
fn get_git_commit_id(path: &Path) -> String {
82-
let repo = git2::Repository::discover(path)
83-
.expect(&format!("Node template ({}) should be in a git repository.", path.display()));
84-
85-
let commit_id = repo
86-
.head()
87-
.expect("Repository should have a head")
88-
.peel_to_commit()
89-
.expect("Head references a commit")
90-
.id();
81+
let mut dir = path;
82+
while !dir.join(".git").exists() {
83+
dir = dir
84+
.parent()
85+
.expect(&format!("Node template ({}) should be in a git repository.", path.display()));
86+
}
9187

92-
format!("{}", commit_id)
88+
let git = dir.join(".git");
89+
let head = git.join("HEAD");
90+
let head_contents = fs::read_to_string(head).expect("Repository should have a HEAD");
91+
let branch = head_contents.strip_prefix("ref: ").expect(".git/HEAD to start 'ref: '").trim();
92+
let mut commit = fs::read_to_string(git.join(branch)).expect("Head references a commit");
93+
commit.truncate(commit.trim_end().len());
94+
commit
9395
}
9496

9597
/// Rewrites git dependencies:

utils/frame/generate-bags/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@ pallet-staking = { version = "4.0.0-dev", path = "../../../frame/staking" }
1717

1818
# third party
1919
chrono = { version = "0.4.19" }
20-
git2 = { version = "0.16.0", default-features = false }
2120
num-format = "0.4.3"

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ fn existential_weight<T: pallet_staking::Config>(
8989
/// Just searches the git working directory root for files matching certain patterns; it's
9090
/// pretty naive.
9191
fn path_to_header_file() -> Option<PathBuf> {
92-
let repo = git2::Repository::open_from_env().ok()?;
93-
let workdir = repo.workdir()?;
92+
let mut workdir: &Path = &std::env::current_dir().ok()?;
93+
while !workdir.join(".git").exists() {
94+
workdir = workdir.parent()?;
95+
}
96+
9497
for file_name in &["HEADER-APACHE2", "HEADER-GPL3", "HEADER", "file_header.txt"] {
9598
let path = workdir.join(file_name);
9699
if path.exists() {

0 commit comments

Comments
 (0)