From 91b0ce1cb6dc1501af9bf55eb5200cab71210559 Mon Sep 17 00:00:00 2001 From: Francois Dupoux <2386566-fdupoux@users.noreply.gitlab.com> Date: Sat, 26 Feb 2022 17:38:12 +0000 Subject: [PATCH] Support for building the i686 edition in docker --- README.md | 25 ++++++++++++++++++++----- docker/Dockerfile-build-iso-i686 | 7 +++++++ docker/build-docker-image.sh | 16 ++++++++++++---- docker/build-iso-image.sh | 16 ++++++++++++---- 4 files changed, 51 insertions(+), 13 deletions(-) create mode 100644 docker/Dockerfile-build-iso-i686 diff --git a/README.md b/README.md index 38e464f..4c444dd 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,26 @@ 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. +## Building SystemRescue with docker +If you are not running archlinux, you can run the build process in docker +containers. 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. + +You must export the environment variable named `sysrescuearch` before you +run the two helper scripts. It should be set as either `x86_64` or `i686` +depending on the target architecture for which you want to build the ISO image. + +After this, you need to run the script which builds a new docker image, and +then the script which uses this docker image to builds the ISO image. The second +script will pass the arguments it receives to the main `build.sh` script. + +For example you can build a 64bit version of SystemRescue in docker using these commands: +``` +export sysrescuearch="x86_64" +./docker/build-docker-image.sh +./docker/build-iso-image.sh -v +``` ## Including your SystemRescueModules If you want to include your own [SystemRescueModules][srm], place their srm files diff --git a/docker/Dockerfile-build-iso-i686 b/docker/Dockerfile-build-iso-i686 new file mode 100644 index 0000000..a93fd1c --- /dev/null +++ b/docker/Dockerfile-build-iso-i686 @@ -0,0 +1,7 @@ +FROM fdupoux/archlinux32 +RUN mkdir -p /workspace +COPY tmpfiles/pacman.conf /etc/pacman.conf +RUN sed -i -e 's/^Architecture.*$/Architecture = i686/' /etc/pacman.conf +RUN pacman -Syyu --noconfirm archiso binutils edk2-shell grub hugo mtools && rm -rf /var/cache/pacman/pkg/* +CMD ["setarch","i686","/usr/bin/bash"] +WORKDIR /workspace diff --git a/docker/build-docker-image.sh b/docker/build-docker-image.sh index 461af42..4c5df6e 100755 --- a/docker/build-docker-image.sh +++ b/docker/build-docker-image.sh @@ -1,8 +1,15 @@ #!/bin/bash -# Parameters -architecture="x86_64" -dockerimg="sysrescuebuildiso-${architecture}:latest" +# Parameters validation +if [ -z "${sysrescuearch}" ] ; then + echo "ERROR: You must define the environment variable 'sysrescuearch' as either 'x86_64' or 'i686' before you run this script" + exit 1 +fi + +if [ "${sysrescuearch}" != "x86_64" ] && [ "${sysrescuearch}" != "i686" ] ; then + echo "Value '${sysrescuearch}' is invalid for environment variable 'sysrescuearch'. Only 'x86_64' and 'i686' are supported" + exit 1 +fi # Determine the path to the git repository fullpath="$(realpath $0)" @@ -17,7 +24,8 @@ 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 +dockerimg="sysrescuebuildiso-${sysrescuearch}:latest" +docker build -t ${dockerimg} -f ${repodir}/docker/Dockerfile-build-iso-${sysrescuearch} ${repodir}/docker # Cleanup rm -rf ${tmpdir} diff --git a/docker/build-iso-image.sh b/docker/build-iso-image.sh index 95ec138..08d68b3 100755 --- a/docker/build-iso-image.sh +++ b/docker/build-iso-image.sh @@ -1,10 +1,18 @@ #!/bin/bash -# Parameters -architecture="x86_64" -dockerimg="sysrescuebuildiso-${architecture}:latest" +# Parameters validation +if [ -z "${sysrescuearch}" ] ; then + echo "ERROR: You must define the environment variable 'sysrescuearch' as either 'x86_64' or 'i686' before you run this script" + exit 1 +fi + +if [ "${sysrescuearch}" != "x86_64" ] && [ "${sysrescuearch}" != "i686" ] ; then + echo "Value '${sysrescuearch}' is invalid for environment variable 'sysrescuearch'. Only 'x86_64' and 'i686' are supported" + exit 1 +fi # Make sure the docker image exists +dockerimg="sysrescuebuildiso-${sysrescuearch}:latest" 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 @@ -30,4 +38,4 @@ fi 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 "$@" + ${dockerimg} setarch ${sysrescuearch} /bin/bash /workspace/build.sh "$@"