Class: Libpng::OHOS::CodeSigner

Inherits:
Object
  • Object
show all
Defined in:
lib/libpng/ohos/code_signer.rb

Overview

Wraps OHOS's binary-sign-tool to apply -selfSign 1 to a freshly built shared library. Mandatory for runtime loading on production OHOS devices; dockerharmony skips this check (dev container).

Design: #sign_command is a pure-data accessor returning the argv that #sign would run. Specs assert on the command shape without actually invoking the tool -- no doubles needed.

Instance Method Summary collapse

Constructor Details

#initialize(ndk) ⇒ CodeSigner

Returns a new instance of CodeSigner.



15
16
17
# File 'lib/libpng/ohos/code_signer.rb', line 15

def initialize(ndk)
  @ndk = ndk
end

Instance Method Details

#sign(so_path) ⇒ Object

Runs binary-sign-tool on the .so, in-place. Returns true on success, false otherwise. Caller (OHOS::Recipe#install) raises on false.



33
34
35
# File 'lib/libpng/ohos/code_signer.rb', line 33

def sign(so_path)
  system(*sign_command(so_path))
end

#sign_command(so_path) ⇒ Object

Returns the argv for the signing invocation. Pure data.



20
21
22
23
24
25
26
27
28
# File 'lib/libpng/ohos/code_signer.rb', line 20

def sign_command(so_path)
  [
    @ndk.sign_tool_path.to_s,
    'sign',
    '-selfSign', '1',
    '-inFile', so_path.to_s,
    '-outFile', so_path.to_s
  ]
end