summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/init.sh41
-rwxr-xr-xmk18
2 files changed, 30 insertions, 29 deletions
diff --git a/include/init.sh b/include/init.sh
index 5b158e0e..a88bd13f 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -53,12 +53,8 @@ xbmk_init()
id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)"
[ "$(id -u)" != "0" ] || $err "this command as root is not permitted"
- for fv in version versiondate; do
- eval "[ ! -f \".$fv\" ] || read -r $fv < \".$fv\" || :"
- done
-
- for init_cmd in set_pyver init_vars init_ver create_tmpdir lock \
- create_pathdirs child_exec; do
+ for init_cmd in set_pyver set_env set_version git_init create_tmpdir \
+ lock create_pathdirs child_exec; do
xbmk_$init_cmd "$@" || break
done
}
@@ -143,7 +139,7 @@ pybin()
command -v "$1" 2>/dev/null || return 1
}
-xbmk_init_vars()
+xbmk_set_env()
{
# XBMK_CACHE is a directory, for caching downloads and git repon
[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$xbmkpwd/cache"
@@ -160,16 +156,20 @@ xbmk_init_vars()
[ -z "${XBMK_THREADS+x}" ] && export XBMK_THREADS=1
expr "X$XBMK_THREADS" : "X-\{0,1\}[0123456789][0123456789]*$" \
- 1>/dev/null 2>/dev/null || export XBMK_THREADS=1
+ 1>/dev/null 2>/dev/null || export XBMK_THREADS=1; :
+}
+
+xbmk_set_version()
+{
+ for fv in version versiondate; do
+ eval "[ ! -f \".$fv\" ] || read -r $fv < \".$fv\" || :"
+ done
[ -e ".git" ] || [ -f ".version" ] || printf "unknown\n" > .version \
|| $err "Cannot generate unknown .version file"
[ -e ".git" ] || [ -f ".versiondate" ] || printf "1716415872\n" > \
.versiondate || $err "Cannot generate unknown .versiondate file"; :
-}
-xbmk_init_ver()
-{
version_="$version"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
@@ -185,6 +185,25 @@ xbmk_init_ver()
export LOCALVERSION="-$projectname-${version%%-*}"
}
+xbmk_git_init()
+{
+ [ -L ".git" ] && return 1
+ [ -e ".git" ] && return 0
+ eval "`setvars "$(date -Rud @$versiondate)" cdate _nogit`"
+
+ x_ git init 1>/dev/null 2>/dev/null
+ x_ git add -A . 1>/dev/null 2>/dev/null
+ x_ git commit -m "$projectname $version" --date "$cdate" \
+ --author="xbmk <xbmk@example.com>" 1>/dev/null 2>/dev/null
+ x_ git tag -a "$version" -m "$projectname $version" 1>/dev/null \
+ 2>/dev/null
+
+ for gitarg in "--global user.name" "--global user.email"; do
+ gitcmd="git config $gitarg"; $gitcmd || $err \
+ "Please run this first: $gitcmd \"your ${gitcmd##*.}\""
+ done
+}
+
xbmk_create_tmpdir()
{
# unify all temporary files/directories in a single TMPDIR
diff --git a/mk b/mk
index c0184384..bc816229 100755
--- a/mk
+++ b/mk
@@ -23,11 +23,6 @@ main()
{
cmd="" && [ $# -gt 0 ] && cmd="$1" && shift 1
- for g in "command -v git" "git config --global user.name" \
- "git config --global user.email" "git_init"; do
- eval "$g 1>/dev/null 2>/dev/null || $err \"Unconfigured: $g\""
- done
-
case "$cmd" in
version) printf "%s\nWebsite: %s\n" "$relname" "$projectsite" ;;
release|download|inject) $cmd "$@" ;;
@@ -37,19 +32,6 @@ main()
set -u -e # some commands disable them. turn them on!
}
-git_init()
-{
- [ -L ".git" ] && return 1
- [ -e ".git" ] && return 0
- eval "`setvars "$(date -Rud @$versiondate)" cdate _nogit`"
-
- git init || return 1
- git add -A . || return 1
- git commit -m "$projectname $version" --date "$cdate" \
- --author="xbmk <xbmk@example.com>" || return 1
- git tag -a "$version" -m "$projectname $version" || return 1
-}
-
release()
{
export XBMK_RELEASE="y"