diff options
author | Bryan Drewery <bryan@shatow.net> | 2021-11-20 06:46:57 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2021-11-24 06:31:02 +0300 |
commit | 56233a1aaea1be59dcc111e7b3f97b6e891bb06a (patch) | |
tree | a71ba56cf2808b4ab20f3f679e0d870252bddf87 /src | |
parent | 023730307e6e7e0878fd25665a950007b07d7bfd (diff) |
Add a mechanishm to avoid building rust in tmpfs.
- TMPFS_BLACKLIST should contain a list of package globs
- TMPFS_BLACKLIST_TMPDIR should contain a host directory prefix where
temporary directories can be created, outside tmpfs of course, to be
used as the WRKDIR for packages in TMPFS_BLACKLIST.
Fixes #888
Diffstat (limited to 'src')
-rw-r--r-- | src/etc/poudriere.conf.sample | 9 | ||||
-rwxr-xr-x | src/share/poudriere/common.sh | 36 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/etc/poudriere.conf.sample b/src/etc/poudriere.conf.sample index 71b5b897..f6020fb3 100644 --- a/src/etc/poudriere.conf.sample +++ b/src/etc/poudriere.conf.sample @@ -62,6 +62,15 @@ USE_TMPFS=yes # (default: none) #TMPFS_LIMIT=8 +# List of package globs that are not allowed to use tmpfs for their WRKDIR +# Note that you *must* set TMPFS_BLACKLIST_TMPDIR +# EXAMPLE: TMPFS_BLACKLIST="rust" + +# The host path where tmpfs-blacklisted packages can be built in. +# A temporary directory will be generated here and be null-mounted as the +# WRKDIR for any packages listed in TMPFS_BLACKLIST. +# EXAMPLE: TMPFS_BLACKLIST_TMPDIR=${BASEFS}/data/cache/tmp + # How much memory to limit jail processes to for *each builder* # in GiB (default: none) #MAX_MEMORY=8 diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 517c3c11..0570e940 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -4633,6 +4633,16 @@ stop_builders() { parallel_run stop_builder "${j}" done parallel_stop + + if [ -n "${TMPFS_BLACKLIST_TMPDIR-}" ] && + [ -d "${TMPFS_BLACKLIST_TMPDIR}/wrkdirs" ]; then + if ! rm -rf "${TMPFS_BLACKLIST_TMPDIR}/wrkdirs/"*; then + chflags -R 0 \ + "${TMPFS_BLACKLIST_TMPDIR}/wkrdirs"/* || : + rm -rf "${TMPFS_BLACKLIST_TMPDIR}/wrkdirs"/* || + : + fi + fi fi # No builders running, unset JOBS @@ -5006,6 +5016,7 @@ build_pkg() { local log local errortype local ret=0 + local tmpfs_blacklist_dir local elapsed now pkgname_varname jpkg originspec _my_path mnt @@ -5052,11 +5063,30 @@ build_pkg() { :> "${mnt}/${LOCALBASE:-/usr/local}/.mounted" fi + if [ -f "${mnt}/.tmpfs_blacklist_dir" ]; then + umount "${mnt}/wrkdirs" + rm -rf $(cat "${mnt}/.tmpfs_blacklist_dir") + fi [ -f ${mnt}/.need_rollback ] && rollbackfs prepkg ${mnt} [ -f ${mnt}/.need_rollback ] && \ err 1 "Failed to rollback ${mnt} to prepkg" :> ${mnt}/.need_rollback + for jpkg in ${TMPFS_BLACKLIST-}; do + case "${pkgname%-*}" in + ${jpkg}) + mkdir -p "${TMPFS_BLACKLIST_TMPDIR:?}/wrkdirs" + tmpfs_blacklist_dir=$(\ + TMPDIR="${TMPFS_BLACKLIST_TMPDIR:?}/wrkdirs" \ + mktemp -dt "${pkgname}") + ${NULLMOUNT} "${tmpfs_blacklist_dir}" "${mnt}/wrkdirs" + echo "${tmpfs_blacklist_dir}" \ + > "${mnt}/.tmpfs_blacklist_dir" + break + ;; + esac + done + rm -rfx ${mnt}/wrkdirs/* || : log_start "${pkgname}" 0 @@ -5135,6 +5165,12 @@ build_pkg() { -DNOCLEANDEPENDS clean ${MAKE_ARGS} || : rm -rfx ${mnt}/wrkdirs/* || : + if [ -n "${tmpfs_blacklist_dir}" ]; then + umount "${mnt}/wrkdirs" + rm -f "${mnt}/.tmpfs_blacklist_dir" + rm -rf "${tmpfs_blacklist_dir}" + fi + clean_pool "${pkgname}" "${originspec}" "${clean_rdepends}" stop_build "${pkgname}" "${originspec}" ${build_failed} |