pi-gen: Choosing the package to install or to skip

Pi-gen has nicely divided the build process into stages so that we can choose which stages to build and which stages to skip. However, within a stage, sometimes there are still packages that we want to include or exclude. For example, I like to use the vim text editor which is not included anywhere. I see that stage2 is where system packages are installed, so I added vim at the end of stage02/01-sys-tweaks/00-packages.

I haven’t used Epiphany browser before, and I think I only need Chromium for my project. So I can save some build time and some disk space by excluding it from my packages. Basically I removed the line with ephibany-browser from stage3/00-install-packages/00-packages-nr.

One thing that intrigued me was the difference between the file names for 00-packages and 00-packages-nr, and in some folders both files are present. So what determines which package should be in which file? I took a look at build.sh and the answer is there:

  • For packages defined in 00-packages, the command to install the packages is apt-get install -y $PACKAGES
  • For packages defined in 00-packages-nr, the command to install the packages is apt-get install --no-install-recommends -y $PACKAGES

pi-gen: Starting chromium into kiosk mode upon start-up

In my use-case, I want the GUI to start Chromium into kiosk mode. This is done by putting settings into the autostart file.  Stage3 in pi-gen is where the GUI is first installed, so I used the 01-tweaks sub-stage to specify this.

I added the folder files under stage3/01-tweaks and created a file autostart with the following contents:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xset s off
@xset -dpms
@xset s noblank
@sed -i 's/"exited_cleanly": false/"exited_cleanly": true/' ~/.config/chromium-browser Default/Preferences
@chromium-browser --noerrdialogs --kiosk http://apple.com --incognito --disable-translate

Note that I used apple.com in this example. You can use whatever URL you like.

To copy the above file into the correct place in the image, we need to add the following lines at the end of stage3/01-tweaks/00-run.sh:

install -v -d                         ${ROOTFS_DIR}/etc/xdg/lxsession/LXDE/
install -v -m 644 files/autostart     ${ROOTFS_DIR}/etc/xdg/lxsession/LXDE/

The first line creates the LXDE folder in the image and the second line copies the autostart file above to the /etc/xdg/lxsession/LXDE/ folder in the image.

Sustainability is key

I Learn, I Think, I Solve, I Create

I used to blog a lot, back when I had a lot of time. Looking back, some of the posts are still interesting when I read them now. I realise that if I want to remember the things I am doing today, I need to write them down somewhere, otherwise in years to come, when I try to recall what I have been spending my time on, I might pull a blank. So here I am, trying to start another blog, this one to focus on the technical stuff that I am do on a day-to-day basis. Basically every day I do one of these four things: Learn something new, Think about what I have learnt, and try to use it to Solve some problem that I am facing, and at the end, possibly Creating a way to do certain things. Yah, I think I sound abstract, but let’s see what I produce in this blog and we can better define this…