Browse Source

Allow leaving /etc as untouched as possible

For customized setups, it's hard to control what files get installed
into /etc since in addition to the base-files package, any other package
may install a sample config. When two packages provide the same file,
which one of them makes it into the image depends on the order of them
being installed.

Solving this problem is not as trivial, as there are packages which must
be allowed to install stuff into /etc. Best examples are base-files and
ca-certificates.

This patch solves the problem by adding another PKG_template flag
"force_etc", which one can define in order to override the as well new
Config.in symbol "ADK_LEAVE_ETC_ALONE".
Phil Sutter 13 years ago
parent
commit
6eb624f2ea
5 changed files with 27 additions and 8 deletions
  1. 18 0
      Config.in
  2. 7 0
      mk/package.mk
  3. 1 3
      package/base-files/Makefile
  4. 1 1
      package/ca-certificates/Makefile
  5. 0 4
      package/ppp/Makefile

+ 18 - 0
Config.in

@@ -45,9 +45,26 @@ endmenu
 menu "Package selection"
 depends on !ADK_CHOOSE_TARGET_ARCH && !ADK_CHOOSE_TARGET_KERNEL && !ADK_CHOOSE_TARGET_SYSTEM
 
+config ADK_LEAVE_ETC_ALONE
+	boolean "do not install anything into /etc"
+	default n
+	help
+	  Enabling this option will prevent the ADK from installing anything
+	  into /etc. This is useful for highly customised setups with custom
+	  base-files packages.
+
+	  Package Makefiles can override this setting by passing "force_etc" to
+	  the package-template.  to a non-empty value. This is useful for
+	  packages traditionally installing non-config stuff into /etc, like
+	  e.g. ca-certificates.
+
+	  Note that without further customisation, turning this option
+	  on will almost certainly render the resulting system unusable.
+
 config ADK_INSTALL_PACKAGE_INIT_SCRIPTS
 	boolean "ship custom init-scripts along with packages"
 	default y
+	depends on !ADK_LEAVE_ETC_ALONE
 	help
 	  Turning this option to false will prevent the ADK from
 	  installing init-scripts (i.e. files in /etc/init.d) for
@@ -59,6 +76,7 @@ config ADK_INSTALL_PACKAGE_INIT_SCRIPTS
 config ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS
 	boolean "ship custom network-scripts along with packages"
 	default y
+	depends on !ADK_LEAVE_ETC_ALONE
 	help
 	  Turning this option to false will prevent the ADK from
 	  installing network-scripts (i.e. files in /etc/network/) for

+ 7 - 0
mk/package.mk

@@ -159,6 +159,9 @@ endif
 ifeq ($(ADK_DEBUG_STRIP),y)
 	$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
 endif
+ifeq (${ADK_LEAVE_ETC_ALONE}$(filter force_etc,$(7)),y)
+	-rm -rf $${IDIR_$(1)}/etc
+else
 ifeq (${ADK_INSTALL_PACKAGE_INIT_SCRIPTS},y)
 	@for file in $$$$(ls ./files/*.init 2>/dev/null); do \
 		fname=$$$$(echo $$$$file| sed -e "s#.*/##" -e "s#.init##"); \
@@ -171,6 +174,10 @@ ifeq (${ADK_INSTALL_PACKAGE_INIT_SCRIPTS},y)
 		[[ -e $$$$script ]] || continue; \
 		chmod 0755 "$$$$script"; \
 	done
+endif
+ifneq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
+	-rm -rf $${IDIR_$(1)}/etc/network
+endif
 endif
 	@mkdir -p $${PACKAGE_DIR} '$${STAGING_PKG_DIR}' \
 	    '$${STAGING_DIR}/scripts'

+ 1 - 3
package/base-files/Makefile

@@ -15,7 +15,7 @@ NO_DISTFILES:=		1
 
 include $(TOPDIR)/mk/package.mk
 
-$(eval $(call PKG_template,BASE_FILES,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
+$(eval $(call PKG_template,BASE_FILES,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},force_etc))
 
 CONFIG_STYLE:=		manual
 BUILD_STYLE:=		manual
@@ -45,9 +45,7 @@ endif
 	mkdir -p $(IDIR_BASE_FILES)/usr/lib/ipkg/lists
 	mkdir -p $(IDIR_BASE_FILES)/etc/crontabs
 	mkdir -p $(IDIR_BASE_FILES)/{dev,boot,root,sys,proc,tmp,mnt}
-ifeq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
 	mkdir -p $(IDIR_BASE_FILES)/etc/network/{if-pre-up.d,if-up.d,if-down.d,if-post-down.d}
-endif
 	mkdir -p $(IDIR_BASE_FILES)/usr/{lib,bin}
 	chmod 755 $(IDIR_BASE_FILES)/lib/mdev/init
 	chmod 600 $(IDIR_BASE_FILES)/etc/shadow

+ 1 - 1
package/ca-certificates/Makefile

@@ -20,7 +20,7 @@ PKGFD_SMALL:=		Minimal set of CA certificates
 
 include $(TOPDIR)/mk/package.mk
 
-$(eval $(call PKG_template,CA_CERTIFICATES,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION}))
+$(eval $(call PKG_template,CA_CERTIFICATES,${PKG_NAME},${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},force_etc))
 
 CONFIG_STYLE:=		manual
 

+ 0 - 4
package/ppp/Makefile

@@ -57,11 +57,9 @@ post-install:
 	${INSTALL_BIN} ./files/pon ${IDIR_PPP}/usr/sbin/
 	${INSTALL_BIN} ./files/poff ${IDIR_PPP}/usr/sbin/
 	${INSTALL_DIR} ${IDIR_PPP}/etc/ppp/peers
-ifeq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
 	$(INSTALL_DIR) ${IDIR_PPP}/etc/network/if-pre-up.d
 	$(INSTALL_BIN) ./files/ppp.pre-up \
 		${IDIR_PPP}/etc/network/if-pre-up.d/05-ppp
-endif
 
 ppp-mod-radius-install:
 	${INSTALL_DIR} ${IDIR_PPP_MOD_RADIUS}/etc/radiusclient
@@ -104,13 +102,11 @@ ppp-mod-pppumts-install:
 	${INSTALL_DIR} ${IDIR_PPP_MOD_PPPUMTS}/etc/ppp/templates
 	${INSTALL_DATA} ./files/etc/ppp/templates/umts \
 		${IDIR_PPP_MOD_PPPUMTS}/etc/ppp/templates/
-ifeq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
 	$(INSTALL_DIR) ${IDIR_PPP_MOD_PPPUMTS}/etc/network/if-pre-up.d
 	$(INSTALL_DIR) ${IDIR_PPP_MOD_PPPUMTS}/etc/network/if-post-down.d
 	$(INSTALL_BIN) ./files/hso.if-up \
 		${IDIR_PPP_MOD_PPPUMTS}/etc/network/if-pre-up.d/06-hso
 	$(INSTALL_BIN) ./files/hso.if-down \
 		${IDIR_PPP_MOD_PPPUMTS}/etc/network/if-post-down.d/06-hso
-endif
 
 include ${TOPDIR}/mk/pkg-bottom.mk