Skip to content

Commit

Permalink
Expose the pbulk logs outside of the sandbox
Browse files Browse the repository at this point in the history
Add a new PBULK_LOG configuration variable that points to a directory
outside of the sandbox and that is used to record all pbulk build logs.
These logs are necessary to troubleshoot any build failures that happen
during the build, and are also useful under successful conditions to
get summaries about what was built.

Fixes #3.
  • Loading branch information
jmmv committed Aug 31, 2018
1 parent 591332a commit 0bc1de1
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 9 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Changes in version 2.1

**STILL UNDER DEVELOPMENT; NOT RELEASED YET.**

* Issue 3: Added a new `PBULK_LOG` setting to point at a location that
holds all build logs, and made the `build` command print out details
about such logs on success and failure.

* Issue 4: Fixed the installable bootstrap kit generated during a build
to not leak pkg_comp-internal paths.

Expand Down
1 change: 1 addition & 0 deletions default.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SANDBOX_CONFFILE="__PKG_COMP_ETCDIR__/sandbox.conf"
PKGSRCDIR="/usr/pkgsrc"
DISTDIR="${PKGSRCDIR}/distfiles"
PACKAGES="${PKGSRCDIR}/packages"
PBULK_LOG="${PACKAGES}/log"
PBULK_PACKAGES="${PACKAGES}/pbulk"

# Target file layout. These are the directories that the built binary
Expand Down
10 changes: 9 additions & 1 deletion pkg_comp.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.Dd February 17, 2017
.Dd August 30, 2018
.Dt PKG_COMP 8
.Os
.Sh NAME
Expand Down Expand Up @@ -253,6 +253,14 @@ This is necessary to keep fully-populated
databases.
However, because pbulk reuses existing binary packages and only rebuilds updated
packages, any packages not given on the command line should "build" quickly.
.Pp
In case of build problems, detailed logs for each package that failed to build
will be located in the directory pointed at by
.Va PBULK_LOG .
Of special interest is the
.Pa SUMMARY
subdirectory, which contains summary reports of the whole operation in various
different formats.
.Ss The config command
The config command dumps the loaded configuration to the standard output.
The format of the output is not a script, so it cannot be fed back into
Expand Down
18 changes: 17 additions & 1 deletion pkg_comp.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
.\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.Dd February 14, 2017
.Dd August 30, 2018
.Dt PKG_COMP.CONF 5
.Os
.Sh NAME
Expand Down Expand Up @@ -156,6 +156,22 @@ packages and bootstrap kit for the target environment.
.Pp
Default:
.Pa /usr/pkgsrc/packages .
.It Va PBULK_LOG
Absolute path to the directory in the host that will hold the logs of the
pbulk build.
The
.Pa SUMMARY
subdirectory of this location will contain final log files for the whole
build, including things like
.Pa report.html
and
.Pa report.txt
with a summary of the packages that were built and their success.
For any packages that failed to build, there will be a separate subdirectory
containing the logs for those failures.
.Pp
Note that the contents of this directory are wiped at the beginning of each
build.
.It Va PBULK_PACKAGES
Absolute path to the directory in the host that will hold the built binary
packages and bootstrap kit for the pbulk installation in the sandbox.
Expand Down
27 changes: 20 additions & 7 deletions pkg_comp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ SHTK_MODULESPATH="${PKG_COMP_SHTK_MODULESDIR}" shtk_import pkgsrc
# Please remember to update pkg_comp.conf(5) if you change this list.
PKG_COMP_CONFIG_VARS="AUTO_PACKAGES CVS_ROOT CVS_TAG DISTDIR EXTRA_MKCONF
FETCH_VCS GIT_BRANCH GIT_URL LOCALBASE NJOBS PACKAGES
PBULK_PACKAGES PKG_DBDIR PKGSRCDIR SANDBOX_CONFFILE
SYSCONFDIR UPDATE_SOURCES VARBASE"
PBULK_LOG PBULK_PACKAGES PKG_DBDIR PKGSRCDIR
SANDBOX_CONFFILE SYSCONFDIR UPDATE_SOURCES VARBASE"


