Skip to content

Commit

Permalink
Add support for git
Browse files Browse the repository at this point in the history
Leverage the new git module in shtk-1.8 to support Git clones and
updates in addition to CVS.  CVS remains the default SCM for
backwards compatibility reasons, but this is subject to change.
  • Loading branch information
Fake User committed Jan 6, 2025
1 parent b52cdff commit 2c032fd
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 27 deletions.
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Changes in version 2.9

STILL UNDER DEVELOPMENT; NOT RELEASED YET.

* No changes recorded.
* Added support to fetch sources from Git in addition to CVS. The new
SCM variable controls which system to use and still defaults to CVS.
The new GIT_{BRANCH,REPO}_{SRC,XSRC} variables configure Git access.


Changes in version 2.8
Expand Down
1 change: 1 addition & 0 deletions NetBSD.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BUILD_TARGETS="release"
INCREMENTAL_BUILD="no"

# Determine the CVS root and the current release.
SCM="git"
if [ -f "${SRCDIR}/CVS/Root" ]; then
CVSROOT="$(cat ${SRCDIR}/CVS/Root)"
else
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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.8])


AM_CONDITIONAL([HOST_IS_NETBSD], [test "$(uname -s)" = NetBSD])
Expand Down
9 changes: 5 additions & 4 deletions default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# This file does not assume that the host is NetBSD. For that reason,
# it cannot automatically determine "valid" settings for some variables
# like MACHINES or CVSTAG and therefore only generic values are set.
# like MACHINES or GIT_*_BRANCH and therefore only generic values are set.

# Place all build files in the user's home directory.
BUILD_ROOT="${HOME}/netbsd"
Expand All @@ -26,6 +26,7 @@ BUILD_TARGETS="release"
# Do not perform update builds by default.
INCREMENTAL_BUILD="no"

# Set the CVS root and the desired release.
CVSROOT=":ext:[email protected]:/cvsroot"
#CVSTAG="netbsd-6"
# Set the Git repo and the desired release.
SCM="git"
GIT_SRC_REPO="https://github.com/NetBSD/src.git"
#GIT_SRC_BRANCH="netbsd-6"
29 changes: 28 additions & 1 deletion sysbuild.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 December 31, 2024
.Dd January 6, 2025
.Dt SYSBUILD.CONF 5
.Os
.Sh NAME
Expand All @@ -52,6 +52,33 @@ Default:
CVS tag to use during checkouts or updates of the src and xsrc modules.
.Pp
Default: not defined.
.It Va GIT_SRC_BRANCH
Name of the Git branch to check out for the src module.
Default:
.Sq trunk .
.It Va GIT_SRC_REPO
URI of the Git repo that contains the src module.
Default:
.Sq https://github.com/NetBSD/src.git .
.It Va GIT_XSRC_BRANCH
Name of the Git branch to check out for the xsrc module.
Default:
.Sq trunk .
.It Va GIT_XSRC_REPO
URI of the Git repo that contains the xsrc module.
Default:
.Sq https://github.com/NetBSD/xsrc.git .
.It Va SCM
Name of the version control system to use.
Can be one of:
.Sq cvs
or
.Sq git .
.Pp
Default:
.Sq cvs .
This will change in the future as CVS is phased out as the preferred SCM for
NetBSD development.
.It Va SRCDIR
Path to the src module.
If you want
Expand Down
56 changes: 44 additions & 12 deletions sysbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -40,9 +41,12 @@ 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
GIT_SRC_BRANCH GIT_SRC_REPO GIT_XSRC_BRANCH GIT_XSRC_REPO
INCREMENTAL_BUILD MACHINES MKVARS NJOBS RELEASEDIR
SCM SRCDIR
UPDATE_SOURCES XSRCDIR"


# Paths to installed files.
Expand All @@ -62,10 +66,15 @@ sysbuild_set_defaults() {
shtk_config_set BUILD_ROOT "${HOME}/sysbuild"
shtk_config_set BUILD_TARGETS "release"
shtk_config_set CVSROOT ":ext:[email protected]:/cvsroot"
shtk_config_set GIT_SRC_BRANCH "trunk"
shtk_config_set GIT_SRC_REPO "https://github.com/NetBSD/src.git"
shtk_config_set GIT_XSRC_BRANCH "trunk"
shtk_config_set GIT_XSRC_REPO "https://github.com/NetBSD/xsrc.git"
shtk_config_set INCREMENTAL_BUILD "false"
shtk_config_set MACHINES "$(uname -m)"
shtk_config_set NJOBS "$(shtk_hw_ncpus)"
shtk_config_set RELEASEDIR "${HOME}/sysbuild/release"
shtk_config_set SCM "cvs"
shtk_config_set SRCDIR "${HOME}/sysbuild/src"
shtk_config_set UPDATE_SOURCES "true"

Expand Down Expand Up @@ -295,17 +304,40 @@ sysbuild_fetch() {

shtk_config_run_hook pre_fetch_hook

local cvsroot="$(shtk_config_get CVSROOT)"
local scm="$(shtk_config_get SCM)"
case "${scm}" in
cvs)
local cvsroot="$(shtk_config_get CVSROOT)"

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"
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)"
fi
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
;;

git)
local srcrepo="$(shtk_config_get GIT_SRC_REPO)"
local srcbranch="$(shtk_config_get GIT_SRC_BRANCH)"
shtk_cli_info "Updating base source tree"
shtk_git_fetch "${srcrepo}" "${srcbranch}" "$(shtk_config_get SRCDIR)"

if shtk_config_has XSRCDIR; then
local xsrcrepo="$(shtk_config_get GIT_XSRC_REPO)"
local xsrcbranch="$(shtk_config_get GIT_XSRC_BRANCH)"
shtk_cli_info "Updating X11 source tree"
shtk_git_fetch "${xsrcrepo}" "${xsrcbranch}" "$(shtk_config_get XSRCDIR)"
fi
;;

*)
shtk_cli_error "Unknown SCM type ${scm}"
;;
esac

shtk_config_run_hook post_fetch_hook
}
Expand Down
Loading

0 comments on commit 2c032fd

Please sign in to comment.