Distrobuilder run custom bash script

Hi,

I like distrobuilder but I was looking for an easy way to modify the image before I export it.
I used debootstrap before, so I did chroot the folder to run my custom bash script.

That doesn’t seem to work anymore.
Bash wasn’t installed, that was an easy fix, however the container had zero network connectivity.

So my attempt didn’t succeed.
This is my script.

cat << OUTEREOF | sudo chroot /home/images/build/$folder
I run my code in here…
OUTEREOF

Any ideas? I didn’t want to modify the .yaml

Modifying the YAML is really the way to go, adding extra actions makes that very easy.

If all you want to do is manipulate some files in the image you could use distrobuilder to create the root filesystem as a directory, modify the contents of the directory, then use distrobuilder to create the image.

This is what I do. I add a few configuration files and binaries this way.

Here is an example of copying the binaries.

#!/bin/bash

set -e

distrobuilder \
    --cache-dir=cache \
    --cleanup=false \
    build-dir debian-custom.yaml rootfs \
    --keep-sources=true \
    --sources-dir=sources \
    -o image.variant=cloud \
    -o image.architecture=amd64 \
    -o image.release=bookworm

cp bin/* rootfs/usr/local/bin

distrobuilder \
    --cache-dir=cache \
    --cleanup=false \
    pack-incus debian-custom.yaml rootfs tarballs \
    -o image.variant=cloud \
    -o image.architecture=amd64 \
    -o image.release=bookworm \
    -o image.serial=container \
    --compression=gzip \
    --type=unified

distrobuilder \
    --cache-dir=cache \
    --cleanup=false \
    pack-incus debian-custom.yaml rootfs tarballs \
    -o image.variant=cloud \
    -o image.architecture=amd64 \
    -o image.release=bookworm \
    -o image.serial=virtual-machine \
    -o targets.incus.vm.size=8589934592 \
    --compression=gzip \
    --type=unified \
    --vm

I don’t think that’s the case for me.
I have to build multiple images, with a different version of a software.

Its easier to just pipe them through a bash script.
Instead of making a yaml for every single version.

Seems like I use the way @jarrodu suggested, downloading and preparing the files outside of the container, then copying them in, doing the rest inside with a bash, to prepare it and let distrobuilder finish the image.