Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for git #7

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/install-shtk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

set -eux

readonly VERSION=1.7
readonly VERSION=HEAD

main() {
local prefix="${1}"; shift
Expand All @@ -39,9 +39,15 @@ main() {

cd "${tmpdir}"

curl -LO "https://github.com/jmmv/shtk/releases/download/shtk-${VERSION}/shtk-${VERSION}.tar.gz"
tar xzvf "shtk-${VERSION}.tar.gz"
cd "shtk-${VERSION}"
if [ "${VERSION}" = HEAD ]; then
git clone https://github.com/jmmv/shtk.git
cd shtk
autoreconf -is
else
curl -LO "https://github.com/jmmv/shtk/releases/download/shtk-${VERSION}/shtk-${VERSION}.tar.gz"
tar xzvf "shtk-${VERSION}.tar.gz"
cd "shtk-${VERSION}"
fi
./configure --prefix="${prefix}"
make
sudo make install
Expand Down
10 changes: 10 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Changes in version 2.9
======================

STILL UNDER DEVELOPMENT; NOT RELEASED YET.

* 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
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

AC_INIT([NetBSD System Builder], [2.8],
AC_INIT([NetBSD System Builder], [2.9],
[https://github.com/jmmv/sysbuild/issues/], [sysbuild], [])
AC_PREREQ([2.65])

Expand Down 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
81 changes: 69 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,65 @@ 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)"

local srcdir="$(shtk_config_get SRCDIR)"
if [ -d "${srcdir}" -a -e "${srcdir}/.git" ]; then
shtk_cli_error "SCM=${scm} but ${srcdir} looks" \
"like a Git repo"
fi

shtk_cli_info "Updating base source tree"
shtk_cvs_fetch "${cvsroot}" src "$(shtk_config_get_default CVSTAG '')" \
"${srcdir}"

if shtk_config_has XSRCDIR; then
local xsrcdir="$(shtk_config_get XSRCDIR)"
if [ -d "${xsrcdir}" -a -e "${xsrcdir}/.git" ]; then
shtk_cli_error "SCM=${scm} but ${xsrcdir} looks" \
"like a Git repo"
fi

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 X11 source tree"
shtk_cvs_fetch "${cvsroot}" xsrc \
"$(shtk_config_get_default CVSTAG '')" "${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)"

local srcdir="$(shtk_config_get SRCDIR)"
if [ -d "${srcdir}" -a -e "${srcdir}/CVS" ]; then
shtk_cli_error "SCM=${scm} but ${srcdir} looks" \
"like a CVS checkout"
fi

shtk_cli_info "Updating base source tree"
shtk_git_fetch "${srcrepo}" "${srcbranch}" "${srcdir}"

if shtk_config_has XSRCDIR; then
local xsrcdir="$(shtk_config_get XSRCDIR)"
if [ -d "${xsrcdir}" -a -e "${xsrcdir}/CVS" ]; then
shtk_cli_error "SCM=${scm} but ${xsrcdir} looks" \
"like a CVS checkout"
fi

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}" "${xsrcdir}"
fi
;;

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

shtk_config_run_hook post_fetch_hook
}
Expand Down
Loading
Loading