imagebuilder: reuse rootfs preparation from rootfs.mk

In addition to removing redundant code, this fixes various issues in
IB-generated images that have been fixed in prepare_rootfs before,
including better handling of CONFIG_CLEAN_IPKG and enabling of initscripts
from FILES.

We also reuse the opkg macro and remove --force-... flags that have been
removed from rootfs.mk as well.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
Matthias Schiffer 2018-03-06 09:38:29 +01:00
parent cf1c7c0f17
commit 2fbf669730
No known key found for this signature in database
GPG key ID: 16EF3F64CB201D9C
5 changed files with 11 additions and 41 deletions

View file

@ -23,8 +23,6 @@ ifneq ($(CONFIG_PER_FEED_REPO),)
endif endif
endif endif
PACKAGE_DIR_ALL := $(TOPDIR)/staging_dir/packages/$(BOARD)
opkg_package_files = $(wildcard \ opkg_package_files = $(wildcard \
$(foreach dir,$(PACKAGE_SUBDIRS), \ $(foreach dir,$(PACKAGE_SUBDIRS), \
$(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk))) $(foreach pkg,$(1), $(dir)/$(pkg)_*.ipk)))

View file

@ -1,5 +1,3 @@
include $(INCLUDE_DIR)/feeds.mk
ifdef CONFIG_USE_MKLIBS ifdef CONFIG_USE_MKLIBS
define mklibs define mklibs
rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out

View file

@ -7,6 +7,7 @@
curdir:=package curdir:=package
include $(INCLUDE_DIR)/feeds.mk
include $(INCLUDE_DIR)/rootfs.mk include $(INCLUDE_DIR)/rootfs.mk
-include $(TMP_DIR)/.packagedeps -include $(TMP_DIR)/.packagedeps

View file

@ -144,6 +144,7 @@ ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_GCC_VERSION_4_8),$(CONFIG_TARGE
endif endif
PACKAGE_DIR:=$(BIN_DIR)/packages PACKAGE_DIR:=$(BIN_DIR)/packages
PACKAGE_DIR_ALL:=$(TOPDIR)/staging_dir/packages/$(BOARD)
BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME) BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME)
STAGING_DIR:=$(TOPDIR)/staging_dir/$(TARGET_DIR_NAME) STAGING_DIR:=$(TOPDIR)/staging_dir/$(TARGET_DIR_NAME)
BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/$(TOOLCHAIN_DIR_NAME) BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/$(TOOLCHAIN_DIR_NAME)

View file

@ -23,6 +23,7 @@ endif
include rules.mk include rules.mk
include $(INCLUDE_DIR)/debug.mk include $(INCLUDE_DIR)/debug.mk
include $(INCLUDE_DIR)/depends.mk include $(INCLUDE_DIR)/depends.mk
include $(INCLUDE_DIR)/rootfs.mk
include $(INCLUDE_DIR)/version.mk include $(INCLUDE_DIR)/version.mk
export REVISION export REVISION
@ -54,20 +55,10 @@ help: FORCE
# override variables from rules.mk # override variables from rules.mk
PACKAGE_DIR:=$(TOPDIR)/packages PACKAGE_DIR:=$(TOPDIR)/packages
LISTS_DIR:=$(subst $(space),/,$(patsubst %,..,$(subst /,$(space),$(TARGET_DIR))))$(DL_DIR) LISTS_DIR:=$(subst $(space),/,$(patsubst %,..,$(subst /,$(space),$(TARGET_DIR))))$(DL_DIR)
OPKG:= \ OPKG:=$(call opkg,$(TARGET_DIR)) \
IPKG_NO_SCRIPT=1 \
IPKG_INSTROOT="$(TARGET_DIR)" \
$(STAGING_DIR_HOST)/bin/opkg \
-f $(TOPDIR)/repositories.conf \ -f $(TOPDIR)/repositories.conf \
--force-depends \
--force-overwrite \
--force-postinstall \
--cache $(DL_DIR) \ --cache $(DL_DIR) \
--lists-dir $(LISTS_DIR) \ --lists-dir $(LISTS_DIR)
--offline-root $(TARGET_DIR) \
--add-dest root:/ \
--add-arch all:100 \
--add-arch $(ARCH_PACKAGES):200
include $(INCLUDE_DIR)/target.mk include $(INCLUDE_DIR)/target.mk
-include .profiles.mk -include .profiles.mk
@ -109,14 +100,11 @@ _call_image: staging_dir/host/.prereq-build
echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))' echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))'
echo 'Packages: $(BUILD_PACKAGES)' echo 'Packages: $(BUILD_PACKAGES)'
echo echo
rm -rf $(TARGET_DIR) rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR) mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR)
$(MAKE) package_reload $(MAKE) package_reload
$(MAKE) package_install $(MAKE) package_install
ifneq ($(USER_FILES),) $(MAKE) -s prepare_rootfs
$(MAKE) copy_files
endif
$(MAKE) -s package_postinst
$(MAKE) -s build_image $(MAKE) -s build_image
$(MAKE) -s checksum $(MAKE) -s checksum
@ -148,28 +136,13 @@ package_install: FORCE
$(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/libc_*.ipk $(PACKAGE_DIR)/base/libc_*.ipk)) $(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/libc_*.ipk $(PACKAGE_DIR)/base/libc_*.ipk))
$(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/kernel_*.ipk $(PACKAGE_DIR)/base/kernel_*.ipk)) $(OPKG) install $(firstword $(wildcard $(PACKAGE_DIR)/kernel_*.ipk $(PACKAGE_DIR)/base/kernel_*.ipk))
$(OPKG) install $(BUILD_PACKAGES) $(OPKG) install $(BUILD_PACKAGES)
rm -f $(TARGET_DIR)/usr/lib/opkg/lists/*
copy_files: FORCE prepare_rootfs: FORCE
@echo @echo
@echo Copying extra files @echo Finalizing root filesystem...
@$(call file_copy,$(USER_FILES)/*,$(TARGET_DIR)/)
package_postinst: FORCE $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
@echo $(call prepare_rootfs,$(TARGET_DIR),$(USER_FILES))
@echo Cleaning up
@rm -f $(TARGET_DIR)/tmp/opkg.lock
@echo
@echo Activating init scripts
@mkdir -p $(TARGET_DIR)/etc/rc.d
@( \
cd $(TARGET_DIR); \
for script in ./usr/lib/opkg/info/*.postinst; do \
IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) $$script; \
done || true \
)
rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst
$(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
build_image: FORCE build_image: FORCE
@echo @echo
@ -207,4 +180,3 @@ endif
$(if $(BIN_DIR),BIN_DIR="$(BIN_DIR)")) $(if $(BIN_DIR),BIN_DIR="$(BIN_DIR)"))
.SILENT: help info image .SILENT: help info image