Skip to content

Commit

Permalink
Fix test builds
Browse files Browse the repository at this point in the history
  • Loading branch information
johnschug committed Aug 4, 2021
1 parent 950c4f1 commit 00d3a70
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 42 deletions.
14 changes: 6 additions & 8 deletions docker/Dockerfile.static
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
FROM clux/muslrust as base

RUN apt-get update && apt-get install -y --no-install-recommends bzip2 && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends bzip2 gnupg && rm -rf /var/lib/apt/lists/*

ENV TARGET "x86_64-unknown-linux-musl"

# Optional localization support:
# To enable uncomment the following commands, replace "--disable-nls" with
# "--with-libintl-prefix=$PREFIX", and add ":intl" to the LIBGPG_ERROR_LIBS
# environment variable.
# ARG GETTEXT_VER=0.19.8
# ARG GETTEXT_VER=0.21
# WORKDIR /usr/src
# RUN curl -sL "https://ftp.gnu.org/gnu/gettext/gettext-${GETTEXT_VER}.tar.bz2" | tar -xj
# RUN curl -sL "https://ftp.gnu.org/gnu/gettext/gettext-${GETTEXT_VER}.tar.xz" | tar -xj
# WORKDIR "gettext-$GETTEXT_VER"
# RUN ./configure --host "$TARGET" --prefix="$PREFIX" --with-pic --enable-fast-install --disable-dependency-tracking --without-emacs --disable-java --disable-csharp --disable-c++
# RUN make -j$(nproc) install

ARG LIBGPG_ERROR_VER=1.39
ARG LIBGPG_ERROR_VER=1.42
WORKDIR /usr/src
RUN curl -sSL "https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${LIBGPG_ERROR_VER}.tar.bz2" | tar -xj
WORKDIR libgpg-error-$LIBGPG_ERROR_VER
RUN ./configure --host "$TARGET" --prefix="$PREFIX" --with-pic --enable-fast-install --disable-dependency-tracking --enable-static --disable-shared --disable-nls --disable-doc --disable-languages --disable-tests
RUN make -j$(nproc) install
RUN true

RUN apt-get update && apt-get install -y --no-install-recommends gnupg2 && rm -rf /var/lib/apt/lists/*

ARG LIBASSUAN_VER=2.5.3
ARG LIBASSUAN_VER=2.5.5
WORKDIR /usr/src
RUN curl -sSL "https://www.gnupg.org/ftp/gcrypt/libassuan/libassuan-${LIBASSUAN_VER}.tar.bz2" | tar -xj
WORKDIR "libassuan-$LIBASSUAN_VER"
RUN ./configure --host "$TARGET" --prefix="$PREFIX" --with-pic --enable-fast-install --disable-dependency-tracking --enable-static --disable-shared --disable-doc --with-gpg-error-prefix="$PREFIX"
RUN make -j$(nproc) install

ARG GPGME_VER=1.14.0
ARG GPGME_VER=1.16.0
WORKDIR /usr/src
RUN curl -sSL "https://www.gnupg.org/ftp/gcrypt/gpgme/gpgme-${GPGME_VER}.tar.bz2" | tar -xj
WORKDIR "gpgme-$GPGME_VER"
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN C:\TEMP\rustup-init.exe -y --profile minimal --default-host i686-pc-windows-

RUN setx /M PATH $(${Env:PATH} + \";${Env:CARGO_HOME}\bin\")

ARG GNUPG_VERSION=2.2.21_20200709
ARG GNUPG_VERSION=2.3.1_20210420
ADD https://gnupg.org/ftp/gcrypt/binary/gnupg-w32-${GNUPG_VERSION}.exe C:\TEMP\gnupg-w32.exe

RUN C:\TEMP\gnupg-w32.exe /S
Expand Down
2 changes: 1 addition & 1 deletion gpgme-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ libc = "0.2"
libgpg-error-sys = "0.5.1"

[target.'cfg(windows)'.build-dependencies]
winreg = "0.7"
winreg = "0.9"
2 changes: 1 addition & 1 deletion gpgme-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn try_registry(proj: &Project) -> Result<Config> {
let hklm = RegKey::predef(HKEY_LOCAL_MACHINE);
let root = PathBuf::from(
hklm.open_subkey("SOFTWARE\\GnuPG")
.and_then(|k| k.get_value::<String, _>("Install Directory"))
.and_then(|k| k.get_value::<OsString, _>("Install Directory"))
.warn_err("unable to retrieve install location")?,
);
if root.join("lib/libgpgme.imp").exists() {
Expand Down
12 changes: 4 additions & 8 deletions src/callbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,7 @@ where
pub(crate) extern "C" fn passphrase_cb<P: PassphraseProviderNew>(
hook: *mut libc::c_void, uid_hint: *const libc::c_char, info: *const libc::c_char,
was_bad: libc::c_int, fd: libc::c_int,
) -> ffi::gpgme_error_t
{
) -> ffi::gpgme_error_t {
let hook = unsafe { &mut *(hook as *mut Hook<P>) };
update_hook(&mut hook.0, move |h| unsafe {
let info = PassphraseRequest {
Expand All @@ -336,8 +335,7 @@ pub(crate) extern "C" fn passphrase_cb<P: PassphraseProviderNew>(
pub(crate) extern "C" fn progress_cb<H: ProgressReporter>(
hook: *mut libc::c_void, what: *const libc::c_char, typ: libc::c_int, current: libc::c_int,
total: libc::c_int,
)
{
) {
let hook = unsafe { &mut *(hook as *mut Hook<H>) };
update_hook(&mut hook.0, move |h| unsafe {
let info = ProgressInfo {
Expand Down Expand Up @@ -365,8 +363,7 @@ pub(crate) extern "C" fn status_cb<H: StatusHandler>(
pub(crate) extern "C" fn edit_cb<E: EditInteractor>(
hook: *mut libc::c_void, status: ffi::gpgme_status_code_t, args: *const libc::c_char,
fd: libc::c_int,
) -> ffi::gpgme_error_t
{
) -> ffi::gpgme_error_t {
let hook = unsafe { &mut *(hook as *mut InteractorHook<'_, E>) };
let response = hook.response;
update_hook(&mut hook.inner.0, move |h| unsafe {
Expand All @@ -386,8 +383,7 @@ pub(crate) extern "C" fn edit_cb<E: EditInteractor>(
pub(crate) extern "C" fn interact_cb<I: InteractorNew>(
hook: *mut libc::c_void, keyword: *const libc::c_char, args: *const libc::c_char,
fd: libc::c_int,
) -> ffi::gpgme_error_t
{
) -> ffi::gpgme_error_t {
let hook = unsafe { &mut *(hook as *mut InteractorHook<'_, I>) };
let response = hook.response;
update_hook(&mut hook.inner.0, move |h| unsafe {
Expand Down
21 changes: 8 additions & 13 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,7 @@ impl Context {
pub fn create_key_with_flags(
&mut self, userid: impl CStrArgument, algo: impl CStrArgument, expires: Duration,
flags: crate::CreateKeyFlags,
) -> Result<results::KeyGenerationResult>
{
) -> Result<results::KeyGenerationResult> {
require_gpgme_ver! {
(1, 7) => {
let userid = userid.into_cstr();
Expand Down Expand Up @@ -706,8 +705,7 @@ impl Context {
pub fn create_subkey_with_flags(
&mut self, key: &Key, algo: impl CStrArgument, expires: Duration,
flags: crate::CreateKeyFlags,
) -> Result<results::KeyGenerationResult>
{
) -> Result<results::KeyGenerationResult> {
require_gpgme_ver! {
(1, 7) => {
let algo = algo.into_cstr();
Expand Down Expand Up @@ -828,8 +826,7 @@ impl Context {
pub fn set_uid_flag(
&mut self, key: &Key, userid: impl CStrArgument, name: impl CStrArgument,
value: Option<impl CStrArgument>,
) -> Result<()>
{
) -> Result<()> {
require_gpgme_ver! {
(1, 8) => {
let userid = userid.into_cstr();
Expand Down Expand Up @@ -1354,8 +1351,7 @@ impl Context {
pub fn add_signature_notation(
&mut self, name: impl CStrArgument, value: impl CStrArgument,
flags: crate::SignatureNotationFlags,
) -> Result<()>
{
) -> Result<()> {
let name = name.into_cstr();
let value = value.into_cstr();
unsafe {
Expand Down Expand Up @@ -1528,8 +1524,7 @@ impl Context {
fn verify(
&mut self, signature: &mut Data<'_>, signedtext: Option<&mut Data<'_>>,
plaintext: Option<&mut Data<'_>>,
) -> Result<results::VerificationResult>
{
) -> Result<results::VerificationResult> {
unsafe {
let signed = signedtext.map_or(ptr::null_mut(), |d| d.as_raw());
let plain = plaintext.map_or(ptr::null_mut(), |d| d.as_raw());
Expand Down Expand Up @@ -1977,9 +1972,9 @@ impl fmt::Debug for Signers<'_> {
/// [`gpgme_ctx_t`](https://www.gnupg.org/documentation/manuals/gpgme/Contexts.html#Contexts)
pub struct ContextWithCallbacks<'a> {
inner: Context,
passphrase_hook: Option<Box<dyn Drop + 'a>>,
progress_hook: Option<Box<dyn Drop + 'a>>,
status_hook: Option<Box<dyn Drop + 'a>>,
passphrase_hook: Option<Box<dyn Send + 'a>>,
progress_hook: Option<Box<dyn Send + 'a>>,
status_hook: Option<Box<dyn Send + 'a>>,
}

impl<'a> ContextWithCallbacks<'a> {
Expand Down
11 changes: 5 additions & 6 deletions src/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -887,13 +887,13 @@ impl<'key> UserIdSignature<'key> {
}

#[inline]
pub fn trust_value(&self) -> u8 {
pub fn trust_value(&self) -> SignatureTrust {
let value = unsafe {
(*self.as_raw()).trust_value
(*self.as_raw()).trust_value()
};
if (!self.is_trust_signature()) {
if !self.is_trust_signature() {
SignatureTrust::None
} else if (value >= 120) {
} else if value >= 120 {
SignatureTrust::Complete
} else {
SignatureTrust::Partial
Expand All @@ -903,7 +903,7 @@ impl<'key> UserIdSignature<'key> {
#[inline]
pub fn trust_depth(&self) -> u8 {
unsafe {
(*self.as_raw()).trust_depth
(*self.as_raw()).trust_depth()
}
}

Expand All @@ -920,7 +920,6 @@ impl<'key> UserIdSignature<'key> {
}
}
}

}

impl fmt::Debug for UserIdSignature<'_> {
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,7 @@ impl Gpgme {
pub fn set_engine_info(
&self, proto: Protocol, path: Option<impl CStrArgument>,
home_dir: Option<impl CStrArgument>,
) -> Result<()>
{
) -> Result<()> {
let path = path.map(CStrArgument::into_cstr);
let home_dir = home_dir.map(CStrArgument::into_cstr);
unsafe {
Expand Down
8 changes: 6 additions & 2 deletions tests/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ test_case! {
ctx.set_offline(true);
ctx.set_armor(true);

let res = ctx.create_key_with_flags("test user <[email protected]>",
"future-default", Default::default(), CreateKeyFlags::NOPASSWD).unwrap();
let res = match ctx.create_key_with_flags("test user <[email protected]>",
"future-default", Default::default(), CreateKeyFlags::NOPASSWD) {
Ok(r) => r,
Err(e) if e.code() == gpgme::Error::NOT_SUPPORTED.code() => return,
Err(e) => panic!("error: {:?}", e),
};
let fpr = res.fingerprint_raw().unwrap();

let mut data = Vec::new();
Expand Down

0 comments on commit 00d3a70

Please sign in to comment.