carbon-core-system

Integration repository for versioned configuration and software on Carbon
git clone https://ccx.te2000.cz/git/carbon-core-system
Log | Files | Refs | Submodules

commit 07e995e1a5baaa8f855bb9774c1fc87cd2320130
parent 23eb1c356e461ce7629b66de60d87992bed64f26
Author: ccx <root@dorje.wpr.cz>
Date:   Wed, 10 Mar 2021 21:13:14 +0100

Rename slashpackage to package, initial support for multiple submodules.

Diffstat:
M.gitmodules | 2+-
Ainstall | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Dinstall-versioned-slashpackage | 54------------------------------------------------------
Apackage | 1+
Dslashpackage | 1-
5 files changed, 68 insertions(+), 56 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -1,3 +1,3 @@ [submodule "slashpackage"] - path = slashpackage + path = package url = /home/ccx/git/slashpackage diff --git a/install b/install @@ -0,0 +1,66 @@ +#!/bin/zsh +setopt no_unset warn_create_global extended_glob +cd $0:h || exit $? + +require() { + if ! check_$1; then + make_$1 + if ! check_$1; then + echo "ERROR: check_$1 failed after make_$1" + fi + fi +} + +check_committed() { + local git_status + git_status=$(cd $submodule && git status -s) || return $? + [[ -z $git_status ]] +} +make_committed() { + local REPLY + local -a empty_dirs + echo "Uncommited changes. Add and commit them?" + empty_dirs=( $submodule/(**~.git)/*(ND/^F) ) + (( $#empty_dirs )) && echo "WARNING: $#empty_dirs empty directories found." + read -q || exit 0 + ( cd $submodule && git add . && git commit ) || exit $? +} + +install_package() { + git checkout --force || exit $? + git clean -fx || exit $? + git submodule update --force || exit $? + exec env slashpackage=${sm_dst[$submodule]} ./install-all +} + +install_submodule() { + case $submodule in + (package) install_package;; + (*) echo >&2 "unhandled submodule: ${(qqq)submodule}";; + esac +} + +check_installed() { + [[ -f ${sm_dst[$submodule]}/.done ]] +} +make_installed() { + git submodule update --recursive --force $submodule || exit $? + ( cd $submodule && install_submodule ) || exit $? + touch ${sm_dst[$submodule]}/.done +} +typeset -f -t make_installed + +typeset -g submodule +typeset -gA sm_commit sm_dst + +submodule=. +require committed + +submodule=package +#require committed + +# read into globals here +sm_commit[$submodule]=$(cd $submodule && git show -s --pretty=format:%H%n) || exit $? +sm_dst[$submodule]=/versions/package.${sm_commit[$submodule]} + +require installed diff --git a/install-versioned-slashpackage b/install-versioned-slashpackage @@ -1,54 +0,0 @@ -#!/bin/zsh -setopt no_unset warn_create_global extended_glob -cd $0:h || exit $? -typeset -g submodule=slashpackage - -set -x - -require() { - if ! check_$1; then - make_$1 - if ! check_$1; then - echo "ERROR: check_$1 failed after make_$1" - fi - fi -} - -check_committed() { - local git_status - git_status=$(cd $submodule && git status -s) || return $? - [[ -z $git_status ]] -} -make_committed() { - local REPLY - local -a empty_dirs - echo "Uncommited changes. Add and commit them?" - empty_dirs=( $submodule/(**~.git)/*(ND/^F) ) - (( $#empty_dirs )) && echo "WARNING: $#empty_dirs empty directories found." - read -q || exit 0 - ( cd $submodule && git add . && git commit ) || exit $? -} - -require committed - -typeset -g commit dst -commit=$(cd $submodule && git show -s --pretty=format:%H%n) || exit $? -dst=/versions/package.$commit - -install_all() { - git checkout --force || exit $? - git clean -fx || exit $? - git submodule update --force || exit $? - exec env slashpackage=$dst ./install-all -} - -check_compiled() { - [[ -f $dst/.done ]] -} -make_compiled() { - git submodule update --recursive --force $submodule || exit $? - ( cd $submodule && install_all ) || exit $? - touch $dst/.done -} -typeset -f -t make_compiled -require compiled diff --git a/package b/package @@ -0,0 +1 @@ +Subproject commit 26ac49acd9773a2bbae34c99d09483a374d370ce diff --git a/slashpackage b/slashpackage @@ -1 +0,0 @@ -Subproject commit 26ac49acd9773a2bbae34c99d09483a374d370ce