3

For a new project, I plan to release ready-to-use bootable SDcard image files for various Raspberry Pi models (2, 3, Zero, Zero-W). The actual OS will be PiCore, the RAM-only Linux variant based on Tiny Core.

The required customization steps will be

  • installing packages
  • changing configuration files
  • some Unix shell commands (like changing file permissions)
  • generating or modifying some files.

The required steps are basically clear, but I want to minimize the manual effort AND remove the risk of errors or omissions AND have a single, transparent place for keeping track of the respective knowledge.

I could simply write down the required steps, execute them per each release, and then create and compress an SDcard image from that.

However, inspired by Larry Hasting's argument of automating task in Python rather than collections of shell scripts, I want to write a Python script that does most of the work in order to automate the future release cycles.

It is clear that the exact steps will have to evolve with future releases of the OS, and that there must be automated testing, too.

What is the best way to achieve this? My naive approach would be:

  1. Write a simple shell script #1 for downloading and burning the latest version of the OS to an SD card.
  2. Write a Python script that will
    • connect to the Raspberry via SSH
    • either execute the necessary shell commands for installing packages etc. via SSH or copying another Python script to the RBPi and then running it therefrom.
  3. A third script that generates an SDcard image, does some post-processing (e.g. compression) etc.

Has anybody done this before? Are there readily available tools for automating this?

Martin Hepp
  • 181
  • 7

2 Answers2

5

Bart van Leeuwen pointed me to CustomPiOS as a nice solution:

https://github.com/guysoft/CustomPiOS

It may not work for my project, because it is bound to Raspbian (and I will need PiCore), and it is not Python, but as far as I can know, it is the best solution to the problem of generating custom images for Raspberry Pi projects.

Here is a list of projects that use CustomPiOS for their images.

Martin Hepp
  • 181
  • 7
0

Your question is unclear.

If you plan to make new images each time using latest available packages it is a non-trivial task, which requires manual intervention to test compatibility etc, but there are available tools.

If your intention is to customise an image, adding your own packages it can be done, but there is no way to avoid the effort involved in resolving incompatibilities. I do this when a new version of Raspbian is released, but this has to be customised each time.

If you want to make images which can be used to generate new SD Cards from a working image, you could use a variant of the procedure I use to make backup images.

This runs on the Pi itself, but could be adapted to run on another Linux machine. https://raspberrypi.stackexchange.com/a/103991/8697

Attempting to do any of these from Python is unrealistic, and unnecessary.

Milliways
  • 62,573
  • 32
  • 113
  • 225