Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common.sh: retrieve linux base path from sysctl when available #986

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions src/share/poudriere/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ post_getopts() {
fi
}

_sys_linuxbase() {
local default="/compat/linux"
local mib=compat.linux.emul_path
if [ -z "${NOLINUX-}" ]; then
sysctl -qn "${mib}" || echo "${default}"
else
echo "${default}"
fi
}

_mastermnt() {
local -; set -u
local hashed_name mnt mnttest mnamelen testpath mastername
Expand All @@ -314,7 +324,7 @@ _mastermnt() {
_gsub_badchars "${mastername}" ":" mastername
mnt="${POUDRIERE_DATA}/.m/${mastername}/ref"
if [ -z "${NOLINUX-}" ]; then
testpath="/compat/linux/proc"
testpath="$(_sys_linuxbase)/proc"
else
testpath="/var/db/ports"
fi
Expand Down Expand Up @@ -1753,14 +1763,15 @@ unlink() {
common_mtree() {
[ $# -eq 1 ] || eargs common_mtree mnt
local mnt="${1}"
local linuxbase=$(_sys_linuxbase)
local exclude nullpaths schgpaths dir

cat <<-EOF
./.npkg
./${DATADIR_NAME}
./.poudriere-snap-*
.${HOME}/.ccache
./compat/linux/proc
./${linuxbase}/proc
./dev
./distfiles
.${OVERLAYSDIR}
Expand Down Expand Up @@ -1959,6 +1970,7 @@ do_jail_mounts() {
local mnt="$2"
local name="$3"
local devfspath="null zero random urandom stdin stdout stderr fd fd/* pts pts/*"
local linuxbase=$(_sys_linuxbase)
local srcpath nullpaths nullpath p arch

# from==mnt is via jail -u
Expand All @@ -1967,7 +1979,7 @@ do_jail_mounts() {
if [ ${mnt##*/} = "ref" ]; then
mkdir -p ${mnt}/proc \
${mnt}/dev \
${mnt}/compat/linux/proc \
${mnt}/${linuxbase}/proc \
${mnt}/usr/src
fi

Expand Down Expand Up @@ -2003,11 +2015,11 @@ do_jail_mounts() {
mount -t procfs proc "${mnt}/proc"
fi

if [ -z "${NOLINUX-}" ] && [ -d "${mnt}/compat" ]; then
if [ -z "${NOLINUX-}" ] && [ -d "${mnt}/${linuxbase}" ]; then
_jget arch "${name}" arch || \
err 1 "Missing arch metadata for jail"
if [ "${arch}" = "i386" -o "${arch}" = "amd64" ]; then
mount -t linprocfs linprocfs "${mnt}/compat/linux/proc"
mount -t linprocfs linprocfs "${mnt}/${linuxbase}/proc"
fi
fi

Expand Down