Add initial version of the new Image Builder It's still a bit rough in a few places...
authorFelix Fietkau <nbd@openwrt.org>
Wed, 10 Jan 2007 21:52:28 +0000 (21:52 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Wed, 10 Jan 2007 21:52:28 +0000 (21:52 +0000)
SVN-Revision: 6071

14 files changed:
Config.in
include/image.mk
include/target.mk
target/Makefile
target/imagebuilder/Config.in [new file with mode: 0644]
target/imagebuilder/Makefile [new file with mode: 0644]
target/imagebuilder/files/Makefile [new file with mode: 0644]
target/linux/atheros-2.6/image/Makefile
target/linux/ixp4xx-2.6/image/Makefile
target/linux/magicbox-2.6/image/Makefile
target/linux/rb532-2.6/image/Makefile
target/linux/rdc-2.6/image/Makefile
target/linux/uml-2.6/image/Makefile
target/linux/x86-2.6/image/Makefile

index 18555a432571fd1f2110472f20063cba2a347ac8..2efd1ce25d8f9bbf21fe3056d830b7c92dfab57f 100644 (file)
--- a/Config.in
+++ b/Config.in
@@ -59,6 +59,7 @@ config SOURCE_FEEDS
                Separate sources with spaces : " "
 
 source "toolchain/Config.in"
+source "target/imagebuilder/Config.in"
 source "target/sdk/Config.in"
 
 menu "Target Images"
index 702434ec86152099dc622ff14d767f4f63d731c8..4f638f026094b2a4bec81bd716921fbc739a246f 100644 (file)
@@ -77,10 +77,15 @@ endef
 define BuildImage
 download:
 prepare:
-compile: compile-targets
+ifneq ($(IB),1)
+  compile: compile-targets
        $(call Build/Compile)
+else
+  compile:
+endif
 
-install: compile install-targets
+ifneq ($(IB),1)
+  install: compile install-targets
        $(call Image/Prepare)
        $(call Image/mkfs/prepare)
        $(call Image/BuildKernel)
@@ -88,9 +93,21 @@ install: compile install-targets
        $(call Image/mkfs/squashfs)
        $(call Image/mkfs/tgz)
        $(call Image/mkfs/ext2)
+else
+  install: compile install-targets
+       $(call Image/BuildKernel)
+       $(call Image/mkfs/jffs2)
+       $(call Image/mkfs/squashfs)
+       $(call Image/mkfs/tgz)
+       $(call Image/mkfs/ext2)
+endif
        
-clean: clean-targets
+ifneq ($(IB),1)
+  clean: clean-targets
        $(call Build/Clean)
+else
+  clean:
+endif
 
 compile-targets:
 install-targets:
index 042e85d326781967f509d6809fe2489993cd7a5c..17a41f7c492817b739f8f8c6dc40a51069bb8f7f 100644 (file)
@@ -7,6 +7,11 @@
 
 include $(TMP_DIR)/.target.mk
 
+ifeq ($(IB),1)
+$(TMP_DIR)/.target.mk: $(TOPDIR)/.target.mk
+       $(CP) $< $@
+else
 $(TMP_DIR)/.target.mk: $(TMP_DIR)/.targetinfo
        $(SCRIPT_DIR)/gen_target_mk.pl < $(TMP_DIR)/.targetinfo > $@
+endif
 
index 651c13f6ff91dff08b5e3f7a9e11541a36c78452..4853e3fbd2df3a829e4fc8d0213f4a6c182b000f 100644 (file)
@@ -12,25 +12,24 @@ all: install
 $(BIN_DIR):
        mkdir -p $(BIN_DIR)
 
-TARGETS-y := linux
-TARGETS-$(CONFIG_SDK) += sdk
-
 linux-install: $(BIN_DIR)
 image_install: linux-install
 
 IMAGE_DIR:=linux/$(BOARD)-$(KERNEL)/image
 
-
 download: $(patsubst %,%-download,$(TARGETS-y))
 prepare: linux-prepare
 compile: linux-compile image_compile
-install: image_clean $(patsubst %,%-install,$(TARGETS-y)) image_install
-clean: $(patsubst %,%-clean,$(TARGETS-y)) image_clean
+install: image_clean linux-install sdk_install image_install imagebuilder_install
+clean: linux-clean sdk-clean imagebuilder-clean image_clean
 
 prereq: FORCE
        $(MAKE) -C linux/$(BOARD)-$(KERNEL) prereq
        $(MAKE) -C $(IMAGE_DIR) prereq
 
+sdk_install: FORCE
+       $(MAKE) -C sdk install
+
 image_clean: FORCE
        $(MAKE) -C $(IMAGE_DIR) clean
        rm -f $(BIN_DIR)/openwrt-*
@@ -41,6 +40,9 @@ image_compile: FORCE
 image_install: image_compile
        $(MAKE) -C $(IMAGE_DIR) install
 
+imagebuilder_install: image_install
+       $(MAKE) -C imagebuilder install
+
 %-clean: FORCE
        $(MAKE) -C $(patsubst %-clean,%,$@) clean
 %-download: FORCE
diff --git a/target/imagebuilder/Config.in b/target/imagebuilder/Config.in
new file mode 100644 (file)
index 0000000..95aeb5d
--- /dev/null
@@ -0,0 +1,10 @@
+config IB
+       bool "Build the OpenWrt Image Builder"
+       depends !TARGET_ROOTFS_INITRAMFS
+       default y if ALL
+       help
+         This is essentially a stripped-down version of the buildroot
+         with precompiled packages, kernel image and image building tools.
+         You can use it to generate custom images without compiling anything
+
+
diff --git a/target/imagebuilder/Makefile b/target/imagebuilder/Makefile
new file mode 100644 (file)
index 0000000..470d045
--- /dev/null
@@ -0,0 +1,46 @@
+# 
+# Copyright (C) 2006 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+# $Id: Makefile 6070 2007-01-10 21:21:59Z nbd $
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+include $(INCLUDE_DIR)/host.mk
+
+PKG_OS:=$(shell uname -s)
+PKG_CPU:=$(shell uname -m)
+
+IB_NAME:=OpenWrt-ImageBuilder-$(BOARD)-$(KERNEL)-for-$(PKG_OS)-$(PKG_CPU)
+IB_BUILD_DIR:=$(BUILD_DIR)/$(IB_NAME)
+
+all: compile
+
+$(BIN_DIR)/$(IB_NAME).tar.bz2:
+       rm -rf $(IB_BUILD_DIR)
+       mkdir -p $(IB_BUILD_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) $(IB_BUILD_DIR)/staging_dir_$(ARCH)/bin $(IB_BUILD_DIR)/target/linux
+       $(CP) \
+               $(INCLUDE_DIR) $(SCRIPT_DIR) $(PACKAGE_DIR) \
+               $(TOPDIR)/rules.mk $(TOPDIR)/.config \
+               $(TMP_DIR)/.target.mk \
+               ./files/Makefile \
+               $(IB_BUILD_DIR)/
+       $(CP) $(STAGING_DIR)/bin/* $(IB_BUILD_DIR)/staging_dir_$(ARCH)/bin
+       $(CP) $(TOPDIR)/target/linux/* $(IB_BUILD_DIR)/target/linux
+       rm -rf $(IB_BUILD_DIR)/target/linux/*/patches
+       -cp $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/* $(IB_BUILD_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD) # don't copy subdirectories here
+       find $(IB_BUILD_DIR) -name .svn | xargs rm -rf 
+       find $(IB_BUILD_DIR) -name CVS | xargs rm -rf 
+       (cd $(BUILD_DIR); \
+               tar cfj $@ $(IB_NAME); \
+       )
+
+download:
+prepare:
+compile: $(BIN_DIR)/$(IB_NAME).tar.bz2
+install: compile
+
+clean:
+       rm -rf $(IB_BUILD_DIR) $(BIN_DIR)/$(IB_NAME).tar.bz2
diff --git a/target/imagebuilder/files/Makefile b/target/imagebuilder/files/Makefile
new file mode 100644 (file)
index 0000000..720bcfa
--- /dev/null
@@ -0,0 +1,147 @@
+# Makefile for the OpenWrt Image Builder
+#
+# Copyright (C) 2006-2007 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+export TOPDIR=${CURDIR}
+
+all: help
+
+include rules.mk
+include .config
+
+SHELL:=/usr/bin/env bash
+export LC_ALL=C
+export LANG=C
+ifeq ($(KBUILD_VERBOSE),99)
+  MAKE:=3>/dev/null $(MAKE)
+endif
+export IS_TTY=$(shell tty -s && echo 1 || echo 0)
+
+# override variables from rules.mk
+PACKAGE_DIR:=$(TOPDIR)/packages
+IPKG:= \
+  IPKG_TMP="$(TOPDIR)/tmp/ipkgtmp" \
+  IPKG_INSTROOT="$(TARGET_DIR)" \
+  IPKG_CONF_DIR="$(TOPDIR)/tmp" \
+  IPKG_OFFLINE_ROOT="$(TARGET_DIR)" \
+  $(SCRIPT_DIR)/ipkg -force-defaults
+
+
+define Profile/Default
+  ID:=
+  NAME:=
+  PACKAGES:=
+endef
+
+define Profile
+  $(eval $(call Profile/Default))
+  $(eval $(call Profile/$(1)))
+  ifneq ($(ID),)
+    ifeq ($(PROFILE),)
+      PROFILE:=$(ID)
+    endif
+       $(ID)_NAME:=$(NAME)
+       $(ID)_PACKAGES:=$(PACKAGES)
+    PROFILE_LIST += \
+               echo '$(ID):'; echo '   $(NAME)';
+  endif
+endef
+
+include .target.mk
+
+define Helptext
+Available Commands:
+       help:   This help text
+       info:   Show a list of available target profiles
+       clean:  Remove images and temporary build files
+       image:  Build an image (see below for more information).
+
+Building images:
+       By default 'make image' will create an image with the default
+       target profile and package set. You can use the following parameters
+       to change that:
+       
+       make image PROFILE="<profilename>" # override the default target profile
+       make image PACKAGES="<pkg1> [<pkg2> [<pkg3> ...]]" # include extra packages
+       make image FILES="<path>" # include extra files from <path>
+
+endef
+$(eval $(call shexport,Helptext))
+
+help: FORCE
+       echo "$$$(call shvar,Helptext)"
+
+info: FORCE
+       echo 'Current Target: "$(BOARDNAME)"'
+       echo 'Available Profiles:'
+       echo; $(PROFILE_LIST)
+
+$(TOPDIR)/tmp/ipkg.conf: FORCE
+       @mkdir -p $(TOPDIR)/tmp
+       @echo 'dest root /' > $@
+       @echo 'src packages file:$(TOPDIR)/packages' >> $@
+
+BUILD_PACKAGES:=$(sort $(DEFAULT_PACKAGES) $(PACKAGES) $($(PROFILE)_PACKAGES) kernel)
+BUILD_PACKAGES:=$(patsubst base-files,base-files-$(BOARD)-$(KERNEL),$(BUILD_PACKAGES))
+
+image: $(TOPDIR)/tmp/ipkg.conf
+       if [ -z "$($(PROFILE)_NAME)" ]; then \
+               echo Profile $(PROFILE) not found.; \
+               echo 'Use "make info" to get a list of available target profiles'; \
+               false; \
+       fi
+       echo 'Building images for $(BOARDNAME) - $($(PROFILE)_NAME)'
+       echo 'Packages: $(BUILD_PACKAGES)'
+       echo
+       rm -rf $(TARGET_DIR)
+       mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR)
+       $(MAKE) package_index
+       $(MAKE) package_install
+ifneq ($(FILES),)
+       $(MAKE) copy_files
+endif
+       $(MAKE) package_postinst
+       $(MAKE) build_image
+       
+package_index: FORCE
+       @echo
+       @echo Building package index...
+       (cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages) >/dev/null 2>/dev/null
+       $(IPKG) update
+
+package_install: FORCE
+       @echo
+       @echo Installing packages...
+       $(IPKG) install $(BUILD_PACKAGES)
+
+copy_files: FORCE
+       @echo
+       @echo Copying extra files
+       $(CP) $(FILES)/* $(TARGET_DIR)/
+
+package_postinst: FORCE
+       @echo
+       @echo Activating init scripts
+       ( \
+               cd $(BUILD_DIR)/root; \
+               for script in ./etc/init.d/*; do \
+                       grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+                       IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \
+               done; \
+       )
+
+build_image: FORCE
+       @echo
+       @echo Building images...
+       $(NO_TRACE_MAKE) -C target/linux/$(BOARD)-$(KERNEL)/image install IB=1
+       
+clean:
+       rm -rf tmp $(TARGET_DIR)
+
+.PHONY: FORCE
+.SILENT: help info image
+%: ;
index fb8cf3ced258cd119bf89817dcd128e7ed2ee719..80e333592007e12e4c412b39faad2eeac3494900 100644 (file)
@@ -7,8 +7,12 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
 
+define Image/Prepare
+       cp $(KDIR)/linux-*/vmlinux $(KDIR)/vmlinux.elf
+endef
+
 define Image/BuildKernel
-       cp $(KDIR)/linux-*/vmlinux $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
+       cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
        gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
        $(STAGING_DIR)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
        dd if=$(KDIR)/vmlinux.bin.l7 of=$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.lzma bs=65536 conv=sync
index 9359c5b11e9195ffb7e2fce986f867e630580c28..cbbb29b6b98455858186f35df3073e42ebf2b384 100644 (file)
@@ -24,10 +24,11 @@ define Build/Clean
 endef
 
 define Image/Prepare
+       cp $(LINUX_DIR)/arch/arm/boot/zImage $(KDIR)/zImage
 endef
 
 define Image/BuildKernel
-       cp $(LINUX_DIR)/arch/arm/boot/zImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-zImage
+       cp $(KDIR)/zImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-zImage
 #      $(shell BIN_DIR=$(BIN_DIR) $(TOPDIR)/scripts/arm-magic.sh)
        BIN_DIR=$(BIN_DIR) $(TOPDIR)/scripts/arm-magic.sh
 endef
index 10f71df2a99f2a125b75430a2b998fe7b57a5420..77ff88f52140c8b1912143e3cfd131c73db90d36 100644 (file)
@@ -11,10 +11,11 @@ define Build/Clean
 endef
 
 define Image/Prepare
+       cp $(LINUX_DIR)/arch/ppc/boot/images/uImage $(KDIR)/uImage
 endef
 
 define Image/BuildKernel
-       cp $(LINUX_DIR)/arch/ppc/boot/images/uImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-uImage
+       cp $(KDIR)/uImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-uImage
 endef
 
 define Image/Build
@@ -23,7 +24,7 @@ endef
 
 define Image/Build/jffs2-64k
        ( \
-               dd if=$(LINUX_DIR)/arch/ppc/boot/images/uImage bs=65536 conv=sync; \
+               dd if=$(KDIR)/uImage bs=65536 conv=sync; \
                dd if=$(KDIR)/root.$(1) bs=65536 conv=sync; \
        ) > $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
 endef
index 4e1c1addd15518a18b1d9bea8f104805358f0eef..706b672e74a67da166fdb5d08b04f682e17cdbca 100644 (file)
@@ -29,13 +29,13 @@ define Build/Clean
 endef
 
 define Image/Prepare
-       $(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux 'root=/dev/cfa2 '
        $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $(LINUX_DIR)/vmlinux $(LINUX_KERNEL)
+       cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+       $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
+       cp $(LINUX_DIR)/vmlinux $(KDIR)/vmlinux.elf
 endef
 
 define Image/BuildKernel
-       cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
-       $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
        $(CP) $(KDIR)/loader.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
 endef
 
@@ -52,7 +52,7 @@ root=/dev/cfa2 rootfstype=ext2
 endef
 
 define Image/Build
-       $(STAGING_DIR)/bin/patch-cmdline $(LINUX_DIR)/vmlinux '$(strip $(call Image/cmdline/$(1))) '
+       $(STAGING_DIR)/bin/patch-cmdline $(KDIR)/vmlinux.elf '$(strip $(call Image/cmdline/$(1))) '
        ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin 4 $(LINUX_DIR)/vmlinux 16 $(KDIR)/root.$(1)
 endef
 
index 13c8718430967dcf504fa7fc41efadc1539a2e64..078e754e1083fc27dbd154ded312a4f74c70c65f 100644 (file)
@@ -11,11 +11,12 @@ define Build/Clean
 endef
 
 define Image/Prepare
+       $(CP) $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/bzImage
 endef
 
 define Image/Build
        touch $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
-       $(STAGING_DIR)/bin/airlink -b 0 -j $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
+       $(STAGING_DIR)/bin/airlink -b 0 -j $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
 endef
 
 $(eval $(call BuildImage))
index 6af4b8b8165f79f98d8f91e09138b0fe76edd1df..b7bd9e9e65df53a58bba13b94b8f7b3f2ab9bf73 100755 (executable)
@@ -7,9 +7,13 @@
 include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
 
+define Image/Prepare
+       cp $(LINUX_DIR)/linux $(KDIR)/vmlinux.elf
+endef
+
 define Image/Build
        cp $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).img
-       cp $(LINUX_DIR)/linux $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
+       cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux
 endef
 
 $(eval $(call BuildImage))
index e1425676dd693eb75f4d1febe2d0d00d1bec68e6..44c2ff7e3b2b4bbca9e5129a96160b5122b7c902 100644 (file)
@@ -49,10 +49,14 @@ ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
   endef
 endif
 
+define Image/Prepare
+       cp $(LINUX_DIR)/arch/i386/boot/bzImage $(KDIR)/bzImage
+endef
+
 define Image/Build
        $(call Image/Build/grub,$(1))
        cp $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).fs
-       cp $(LINUX_DIR)/arch/i386/boot/bzImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz
+       cp $(KDIR)/bzImage $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz
 endef
 
 $(eval $(call BuildImage))