From owner-p4-projects@FreeBSD.ORG Tue Jul 24 23:14:42 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 22F5C16A419; Tue, 24 Jul 2007 23:14:42 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA94716A417 for ; Tue, 24 Jul 2007 23:14:41 +0000 (UTC) (envelope-from sat@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id E0E2E13C442 for ; Tue, 24 Jul 2007 23:14:41 +0000 (UTC) (envelope-from sat@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l6ONEfjV010817 for ; Tue, 24 Jul 2007 23:14:41 GMT (envelope-from sat@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l6ONEfcX010814 for perforce@freebsd.org; Tue, 24 Jul 2007 23:14:41 GMT (envelope-from sat@freebsd.org) Date: Tue, 24 Jul 2007 23:14:41 GMT Message-Id: <200707242314.l6ONEfcX010814@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sat@freebsd.org using -f From: Andrew Pantyukhin To: Perforce Change Reviews Cc: Subject: PERFORCE change 124062 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jul 2007 23:14:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=124062 Change 124062 by sat@sat_amilo on 2007/07/24 23:14:33 - Finally back in a seemingly working shape Affected files ... .. //depot/projects/soc2006/gabor_destdir/Mk/bsd.destdir.mk#26 edit Differences ... ==== //depot/projects/soc2006/gabor_destdir/Mk/bsd.destdir.mk#26 (text+ko) ==== @@ -52,7 +52,7 @@ _DESTDIRMKINCLUDED= yes DESTDIR_ENV_LIST?= -DESTDIR_ENV= DESTDIR= CHROOTED=YES +DESTDIR_ENV= CHROOTED=yes .for _var in ${DESTDIR_ENV_LIST:NDESTDIR:NCHROOTED:NPORTSDIR} DESTDIR_ENV+= ${_var}="${${_var}}" .endfor @@ -63,7 +63,7 @@ # VAR:HOST_PATH:DEST_PATH # VAR -> VAR:${VAR}:TMP # VAR:HOST_PATH -> VAR:HOST_PATH:TMP -DESTDIR_MOUNT_LIST?= +DESTDIR_MOUNT_LIST?= PORTSDIR DISTDIR #DESTDIR_MOUNT_LIST?= PORTSDIR WRKDIR:/123 WRKSRC:/567:/789 ABC _DESTDIR_MOUNT_LIST= .for _entry in ${DESTDIR_MOUNT_LIST} @@ -103,15 +103,20 @@ exit 1; \ fi; \ _destdir=`realpath ${DESTDIR}`; \ - if [ ! -d $${_destdir}/tmp ]; then \ - ${ECHO_MSG} "===> Directory ${DESTDIR}/tmp does not exist"; \ - if mkdir $${_destdir}/tmp; then \ - ${ECHO_MSG} "=> /tmp subdirectory has been successfully created"; \ - else \ - ${ECHO_MSG} "=> /tmp subdirectory could not be created"; \ - exit 2; \ - fi; \ - fi; \ + _mounted_entries_list=""; \ + _created_mountpoints_list=""; \ + _var_path_list=""; \ + ${ECHO_MSG} "===> Creating some important subdirectories"; \ + for _dir in tmp dev; do \ + [ -d $${_destdir}/$${_dir} ] || \ + if ${MKDIR} $${_destdir}/$${_dir}; then \ + ${ECHO_MSG} "=> /$${_dir} subdirectory has been successfully created"; \ + _created_mountpoints_list="$${_destdir}/$${_dir} $${_created_mountpoints_list}"; \ + else \ + ${ECHO_MSG} "=> /$${_dir} subdirectory could not be created"; \ + exit 2; \ + fi; \ + done; \ ${ECHO_MSG} "_DESTDIR_MOUNT_LIST=${_DESTDIR_MOUNT_LIST}"; \ for _entry in ${_DESTDIR_MOUNT_LIST}; do \ ${ECHO_MSG} "==> Processing $${_entry}"; \ @@ -120,66 +125,81 @@ _host_path=`realpath $${_tp%:*}`; \ _dest_path=$${_entry##*:}; \ _full_dest_path=`realpath $${_destdir}/$${_dest_path}`; \ - _mounted_entries_list=""; \ - _created_mountpoints_list=""; \ - _var_path_list=""; \ _entry_was_created=0; \ _entry_should_mount=0; \ - echo "$${_mount_var}:$${_host_path}:$${_full_dest_path}"; \ + ${ECHO_CMD} "$${_mount_var}:$${_host_path}:$${_full_dest_path}"; \ if [ "$${_dest_path}" = "___temp___" ]; then \ - echo "Creating temporary mount point"; \ + ${ECHO_CMD} "Creating temporary mount point"; \ if _full_dest_path=`${MKTEMP} -d $${_destdir}/tmp/mountpoint.XXXXXX`; then \ - echo "Temporary mount point $${_full_dest_path} created successfully"; \ + ${ECHO_CMD} "Temporary mount point $${_full_dest_path} created successfully"; \ _entry_was_created=1; \ _entry_should_mount=1; \ - _dest_path=$${_full_dest_path#$${_destdir}/}; \ - _created_mountpoints_list="$${_created_mountpoints_list} ${_full_dest_path}"; \ + _dest_path=$${_full_dest_path#$${_destdir}}; \ + _created_mountpoints_list="$${_full_dest_path} $${_created_mountpoints_list}"; \ else \ - echo "Failed to create temporary mount point"; \ + ${ECHO_CMD} "Failed to create temporary mount point"; \ exit 9; \ fi; \ else \ - echo "Checking if already mounted"; \ - if ${MOUNT}|grep -qs "^$${_host_path} on $${_full_dest_path} ("; then \ - echo "$${_host_path} is already mounted on $${_full_dest_path}"; \ + ${ECHO_CMD} "Checking if already mounted"; \ + if ${MOUNT}|${GREP} -qs "^$${_host_path} on $${_full_dest_path} ("; then \ + ${ECHO_CMD} "$${_host_path} is already mounted on $${_full_dest_path}"; \ _var_path_list="$${_var_path_list} $${_mount_var}=$${_dest_path}"; \ else \ - echo "$${_host_path} is not mounted on $${_full_dest_path}"; \ + ${ECHO_CMD} "$${_host_path} is not mounted on $${_full_dest_path}"; \ _entry_should_mount=1; \ fi; \ fi; \ [ -d $${_full_dest_path} ] || \ - if mkdir $${_full_dest_path}; then \ - echo "Mount point $${_full_dest_path} created"; \ + if ${MKDIR} $${_full_dest_path}; then \ + ${ECHO_CMD} "Mount point $${_full_dest_path} created"; \ _entry_was_created=1; \ _created_mountpoints_list="$${_created_mountpoints_list} ${_full_dest_path}"; \ else \ - echo "Mount point $${_full_dest_path} could not be created"; \ + ${ECHO_CMD} "Mount point $${_full_dest_path} could not be created"; \ exit 7; \ fi; \ [ "$${_entry_should_mount}" = "0" ] || \ if ${MOUNT_NULLFS} $${_host_path} $${_full_dest_path}; then \ - echo "Dir $${_host_path} mounted"; \ - _mounted_entries_list="$${_mounted_entries_list} $${_full_dest_path}"; \ + ${ECHO_CMD} "Dir $${_host_path} mounted"; \ + _mounted_entries_list="$${_full_dest_path} $${_mounted_entries_list}"; \ + _var_path_list="$${_var_path_list} $${_mount_var}=$${_dest_path}"; \ else \ - echo "Dir $${_host_path} could not be mounted"; \ - [ "$${_entry_was_created}" = "0" ]||rmdir $${_full_dest_path}; \ + ${ECHO_CMD} "Dir $${_host_path} could not be mounted"; \ + [ "$${_entry_was_created}" = "0" ] || \ + ${RMDIR} $${_full_dest_path} || ${TRUE}; \ exit 8; \ fi; \ done; \ - echo "$${_destdir_env}"; \ - ${ECHO_CMD} "Things we mounted: $${_mounted_entries_list};" \ - ${ECHO_CMD} "Things we created: $${_created_mountpoints_list};" \ - ${ECHO_CMD} "_var_path_list: $${_var_path_list};" \ + ${ECHO_CMD} "Handling devfs separately"; \ + _full_dest_path=$${_destdir}/dev; \ + ${MOUNT}|${GREP} -qs "^devfs on $${_full_dest_path} (" || \ + if ${MOUNT_DEVFS} $${_full_dest_path}; then \ + ${ECHO_CMD} "devfs mounted"; \ + _mounted_entries_list="$${_full_dest_path} $${_mounted_entries_list}"; \ + else \ + ${ECHO_CMD} "devfs could not be mounted"; \ + [ -n "$${_created_mountpoints_list%%* $${_destdir}/dev *}" ] || \ + ${RMDIR} $${_destdir}/dev || ${TRUE}; \ + exit 9; \ + fi; \ + _var_path_list="$${_var_path_list} DEVFS=/dev"; \ + ${ECHO_CMD} "Things we mounted: $${_mounted_entries_list}"; \ + ${ECHO_CMD} "Things we created: $${_created_mountpoints_list}"; \ + ${ECHO_CMD} "_var_path_list: $${_var_path_list}"; \ ${ECHO_CMD} "===> Starting chrooted make in ${DESTDIR}..."; \ - ${CHROOT} $${_destdir} ${SH} -c "(cd $${_builddir}; \ - ${SETENV} -i ${DESTDIR_ENV} $${_destdir_env} ${MAKE} ${.TARGETS})"; \ - ${ECHO_CMD} "===> Chrooted make in ${DESTDIR} finished. Cleaning up..."; \ + export $${_var_path_list}; \ + ${CHROOT} $${_destdir} ${SH} -c "\ + cd $${PORTSDIR}${.CURDIR:S|^${PORTSDIR}||}; \ + ${SETENV} -i ${DESTDIR_ENV} $${_var_path_list} ${MAKE} ${.TARGETS}" && \ + ${ECHO_CMD} "===> Chrooted make in ${DESTDIR} succeeded" || \ + ${ECHO_CMD} "===> Chrooted make in ${DESTDIR} failed"; \ + ${ECHO_CMD} "===> Cleaning up..."; \ for _entry in $${_mounted_entries_list}; do \ - umount -f $${_entry}; \ + ${UMOUNT} -f $${_entry} || ${TRUE}; \ done; \ for _entry in $${_created_mountpoints_list}; do \ - rmdir $${_entry}; \ + ${RMDIR} $${_entry} || ${TRUE}; \ done; \ ${ECHO_CMD} "===> Congratulations!"; \ exit 0