From b4ee9ecb493384b3fccba26428acb226b7a164fa Mon Sep 17 00:00:00 2001 From: builder Date: Sat, 22 Feb 2020 07:34:25 +0100 Subject: [PATCH 1/4] Dispatch build.sh outputs for each machine. build.sh's output goes to "${BUILDROOT}/${machine}/build.log" Sysbuild echoes SUCCESS or FAIL for each build. --- sysbuild.1.in | 6 +++++- sysbuild.sh | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/sysbuild.1.in b/sysbuild.1.in index 4a986c8..7271adc 100644 --- a/sysbuild.1.in +++ b/sysbuild.1.in @@ -167,7 +167,11 @@ For every machine type listed in issues a .Nm build.sh call for that particular machine using the rest of the settings defined in -the configuration file. +the configuration file. Each +.Nm build.sh +call produces +.Pa ${BUILD_ROOT}/${MACHINE}/build.log +and sysbuild echoes build SUCESS or FAILURE on its output for each machine. The targets passed to the .Nm build.sh script are those defined in the diff --git a/sysbuild.sh b/sysbuild.sh index 78196b5..745d2b0 100644 --- a/sysbuild.sh +++ b/sysbuild.sh @@ -137,6 +137,8 @@ do_one_build() { esac done + mkdir -p "${basedir}" + ( cd "$(shtk_config_get SRCDIR)" && shtk_process_run ./build.sh \ -D"${basedir}/destdir" \ -M"${basedir}/obj" \ @@ -150,7 +152,7 @@ do_one_build() { -m"${machine}" \ ${uflag} \ ${xflag} \ - ${targets} ) + ${targets} >"${basedir}/build.log" 2>&1 ) } @@ -206,7 +208,8 @@ sysbuild_build() { shtk_config_run_hook pre_build_hook for machine in ${machines}; do - do_one_build "${machine}" + printf "Build ${machine}...\n" + do_one_build "${machine}" && printf "SUCCESS\n" || printf "FAIL\n" done shtk_config_run_hook post_build_hook } From 551197d9b64f518720b4f63cba7631bd5ad4f853 Mon Sep 17 00:00:00 2001 From: builder Date: Sat, 22 Feb 2020 07:40:09 +0100 Subject: [PATCH 2/4] Add git support. A new configuration variable, FETCH_METHOD, determine if sysbuild uses 'cvs' or 'git'. --- configure.ac | 2 +- sysbuild.1.in | 8 ++++++++ sysbuild.conf.5 | 10 ++++++++-- sysbuild.sh | 38 ++++++++++++++++++++++++++------------ sysbuild_test.sh | 2 ++ 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 4b9b0cb..9a46edd 100644 --- a/configure.ac +++ b/configure.ac @@ -65,7 +65,7 @@ m4_ifndef([PKG_CHECK_MODULES], m4_ifndef([SHTK_CHECK], [m4_fatal([Cannot find shtk.m4; see the INSTALL document for help])]) -SHTK_CHECK([>= 1.7]) +SHTK_CHECK([>= 1.7.1]) AC_PATH_PROG([KYUA], [kyua]) diff --git a/sysbuild.1.in b/sysbuild.1.in index 7271adc..9fa78e6 100644 --- a/sysbuild.1.in +++ b/sysbuild.1.in @@ -70,6 +70,8 @@ now. .Nm can be seen as a simple wrapper over .Xr cvs 1 +or +.Xr git 1 and the .Nm build.sh script that ships with the @@ -261,12 +263,18 @@ The fetch command downloads or updates the .Nx source trees, which include src and, optionally, xsrc. .Pp +The method used to fetch the source is either git or cvs and it +is choosen using +.Va FETCH_METHOD +, it is cvs by default. If the modules do not exist yet in the locations specified by .Va SRCDIR and .Va XSRCDIR , this performs an initial CVS checkout of the trees. If the modules exist, this performs a CVS update. +If using git, repositories must have been cloned and switched to the +desired branch as sysbuild only performs a pull. .Pp The .Va CVSROOT diff --git a/sysbuild.conf.5 b/sysbuild.conf.5 index e3cbc94..8e989ae 100644 --- a/sysbuild.conf.5 +++ b/sysbuild.conf.5 @@ -52,8 +52,14 @@ Default: CVS tag to use during checkouts or updates of the src and xsrc modules. .Pp Default: not defined. +.It Va FETCH_METHOD +Method used to fetch sources, either git or cvs. If git then both variables above +are not used. +.Pp +Default: +.Sq cvs .It Va SRCDIR -Path to the src module. +Path to the src module or local git repository. If you want .Xr sysbuild 1 to perform an update of this directory before every build, you will need @@ -68,7 +74,7 @@ Whether to perform an update of the source tree before every build or not. Default: .Sq true . .It Va XSRCDIR -Path to the xsrc module. +Path to the xsrc module or local git repository. If you want .Xr sysbuild 1 to perform an update of this directory before every build, you will need diff --git a/sysbuild.sh b/sysbuild.sh index 745d2b0..def8978 100644 --- a/sysbuild.sh +++ b/sysbuild.sh @@ -32,6 +32,7 @@ shtk_import cli shtk_import config shtk_import cvs +shtk_import git shtk_import hw shtk_import list shtk_import process @@ -40,9 +41,9 @@ shtk_import process # List of valid configuration variables. # # Please remember to update sysbuild.conf(5) if you change this list. -SYSBUILD_CONFIG_VARS="BUILD_ROOT BUILD_TARGETS CVSROOT CVSTAG INCREMENTAL_BUILD - MACHINES MKVARS NJOBS RELEASEDIR SRCDIR UPDATE_SOURCES - XSRCDIR" +SYSBUILD_CONFIG_VARS="BUILD_ROOT BUILD_TARGETS CVSROOT CVSTAG FETCH_METHOD + INCREMENTAL_BUILD MACHINES MKVARS NJOBS RELEASEDIR + SRCDIR UPDATE_SOURCES XSRCDIR" # Paths to installed files. @@ -62,6 +63,7 @@ sysbuild_set_defaults() { shtk_config_set BUILD_ROOT "${HOME}/sysbuild" shtk_config_set BUILD_TARGETS "release" shtk_config_set CVSROOT ":ext:anoncvs@anoncvs.NetBSD.org:/cvsroot" + shtk_config_set FETCH_METHOD "cvs" shtk_config_set INCREMENTAL_BUILD "false" shtk_config_set MACHINES "$(uname -m)" shtk_config_set NJOBS "$(shtk_hw_ncpus)" @@ -208,8 +210,9 @@ sysbuild_build() { shtk_config_run_hook pre_build_hook for machine in ${machines}; do - printf "Build ${machine}...\n" - do_one_build "${machine}" && printf "SUCCESS\n" || printf "FAIL\n" + shtk_cli_info "Build ${machine}...\n" + do_one_build "${machine}" && shtk_cli_info "Build ${machine} SUCCESS\n" ||\ + shtk_cli_info "Build ${machine} FAIL\n" done shtk_config_run_hook post_build_hook } @@ -285,15 +288,26 @@ sysbuild_fetch() { shtk_config_run_hook pre_fetch_hook local cvsroot="$(shtk_config_get CVSROOT)" + local fetch_method="$(shtk_config_get FETCH_METHOD)" - shtk_cli_info "Updating base source tree" - shtk_cvs_fetch "${cvsroot}" src "$(shtk_config_get_default CVSTAG '')" \ - "$(shtk_config_get SRCDIR)" + shtk_cli_info "Updating base source tree using ${fetch_method}" + if [ "${fetch_method}" = "cvs" ]; then + shtk_cvs_fetch "${cvsroot}" src "$(shtk_config_get_default CVSTAG '')" \ + "$(shtk_config_get SRCDIR)" - if shtk_config_has XSRCDIR; then - shtk_cli_info "Updating X11 source tree" - shtk_cvs_fetch "${cvsroot}" xsrc \ - "$(shtk_config_get_default CVSTAG '')" "$(shtk_config_get XSRCDIR)" + if shtk_config_has XSRCDIR; then + shtk_cli_info "Updating X11 source tree" + shtk_cvs_fetch "${cvsroot}" xsrc \ + "$(shtk_config_get_default CVSTAG '')" "$(shtk_config_get XSRCDIR)" + fi + elif [ "${fetch_method}" = "git" ]; then + shtk_git_pull "$(shtk_config_get SRCDIR)" + if shtk_config_has XSRCDIR; then + shtk_cli_info "Updating X11 source tree" + shtk_git_pull "$(shtk_config_get XSRCDIR)" + fi + else + shtk_cli_usage_error "FETCH_METHOD '${fetch_method}' is invalid" fi shtk_config_run_hook post_fetch_hook diff --git a/sysbuild_test.sh b/sysbuild_test.sh index 060fefb..11b66f9 100644 --- a/sysbuild_test.sh +++ b/sysbuild_test.sh @@ -668,6 +668,7 @@ BUILD_ROOT = ${HOME}/sysbuild BUILD_TARGETS = release CVSROOT = :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot CVSTAG is undefined +FETCH_METHOD = cvs INCREMENTAL_BUILD = false MACHINES = $(uname -m) MKVARS is undefined @@ -753,6 +754,7 @@ BUILD_ROOT = /tmp/test BUILD_TARGETS = release CVSROOT = foo bar CVSTAG = the-new-tag +FETCH_METHOD = cvs INCREMENTAL_BUILD = false MACHINES = $(uname -m) MKVARS is undefined From 367f5d4a0d77e2c215fd6de521bbad01ab9e2dc1 Mon Sep 17 00:00:00 2001 From: builder Date: Sat, 22 Feb 2020 09:07:31 +0100 Subject: [PATCH 3/4] Do not attempt to build if sources have not changed since the last successful build (git only) ${BUILDROOT}/${machine}/.srchash_last_successful_build (and ${BUILDROOT}/${machine}/.xsrchash_last_successful_build, if XSRCDIR is set) are checked before a build to know if the sources changed since the last successful build. These files are set after a successful build. --- sysbuild.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sysbuild.sh b/sysbuild.sh index def8978..d4a835a 100644 --- a/sysbuild.sh +++ b/sysbuild.sh @@ -86,6 +86,31 @@ do_one_build() { local basedir="$(shtk_config_get BUILD_ROOT)/${machine}" + if [ "$(shtk_config_get FETCH_METHOD)" = "git" ]; then + local lsb_file="${basedir}/.srchash_last_successful_build" + local lsb= + if [ -f "${lsb_file}" ]; then + read lsb _ <"${lsb_file}" + fi + local hash="$(shtk_git_gethash $(shtk_config_get SRCDIR))" + if [ "${lsb}" = "${hash}" ]; then + if shtk_config_has XSRCDIR ; then + lsb_file="${basedir}/.xsrchash_last_successful_build" + if [ -f "${lsb_file}" ]; then + read lsb _ <"${lsb_file}" + fi + hash="$(shtk_git_gethash $(shtk_config_get XSRCDIR))" + if [ "${lsb}" = "${hash}" ]; then + shtk_cli_info "(no change in sources since last successful build)" + return 0 + fi + else + shtk_cli_info "(no change in sources since last successful build)" + return 0 + fi + fi + fi + local njobs="$(shtk_config_get NJOBS)" local jflag= if [ "${njobs}" -gt 1 ]; then @@ -155,6 +180,13 @@ do_one_build() { ${uflag} \ ${xflag} \ ${targets} >"${basedir}/build.log" 2>&1 ) + + if [ $? -eq 0 -a "$(shtk_config_get FETCH_METHOD)" = "git" ]; then + echo "$(shtk_git_gethash $(shtk_config_get SRCDIR))" >"${basedir}/.srchash_last_successful_build" + if shtk_config_hash XSRCDIR; then + echo "$(shtk_git_gethash $(shtk_config_get XSRCDIR))" >"${basedir}/.xsrchash_last_successful_build" + fi + fi } From b70a3bc320001006dcfb42e7509bc6e22d00d023 Mon Sep 17 00:00:00 2001 From: builder Date: Sun, 23 Feb 2020 17:29:00 +0100 Subject: [PATCH 4/4] tiny typo --- sysbuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbuild.sh b/sysbuild.sh index d4a835a..ef0b021 100644 --- a/sysbuild.sh +++ b/sysbuild.sh @@ -183,7 +183,7 @@ do_one_build() { if [ $? -eq 0 -a "$(shtk_config_get FETCH_METHOD)" = "git" ]; then echo "$(shtk_git_gethash $(shtk_config_get SRCDIR))" >"${basedir}/.srchash_last_successful_build" - if shtk_config_hash XSRCDIR; then + if shtk_config_has XSRCDIR; then echo "$(shtk_git_gethash $(shtk_config_get XSRCDIR))" >"${basedir}/.xsrchash_last_successful_build" fi fi