diff options
author | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-04-23 11:58:19 +0400 |
---|---|---|
committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2014-04-23 11:58:19 +0400 |
commit | 7e457d7068c92e31bd276486d06039ec16606bb7 (patch) | |
tree | 1744da85bac7558d9f325599e1ef0f07bb96e1e2 | |
parent | 5bfd2bffdd059aa213f5ddb24176f68000487d9d (diff) |
Reduce jail dancing by at start creating 2 version of each jails, one with network and the other without network
-rwxr-xr-x | src/share/poudriere/common.sh | 32 | ||||
-rwxr-xr-x | src/share/poudriere/jail.sh | 6 |
2 files changed, 18 insertions, 20 deletions
diff --git a/src/share/poudriere/common.sh b/src/share/poudriere/common.sh index 089a6cbe..7e3bb3d1 100755 --- a/src/share/poudriere/common.sh +++ b/src/share/poudriere/common.sh @@ -126,27 +126,30 @@ my_path() { my_name() { echo ${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}} } - + log_path() { echo "${POUDRIERE_DATA}/logs/${POUDRIERE_BUILD_TYPE}/${MASTERNAME}/${BUILDNAME}" } injail() { - jexec -U ${JUSER:-root} ${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}} "$@" + jexec -U ${JUSER:-root} ${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}}${JNETNAME:+-${JNETNAME}} "$@" } jstart() { - local enable_networking="$1" local network="${localipargs}" - [ "${RESTRICT_NETWORKING}" = "yes" ] || enable_networking=1 - [ ${enable_networking} -eq 1 ] && network="${ipargs}" + [ "${RESTRICT_NETWORKING}" = "yes" ] || network="${ipargs}" jail -c persist name=${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}} \ path=${MASTERMNT}${MY_JOBID+/../${MY_JOBID}} \ host.hostname=${BUILDER_HOSTNAME-${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}}} \ ${network} \ allow.socket_af allow.raw_sockets allow.chflags allow.sysvipc + jail -c persist name=${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}}-network \ + path=${MASTERMNT}${MY_JOBID+/../${MY_JOBID}} \ + host.hostname=${BUILDER_HOSTNAME-${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}}} \ + ${ipargs} \ + allow.socket_af allow.raw_sockets allow.chflags allow.sysvipc if ! injail id ${PORTBUILD_USER} >/dev/null 2>&1 ; then msg_n "Creating user/group ${PORTBUILD_USER}" injail pw groupadd ${PORTBUILD_USER} -g 65532 || \ @@ -159,6 +162,7 @@ jstart() { jstop() { jail -r ${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}} 2>/dev/null || : + jail -r ${MASTERNAME}${MY_JOBID+-job-${MY_JOBID}}-network 2>/dev/null || : } eargs() { @@ -788,8 +792,7 @@ enter_interactive() { done # Enable networking - jstop - jstart 1 + JNETNAME="network" # Create a pkgng repo configuration, and disable FreeBSD if [ ${PKGNG} -eq 1 ]; then @@ -1122,7 +1125,7 @@ jail_start() { test -n "${RESOLV_CONF}" && cp -v "${RESOLV_CONF}" "${tomnt}/etc/" msg "Starting jail ${MASTERNAME}" - jstart 0 + jstart # Only set STATUS=1 if not turned off # jail -s should not do this or jail will stop on EXIT WITH_PKGNG=$(injail make -f /usr/ports/Mk/bsd.port.mk -V WITH_PKGNG) @@ -1477,8 +1480,7 @@ _real_build_port() { mkdir -p ${mnt}/portdistfiles echo "DISTDIR=/portdistfiles" >> ${mnt}/etc/make.conf gather_distfiles ${portdir} ${DISTFILES_CACHE} ${mnt}/portdistfiles || return 1 - jstop - jstart 1 + JNETNAME="network" JUSER=root ;; extract) @@ -1588,8 +1590,7 @@ _real_build_port() { fi if [ "${phase}" = "checksum" ]; then - jstop - jstart 0 + JNETNAME="" fi print_phase_footer @@ -1856,7 +1857,7 @@ start_builder() { markfs prepkg ${mnt} >/dev/null do_jail_mounts ${mnt} ${arch} do_portbuild_mounts ${mnt} ${jname} ${ptname} ${setname} - jstart 0 + jstart bset ${id} status "idle:" } @@ -2226,7 +2227,7 @@ build_pkg() { jstop [ -f ${mnt}/.need_rollback ] && rollbackfs prepkg ${mnt} # Make sure we start with no network - jstart 0 + jstart :> ${mnt}/.need_rollback @@ -3391,8 +3392,7 @@ build_repo() { -o ${MASTERMNT}/tmp/packages ${MASTERMNT}/packages \ ${SIGNING_COMMAND:+signing_command: ${SIGNING_COMMAND}} else - jstop - jstart 1 + JNETNAME="network" injail /poudriere/pkg-static repo -o /tmp/packages \ /packages \ ${SIGNING_COMMAND:+signing_command: ${SIGNING_COMMAND}} diff --git a/src/share/poudriere/jail.sh b/src/share/poudriere/jail.sh index 3ba6fde3..1d5679b7 100755 --- a/src/share/poudriere/jail.sh +++ b/src/share/poudriere/jail.sh @@ -164,7 +164,7 @@ update_jail() { MASTERNAME=${JAILNAME} [ -n "${RESOLV_CONF}" ] && cp -v "${RESOLV_CONF}" "${JAILMNT}/etc/" do_jail_mounts ${JAILMNT} ${ARCH} - jstart 1 + JNETNAME="network" if [ -z "${TORELEASE}" ]; then injail env PAGER=/bin/cat /usr/sbin/freebsd-update fetch install else @@ -754,9 +754,7 @@ case "${CREATE}${INFO}${LIST}${STOP}${START}${DELETE}${UPDATE}${RENAME}" in export MASTERNAME=${JAILNAME}-${PTNAME}${SETNAME:+-${SETNAME}} export MASTERMNT=${POUDRIERE_DATA}/build/${MASTERNAME}/ref jail_start ${JAILNAME} ${PTNAME} ${SETNAME} - jstop - # Restart with network - jstart 1 + JNETNAME="network" ;; 00000100) test -z ${JAILNAME} && usage |