diff --git a/ChangeLog b/ChangeLog index d644771..0c36105 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ SystemRescue ChangeLog 9.02 (YYYY-MM-DD): ------------------------------------------------------------------------------- * Fix the type of the default definition of parameter "ar_attempts" (#266) +* Added scripts and documentation to help build the ISO image in a docker container ------------------------------------------------------------------------------- 9.01 (2022-02-10): diff --git a/README.md b/README.md index ce462d1..38e464f 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,14 @@ The build process can be started by running the build.sh script. It will create a large "work" sub-directory and the ISO file will be written in the "out" sub-directory. +If you are not running archlinux, you can run the build process in docker. +You need to have a Linux system running with docker installed and configured. +You can use the scripts provided in the `docker` folder of this repository. +First you need to run the script which builds a new docker image, and then you +need to run the script which uses this docker image to builds the ISO image. + ## Including your SystemRescueModules If you want to include your own [SystemRescueModules][srm], place their srm files in the [srm](./srm) directory of the repository before running the build script. [srm]: https://www.system-rescue.org/Modules/ - diff --git a/docker/Dockerfile-build-iso-x86_64 b/docker/Dockerfile-build-iso-x86_64 new file mode 100644 index 0000000..37be4bc --- /dev/null +++ b/docker/Dockerfile-build-iso-x86_64 @@ -0,0 +1,6 @@ +FROM archlinux:latest +RUN mkdir -p /workspace +COPY tmpfiles/pacman.conf /etc/pacman.conf +RUN pacman -Syyu --noconfirm archiso binutils edk2-shell grub hugo mtools && rm -rf /var/cache/pacman/pkg/* +CMD ["setarch","x86_64","/usr/bin/bash"] +WORKDIR /workspace diff --git a/docker/build-docker-image.sh b/docker/build-docker-image.sh new file mode 100755 index 0000000..461af42 --- /dev/null +++ b/docker/build-docker-image.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +# Parameters +architecture="x86_64" +dockerimg="sysrescuebuildiso-${architecture}:latest" + +# Determine the path to the git repository +fullpath="$(realpath $0)" +curdir="$(dirname ${fullpath})" +repodir="$(realpath ${curdir}/..)" +tmpdir="${repodir}/docker/tmpfiles" +echo "fullpath=${fullpath}" +echo "repodir=${repodir}" + +# Copy configuration files +mkdir -p ${tmpdir} +cp -a ${repodir}/pacman.conf ${tmpdir} + +# Build the docker image +docker build -t ${dockerimg} -f ${repodir}/docker/Dockerfile-build-iso-${architecture} ${repodir}/docker + +# Cleanup +rm -rf ${tmpdir} diff --git a/docker/build-iso-image.sh b/docker/build-iso-image.sh new file mode 100755 index 0000000..95ec138 --- /dev/null +++ b/docker/build-iso-image.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Parameters +architecture="x86_64" +dockerimg="sysrescuebuildiso-${architecture}:latest" + +# Make sure the docker image exists +if ! docker inspect ${dockerimg} >/dev/null 2>/dev/null ; then + echo "ERROR: You must build the following docker image before you run this script: ${dockerimg}" + exit 1 +fi + +# Determine the path to the git repository +fullpath="$(realpath $0)" +curdir="$(dirname ${fullpath})" +repodir="$(realpath ${curdir}/..)" +echo "curdir=${curdir}" +echo "repodir=${repodir}" + +# Create a tmpfs for storing packages cache in memory +pkgcache="/tmp/pkgcache" +echo "pkgcache=${pkgcache}" +mkdir -p ${pkgcache} +if ! findmnt ${pkgcache} >/dev/null; then + echo "Mounting ${pkgcache} as a tmpfs" + sudo mount -t tmpfs tmpfs -o size=2G ${pkgcache} +fi + +# Run the build process in the container +docker run --user 0:0 --privileged -it --workdir /workspace \ + --volume=${repodir}:/workspace \ + --volume=${pkgcache}:/var/cache/pacman/pkg \ + ${dockerimg} setarch ${architecture} /bin/bash -x /workspace/build.sh "$@"