From f32b8d4f6e8f3d24d3d487d2a2cb42f2db6ee4c3 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Tue, 13 Sep 2011 19:15:42 +0300 Subject: [PATCH] features.in: tagged scripts support From now on a feature can contain this tree: . +- scripts.d/ +- image-scripts.d/ `- tagged/ +- scripts.d/ `- image-scripts.d/ ...per subprofile part or in its root -- the latter one gets merged into toplevel directory responsible for the final image build. NB: autoselected tags include only subprofile names (or both parts, for complex subprofiles) -- this is highly prone to change yet! --- features.in/Makefile | 58 ++++++++++++++++++++++++++++---------------- features.in/README | 8 ++++-- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/features.in/Makefile b/features.in/Makefile index 49963fd2..bb82bbac 100644 --- a/features.in/Makefile +++ b/features.in/Makefile @@ -9,45 +9,61 @@ include $(BUILDDIR)/distcfg.mk # first rsync what's static, and make backups (*~) -- # these might signal of file clashes (or plain dirt); +# second, care for toplevel and tagged script dirs; # then handle two more ways of implementing a feature +# # NB: some subprofiles will be specified as "src/dst" -# (then both src/ and dst/ can hold the addons) +# -- then both src/ and dst/ can hold the addons; +# still both pieces go into a single destination + +### {image-,}scripts.d/ get rsynced twice :-/ +### still we don't want the trimmed-down case + all: @echo "** starting feature configuration" @if [ -n "$(GLOBAL_DEBUG)" ]; then \ echo "** target subprofiles: $(SUBPROFILES)"; \ echo "** requested features: $(FEATURES)"; \ fi - @for dir in $(FEATURES); do \ - pushd "$$dir" && \ - for sub in $(SUBPROFILES); do \ - src="$${sub%/*}/"; \ - dst="$${sub#*/}/"; \ - if [ -d "$$src/" ]; then rsync -qab "$$src" "$(BUILDDIR)/$$dst/"; fi; \ - if [ -d "$$dst/" ]; then rsync -qab "$$dst" "$(BUILDDIR)/$$dst/"; fi; \ + @for feat in $(FEATURES); do \ + pushd "$$feat" && \ + for sub in / $(SUBPROFILES); do \ + src="$${sub%/*}"; \ + dst="$${sub#*/}"; \ + if [ -d "$$src" ]; then rsync -qab "$$src/" "$(BUILDDIR)/$$dst/"; fi; \ + if [ -d "$$dst" ]; then rsync -qab "$$dst/" "$(BUILDDIR)/$$dst/"; fi; \ + for scr in {image-,}scripts.d; do \ + scriptdir="$(BUILDDIR)/$$dst/$$scr/"; \ + if [ -d "$$scriptdir" ]; then \ + if [ -d "$$scr" ]; then \ + rsync -qab "$$scr/" "$$scriptdir/"; \ + fi; \ + if [ -d "tagged/$$scr" ]; then \ + pushd "tagged/$$scr" && \ + echo "($$src || $$dst)" \ + | tags2lists . \ + | xargs -r cp -v -pLt "$$scriptdir" --; \ + popd; \ + fi; \ + fi; \ + done; \ type -t git >&/dev/null && \ pushd "$(BUILDDIR)/$$dst/" && \ git add . && \ - git commit -qam "$$dir feature ($$sub subprofile part)" ||:; \ - popd; \ - done; \ - for scripts in scripts.d image-scripts.d; do \ - if [ -d "$(BUILDDIR)/$$scripts" -a -d "$$scripts" ]; then \ - if rsync -qab "$$scripts/" "$(BUILDDIR)/$$scripts/"; then \ - type -t git >&/dev/null && \ - pushd "$(BUILDDIR)/$$scripts/" && \ - git add . && \ - git commit -qam "$$dir feature (toplevel $$scripts)" ||:; \ - popd; \ - fi; \ + if [ -n "$$dst" ]; then \ + the="$$sub subprofile"; \ + else \ + the="toplevel"; \ fi; \ + git commit -qam "$$feat feature ($$the part)" ||:; \ + popd; \ done; \ if [ -x "generate.sh" ]; then sh generate.sh; fi; \ if [ -s "generate.mk" ]; then $(MAKE) -f generate.mk; fi; \ type -t git >&/dev/null && \ pushd "$(BUILDDIR)/" && \ git add . && \ - git commit -qam "$$dir feature generation complete" ||:; \ + git commit -qam "$$feat feature generation complete" ||:; \ popd; \ popd; \ done diff --git a/features.in/README b/features.in/README index 057a792d..3c67ae05 100644 --- a/features.in/README +++ b/features.in/README @@ -13,8 +13,12 @@ после инициализации профиля (см. ../image.in/) и копирования субпрофилей (см. ../sub.in/). Для каждой фичи, указанной в $(FEATURES), копируются подкаталоги сообразно субпрофилям, -а также выполняется скрипт generate.sh и задействуется generate.mk -(при их наличии). +а также производится обработка {tagged/,}{image-},scripts.d/ +(см. cleanup/ в качестве примера); затем выполняется скрипт +generate.sh и задействуется generate.mk (при их наличии). + + NB: тегированные скрипты являются экспериментальными, + возможны недоработки и существенные изменения! Если фича дополняет хуками семейство целевых субпрофилей, построенных на одном базовом, можно воспользоваться подкаталогом