git usage refactoring
There were heaps of "if type -t git" there already; it wasn't an unintentional mishap but rather a moderate copy-paste to get the use cases, and now these seem to have essentially settled. So time to scrap some dups. NB: the scripts in the generated profile can't rely on the contents of the metaprofile (these need to be able to work in standalone case either), so a bit of crap still lurks there.
This commit is contained in:
parent
a3779231cb
commit
c4311108ea
21
bin/mp-commit
Executable file
21
bin/mp-commit
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# commit the directory ($1) with a message ($2) to git
|
||||
|
||||
. shell-error
|
||||
|
||||
[ -d "$1" ] || fatal "$1 is not an existing directory"
|
||||
|
||||
if type -t git >&/dev/null && pushd "$1" >/dev/null; then
|
||||
if [ -z "$(git config --global user.name)" ]; then
|
||||
exit 0
|
||||
fi
|
||||
if [ ! -d .git ]; then
|
||||
git init -q || fatal "git init failed"
|
||||
fi
|
||||
if [ -n "$(git status -s)" ]; then
|
||||
git add . \
|
||||
&& git commit -qam "$2" \
|
||||
|| fatal "git add/commit failed"
|
||||
fi
|
||||
popd >/dev/null
|
||||
fi
|
11
bin/mp-showref
Executable file
11
bin/mp-showref
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# report on git repo in the current directory
|
||||
|
||||
if type -t git >&/dev/null; then
|
||||
if pushd "$1" >/dev/null && [ -d .git ]; then
|
||||
git show-ref --head -ds -- HEAD
|
||||
git status -s
|
||||
echo
|
||||
popd >/dev/null
|
||||
fi
|
||||
fi
|
@ -108,29 +108,16 @@ $(FEATURES):
|
||||
done; \
|
||||
popd >&/dev/null; \
|
||||
done; \
|
||||
if type -t git >&/dev/null && \
|
||||
pushd "$(BUILDDIR)/$$dst/" >/dev/null; then \
|
||||
test -n "`git status -s`" && \
|
||||
git add . && \
|
||||
if [ -n "$$dst" ]; then \
|
||||
the="$$sub subprofile"; \
|
||||
else \
|
||||
the="toplevel"; \
|
||||
fi && \
|
||||
git commit -qam "$$feat feature: $$the part added"; \
|
||||
popd >/dev/null; \
|
||||
if [ -n "$$dst" ]; then \
|
||||
the="$$sub subprofile"; \
|
||||
else \
|
||||
the="toplevel"; \
|
||||
fi; \
|
||||
mp-commit "$(BUILDDIR)/$$dst/" "$$feat feature: $$the part added"; \
|
||||
done; \
|
||||
if [ -x "generate.sh" ]; then sh generate.sh; fi; \
|
||||
if [ -s "generate.mk" ]; then $(MAKE) -f generate.mk; fi; \
|
||||
if type -t git >&/dev/null && \
|
||||
pushd "$(BUILDDIR)/" >/dev/null; then \
|
||||
if [ -n "`git status -s`" ]; then \
|
||||
git add . && \
|
||||
git commit -qam "$$feat feature generation complete"; \
|
||||
fi; \
|
||||
popd >/dev/null; \
|
||||
fi; \
|
||||
mp-commit "$(BUILDDIR)" "$$feat feature generation complete"; \
|
||||
popd >/dev/null
|
||||
|
||||
finalize:
|
||||
|
@ -24,6 +24,7 @@ all: $(GLOBAL_DEBUG) prep copy-subdirs copy-tree run-scripts pack-image \
|
||||
|
||||
prep: $(GLOBAL_DEBUG) dot-disk $(WHATEVER)
|
||||
|
||||
# can't use mp-showref which belongs to the metaprofile
|
||||
dot-disk:
|
||||
@mkdir -p files/.disk
|
||||
@echo "ALT Linux based" >files/.disk/info
|
||||
|
@ -44,13 +44,7 @@ profile/init: distclean
|
||||
@$(call put,ifndef DISTCFG_MK)
|
||||
@$(call put,DISTCFG_MK = 1)
|
||||
@{ \
|
||||
if type -t git >&/dev/null; then \
|
||||
if [ -d .git ]; then \
|
||||
git show-ref --head -d -s -- HEAD && \
|
||||
git status -s && \
|
||||
echo; \
|
||||
fi $(LOG); \
|
||||
fi; \
|
||||
mp-showref $(LOG); \
|
||||
{ \
|
||||
APTCONF="$(wildcard $(APTCONF))"; \
|
||||
echo "** using $${APTCONF:-system apt configuration}:"; \
|
||||
@ -71,14 +65,7 @@ profile/init: distclean
|
||||
fi >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if type -t git >&/dev/null; then \
|
||||
if cd $(BUILDDIR); then \
|
||||
git init -q && \
|
||||
git add . && \
|
||||
git commit -qam 'derivative profile initialized'; \
|
||||
cd ->&/dev/null; \
|
||||
fi; \
|
||||
fi; \
|
||||
mp-commit "$(BUILDDIR)" "derivative profile initialized"; \
|
||||
if [ -w . ]; then \
|
||||
rm -f "$(SYMLINK)" && \
|
||||
ln -s "$(BUILDDIR)" "$(SYMLINK)" && \
|
||||
@ -99,20 +86,12 @@ profile/bare: profile/init
|
||||
@$(call try,LOGDIR,$(LOGDIR))
|
||||
@$(call try,BRANDING,altlinux-sisyphus)
|
||||
@$(call set,IMAGE_INIT_LIST,+branding-$$(BRANDING)-release)
|
||||
@if type -t git >&/dev/null && cd $(BUILDDIR); then \
|
||||
git init -q && \
|
||||
git add . && \
|
||||
git commit -qam 'image configuration defaults set'; \
|
||||
fi
|
||||
@mp-commit "$(BUILDDIR)" "image configuration defaults set"
|
||||
|
||||
profile/finalize:
|
||||
@if [ -s $(RC) ]; then $(call put,-include $(RC)); fi
|
||||
@$(call put,endif)
|
||||
@if type -t git >&/dev/null && cd $(BUILDDIR); then \
|
||||
git init -q && \
|
||||
git add . && \
|
||||
git commit -qam 'image configuration finalized'; \
|
||||
fi
|
||||
@mp-commit "$(BUILDDIR)" "image configuration finalized"
|
||||
|
||||
# requires already formed distcfg.mk for useful output
|
||||
profile/dump-vars:
|
||||
|
@ -14,13 +14,7 @@ all: $(GLOBAL_DEBUG)
|
||||
mkdir -p $(TARGET) && \
|
||||
cp -at $(TARGET) -- \
|
||||
$(addsuffix .directory,$(THE_GROUPS) $(MAIN_GROUPS)); \
|
||||
if type -t git >&/dev/null && cd $(TARGET); then \
|
||||
if [ -n "`git status -s`" ]; then \
|
||||
git add . && \
|
||||
git commit -qam "requested $(SUFFIX) copied over"; \
|
||||
fi; \
|
||||
cd - >&/dev/null; \
|
||||
fi; \
|
||||
mp-commit "$(TARGET)" "requested $(SUFFIX) copied over"; \
|
||||
fi
|
||||
|
||||
debug:
|
||||
|
@ -19,13 +19,7 @@ SUFFIX := pkg/lists
|
||||
TARGET := $(BUILDDIR)/$(SUFFIX)
|
||||
|
||||
all: $(TARGET) $(GLOBAL_DEBUG) $(DOTBASE) copy-lists copy-groups
|
||||
@if type -t git >&/dev/null && cd $(TARGET); then \
|
||||
if [ -n "`git status -s`" ]; then \
|
||||
git add . && \
|
||||
git commit -qam "requested $(SUFFIX) copied over"; \
|
||||
fi; \
|
||||
cd - >&/dev/null; \
|
||||
fi
|
||||
@mp-commit "$(TARGET)" "requested $(SUFFIX) copied over"
|
||||
|
||||
copy-lists:
|
||||
@# env | sort -u | grep _LISTS | xargs cp
|
||||
|
@ -14,13 +14,8 @@ all:
|
||||
dst="$${sub#*/}" && \
|
||||
neq="$${src#$$dst}" && \
|
||||
rsync -qa "$$src/" "$(BUILDDIR)/$$dst/" && \
|
||||
if type -t git >&/dev/null && cd "$(BUILDDIR)/$$dst/"; then \
|
||||
if [ -n "`git status -s`" ]; then \
|
||||
git add . && \
|
||||
git commit -qam "$$dst subprofile initialized$${neq:+ (using $$src)}"; \
|
||||
fi; \
|
||||
cd - >&/dev/null; \
|
||||
fi; \
|
||||
mp-commit "$(BUILDDIR)/$$dst/" \
|
||||
"$$dst subprofile initialized$${neq:+ (using $$src)}"; \
|
||||
done
|
||||
|
||||
clean:
|
||||
|
Loading…
Reference in New Issue
Block a user