Skip to content

Commit 5615410

Browse files
committed
snap: Turn into strict snap
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent abda498 commit 5615410

4 files changed

Lines changed: 155 additions & 4 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ dump.bmp
2727
OVMF.fd
2828
OVMF_CODE.fd
2929
OVMF_VARS.fd
30+
31+
# Snap
32+
*.snap

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,46 @@ You can find lots of examples in [EXAMPLES.md](./EXAMPLES.md).
3232
- Build from source
3333
- Homebrew
3434
- Add [this homebrew tap](https://github.com/ublue-os/homebrew-tap), then `brew install --cask framework-tool`
35+
- Snap (Not yet in the snap store!)
36+
- `sudo snap install framework-tool`
37+
- Then connect the required interfaces (see [Snap Interfaces](#snap-interfaces) below)
3538
- Cargo (Any distro)
3639
- `cargo install --locked framework_tool`
3740

41+
#### Snap Interfaces
42+
43+
The snap uses strict confinement. After installing, connect the required interfaces
44+
to allow access to the hardware:
45+
46+
```sh
47+
# Required for most functionality (EC communication)
48+
sudo snap connect framework-tool:cros-ec
49+
sudo snap connect framework-tool:hardware-observe
50+
51+
# Required for HID devices (touchpad, touchscreen, PD controller firmware)
52+
sudo snap connect framework-tool:hidraw
53+
54+
# Required for USB devices (expansion cards, input modules, camera)
55+
sudo snap connect framework-tool:raw-usb
56+
57+
# Required for NVMe firmware version detection
58+
sudo snap connect framework-tool:block-devices
59+
60+
# Required for EC port I/O fallback (when cros_ec driver is unavailable)
61+
sudo snap connect framework-tool:io-ports-control
62+
63+
# Required for SMBIOS table fallback via /dev/mem
64+
sudo snap connect framework-tool:physical-memory-observe
65+
```
66+
67+
You can connect all interfaces at once:
68+
69+
```sh
70+
for plug in cros-ec hardware-observe hidraw raw-usb block-devices io-ports-control physical-memory-observe; do
71+
sudo snap connect framework-tool:$plug
72+
done
73+
```
74+
3875
### Windows
3976

4077
```

contrib/snap.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Snap Package
2+
3+
## Building
4+
5+
Make sure `snapcraft` is installed:
6+
7+
```sh
8+
sudo snap install snapcraft --classic
9+
```
10+
11+
Build the snap:
12+
13+
```sh
14+
snapcraft
15+
```
16+
17+
This produces a file like `framework-tool_v0.6.1-20-gabda498ca6_amd64.snap`.
18+
19+
To clean up build artifacts and start fresh:
20+
21+
```sh
22+
snapcraft clean
23+
```
24+
25+
## Installing Locally
26+
27+
Install the locally built snap (bypasses store signature check):
28+
29+
```sh
30+
sudo snap install --dangerous framework-tool_*.snap
31+
```
32+
33+
## Connecting Interfaces
34+
35+
The snap uses strict confinement, so hardware interfaces must be connected
36+
manually after install:
37+
38+
```sh
39+
for plug in cros-ec hardware-observe hidraw raw-usb block-devices io-ports-control physical-memory-observe; do
40+
sudo snap connect framework-tool:$plug
41+
done
42+
```
43+
44+
Verify the connections:
45+
46+
```sh
47+
snap connections framework-tool
48+
```
49+
50+
## Testing
51+
52+
```sh
53+
# Basic functionality
54+
sudo framework-tool --help
55+
sudo framework-tool --versions
56+
sudo framework-tool --esrt
57+
58+
# EC communication (needs cros-ec + hardware-observe)
59+
sudo framework-tool --power
60+
sudo framework-tool --pdports
61+
62+
# HID devices (needs hidraw)
63+
sudo framework-tool --touchpad-info
64+
65+
# USB devices (needs raw-usb)
66+
sudo framework-tool --dp-hdmi-info
67+
sudo framework-tool --audio-card-info
68+
69+
# NVMe (needs block-devices)
70+
sudo framework-tool --nvme-info
71+
```
72+
73+
If a command fails with a permission error, check which interface it needs
74+
and make sure it is connected.
75+
76+
## Publishing
77+
78+
See: https://snapcraft.io/docs/releasing-your-app
79+
80+
Note: Several interfaces (`block-devices`, `physical-memory-observe`,
81+
`io-ports-control`, `system-files`) are privileged and require a manual
82+
review by the snap store team before they can be used in a published snap.

snap/snapcraft.yaml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: framework-tool
2+
title: Framework Tool
23
base: core24
34
adopt-info: framework-tool
5+
license: BSD-2-Clause
6+
contact: https://github.com/FrameworkComputer/framework-system/issues
7+
issues: https://github.com/FrameworkComputer/framework-system/issues
8+
source-code: https://github.com/FrameworkComputer/framework-system
9+
website: https://frame.work
410
summary: CLI tool to inspect and control Framework Computer systems
511
description: |
612
framework_tool is a CLI utility to interact with Framework Computer laptop
@@ -16,9 +22,18 @@ description: |
1622
Note: Most features require root privileges (sudo framework-tool ...).
1723
1824
grade: stable
19-
confinement: classic
25+
confinement: strict
2026
compression: lzo
2127

28+
# /dev/cros_ec needs ioctl access, which requires custom-device interface.
29+
# This needs a store assertion for the slot. For local testing use --devmode.
30+
plugs:
31+
cros-ec:
32+
interface: custom-device
33+
custom-device: cros-ec
34+
devices:
35+
- /dev/cros_ec
36+
2237
parts:
2338
framework-tool:
2439
plugin: rust
@@ -35,14 +50,14 @@ parts:
3550
override-pull: |
3651
craftctl default
3752
VERSION=$(craftctl get version)
38-
if [ -z $VERSION ]; then
53+
if [ -z "$VERSION" ] && git rev-parse --git-dir > /dev/null 2>&1; then
3954
VERSION=$(git describe --tags --abbrev=10)
40-
craftctl set version=$VERSION
55+
craftctl set version="$VERSION"
4156
fi
4257
override-build: |
4358
cd "${CRAFT_PART_SRC}"
4459
cargo build --release -p framework_tool --features nvidia
45-
install -Dm755 target/release/framework_tool "${CRAFT_PART_INSTALL}/bin/framework_tool"
60+
install -Dm755 "${CRAFT_PART_SRC}/target/release/framework_tool" "${CRAFT_PART_INSTALL}/bin/framework_tool"
4661
install -Dm644 "${CRAFT_PART_SRC}/completions/bash/framework_tool" \
4762
"${CRAFT_PART_INSTALL}/share/bash-completion/completions/framework_tool"
4863
install -Dm644 "${CRAFT_PART_SRC}/completions/zsh/_framework_tool" \
@@ -53,3 +68,17 @@ parts:
5368
apps:
5469
framework-tool:
5570
command: bin/framework_tool
71+
plugs:
72+
# EC communication via /dev/cros_ec ioctl
73+
- cros-ec
74+
# HID devices: touchpad, touchscreen, PD controller firmware
75+
- hidraw
76+
# USB devices: audio card, camera, USB hub, input modules
77+
- raw-usb
78+
# NVMe device access for firmware version detection
79+
- block-devices
80+
# /dev/mem for SMBIOS table fallback, /dev/port for EC port I/O
81+
- physical-memory-observe
82+
- io-ports-control
83+
# /sys/firmware (SMBIOS/DMI, EFI ESRT), /sys/class/mei, hardware enumeration
84+
- hardware-observe

0 commit comments

Comments
 (0)