use system adb/collector when available, extract bundled assets to temp dir#81
use system adb/collector when available, extract bundled assets to temp dir#81
Conversation
…to temp dir - assets: replace DeployAssets()/CleanAssets() with DeployAssetsToDir(dir) so callers control where binaries land and cleanup is simply os.RemoveAll. - adb (all platforms): check PATH for adb first; only extract the bundled binary when no system adb is found, and extract it into os.MkdirTemp instead of next to the executable (which may be /usr/bin or read-only). Store the temp dir in ADB.TmpAssetsDir for later cleanup. - adb: add ADB.Cleanup() that removes TmpAssetsDir; it is a no-op when the system adb was used and nothing was extracted. - collector: before reading from the embedded assets, check the ANDROIDQF_COLLECTOR_DIR environment variable; if set and readable, use those binaries instead. Distro packagers can point this at /usr/lib/androidqf/android-collector/; portable-binary users get the embedded fallback automatically. - acquisition: replace assets.CleanAssets() with adb.Client.Cleanup(). Addresses the issues raised in #79 without breaking the portable-binary use case.
tesitura
left a comment
There was a problem hiding this comment.
Looks good to me. One thing worth noting is that encrypted zip output path and key.txt lookup still use GetExecutableDirectory() in:
androidqf/acquisition/encrypted_stream.go
Lines 34 to 35 in dcfc1e9
androidqf/acquisition/encrypted_stream.go
Line 58 in dcfc1e9
androidqf/acquisition/secure.go
Lines 47 to 49 in dcfc1e9
androidqf/acquisition/secure.go
Line 57 in dcfc1e9
I believe is worth aligning those to the same base path in a followup.
|
How would you feel about using build tags123 for this? They'd be defined like: at the top of a file and would allow for something like: So for "normal" builds everything stays the same, but one could optionally opt-out of Footnotes |
|
I think we can even have both solutions. Use the adb from Path if available still might make sense, but using build tags also makes sense so you can have smaller binaries for distros. |
assets: replace DeployAssets()/CleanAssets() with DeployAssetsToDir(dir) so callers control where binaries land and cleanup is simply os.RemoveAll.
adb (all platforms): check PATH for adb first; only extract the bundled binary when no system adb is found, and extract it into os.MkdirTemp instead of next to the executable (which may be /usr/bin or read-only). Store the temp dir in ADB.TmpAssetsDir for later cleanup.
adb: add ADB.Cleanup() that removes TmpAssetsDir; it is a no-op when the system adb was used and nothing was extracted.
collector: before reading from the embedded assets, check the ANDROIDQF_COLLECTOR_DIR environment variable; if set and readable, use those binaries instead. Distro packagers can point this at /usr/lib/androidqf/android-collector/; portable-binary users get the embedded fallback automatically.
acquisition: replace assets.CleanAssets() with adb.Client.Cleanup().
Addresses the issues raised in mvt-project/androidqf#79 without breaking the portable-binary use case.