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 4a986c8..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 @@ -167,7 +169,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 @@ -257,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 78196b5..ef0b021 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)" @@ -84,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 @@ -137,6 +164,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 +179,14 @@ do_one_build() { -m"${machine}" \ ${uflag} \ ${xflag} \ - ${targets} ) + ${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_has XSRCDIR; then + echo "$(shtk_git_gethash $(shtk_config_get XSRCDIR))" >"${basedir}/.xsrchash_last_successful_build" + fi + fi } @@ -206,7 +242,9 @@ sysbuild_build() { shtk_config_run_hook pre_build_hook for machine in ${machines}; do - do_one_build "${machine}" + 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 } @@ -282,15 +320,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