Skip to content

Commit ba4cbda

Browse files
kpcyrdbesendorf
andauthored
Add -tags unbundle to read executables from filesystem (#83)
* Add `-tags unbundle` to read executables from filesystem * Document unbundle package build requirements --------- Co-authored-by: Janik Besendorf <janik@besendorf.org>
1 parent c142aa1 commit ba4cbda

7 files changed

Lines changed: 65 additions & 2 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,27 @@ Then compile AndroidQF for your platform of choice:
4848

4949
These commands will generate binaries in a *build/* folder.
5050

51+
### Building for distribution packages without bundled assets
52+
53+
Distribution packages can opt out of embedding the bundled ADB and collector
54+
binaries by building with the `unbundle` build tag:
55+
56+
```bash
57+
go build -tags unbundle -o build/
58+
```
59+
60+
When this tag is enabled, androidqf expects:
61+
62+
- `adb` to be available from the system `PATH`.
63+
- collector binaries to be installed under
64+
`/usr/lib/androidqf/android-collector/` using the names expected by
65+
androidqf, such as `collector_arm` and `collector_arm64`.
66+
67+
Packagers may remove the bundled binary assets from `assets/` before building,
68+
but the `assets/` package directory and its Go source files must remain present.
69+
The `unbundle` build still imports the `assets` package, and the build will fail
70+
if the whole `assets/` directory is deleted.
71+
5172
## How to use
5273

5374
> [!TIP]

adb/collector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (c *Collector) Install() error {
112112
}
113113

114114
log.Debugf("Deploying collector binary '%s' for architecture '%s'.", collectorName, c.Architecture)
115-
collectorBinary, err := assets.Collector.ReadFile(collectorName)
115+
collectorBinary, err := assets.ReadCollectorFile(collectorName)
116116
if err != nil {
117117
// Somehow the file doesn't exist
118118
return errors.New("couldn't find the collector binary")
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Use of this software is governed by the MVT License 1.1 that can be found at
44
// https://license.mvt.re/1.1/
55

6+
//go:build !unbundle
7+
68
package assets
79

810
import (
@@ -15,13 +17,18 @@ import (
1517
)
1618

1719
//go:embed collector_*
18-
var Collector embed.FS
20+
var collector embed.FS
1921

2022
type Asset struct {
2123
Name string
2224
Data []byte
2325
}
2426

27+
// Read a specific embedded collector binary
28+
func ReadCollectorFile(collectorName string) ([]byte, error) {
29+
return collector.ReadFile(collectorName)
30+
}
31+
2532
// DeployAssets is used to retrieve the embedded adb binaries and store them.
2633
func DeployAssets() error {
2734
cwd := saveRuntime.GetExecutableDirectory()

assets/assets_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Use of this software is governed by the MVT License 1.1 that can be found at
44
// https://license.mvt.re/1.1/
55

6+
//go:build !unbundle
7+
68
package assets
79

810
import (

assets/assets_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Use of this software is governed by the MVT License 1.1 that can be found at
44
// https://license.mvt.re/1.1/
55

6+
//go:build !unbundle
7+
68
package assets
79

810
import (

assets/assets_system.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// androidqf - Android Quick Forensics
2+
// Copyright (c) 2026 kpcyrd.
3+
// Use of this software is governed by the MVT License 1.1 that can be found at
4+
// https://license.mvt.re/1.1/
5+
6+
//go:build unbundle
7+
8+
package assets
9+
10+
import (
11+
"os"
12+
"path/filepath"
13+
)
14+
15+
// Read a specific collector binary from filesystem
16+
func ReadCollectorFile(collectorName string) ([]byte, error) {
17+
path := filepath.Join("/usr/lib/androidqf/android-collector", collectorName)
18+
return os.ReadFile(path)
19+
}
20+
21+
// Assets are expected to be installed by package manager
22+
func DeployAssets() error {
23+
return nil
24+
}
25+
26+
// No assets to clean up
27+
func CleanAssets() error {
28+
return nil
29+
}

assets/assets_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Use of this software is governed by the MVT License 1.1 that can be found at
44
// https://license.mvt.re/1.1/
55

6+
//go:build !unbundle
7+
68
package assets
79

810
import (

0 commit comments

Comments
 (0)