Skip to content

Conversation

@martacarbone
Copy link
Contributor

@martacarbone martacarbone commented Dec 14, 2025

Motivation

Currently the examples (and other static data) are stored inside the arduino home folder.
Current location: ~/.local/share/arduino-app-cli

This is needed because at some point the arduino-flasher-cli will support keeping user data, by preserving the user partition (where the arduino home folder is mounted). And we cannot keep some static data in the preserved paths, otherwise that data would not match the software version that gets installed in the root partition (which is not preserved).

Change description

# copied from prev installation
/home/arduino/.local/share/arduino-app-cli/examples -> /var/lib/arduino-app-cli/examples
/home/arduino/.local/share/arduino-app-cli/properties.msgpack -> /var/lib/arduino-app-cli/properties.msgpack
/home/arduino/.local/share/arduino-app-cli/bootloader_burned.flag -> /var/lib/arduino-app-cli/bootloader_burned.flag
/home/arduino/.local/share/arduino-app-cli/properties.msgpack.lock -> /var/lib/arduino-app-cli/properties.msgpack.lock

# created by the new installation
/home/arduino/.local/share/arduino-app-cli/assets -> /var/lib/arduino-app-cli/assets
/home/arduino/.local/share/arduino-app-cli/examples -> /var/lib/arduino-app-cli/examples (overwrite)

Additional Notes

The installation scripts try to gracefully stop any runner application and delete the .cache directory, allowing the packaging system to clean the installed files.

Test

Case test #1 fresh install

# Test from a clean system, expected no package installed, empty local dir
dpkg -l |grep arduino-app-cli;
ls -la /home/arduino/.local;
# going to install
sudo dpkg --install arduino-app-cli_0.9.0-1_arm64.deb ;
# expect no .local, expected examples and assets in new dir
ls -la /home/arduino/.local/share/arduino-app-cli;
ls -la /var/lib/arduino-app-cli/;

Case test #2 purge after a fresh install

# check 0.9.0 installed
dpkg -l |grep arduino-app-cli
# Create caches
# Start blink
arduino-app-cli app start /var/lib/arduino-app-cli/examples/blink
# check cache
ls -la /var/lib/arduino-app-cli/examples/blink
# purge
sudo dpkg --purge arduino-app-cli
# check not installed
dpkg -l |grep arduino-app-cli
# check not exists
ls -la /var/lib/arduino-app-cli/
# this does not exists before too
ls -la /home/arduino/.local/share/arduino-app-cli

Case test #3 upgrade from 0.8.0 to 0.9.0

# old version should be installed
dpkg -l |grep arduino-app-cli
dpkg --install arduino-app-cli_0.8.0-1_arm64.deb
# expected
ls -la /home/arduino/.local/share/arduino-app-cli/examples/blink
# not expected
ls -la /var/lib/arduino-app-cli/examples/blink
# trigger cache creation, start app
arduino-app-cli app start  /home/arduino/.local/share/arduino-app-cli/examples/blink
# expected to see .cache
ls -la /home/arduino/.local/share/arduino-app-cli/examples/blink
# here no .cache
ls -la /home/arduino/.local/share/arduino-app-cli/examples/code-detector/
# run upgrade
sudo apt install ./arduino-app-cli_0.9.0-1_arm64.deb
# test upgrade results
# check new package is installed
dpkg -l |grep arduino-app-cli
# check for .cache removal
ls -la /home/arduino/.local/share/arduino-app-cli/examples/blink
# here all should be fine
find /home/arduino/.local/share/arduino-app-cli/
# check new file installation
# expected assets and examples
ls -la /var/lib/arduino-app-cli
# run blink
arduino-app-cli app start  /var/lib/arduino-app-cli/examples/blink
# verify .cache is created in the new dir (the old one not exists, the new one has .cache)
ls -la /home/arduino/.local/share/arduino-app-cli/examples/blink
ls -la /var/lib/arduino-app-cli/examples/blink

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged in main.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

Comment on lines 10 to 11
echo "Running pre-0.8.0 legacy cleanup/migration..."
cleanup_arduino_examples /home/arduino/.local/share/arduino-app-cli/examples
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Running pre-0.8.0 legacy cleanup/migration..."
cleanup_arduino_examples /home/arduino/.local/share/arduino-app-cli/examples

Copy link
Contributor Author

@martacarbone martacarbone Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the cleanup of old dir examples; leave the app shutdown and cache cleanup of /var/lib/arduino-app-cli

cleanup_arduino_examples /home/arduino/.local/share/arduino-app-cli/examples
fi
fi
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fi
cp -r /home/arduino/.local/share/arduino-app-cli /examples /var/lib/arduino-app-cli

Copy link
Contributor Author

@martacarbone martacarbone Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the copy of examples here; add the copy of properties.msgpack* and bootloader_burned.flag here;
add rm -rf of examples, properties.msgpack, properties.msgpack.lock and bootloader_burned.flag in postinst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants