summarylogtreecommitdiffstats
path: root/use-system-library.patch
blob: 4aea1e65e7c78e8ed16aad06fecfe1d3dfac3e77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
diff -ura nitrocli-0.2.2.orig/nitrocli/Cargo.lock nitrocli-0.2.2.new/nitrocli/Cargo.lock
--- nitrocli-0.2.2.orig/nitrocli/Cargo.lock	2019-01-14 03:25:50.000000000 +0000
+++ nitrocli-0.2.2.new/nitrocli/Cargo.lock	2019-01-14 11:48:45.277717389 +0000
@@ -20,16 +20,6 @@
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "cc"
-version = "1.0.28"
-
-[[package]]
-name = "cc"
-version = "1.0.28"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-replace = "cc 1.0.28"
-
-[[package]]
 name = "cfg-if"
 version = "0.1.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -105,9 +95,6 @@
 [[package]]
 name = "nitrokey-sys"
 version = "3.4.1"
-dependencies = [
- "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
-]
 
 [[package]]
 name = "nitrokey-sys"
@@ -321,7 +308,6 @@
 [metadata]
 "checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
 "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
-"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
 "checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
 "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
 "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
Only in nitrocli-0.2.2.new/nitrocli: target
diff -ura nitrocli-0.2.2.orig/nitrokey-sys/build.rs nitrocli-0.2.2.new/nitrokey-sys/build.rs
--- nitrocli-0.2.2.orig/nitrokey-sys/build.rs	2019-01-14 03:25:50.000000000 +0000
+++ nitrocli-0.2.2.new/nitrokey-sys/build.rs	2019-01-14 11:46:43.052438908 +0000
@@ -1,104 +1,3 @@
-extern crate cc;
-
-use std::env;
-use std::io;
-use std::io::{Read, Write};
-use std::fs;
-use std::path;
-
-struct Version {
-    major: String,
-    minor: String,
-    git: String,
-}
-
-fn stringify(err: env::VarError) -> String {
-    format!("{}", err)
-}
-
-fn extract_git_version(pre: &str) -> Result<String, String> {
-    // If a pre-release version is set, it is expected to have the format
-    // pre.v<maj>.<min>.<n>.g<hash>, where <maj> and <min> are the last major and minor version,
-    // <n> is the number of commits since this version and <hash> is the hash of the last commit.
-    let parts: Vec<&str> = pre.split('.').collect();
-    if parts.len() != 5 {
-        return Err(format!("'{}' is not a valid pre-release version", pre));
-    }
-    Ok(format!("{}.{}-{}-{}", parts[1], parts[2], parts[3], parts[4]))
-}
-
-fn get_version() -> Result<Version, String> {
-    let major = env::var("CARGO_PKG_VERSION_MAJOR").map_err(stringify)?;
-    let minor = env::var("CARGO_PKG_VERSION_MINOR").map_err(stringify)?;
-    let patch = env::var("CARGO_PKG_VERSION_PATCH").map_err(stringify)?;
-    let pre = env::var("CARGO_PKG_VERSION_PRE").map_err(stringify)?;
-
-    let git = match pre.is_empty() {
-        true => match patch.is_empty() {
-            true => format!("v{}.{}", major, minor),
-            false => format!("v{}.{}.{}", major, minor, patch),
-        },
-        false => extract_git_version(&pre)?,
-    };
-
-    Ok(Version {
-        major,
-        minor,
-        git,
-    })
-}
-
-fn prepare_version_source(
-    version: &Version,
-    out_path: &path::Path,
-    library_path: &path::Path
-) -> io::Result<path::PathBuf> {
-    let out = out_path.join("version.cc");
-    let template = library_path.join("version.cc.in");
-
-    let mut file = fs::File::open(template)?;
-    let mut data = String::new();
-    file.read_to_string(&mut data)?;
-    drop(file);
-
-    let data = data
-        .replace("@PROJECT_VERSION_MAJOR@", &version.major)
-        .replace("@PROJECT_VERSION_MINOR@", &version.minor)
-        .replace("@PROJECT_VERSION_GIT@", &version.git);
-
-    let mut file = fs::File::create(&out)?;
-    file.write_all(data.as_bytes())?;
-
-    Ok(out)
-}
-
 fn main() {
-    let out_dir = env::var("OUT_DIR").expect("Environment variable OUT_DIR is not set");
-    let out_path = path::PathBuf::from(out_dir);
-
-    let version = get_version().expect("Could not extract library version");
-
-    let sources = [
-        "DeviceCommunicationExceptions.cpp",
-        "NK_C_API.cc",
-        "NitrokeyManager.cc",
-        "command_id.cc",
-        "device.cc",
-        "log.cc",
-        "misc.cc",
-    ];
-    let library_dir = format!("libnitrokey-{}", version.git);
-    let library_path = path::Path::new(&library_dir);
-
-    let version_source = prepare_version_source(&version, &out_path, &library_path)
-        .expect("Could not prepare the version source file");
-
-    cc::Build::new()
-        .cpp(true)
-        .include(library_path.join("libnitrokey"))
-        .files(sources.iter().map(|s| library_path.join(s)))
-        .file(version_source)
-        .compile("libnitrokey.a");
-
-    println!("cargo:rustc-link-lib=hidapi-libusb");
+    println!("cargo:rustc-link-lib=nitrokey");
 }
diff -ura nitrocli-0.2.2.orig/nitrokey-sys/Cargo.toml nitrocli-0.2.2.new/nitrokey-sys/Cargo.toml
--- nitrocli-0.2.2.orig/nitrokey-sys/Cargo.toml	2019-01-14 03:25:50.000000000 +0000
+++ nitrocli-0.2.2.new/nitrokey-sys/Cargo.toml	2019-01-14 11:46:43.052438908 +0000
@@ -10,6 +10,3 @@
 links = "nitrokey"
 build = "build.rs"
 readme = "README.md"
-
-[build-dependencies]
-cc = "1.0"