Remove native deps: openssl-sys, git2-sys, libssh2-sys (#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 <git@kchr.de>

* remove trailing new line

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
Squirrel
2023-06-07 16:32:54 +01:00
committed by GitHub
parent b14238cb7d
commit c31c6a1a73
5 changed files with 18 additions and 73 deletions
-58
View File
@@ -3161,7 +3161,6 @@ dependencies = [
"frame-election-provider-support",
"frame-support",
"frame-system",
"git2",
"num-format",
"pallet-staking",
]
@@ -3251,21 +3250,6 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "git2"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf7f68c2995f392c49fffb4f95ae2c873297830eb25c6bc4c114ce8f4562acc"
dependencies = [
"bitflags",
"libc",
"libgit2-sys",
"log",
"openssl-probe",
"openssl-sys",
"url",
]
[[package]]
name = "glob"
version = "0.3.1"
@@ -4196,20 +4180,6 @@ version = "0.2.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc86cde3ff845662b8f4ef6cb50ea0e20c524eb3d29ae048287e06a1b3fa6a81"
[[package]]
name = "libgit2-sys"
version = "0.14.2+1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f3d95f6b51075fe9810a7ae22c7095f12b98005ab364d8544797a825ce946a4"
dependencies = [
"cc",
"libc",
"libssh2-sys",
"libz-sys",
"openssl-sys",
"pkg-config",
]
[[package]]
name = "libloading"
version = "0.7.4"
@@ -4720,20 +4690,6 @@ dependencies = [
"libsecp256k1-core",
]
[[package]]
name = "libssh2-sys"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca"
dependencies = [
"cc",
"libc",
"libz-sys",
"openssl-sys",
"pkg-config",
"vcpkg",
]
[[package]]
name = "libz-sys"
version = "1.1.9"
@@ -4741,7 +4697,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
@@ -5654,7 +5609,6 @@ dependencies = [
"clap 4.3.2",
"flate2",
"fs_extra",
"git2",
"glob",
"itertools",
"tar",
@@ -5929,18 +5883,6 @@ version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2ce0f250f34a308dcfdbb351f511359857d4ed2134ba715a4eadd46e1ffd617"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "os_str_bytes"
version = "6.5.0"
@@ -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"
@@ -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;
@@ -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 mut dir = path;
while !dir.join(".git").exists() {
dir = dir
.parent()
.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();
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:
@@ -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"
@@ -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() {