From ac9abc3fff91e75046be5775b3d2e1dff98e4548 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Thu, 26 Mar 2026 17:30:18 +0100 Subject: [PATCH 1/2] Add `-tags unbundle` to read executables from filesystem --- adb/collector.go | 2 +- assets/{assets.go => assets_bundled.go} | 9 +++++++- assets/assets_darwin.go | 2 ++ assets/assets_linux.go | 2 ++ assets/assets_system.go | 29 +++++++++++++++++++++++++ assets/assets_windows.go | 2 ++ 6 files changed, 44 insertions(+), 2 deletions(-) rename assets/{assets.go => assets_bundled.go} (90%) create mode 100644 assets/assets_system.go diff --git a/adb/collector.go b/adb/collector.go index 7baedd3..5471fd6 100644 --- a/adb/collector.go +++ b/adb/collector.go @@ -112,7 +112,7 @@ func (c *Collector) Install() error { } log.Debugf("Deploying collector binary '%s' for architecture '%s'.", collectorName, c.Architecture) - collectorBinary, err := assets.Collector.ReadFile(collectorName) + collectorBinary, err := assets.ReadCollectorFile(collectorName) if err != nil { // Somehow the file doesn't exist return errors.New("couldn't find the collector binary") diff --git a/assets/assets.go b/assets/assets_bundled.go similarity index 90% rename from assets/assets.go rename to assets/assets_bundled.go index 637991a..423bb2f 100644 --- a/assets/assets.go +++ b/assets/assets_bundled.go @@ -3,6 +3,8 @@ // Use of this software is governed by the MVT License 1.1 that can be found at // https://license.mvt.re/1.1/ +//go:build !unbundle + package assets import ( @@ -15,13 +17,18 @@ import ( ) //go:embed collector_* -var Collector embed.FS +var collector embed.FS type Asset struct { Name string Data []byte } +// Read a specific embedded collector binary +func ReadCollectorFile(collectorName string) ([]byte, error) { + return collector.ReadFile(collectorName) +} + // DeployAssets is used to retrieve the embedded adb binaries and store them. func DeployAssets() error { cwd := saveRuntime.GetExecutableDirectory() diff --git a/assets/assets_darwin.go b/assets/assets_darwin.go index f2e71da..a57265f 100644 --- a/assets/assets_darwin.go +++ b/assets/assets_darwin.go @@ -3,6 +3,8 @@ // Use of this software is governed by the MVT License 1.1 that can be found at // https://license.mvt.re/1.1/ +//go:build !unbundle + package assets import ( diff --git a/assets/assets_linux.go b/assets/assets_linux.go index 28416d2..a87dfd3 100644 --- a/assets/assets_linux.go +++ b/assets/assets_linux.go @@ -3,6 +3,8 @@ // Use of this software is governed by the MVT License 1.1 that can be found at // https://license.mvt.re/1.1/ +//go:build !unbundle + package assets import ( diff --git a/assets/assets_system.go b/assets/assets_system.go new file mode 100644 index 0000000..1d14424 --- /dev/null +++ b/assets/assets_system.go @@ -0,0 +1,29 @@ +// androidqf - Android Quick Forensics +// Copyright (c) 2026 kpcyrd. +// Use of this software is governed by the MVT License 1.1 that can be found at +// https://license.mvt.re/1.1/ + +//go:build unbundle + +package assets + +import ( + "os" + "path/filepath" +) + +// Read a specific collector binary from filesystem +func ReadCollectorFile(collectorName string) ([]byte, error) { + path := filepath.Join("/usr/lib/androidqf/android-collector", collectorName) + return os.ReadFile(path) +} + +// Assets are expected to be installed by package manager +func DeployAssets() error { + return nil +} + +// No assets to clean up +func CleanAssets() error { + return nil +} diff --git a/assets/assets_windows.go b/assets/assets_windows.go index 19031ff..55e6569 100644 --- a/assets/assets_windows.go +++ b/assets/assets_windows.go @@ -3,6 +3,8 @@ // Use of this software is governed by the MVT License 1.1 that can be found at // https://license.mvt.re/1.1/ +//go:build !unbundle + package assets import ( From 94590a12972bb2cf913d29f4405a3f31abba4b36 Mon Sep 17 00:00:00 2001 From: Janik Besendorf Date: Wed, 27 May 2026 18:07:37 +0200 Subject: [PATCH 2/2] Document unbundle package build requirements --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 394dc91..1a74ff0 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,27 @@ Then compile AndroidQF for your platform of choice: These commands will generate binaries in a *build/* folder. +### Building for distribution packages without bundled assets + +Distribution packages can opt out of embedding the bundled ADB and collector +binaries by building with the `unbundle` build tag: + +```bash +go build -tags unbundle -o build/ +``` + +When this tag is enabled, androidqf expects: + +- `adb` to be available from the system `PATH`. +- collector binaries to be installed under + `/usr/lib/androidqf/android-collector/` using the names expected by + androidqf, such as `collector_arm` and `collector_arm64`. + +Packagers may remove the bundled binary assets from `assets/` before building, +but the `assets/` package directory and its Go source files must remain present. +The `unbundle` build still imports the `assets` package, and the build will fail +if the whole `assets/` directory is deleted. + ## How to use > [!TIP]