initial rootfs subprofile and services feature
This subprofile is akin to THE_* variables family: the configuration bits and script hooks sitting there influence whatever chroot is declared to be the user facing one in the end, whether it comes from vm image or live subprofile. The services feature ought to be a changeset of its own which would be based on rootfs and become the base for ve/vm changes but I chose to just do it atomically; some pre-existing duplicates are pruned now.
This commit is contained in:
parent
dfaf3fe3ef
commit
67adab492f
@ -36,8 +36,8 @@ 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
|
||||
# second, care for toplevel dirs;
|
||||
# then handle feature generator scripts
|
||||
#
|
||||
# NB: some subprofiles will be specified as "src/dst"
|
||||
# -- then both src/ and dst/ can hold the addons;
|
||||
@ -58,6 +58,11 @@ prep:
|
||||
fi
|
||||
|
||||
# feat
|
||||
# NB: this is somewhat complicated since it has to handle "$sub" like:
|
||||
# - "/": copy feature's toplevel parts to the BUILDDIR toplevel
|
||||
# - "stage1": copy feature's stage1 parts into stage1 subprofile
|
||||
# - "stage2@live": copy feature's stage2 parts into live subprofile
|
||||
# - "rootfs@/": copy feature's rootfs parts into BUILDDIR toplevel
|
||||
$(FEATURES):
|
||||
@feat=$@; \
|
||||
if [ -n "$(GLOBAL_DEBUG)" ]; then \
|
||||
@ -71,6 +76,13 @@ $(FEATURES):
|
||||
else \
|
||||
src="$${sub%@*}"; \
|
||||
dst="$${sub#*@}"; \
|
||||
if [ "$$src" = / ]; then \
|
||||
echo "** src=/: you don't want this" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
if [ "$$dst" = / -o "$$dst" = "" ]; then \
|
||||
dst="."; \
|
||||
fi; \
|
||||
srcdirs=; \
|
||||
if [ -d "$$src" ]; then \
|
||||
srcdirs="$$src"; \
|
||||
@ -78,9 +90,9 @@ $(FEATURES):
|
||||
if [ -d "$$dst" -a "$$dst" != "$$src" ]; then \
|
||||
srcdirs="$${srcdirs:+$$srcdirs }$$dst"; \
|
||||
fi; \
|
||||
: "why this overduplication was done? (still needed)"; \
|
||||
for srcdir in $$srcdirs; do \
|
||||
rsync -qab --exclude tagged \
|
||||
"$$srcdir/" "$(BUILDDIR)/$$dst/"; \
|
||||
rsync -qab "$$srcdir/" "$(BUILDDIR)/$$dst/"; \
|
||||
done; \
|
||||
fi; \
|
||||
if [ -n "$(GLOBAL_DEBUG)" ]; then \
|
||||
@ -98,7 +110,7 @@ $(FEATURES):
|
||||
done; \
|
||||
popd >&/dev/null; \
|
||||
done; \
|
||||
if [ -n "$$dst" ]; then \
|
||||
if [ -n "$$dst" -a "$$dst" != "." ]; then \
|
||||
the="$$sub subprofile"; \
|
||||
else \
|
||||
the="toplevel"; \
|
||||
|
@ -1,3 +1,3 @@
|
||||
# hooked from ../../lib/sugar.mk
|
||||
use/build-ve:
|
||||
use/build-ve: sub/rootfs@/
|
||||
@$(call add_feature)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# hooked from ../../lib/sugar.mk
|
||||
use/build-vm:
|
||||
use/build-vm: sub/rootfs@/
|
||||
@$(call add_feature)
|
||||
@$(call xport,ROOTPW)
|
||||
|
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Run scripts from /etc/firsttime.d at first start
|
||||
[ -f "/var/lock/TMP_1ST" ] || touch "/var/lock/TMP_1ST"
|
@ -2,7 +2,7 @@
|
||||
|
||||
# copy stage2 as live
|
||||
# NB: starts to preconfigure but doesn't use/cleanup yet
|
||||
use/live: use/stage2 sub/stage2@live
|
||||
use/live: use/stage2 sub/rootfs@live sub/stage2@live
|
||||
@$(call add_feature)
|
||||
@$(call add,CLEANUP_PACKAGES,'installer*')
|
||||
|
||||
|
10
features.in/services/README
Normal file
10
features.in/services/README
Normal file
@ -0,0 +1,10 @@
|
||||
Данная фича конфигурирует автоматический запуск сервисов
|
||||
при загрузке системы.
|
||||
|
||||
Поскольку в конкретном образе может быть желательно перекрыть
|
||||
умолчания предыдущей конфигурации, рекомендуется в фичах работать
|
||||
с переменными DEFAULT_SERVICES_* и оставить переменные SERVICES_*
|
||||
для релиз-менеджеров.
|
||||
|
||||
Выключение сервиса в каждой из этих пар имеет приоритет перед
|
||||
включением.
|
14
features.in/services/config.mk
Normal file
14
features.in/services/config.mk
Normal file
@ -0,0 +1,14 @@
|
||||
use/services: sub/rootfs
|
||||
@$(call add_feature)
|
||||
@$(call xport,DEFAULT_SERVICES_ENABLE)
|
||||
@$(call xport,DEFAULT_SERVICES_DISABLE)
|
||||
@$(call xport,SERVICES_ENABLE)
|
||||
@$(call xport,SERVICES_DISABLE)
|
||||
|
||||
# some presets
|
||||
|
||||
use/services/network: use/services
|
||||
@$(call add,DEFAULT_SERVICES_ENABLE,network)
|
||||
|
||||
use/services/ssh: use/services use/services/network
|
||||
@$(call add,DEFAULT_SERVICES_ENABLE,sshd)
|
35
features.in/services/rootfs/image-scripts.d/10-services
Executable file
35
features.in/services/rootfs/image-scripts.d/10-services
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
# this script implements the services regulation
|
||||
# according to what has been decided in the profile
|
||||
|
||||
CHKCONFIG=
|
||||
SYSTEMCTL=
|
||||
|
||||
[ ! -x /sbin/chkconfig ] || CHKCONFIG=1
|
||||
[ ! -x /bin/systemctl ] || SYSTEMCTL=1
|
||||
|
||||
[ -n "$CHKCONFIG$SYSTEMCTL" ] || exit 0
|
||||
|
||||
switch() {
|
||||
case "$2" in
|
||||
on)
|
||||
cc=on; sc=enable;;
|
||||
off)
|
||||
cc=off; sc=disable;;
|
||||
esac
|
||||
|
||||
{
|
||||
[ -z "$SYSTEMCTL" ] || /bin/systemctl --no-reload $sc $1.service
|
||||
[ -z "$CHKCONFIG" ] || /sbin/chkconfig $1 $cc
|
||||
} # 2>/dev/null
|
||||
}
|
||||
|
||||
# defaults (most likely features.in ones)
|
||||
for i in $GLOBAL_DEFAULT_SERVICES_ENABLE; do switch $i on; done
|
||||
for i in $GLOBAL_DEFAULT_SERVICES_DISABLE; do switch $i off; done
|
||||
|
||||
# explicitly specified behaviour (e.g. via conf.d)
|
||||
for i in $GLOBAL_SERVICES_ENABLE; do switch $i on; done
|
||||
for i in $GLOBAL_SERVICES_DISABLE; do switch $i off; done
|
||||
|
||||
:
|
@ -6,10 +6,6 @@ endif
|
||||
|
||||
ifeq (distro,$(IMAGE_CLASS))
|
||||
|
||||
# request particular image subprofile inclusion
|
||||
sub/%:
|
||||
@$(call add,SUBPROFILES,$(@:sub/%=%))
|
||||
|
||||
# install media bootloader
|
||||
boot/%:
|
||||
@$(call set,BOOTLOADER,$*)
|
||||
|
@ -14,5 +14,9 @@ config/pack/%: use/pack/%
|
||||
config/name/%:
|
||||
@$(call set,IMAGE_NAME,$*)
|
||||
|
||||
# request particular image subprofile inclusion
|
||||
sub/%:
|
||||
@$(call add,SUBPROFILES,$(@:sub/%=%))
|
||||
|
||||
# the final thing will pull the rest in
|
||||
build: postclean; @:
|
||||
|
@ -8,14 +8,21 @@ include $(BUILDDIR)/distcfg.mk
|
||||
|
||||
# if the subprofile is specified in src/dst notation,
|
||||
# take src/ and put it as dst/ (for stage2 variants)
|
||||
# NB: rootfs may come in first
|
||||
all:
|
||||
@for sub in $(SUBPROFILES); do \
|
||||
src="$${sub%@*}" && \
|
||||
dst="$${sub#*@}" && \
|
||||
neq="$${src#$$dst}" && \
|
||||
dstdir=""$(BUILDDIR)/$$dst/"" && \
|
||||
if [ -d "$$dstdir" ]; then \
|
||||
action="complemented"; \
|
||||
else \
|
||||
action="initialized"; \
|
||||
fi; \
|
||||
rsync -qa "$$src/" "$(BUILDDIR)/$$dst/" && \
|
||||
mp-commit "$(BUILDDIR)/$$dst/" \
|
||||
"$$dst subprofile initialized$${neq:+ (using $$src)}"; \
|
||||
"$$dst subprofile $$action$${neq:+ (using $$src)}"; \
|
||||
done
|
||||
|
||||
clean:
|
||||
|
18
sub.in/rootfs/README
Normal file
18
sub.in/rootfs/README
Normal file
@ -0,0 +1,18 @@
|
||||
=== sub.in/rootfs ===
|
||||
|
||||
Этот каталог содержит общие компоненты, добавляемые в "пользовательскую"
|
||||
корневую файловую систему вне зависимости от того, с чем именно в итоге
|
||||
столкнётся пользователь: livecd, vm, arm...
|
||||
|
||||
Соответственно функциональность вроде настройки автоматического входа
|
||||
в систему, которая должна быть задействована вне зависимости от того,
|
||||
какая часть профиля отвечает за формирование итоговой "пользоФС",
|
||||
может быть помещена в подкаталог rootfs/ (аналогично stage2/ для фич,
|
||||
дополняющих все производные субпрофиля stage2).
|
||||
|
||||
В фичах, опирающихся на функциональность rootfs, следует указывать
|
||||
зависимость на sub/rootfs@нужное (например, sub/rootfs@live в фиче
|
||||
live, порождающей субпрофиль live из субпрофиля stage2).
|
||||
|
||||
Зависимость на sub/rootfs не имеет смысла, указывать подобное не следует
|
||||
ни в фичах, дополняющих rootfs, ни в фичах, опирающихся на неё.
|
Loading…
Reference in New Issue
Block a user