2024-12-06 18:03:18 +01:00
|
|
|
#!/usr/bin/env bash
|
2022-02-26 17:14:18 +01:00
|
|
|
|
2022-02-26 18:38:12 +01:00
|
|
|
# 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
|
2022-02-26 17:14:18 +01:00
|
|
|
|
|
|
|
|
# Make sure the docker image exists
|
2022-02-26 18:38:12 +01:00
|
|
|
dockerimg="sysrescuebuildiso-${sysrescuearch}:latest"
|
2022-02-26 17:14:18 +01:00
|
|
|
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
|
2024-04-03 21:16:28 +02:00
|
|
|
docker run --rm --pids-limit=4096 --user 0:0 --privileged -it --workdir /workspace \
|
2022-02-26 17:14:18 +01:00
|
|
|
--volume=${repodir}:/workspace \
|
|
|
|
|
--volume=${pkgcache}:/var/cache/pacman/pkg \
|
2022-02-26 18:38:12 +01:00
|
|
|
${dockerimg} setarch ${sysrescuearch} /bin/bash /workspace/build.sh "$@"
|