diff -Nru rust-nitrokey-sys-3.4.1/build.rs rust-nitrokey-sys-3.4.3/build.rs --- rust-nitrokey-sys-3.4.1/build.rs 2018-12-10 13:26:23.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/build.rs 2019-01-12 13:42:28.000000000 +0000 @@ -1,57 +1,38 @@ -extern crate cc; - use std::env; +use std::fs; use std::io; use std::io::{Read, Write}; -use std::fs; use std::path; +use std::string; -struct Version { - major: String, - minor: String, - git: String, -} +use cc; -fn stringify(err: env::VarError) -> String { - format!("{}", err) +#[derive(Clone, Copy, Debug, PartialEq)] +struct Version { + major: u32, + minor: u32, + patch: Option, } -fn extract_git_version(pre: &str) -> Result { - // If a pre-release version is set, it is expected to have the format - // pre.v...g, where and are the last major and minor version, - // is the number of commits since this version and 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)); +impl string::ToString for Version { + fn to_string(&self) -> String { + match self.patch { + Some(patch) => format!("v{}.{}.{}", self.major, self.minor, patch), + None => format!("v{}.{}", self.major, self.minor), + } } - Ok(format!("{}.{}-{}-{}", parts[1], parts[2], parts[3], parts[4])) } -fn get_version() -> Result { - 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, - }) -} +const LIBNITROKEY_VERSION: Version = Version { + major: 3, + minor: 4, + patch: Some(1), +}; fn prepare_version_source( - version: &Version, + version: Version, out_path: &path::Path, - library_path: &path::Path + library_path: &path::Path, ) -> io::Result { let out = out_path.join("version.cc"); let template = library_path.join("version.cc.in"); @@ -62,9 +43,9 @@ drop(file); let data = data - .replace("@PROJECT_VERSION_MAJOR@", &version.major) - .replace("@PROJECT_VERSION_MINOR@", &version.minor) - .replace("@PROJECT_VERSION_GIT@", &version.git); + .replace("@PROJECT_VERSION_MAJOR@", &version.major.to_string()) + .replace("@PROJECT_VERSION_MINOR@", &version.minor.to_string()) + .replace("@PROJECT_VERSION_GIT@", &version.to_string()); let mut file = fs::File::create(&out)?; file.write_all(data.as_bytes())?; @@ -73,11 +54,14 @@ } fn main() { + if env::var("USE_SYSTEM_LIBNITROKEY").is_ok() { + println!("cargo:rustc-link-lib=nitrokey"); + return; + } + 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", @@ -87,18 +71,24 @@ "log.cc", "misc.cc", ]; - let library_dir = format!("libnitrokey-{}", version.git); + let library_dir = format!("libnitrokey-{}", LIBNITROKEY_VERSION.to_string()); let library_path = path::Path::new(&library_dir); - let version_source = prepare_version_source(&version, &out_path, &library_path) + let version_source = prepare_version_source(LIBNITROKEY_VERSION, &out_path, &library_path) .expect("Could not prepare the version source file"); cc::Build::new() .cpp(true) + .flag("-std=c++14") .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"); + let hidapi_library_name = if cfg!(target_os = "linux") { + "hidapi-libusb" + } else { + "hidapi" + }; + println!("cargo:rustc-link-lib={}", hidapi_library_name); } diff -Nru rust-nitrokey-sys-3.4.1/Cargo.toml rust-nitrokey-sys-3.4.3/Cargo.toml --- rust-nitrokey-sys-3.4.1/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/Cargo.toml 1970-01-01 00:00:00.000000000 +0000 @@ -11,8 +11,9 @@ # will likely look very different (and much more reasonable) [package] +edition = "2018" name = "nitrokey-sys" -version = "3.4.1" +version = "3.4.3" authors = ["Robin Krahl "] build = "build.rs" links = "nitrokey" diff -Nru rust-nitrokey-sys-3.4.1/Cargo.toml.orig rust-nitrokey-sys-3.4.3/Cargo.toml.orig --- rust-nitrokey-sys-3.4.1/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/Cargo.toml.orig 1970-01-01 00:00:00.000000000 +0000 @@ -1,7 +1,8 @@ [package] name = "nitrokey-sys" -version = "3.4.1" +version = "3.4.3" authors = ["Robin Krahl "] +edition = "2018" homepage = "https://code.ireas.org/nitrokey-rs/" repository = "https://git.ireas.org/nitrokey-sys-rs/" description = "Low-level bindings to libnitrokey for communication with Nitrokey devices" diff -Nru rust-nitrokey-sys-3.4.1/.cargo_vcs_info.json rust-nitrokey-sys-3.4.3/.cargo_vcs_info.json --- rust-nitrokey-sys-3.4.1/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/.cargo_vcs_info.json 1970-01-01 00:00:00.000000000 +0000 @@ -0,0 +1,5 @@ +{ + "git": { + "sha1": "fe86df47853718983e1f45d6a4289a1d93ace45c" + } +} diff -Nru rust-nitrokey-sys-3.4.1/CHANGELOG.md rust-nitrokey-sys-3.4.3/CHANGELOG.md --- rust-nitrokey-sys-3.4.1/CHANGELOG.md 2018-12-10 13:26:23.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/CHANGELOG.md 2019-01-12 13:59:05.000000000 +0000 @@ -1,3 +1,13 @@ +# v3.4.3 (2019-10-12) +- Link directly against `libnitrokey` if the `USE_SYSTEM_LIBNITROKEY` + environment variable is set. + +# v3.4.2 (2019-01-01) +- Use the -std=c++14 compiler flag. +- Change the build script to link to `-lhidapi` on non-Linux operating systems + (while still using `-lhidapi-libusb` on Linux). +- Decouple the libnitrokey and nitrokey-sys-rs versions. + # v3.4.1 (2018-12-10) - Update to libnitrokey 3.4.1. There are no changes affecting this crate. diff -Nru rust-nitrokey-sys-3.4.1/debian/changelog rust-nitrokey-sys-3.4.3/debian/changelog --- rust-nitrokey-sys-3.4.1/debian/changelog 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/changelog 2019-01-20 19:11:37.000000000 +0000 @@ -1,3 +1,17 @@ +rust-nitrokey-sys (3.4.3-2) unstable; urgency=medium + + * Fix typo in the patching updating the build.rs script. + + -- Robin Krahl Sun, 20 Jan 2019 11:11:37 -0800 + +rust-nitrokey-sys (3.4.3-1) unstable; urgency=medium + + * Package nitrokey-sys 3.4.3 from crates.io using debcargo 2.2.9 + * Don't link against libhidapi-libusb since we don't directly use its symbols + (and libnitrokey already links against it, as it should). + + -- Robin Krahl Sat, 19 Jan 2019 16:08:23 -0800 + rust-nitrokey-sys (3.4.1-1) unstable; urgency=medium * Team upload. diff -Nru rust-nitrokey-sys-3.4.1/debian/control rust-nitrokey-sys-3.4.3/debian/control --- rust-nitrokey-sys-3.4.1/debian/control 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/control 2019-01-20 19:11:37.000000000 +0000 @@ -6,11 +6,11 @@ cargo:native , rustc:native , libstd-rust-dev , - libnitrokey-dev , - libhidapi-dev + libnitrokey-dev Maintainer: Debian Rust Maintainers Uploaders: - Wolfgang Silbermayr + Wolfgang Silbermayr , + Robin Krahl Standards-Version: 4.2.0 Vcs-Git: https://salsa.debian.org/rust-team/debcargo-conf.git [src/nitrokey-sys] Vcs-Browser: https://salsa.debian.org/rust-team/debcargo-conf/tree/master/src/nitrokey-sys @@ -21,16 +21,15 @@ Multi-Arch: same Depends: ${misc:Depends}, - libnitrokey-dev, - libhidapi-dev + libnitrokey-dev Provides: librust-nitrokey-sys+default-dev (= ${binary:Version}), librust-nitrokey-sys-3-dev (= ${binary:Version}), librust-nitrokey-sys-3+default-dev (= ${binary:Version}), librust-nitrokey-sys-3.4-dev (= ${binary:Version}), librust-nitrokey-sys-3.4+default-dev (= ${binary:Version}), - librust-nitrokey-sys-3.4.1-dev (= ${binary:Version}), - librust-nitrokey-sys-3.4.1+default-dev (= ${binary:Version}) + librust-nitrokey-sys-3.4.3-dev (= ${binary:Version}), + librust-nitrokey-sys-3.4.3+default-dev (= ${binary:Version}) Description: Low-level bindings to libnitrokey - Rust source code This package contains the source for the Rust nitrokey-sys crate, packaged by debcargo for use with cargo and dh-cargo. diff -Nru rust-nitrokey-sys-3.4.1/debian/copyright rust-nitrokey-sys-3.4.3/debian/copyright --- rust-nitrokey-sys-3.4.1/debian/copyright 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/copyright 2019-01-20 19:11:37.000000000 +0000 @@ -9,8 +9,9 @@ Files: debian/* Copyright: - 2018 Debian Rust Maintainers - 2018 Wolfgang Silbermayr + 2018-2019 Debian Rust Maintainers + 2018-2019 Wolfgang Silbermayr + 2018-2019 Robin Krahl License: LGPL-3.0 License: LGPL-3.0 diff -Nru rust-nitrokey-sys-3.4.1/debian/copyright.debcargo.hint rust-nitrokey-sys-3.4.3/debian/copyright.debcargo.hint --- rust-nitrokey-sys-3.4.1/debian/copyright.debcargo.hint 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/copyright.debcargo.hint 2019-01-20 19:11:37.000000000 +0000 @@ -21,8 +21,9 @@ Files: debian/* Copyright: - 2018 Debian Rust Maintainers - 2018 Wolfgang Silbermayr + 2018-2019 Debian Rust Maintainers + 2018-2019 Wolfgang Silbermayr + 2018-2019 Robin Krahl License: LGPL-3.0 License: LGPL-3.0 diff -Nru rust-nitrokey-sys-3.4.1/debian/debcargo.toml rust-nitrokey-sys-3.4.3/debian/debcargo.toml --- rust-nitrokey-sys-3.4.1/debian/debcargo.toml 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/debcargo.toml 2019-01-20 19:11:37.000000000 +0000 @@ -1,5 +1,5 @@ overlay = "." -uploaders = ["Wolfgang Silbermayr "] +uploaders = ["Wolfgang Silbermayr ", "Robin Krahl "] excludes = ["libnitrokey-*"] @@ -7,4 +7,4 @@ summary = "Low-level bindings to libnitrokey" [packages.lib] -depends = ["libnitrokey-dev","libhidapi-dev"] +depends = ["libnitrokey-dev"] diff -Nru rust-nitrokey-sys-3.4.1/debian/patches/0001-Update-build.rs-for-shared-library.patch rust-nitrokey-sys-3.4.3/debian/patches/0001-Update-build.rs-for-shared-library.patch --- rust-nitrokey-sys-3.4.1/debian/patches/0001-Update-build.rs-for-shared-library.patch 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/patches/0001-Update-build.rs-for-shared-library.patch 2019-01-20 19:11:37.000000000 +0000 @@ -7,65 +7,46 @@ build.rs | 102 +------------------------------------------------------ 1 file changed, 1 insertion(+), 101 deletions(-) -diff --git a/build.rs b/build.rs -index a22bbd0..3733d8b 100644 ---- a/build.rs -+++ b/build.rs -@@ -1,104 +1,4 @@ --extern crate cc; -- +Index: nitrokey-sys/build.rs +=================================================================== +--- nitrokey-sys.orig/build.rs ++++ nitrokey-sys/build.rs +@@ -1,94 +1,3 @@ -use std::env; +-use std::fs; -use std::io; -use std::io::{Read, Write}; --use std::fs; -use std::path; +-use std::string; - --struct Version { -- major: String, -- minor: String, -- git: String, --} +-use cc; - --fn stringify(err: env::VarError) -> String { -- format!("{}", err) +-#[derive(Clone, Copy, Debug, PartialEq)] +-struct Version { +- major: u32, +- minor: u32, +- patch: Option, -} - --fn extract_git_version(pre: &str) -> Result { -- // If a pre-release version is set, it is expected to have the format -- // pre.v...g, where and are the last major and minor version, -- // is the number of commits since this version and 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)); +-impl string::ToString for Version { +- fn to_string(&self) -> String { +- match self.patch { +- Some(patch) => format!("v{}.{}.{}", self.major, self.minor, patch), +- None => format!("v{}.{}", self.major, self.minor), +- } - } -- Ok(format!("{}.{}-{}-{}", parts[1], parts[2], parts[3], parts[4])) -} - --fn get_version() -> Result { -- 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, -- }) --} +-const LIBNITROKEY_VERSION: Version = Version { +- major: 3, +- minor: 4, +- patch: Some(1), +-}; - -fn prepare_version_source( -- version: &Version, +- version: Version, - out_path: &path::Path, -- library_path: &path::Path +- library_path: &path::Path, -) -> io::Result { - let out = out_path.join("version.cc"); - let template = library_path.join("version.cc.in"); @@ -76,9 +57,9 @@ - drop(file); - - let data = data -- .replace("@PROJECT_VERSION_MAJOR@", &version.major) -- .replace("@PROJECT_VERSION_MINOR@", &version.minor) -- .replace("@PROJECT_VERSION_GIT@", &version.git); +- .replace("@PROJECT_VERSION_MAJOR@", &version.major.to_string()) +- .replace("@PROJECT_VERSION_MINOR@", &version.minor.to_string()) +- .replace("@PROJECT_VERSION_GIT@", &version.to_string()); - - let mut file = fs::File::create(&out)?; - file.write_all(data.as_bytes())?; @@ -87,11 +68,14 @@ -} - fn main() { +- if env::var("USE_SYSTEM_LIBNITROKEY").is_ok() { +- println!("cargo:rustc-link-lib=nitrokey"); +- return; +- } +- - 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", @@ -101,22 +85,25 @@ - "log.cc", - "misc.cc", - ]; -- let library_dir = format!("libnitrokey-{}", version.git); +- let library_dir = format!("libnitrokey-{}", LIBNITROKEY_VERSION.to_string()); - let library_path = path::Path::new(&library_dir); - -- let version_source = prepare_version_source(&version, &out_path, &library_path) +- let version_source = prepare_version_source(LIBNITROKEY_VERSION, &out_path, &library_path) - .expect("Could not prepare the version source file"); - - cc::Build::new() - .cpp(true) +- .flag("-std=c++14") - .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"); +- let hidapi_library_name = if cfg!(target_os = "linux") { +- "hidapi-libusb" +- } else { +- "hidapi" +- }; +- println!("cargo:rustc-link-lib={}", hidapi_library_name); + println!("cargo:rustc-link-lib=nitrokey"); } --- -2.20.0 - diff -Nru rust-nitrokey-sys-3.4.1/debian/patches/0002-Remove-cc-dependency.patch rust-nitrokey-sys-3.4.3/debian/patches/0002-Remove-cc-dependency.patch --- rust-nitrokey-sys-3.4.1/debian/patches/0002-Remove-cc-dependency.patch 2018-12-23 11:27:05.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/debian/patches/0002-Remove-cc-dependency.patch 2019-01-20 19:11:37.000000000 +0000 @@ -2,7 +2,7 @@ =================================================================== --- nitrokey-sys.orig/Cargo.toml +++ nitrokey-sys/Cargo.toml -@@ -22,5 +22,3 @@ readme = "README.md" +@@ -23,5 +23,3 @@ readme = "README.md" categories = ["external-ffi-bindings"] license = "LGPL-3.0" repository = "https://git.ireas.org/nitrokey-sys-rs/" diff -Nru rust-nitrokey-sys-3.4.1/README.md rust-nitrokey-sys-3.4.3/README.md --- rust-nitrokey-sys-3.4.1/README.md 2018-12-10 13:26:23.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/README.md 2019-01-12 13:55:56.000000000 +0000 @@ -3,17 +3,23 @@ Low-level Rust bindings for `libnitrokey`, providing access to Nitrokey devices. -```toml -[dependencies] -nitrokey-sys = "3.4.1" -``` - -The version of this crate corresponds to the wrapped `libnitrokey` version. -This crate contains a copy of the `libnitrokey` library, builds it from source -and links it statically. The host system must provide its dependencies in the -library search path: +This crate contains a copy of the [`libnitrokey`][] library, builds it from +source and links it statically. The host system must provide its dependencies +in the library search path: -- `libhidapi-libusb0` +- `libhidapi-libusb0` (on Linux) +- `libhidapi` (on non-Linux systems) + +If you set the `USE_SYSTEM_LIBNITROKEY` environment variable when building this +crate, it links directly against `libnitrokey` instead of building it from +source. In this case, `libnitrokey` must be available in the library search +path. + +## Versioning + +The major and minor version of the `nitrokey-sys` crate map to the major and +minor version of `libnitrokey`. The `nitrokey-sys` patch version may be +increased independently. ## Contact diff -Nru rust-nitrokey-sys-3.4.1/src/lib.rs rust-nitrokey-sys-3.4.3/src/lib.rs --- rust-nitrokey-sys-3.4.1/src/lib.rs 2018-12-10 13:26:23.000000000 +0000 +++ rust-nitrokey-sys-3.4.3/src/lib.rs 2019-01-01 22:10:52.000000000 +0000 @@ -4,7 +4,7 @@ mod ffi; -pub use ffi::*; +pub use crate::ffi::*; #[cfg(test)] mod tests { @@ -14,8 +14,6 @@ #[test] fn login_auto() { unsafe { - // logout required due to https://github.com/Nitrokey/libnitrokey/pull/115 - NK_logout(); assert_eq!(0, NK_login_auto()); } }