1

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?

  • 1
    Firstly, it's not an ISO, it's a bootable SDcard image. In Raspbian there's a built-in SD Card Copier tool that does this stuff for you (no coding required). github.com/raspberrypi-ui/piclone – Dougie Dec 27 '19 at 23:11
  • Thanks - fixed the ISO vs. SDcard issue. – Martin Hepp Dec 29 '19 at 10:35
1

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.

| improve this answer | |
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year. – Ingo Feb 8 at 17:05
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.

| improve this answer | |
  • Thanks - I tried to clarify the question. I want to automate as much as possible of this so that the process becomes reproducible. I strongly recommend watching Larry Hastings talk, in particular the part where he describes how he now automates all of the tasks for clean OS install on his machine with Python. – Martin Hepp Dec 29 '19 at 10:26
  • @MartinHepp If anyone can't be bothered producing readable documentation rather than a video circus it is probably of little value - I certainly won't be wasting my time watching it. Python is a great tool, but when it comes to basic OS operations it is just another layer. I have programmed in dozens of languages over the years - the art is picking the right tool. – Milliways Dec 29 '19 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.