# Paths to installed files.
Expand All @@ -72,6 +72,7 @@ pkg_comp_set_defaults() {
shtk_config_set LOCALBASE "/usr/pkg"
shtk_config_set NJOBS "$(shtk_hw_ncpus)"
shtk_config_set PACKAGES "/usr/pkgsrc/packages"
shtk_config_set PBULK_LOG "/usr/pkgsrc/packages/log"
shtk_config_set PBULK_PACKAGES "/usr/pkgsrc/packages/pbulk"
shtk_config_set PKG_DBDIR "/usr/pkg/libdata/pkgdb"
shtk_config_set PKGSRCDIR "/usr/pkgsrc"
Expand Down Expand Up @@ -119,6 +120,7 @@ run_sandboxctl() {
cat <<EOF
DISTDIR="$(shtk_config_has DISTDIR && shtk_config_get DISTDIR)"
PACKAGES="$(shtk_config_has PACKAGES && shtk_config_get PACKAGES)"
PBULK_LOG="$(shtk_config_has PBULK_LOG && shtk_config_get PBULK_LOG)"
PBULK_PACKAGES="$(shtk_config_has PBULK_PACKAGES \
&& shtk_config_get PBULK_PACKAGES)"
PKGSRCDIR="$(shtk_config_has PKGSRCDIR && shtk_config_get PKGSRCDIR)"
Expand Down Expand Up @@ -385,9 +387,9 @@ EOF
pbulk_set unprivileged_user root

# Configure pbulk's file layout.
pbulk_set bulklog /pkg_comp/work/bulklog
pbulk_set bulklog /pkg_comp/bulklog
pbulk_set limited_list /pkg_comp/pbulk/etc/pbulk.list
pbulk_set loc /pkg_comp/work/bulklog/meta
pbulk_set loc /pkg_comp/bulklog/SUMMARY

# Configure pkgsrc's file layout.
pbulk_set bootstrapkit "/pkg_comp/packages/pkg/bootstrap.tgz"
Expand Down Expand Up @@ -546,14 +548,25 @@ pkg_comp_build() {
echo "${package}" >>"${list}"
done

local bulklog="$(shtk_config_get PBULK_LOG)"

# Removing bulklog/success seems to be necessary to restart a build, as
# otherwise bulkbuild does not build modified packages. Is this correct?
rm -f "${root}/pkg_comp/work/bulklog/success"
rm -f "${root}/pkg_comp/bulklog/success"

shtk_cli_info "Starting pbulk build in the sandbox"
run_sandboxctl run /pkg_comp/pbulk/bin/bulkbuild || \
shtk_cli_error "bulkbuild failed; see ${root}/pkg_comp/work/bulklog/" \
"for possible details"
shtk_cli_error "bulkbuild failed; see ${bulklog}/ for possible details"
generate_pkg_summary "${root}"

if [ -s "${bulklog}/SUMMARY/error" ]; then
local errors="$(cat ${bulklog}/SUMMARY/error)"
shtk_cli_error "Failed to build ${errors}; see ${bulklog}/ for" \
"detailed logs"
else
shtk_cli_info "All packages built successfully; summary reports are" \
"in ${bulklog}/SUMMARY/"
fi
}


Expand Down
1 change: 1 addition & 0 deletions pkg_comp_inttest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ integration_body() {
cat >pkg_comp.conf <<EOF
DISTDIR="$(atf_config_get distdir)"
PACKAGES="$(pwd)/packages/pkg"
PBULK_LOG="$(pwd)/packages/log"
PBULK_PACKAGES="$(pwd)/packages/pbulk"
PKGSRCDIR="$(atf_config_get pkgsrcdir)"
SANDBOX_CONFFILE="$(pwd)/sandbox.conf"
Expand Down
3 changes: 3 additions & 0 deletions pkg_comp_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ GIT_URL = https://github.com/NetBSD/pkgsrc.git
LOCALBASE = /usr/pkg
NJOBS = 99
PACKAGES = /usr/pkgsrc/packages
PBULK_LOG = /usr/pkgsrc/packages/log
PBULK_PACKAGES = /usr/pkgsrc/packages/pbulk
PKG_DBDIR = /usr/pkg/libdata/pkgdb
PKGSRCDIR = /usr/pkgsrc
Expand Down Expand Up @@ -228,6 +229,7 @@ GIT_URL = https://github.com/NetBSD/pkgsrc.git
LOCALBASE = /usr/pkg
NJOBS = 80
PACKAGES = /usr/pkgsrc/packages
PBULK_LOG = /usr/pkgsrc/packages/log
PBULK_PACKAGES = /usr/pkgsrc/packages/pbulk
PKG_DBDIR = /usr/pkg/libdata/pkgdb
PKGSRCDIR is undefined
Expand Down Expand Up @@ -447,6 +449,7 @@ sandboxctl__create_destroy_integration_body() {
cat >pkg_comp.conf <<EOF
DISTDIR="$(pwd)/distfiles"
PACKAGES="$(pwd)/packages/pkg"
PBULK_LOG="$(pwd)/packages/log"
PBULK_PACKAGES="$(pwd)/packages/pbulk"
PKGSRCDIR="$(pwd)/pkgsrc"
SANDBOX_CONFFILE="$(pwd)/sandbox.conf"
Expand Down
3 changes: 3 additions & 0 deletions sandbox.conf.post
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ post_create_hook() {
# sandbox... but this behavior is less annoying.
mkdir -p "${DISTDIR}"
mkdir -p "${PACKAGES}"
mkdir -p "${PBULK_LOG}"
mkdir -p "${PBULK_PACKAGES}"
mkdir -p "${PKGSRCDIR}"

mkdir "${SANDBOX_ROOT}/pkg_comp"
mkdir "${SANDBOX_ROOT}/pkg_comp/bulklog"
mkdir "${SANDBOX_ROOT}/pkg_comp/distfiles"
mkdir "${SANDBOX_ROOT}/pkg_comp/packages"
mkdir "${SANDBOX_ROOT}/pkg_comp/packages/pbulk"
Expand All @@ -74,6 +76,7 @@ post_create_hook() {
post_mount_hook() {
_pkg_comp_validate_variables

sandbox_bindfs -o rw "${PBULK_LOG}" "${SANDBOX_ROOT}/pkg_comp/bulklog"
sandbox_bindfs -o rw "${DISTDIR}" "${SANDBOX_ROOT}/pkg_comp/distfiles"
sandbox_bindfs -o rw "${PACKAGES}" "${SANDBOX_ROOT}/pkg_comp/packages/pkg"
sandbox_bindfs -o rw "${PBULK_PACKAGES}" \
Expand Down

0 comments on commit 0bc1de1

Please sign in to comment.