OpenWRT rootfs 的生成过程[通俗易懂](openWRT)
生活随笔
收集整理的這篇文章主要介紹了
OpenWRT rootfs 的生成过程[通俗易懂](openWRT)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在include目錄中有一個 rootfs.mk ,里面主要是:
1.定義了 opkg =
2.定義了 prepare_rootfs
opkg = 省略
TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD)
define prepare_rootfs
...省略...
rootfs.mk 被以下兩個文件使用
root@localhost:/home2/lql/openwrt# grep "rootfs\.mk" include/ package/ scripts/ feeds/ -rn
include/image.mk:22:include $(INCLUDE_DIR)/rootfs.mk
package/Makefile:11:include $(INCLUDE_DIR)/rootfs.mk
這里我們看 package/Makefile,里面有這么一段:
$(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
- find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
mkdir -p $(TARGET_DIR)/tmp
$(call opkg,$(TARGET_DIR)) install \
$(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
@for file in $(PACKAGE_INSTALL_FILES); do \
[ -s $$file.flags ] || continue; \
for flag in `cat $$file.flags`; do \
$(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
done; \
done || true
$(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
$(call prepare_rootfs,$(TARGET_DIR),$(TOPDIR)/files)
這里面關鍵的地方是
$(call opkg,$(TARGET_DIR)) install \
$(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
回頭看rootfs.mk 里對 opkg 的定義
opkg = \
IPKG_NO_SCRIPT=1 \
IPKG_INSTROOT=$(1) \
TMPDIR=$(1)/tmp \
$(STAGING_DIR_HOST)/bin/opkg \
--offline-root $(1) \
--force-postinstall \
--add-dest root:/ \
--add-arch all:100 \
--add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
最終展開就是
//類似于
staging_dir/host/bin/opkg --offline-root root-sunxi install *.ipk
這條命令作用就是將*.ipk 文件安裝到 root-sunxi 目錄下
最終root-sunxi 目錄下會有這文件
TODO
:可繼續研究一下OpenWRT 的 Makefile
總結
以上是生活随笔為你收集整理的OpenWRT rootfs 的生成过程[通俗易懂](openWRT)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SAP CRM enterprise s
- 下一篇: 教师节祝福语简短走心