Skip to content

idea: customisation starting from img file?  #486

Open
@RafalSkolasinski

Description

@RafalSkolasinski

In the past I used pi-gen to build a custom Raspbian image by adding stages with my customisations.
Though it was quite easy to do it this way I always find it a bit annoying that I had to go through the full build process.

Did you consider having option to run some custom stages with rootfs extracted from specified img file?

I did a very naive attempt of doing so by modifying Dockerfile used in the build process

ARG BASE_IMAGE=debian:buster
FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get -y update && \
    apt-get -y install --no-install-recommends \
        git vim parted \
        quilt coreutils qemu-user-static debootstrap zerofree zip dosfstools \
        bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file kmod bc\
        binfmt-support ca-certificates \
    && rm -rf /var/lib/apt/lists/*

# Add requiered tools
RUN apt-get -y update && \
    apt-get -y install --no-install-recommends \
        wget p7zip-full \
    && rm -rf /var/lib/apt/lists/*

# Define customisation
ENV PREV_ROOTFS_DIR /base-rootfs/
ENV BASE_IMG_URL https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2020-12-04/2020-12-02-raspios-buster-armhf-lite.zip

RUN mkdir -p ${PREV_ROOTFS_DIR} && \
    cd ${PREV_ROOTFS_DIR} && \
    wget ${BASE_IMG_URL}

RUN cd ${PREV_ROOTFS_DIR} && \
    7z x 2020-12-02-raspios-buster-armhf-lite.zip && \
    7z x 2020-12-02-raspios-buster-armhf-lite.img && \
    7z x 1.img && 7z x 0.fat -oboot/ && \
    rm 0.fat 1.img && rm *.zip *.img

# Define volumes and copy local files
COPY . /pi-gen/
VOLUME [ "/pi-gen/work", "/pi-gen/deploy"]

hoping that copy_previous will just do right thing if I have PREV_ROOTFS_DIR set, and it kind-of does but for some reason things fail on on_chroot stages with

execve /bin/bash failed!

Not sure if there is something in stage0 that I am missing or my procedure of extracting rootfs from img file was incorrect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions