From c5bf0529bcf7866443415acd94c8cd90fb03ba87 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Tue, 13 Sep 2011 19:39:31 +0300 Subject: [PATCH] initial features.in/cleanup This is a sort of anti-feature which removes and not builds; still with mkimage-profiles' approach we can at least build up the removal procedures as well. It's what triggered the tagged scripts, BTW. --- distro.mk | 7 ++++--- features.in/cleanup/README | 6 ++++++ features.in/cleanup/config.mk | 19 ++++++++++++++++++ .../image-scripts.d/01+install2+cleanup | 20 +++++++++++++++++++ features.in/install2/config.mk | 2 +- features.in/install2/install2/stage2cfg.mk | 1 + sub.in/stage2/Makefile | 7 +++++-- 7 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 features.in/cleanup/README create mode 100644 features.in/cleanup/config.mk create mode 100755 features.in/cleanup/tagged/image-scripts.d/01+install2+cleanup diff --git a/distro.mk b/distro.mk index 129da020..15241539 100644 --- a/distro.mk +++ b/distro.mk @@ -26,7 +26,7 @@ distro/syslinux: distro/.init distro/.branding sub/stage1 \ use/syslinux/ui-vesamenu use/hdt use/memtest use/dos # $(VAR) will be substituted before writing them to $(CONFIG); -# $$(VAR) will remain unsubstituted util $(CONFIG) is included +# $$(VAR) will remain unsubstituted until $(CONFIG) is included # and their value requested (so the variable referenced # can change its value during configuration _before_ # it's actually used); just peek inside $(CONFIG) ;-) @@ -50,7 +50,7 @@ distro/server-base: distro/installer sub/main \ use/syslinux/ui-menu use/memtest use/bootloader/grub @$(call add,BASE_LISTS,server-base) -distro/server-mini: distro/server-base +distro/server-mini: distro/server-base use/cleanup/x11-alterator @$(call set,KFLAVOURS,el-smp) @$(call add,KMODULES,e1000e igb) @$(call add,BASE_LISTS,\ @@ -78,7 +78,8 @@ distro/desktop-base: distro/installer sub/main \ distro/icewm: distro/desktop-base \ use/lowmem use/x11/xdm use/x11/runlevel5 \ - use/bootloader/lilo use/powerbutton/acpi + use/bootloader/lilo use/powerbutton/acpi \ + use/cleanup/alterator @$(call add,BASE_LISTS,$(call tags,icewm desktop)) # NB: if there are too many screens above, it might make sense to distro.d/ diff --git a/features.in/cleanup/README b/features.in/cleanup/README new file mode 100644 index 00000000..a2b67a97 --- /dev/null +++ b/features.in/cleanup/README @@ -0,0 +1,6 @@ +Эта фича вместо созидания занимается выкидыванием лишнего +(например, части модулей инсталятора из установленной системы). + +По возможности стоит работать над дизайном инфраструктуры +и пакетной базой так, чтобы ставить-удалять приходилось как +можно меньше. В идеале такой антифичи не должно быть вовсе :) diff --git a/features.in/cleanup/config.mk b/features.in/cleanup/config.mk new file mode 100644 index 00000000..52a3870d --- /dev/null +++ b/features.in/cleanup/config.mk @@ -0,0 +1,19 @@ +use/cleanup: + @$(call add,FEATURES,cleanup) + +use/cleanup/installer: use/cleanup + @$(call add,CLEANUP_PACKAGES,'installer-*') + +use/cleanup/x11: use/cleanup + @$(call add,CLEANUP_PACKAGES,libSM libXext libXmu libXi) + +# as some alterator modules are installed into stage3 (the destination +# root filesystem) to perform actions like bootloader setup, we might +# have to remove them (contrary to the usual build-up)... +use/cleanup/alterator: use/cleanup + @$(call add,CLEANUP_PACKAGES,'alterator*' rpm-macros-alterator) + @$(call add,CLEANUP_PACKAGES,'guile*' libvhttpd) + +# for lightweight server distros +use/cleanup/x11-alterator: use/cleanup/x11 use/cleanup/alterator + @$(call add,CLEANUP_PACKAGES,libmng qt4-common) diff --git a/features.in/cleanup/tagged/image-scripts.d/01+install2+cleanup b/features.in/cleanup/tagged/image-scripts.d/01+install2+cleanup new file mode 100755 index 00000000..13d90134 --- /dev/null +++ b/features.in/cleanup/tagged/image-scripts.d/01+install2+cleanup @@ -0,0 +1,20 @@ +#!/bin/sh -efu + +if [ -n "$GLOBAL_VERBOSE" ]; then + echo "** GLOBAL_CLEANUP_PACKAGES: $GLOBAL_CLEANUP_PACKAGES" +fi >&2 + +SCRIPT="/usr/share/install2/postinstall.d/01+install2+cleanup" +cat > "$SCRIPT" << EOF +#!/bin/sh -efu + +. install2-init-functions + +# don't override the script start message on the same line +echo "removing $GLOBAL_CLEANUP_PACKAGES" + +# remove extra packages from installed system +list="\$(exec_chroot rpmquery -a --qf='%{NAME}\\n' $GLOBAL_CLEANUP_PACKAGES)" +[ -z "\$list" ] || exec_chroot apt-get remove -f -y -- \$list +EOF +chmod +x "$SCRIPT" diff --git a/features.in/install2/config.mk b/features.in/install2/config.mk index 52eeb568..435b5f75 100644 --- a/features.in/install2/config.mk +++ b/features.in/install2/config.mk @@ -1,4 +1,4 @@ -use/install2: use/stage2 sub/stage2/install2 +use/install2: use/stage2 sub/stage2/install2 use/cleanup/installer @$(call add,FEATURES,install2) @$(call set,INSTALL2_PACKAGES,installer-distro-$$(INSTALLER)-stage2) @$(call add,INSTALL2_PACKAGES,branding-$$(BRANDING)-alterator) diff --git a/features.in/install2/install2/stage2cfg.mk b/features.in/install2/install2/stage2cfg.mk index 4dfd85ef..82b31b23 100644 --- a/features.in/install2/install2/stage2cfg.mk +++ b/features.in/install2/install2/stage2cfg.mk @@ -11,3 +11,4 @@ HSH_EXCLUDE_DOCS = 1 debug: @echo "** install2: IMAGE_PACKAGES: $(IMAGE_PACKAGES)" @echo "** install2: IMAGE_PACKAGES_REGEXP: $(IMAGE_PACKAGES_REGEXP)" + @echo "** install2: CLEANUP_PACKAGES: $(CLEANUP_PACKAGES)" diff --git a/sub.in/stage2/Makefile b/sub.in/stage2/Makefile index f0242357..92e7d2b1 100644 --- a/sub.in/stage2/Makefile +++ b/sub.in/stage2/Makefile @@ -36,8 +36,11 @@ IMAGE_PACKAGES_REGEXP = $(call kpackages,$(STAGE1_KMODULES),$(STAGE1_KFLAVOUR)) include $(MKIMAGE_PREFIX)/targets.mk +# NB: it's a collector variable, add()ing to a GLOBAL_ results in lost hair +GLOBAL_CLEANUP_PACKAGES := $(CLEANUP_PACKAGES) + all: | $(GLOBAL_DEBUG) build-image run-image-scripts pack-image \ $(GLOBAL_CLEAN_WORKDIR) -debug: - @echo "stage2: warning: dummy debug target not redefined" +# dummy +debug: ;