add new image builder

SVN-Revision: 1661
This commit is contained in:
Felix Fietkau 2005-08-14 15:00:56 +00:00
parent 9791d7a241
commit 4bcd843c60
16 changed files with 265 additions and 58 deletions

View File

@ -175,7 +175,17 @@ source "package/bluez-utils/Config.in"
comment "Extra stuff"
source "package/sdk/Config.in"
config BR2_PACKAGE_IMAGEBUILDER
bool "OpenWrt Image Builder"
default y if CONFIG_DEVEL
help
Build an OpenWrt Image Builder.
This package contains the necessary (precompiled) tools and all packages to generate
firmware images from package lists, without having to use the full buildroot.
Useful for building images with custom scripts or extra packages.
endmenu
source "package/Sysconf.in"

View File

@ -35,44 +35,6 @@ $(BIN_DIR)/$(SDK_NAME).tar.bz2:
tar cfj $@ $(SDK_NAME); \
)
$(BIN_DIR)/$(IB_NAME).tar.bz2:
rm -rf $(IB_BUILD_DIR)
mkdir -p $(IB_BUILD_DIR)/build
(cd $(BUILD_DIR); \
cp buildroot-kernel-image loader.gz $(IB_BUILD_DIR)/build; \
)
mkdir -p $(IB_BUILD_DIR)/utils
(cd $(STAGING_DIR)/bin; \
cp addpattern trx motorola-bin sed mkfs.jffs2 mksquashfs-lzma $(IB_BUILD_DIR)/utils; \
)
mkdir -p $(IB_BUILD_DIR)/include
mkdir -p $(IB_BUILD_DIR)/packages
(cd $(PACKAGE_DIR); \
cp ipkg_* busybox_* kmod-brcm-* kmod-wlcompat* dnsmasq_* iptables_* dropbear_* kmod-diag_* \
wireless-tools_* zlib* bridge_* ppp_* ppp*pppoe* kmod-ppp* openwrt-utils* $(IB_BUILD_DIR)/packages/; \
)
egrep '^[^(include|prepare|compile|install)]' < $(TOPDIR)/target/jffs2/Makefile > $(IB_BUILD_DIR)/include/jffs2.mk
egrep '^[^(include|prepare|compile|install)]' < $(TOPDIR)/target/squashfs-lzma/Makefile > $(IB_BUILD_DIR)/include/squashfs-lzma.mk
cp ./files/README.ImageBuilder $(IB_BUILD_DIR)/
cp ./files/Makefile.ib $(IB_BUILD_DIR)/Makefile
cp -a $(TOPDIR)/target/default/target_skeleton $(IB_BUILD_DIR)/
for target_dir in etc jffs dev proc tmp lib usr/lib usr/sbin; do \
mkdir -p $(IB_BUILD_DIR)/target_skeleton/$$target_dir; \
done
cp -a ./files/sysconf $(IB_BUILD_DIR)/target_skeleton/etc/
cp -a $(TARGET_DIR)/lib/*.so* $(IB_BUILD_DIR)/target_skeleton/lib/
cp -a $(BUILD_DIR)/libshared/libshared.so $(IB_BUILD_DIR)/target_skeleton/usr/lib/
cp -a $(BUILD_DIR)/libnvram/libnvram.so $(IB_BUILD_DIR)/target_skeleton/usr/lib/
cp -a $(BUILD_DIR)/libnvram/nvram $(IB_BUILD_DIR)/target_skeleton/usr/sbin/
cp -a $(BUILD_DIR)/linksys-wlconf/wlconf $(IB_BUILD_DIR)/target_skeleton/usr/sbin/
-$(STRIP) $(IB_BUILD_DIR)/target_skeleton/usr/lib/* $(IB_BUILD_DIR)/target_skeleton/usr/sbin/*
ln -sf /tmp/resolv.conf $(IB_BUILD_DIR)/target_skeleton/etc/resolv.conf
ln -sf /tmp $(IB_BUILD_DIR)/target_skeleton/var
find $(IB_BUILD_DIR) -name CVS | xargs rm -rf
(cd $(BUILD_DIR); \
tar cfj $@ $(IB_NAME); \
)
source:
prepare:
compile: $(BIN_DIR)/$(SDK_NAME).tar.bz2

View File

@ -26,5 +26,6 @@ image_clean:
$(MAKE) -C $(patsubst %-rebuild,%,$@) rebuild
%-install: %-compile
$(MAKE) -C $(patsubst %-install,%,$@) install
linux-imagebuilder:
$(MAKE) -C linux imagebuilder

View File

@ -1,5 +1,11 @@
include $(TOPDIR)/rules.mk
PKG_OS:=$(shell uname -s)
PKG_CPU:=$(shell uname -m)
IB_NAME:=OpenWrt-ImageBuilder-$(PKG_OS)-$(PKG_CPU)
IB_DIR:=$(BUILD_DIR)/$(IB_NAME)
define kernel_template
$(1)/$(2)-clean:
@ -20,17 +26,45 @@ $(1)/$(2)-install:
$(1)/$(2)-image: $(1)/$(2)-install
$(MAKE) -C image KERNEL="$(1)" BOARD="$(2)" install
$(1)/$(2)-install-ib:
$(MAKE) -C image KERNEL="$(1)" BOARD="$(2)" IB_DIR="$(IB_DIR)" install-ib
echo '$$$$(eval $$$$(call image_template,$(2),$(1)))' >> $(IB_DIR)/kernel.mk
ifeq ($(BR2_LINUX_$(3)),y)
clean: $(1)/$(2)-clean
prepare: $(1)/$(2)-prepare
compile: $(1)/$(2)-compile
rebuild: $(1)/$(2)-rebuild
install: $(1)/$(2)-image
install-ib: $(1)/$(2)-install-ib
endif
.PHONY: $(1)/$(2)-clean $(1)/$(2)-prepare $(1)/$(2)-compile $(1)/$(2)-rebuild $(1)/$(2)-install
.PHONY: $(1)/$(2)-clean $(1)/$(2)-prepare $(1)/$(2)-compile $(1)/$(2)-rebuild $(1)/$(2)-install $(1)/$(2)-install-ib
endef
.PHONY: clean prepare compile rebuild install imagebuilder install-ib
install-ib:
$(BIN_DIR)/$(IB_NAME).tar.bz2:
rm -rf $(IB_DIR)
mkdir -p $(IB_DIR)/packages
mkdir -p $(IB_DIR)/scripts
cp -dpR ./imagebuilder/* $(IB_DIR)/
cp -dpR $(TOPDIR)/bin/packages/*.ipk $(IB_DIR)/packages/
cp $(TOPDIR)/scripts/ipkg $(IB_DIR)/scripts/
$(MAKE) install-ib
cp $(TOPDIR)/rules.mk $(IB_DIR)
cp -dpR ./image $(IB_DIR)/
cp $(TOPDIR)/.config $(IB_DIR)/
find $(IB_DIR) -name CVS | xargs rm -rf
(cd $(BUILD_DIR); tar c $(IB_NAME) | bzip2 -c > $(BIN_DIR)/$(IB_NAME).tar.bz2)
ifeq ($(BR2_PACKAGE_IMAGEBUILDER),y)
install: $(BIN_DIR)/$(IB_NAME).tar.bz2
endif
prepare:
$(MAKE) -C image prepare
compile:

View File

@ -19,6 +19,12 @@ compile:
install:
$(MAKE) -C $(BOARD) prepare
$(MAKE) -C $(BOARD) compile
install-ib:
-$(MAKE) -C $(BOARD) IB_DIR="$(IB_DIR)" install-ib
mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)
cp $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/kernel[-_]*.ipk $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/
rebuild: clean prepare compile install
clean:

View File

@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk
KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-ar7
KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
PKG_BUILD_DIR:=$(BUILD_DIR)/ar7loader
@ -47,9 +47,11 @@ $(KDIR)/vmlinux.bin: $(KDIR)/vmlinux.lzma
-o $(KDIR)/loader
$(TARGET_CROSS)objcopy -O srec $(KDIR)/loader $(KDIR)/ram_zimage.sre
$(STAGING_DIR)/bin/srec2bin $(KDIR)/ram_zimage.sre $@
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin: $(KDIR)/vmlinux.bin
endif
$(BIN_DIR)/openwrt-ar7-2.4-kernel.bin: $(KDIR)/vmlinux.bin
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin:
cp $< $@
ifeq ($(FS),jffs2-8MB)
@ -59,16 +61,16 @@ ifeq ($(FS),jffs2-4MB)
ALIGN:=bs=65536 conv=sync
endif
$(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS).bin: $(BIN_DIR)/openwrt-ar7-2.4-kernel.bin
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin
dd if=$< $(ALIGN) > $@
cat $(BUILD_DIR)/linux-$(KERNEL)-ar7/root.$(FS) >> $@
cat $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/root.$(FS) >> $@
define pattern_template
$(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS)-$(1).bin: $(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS).bin
(dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS).bin) | \
$(STAGING_DIR)/bin/addpattern -p $(1) $(2) -o $(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS)-$(1).bin
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin
(dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin) | \
$(STAGING_DIR)/bin/addpattern -p $(1) $(2) -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin
install: $(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS)-$(1).bin
install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS)-$(1).bin
endef
$(eval $(call pattern_template,WA22))
@ -76,11 +78,23 @@ $(eval $(call pattern_template,WAG2))
$(eval $(call pattern_template,WA21))
$(eval $(call pattern_template,WA32,-b))
ifeq ($(IB),)
clean:
rm -rf $(PKG_BUILD_DIR)
rm -f $(BIN_DIR)/openwrt-ar7*
rm -f $(BIN_DIR)/openwrt-$(BOARD)*
prepare: $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/zimage.script $(PKG_BUILD_DIR)/ld.script
compile: prepare $(PKG_BUILD_DIR)/loader.o $(PKG_BUILD_DIR)/LzmaDecode.o $(STAGING_DIR)/bin/srec2bin
install: $(BIN_DIR)/openwrt-ar7-2.4-kernel.bin $(BIN_DIR)/openwrt-ar7-$(KERNEL)-$(FS).bin
else
clean:
prepare:
compile:
endif
install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-kernel.bin $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).bin
install-ib:
mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)
cp -dpR $(KDIR)/vmlinux.bin $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/
mkdir -p $(IB_DIR)/staging_dir_$(ARCH)
cp -dpR $(STAGING_DIR)/bin/addpattern $(IB_DIR)/staging_dir_$(ARCH)/bin/

View File

@ -1,6 +1,6 @@
include $(TOPDIR)/rules.mk
KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-brcm
KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
lzma-loader-clean:
$(MAKE) -C lzma-loader clean
@ -11,16 +11,20 @@ lzma-loader-prepare:
lzma-loader-compile: lzma-loader-prepare
$(MAKE) -C lzma-loader compile
ifeq ($(IB),)
$(KDIR)/vmlinux.lzma: $(KDIR)/vmlinux
cat $^ | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $@ || (rm -f $@ && false)
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx: $(KDIR)/vmlinux.lzma
endif
ifeq ($(FS),jffs2-8MB)
TRXALIGN:=-a 0x20000
endif
ifeq ($(FS),jffs2-4MB)
TRXALIGN:=-a 0x10000
endif
$(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx: $(KDIR)/vmlinux.lzma
$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx:
$(STAGING_DIR)/bin/trx -o $@ $(BUILD_DIR)/loader.gz $(KDIR)/vmlinux.lzma $(TRXALIGN) $(KDIR)/root.$(FS)
@ -28,26 +32,38 @@ ifeq ($(KERNEL),2.4)
FSNAME:=$(patsubst jffs2-%,jffs2,$(FS))
ifneq ($(FS),jffs2-8MB)
$(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin: $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
$(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
$(STAGING_DIR)/bin/addpattern -4 -p W54G -v v4.20.6 -i $< -o $@ -g
install: $(BIN_DIR)/openwrt-wrt54g-$(FSNAME).bin
endif
ifneq ($(FS),jffs2-4MB)
$(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin: $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
$(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
$(STAGING_DIR)/bin/addpattern -4 -p W54S -v v4.70.6 -i $< -o $@ -g
install: $(BIN_DIR)/openwrt-wrt54gs-$(FSNAME).bin
endif
$(BIN_DIR)/openwrt-motorola-$(FS).bin: $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
$(BIN_DIR)/openwrt-motorola-$(FS).bin: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
$(STAGING_DIR)/bin/motorola-bin $< $@
install: $(BIN_DIR)/openwrt-motorola-$(FS).bin
endif
ifeq ($(IB),)
clean: lzma-loader-clean
prepare: lzma-loader-prepare
compile: lzma-loader-compile
install: compile $(BIN_DIR)/openwrt-brcm-$(KERNEL)-$(FS).trx
install: compile $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
else
clean:
prepare:
compile:
install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(FS).trx
endif
install-ib:
mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin
cp -dpR $(STAGING_DIR)/bin/addpattern $(STAGING_DIR)/bin/trx $(STAGING_DIR)/bin/motorola-bin $(IB_DIR)/staging_dir_$(ARCH)/bin
mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)
cp -dpR $(BUILD_DIR)/loader.gz $(IB_DIR)/build_$(ARCH)/
cp -dpR $(KDIR)/vmlinux.lzma $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/

View File

@ -23,8 +23,13 @@ jffs2-install: $(KDIR)/root.jffs2-4MB $(KDIR)/root.jffs2-8MB
$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-4MB"
$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="jffs2-8MB"
jffs2-install-ib:
mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin
cp $(STAGING_DIR)/bin/mkfs.jffs2 $(IB_DIR)/staging_dir_$(ARCH)/bin
prepare: jffs2-prepare
compile: jffs2-compile
install: jffs2-install
install-ib: jffs2-install-ib
clean: jffs2-clean

View File

@ -27,7 +27,10 @@ $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz: $(KDIR)/bzImage
cp $^ $@
clean:
prepare:
compile:
install: $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinuz
install-ib:
mkdir -p $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)
cp -dpR $(KDIR)/bzImage $(IB_DIR)/build_$(ARCH)/linux-$(KERNEL)-$(BOARD)/

View File

@ -14,7 +14,13 @@ $(KDIR)/root.squashfs:
squashfs-install: $(KDIR)/root.squashfs
$(MAKE) -C $(BOARD) install KERNEL="$(KERNEL)" FS="squashfs"
squashfs-install-ib:
mkdir -p $(IB_DIR)/staging_dir_$(ARCH)/bin
cp $(STAGING_DIR)/bin/mksquashfs-lzma $(IB_DIR)/staging_dir_$(ARCH)/bin
prepare: squashfs-prepare
compile: squashfs-compile
install: squashfs-install
install-ib: squashfs-install-ib
clean: squashfs-clean

View File

@ -0,0 +1,42 @@
default: clean all
TOPDIR:=${shell pwd}
export TOPDIR
IB:=1
export IB
include ./rules.mk
LINUX_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
IPKG_KERNEL:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(LINUX_BUILD_DIR)/root IPKG_CONF_DIR=$(LINUX_BUILD_DIR) $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
define image_template
all: all-$(1)-$(2)
all-$(1)-$(2):
@for listfile in ./lists/*.$(1)-$(2); do \
$(MAKE) -s `echo $$$$listfile | sed 's,.*lists/\(.*\).$(1)-$(2),BOARD=$(1) KERNEL=$(2) LIST=\1,'` build; \
done
endef
include ./kernel.mk
clean:
@rm -rf $(LINUX_BUILD_DIR)/root*
@rm -rf $(BIN_DIR)
all:
build:
echo
echo '### BUILDING IMAGE FROM lists/$(LIST).$(BOARD)-$(KERNEL)'
echo
rm -rf $(LINUX_BUILD_DIR)/root*
mkdir -p $(BIN_DIR)/$(LIST)
mkdir -p $(LINUX_BUILD_DIR)/tmp
mkdir -p $(LINUX_BUILD_DIR)/root
echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
$(IPKG_KERNEL) install $(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)/kernel[-_]*.ipk
for package in `cat lists/$(LIST).$(BOARD)-$(KERNEL)`; do \
$(IPKG_KERNEL) install `ls packages/$${package}_*`; \
done
$(MAKE) -S -C image KERNEL="$(KERNEL)" BOARD="$(BOARD)" BIN_DIR="$(BIN_DIR)/$(LIST)" install

View File

@ -0,0 +1,25 @@
base-files
base-files-ar7
bridge
busybox
dnsmasq
dropbear
ipkg
iptables
kmod-cpmac
kmod-atm
kmod-pppoatm
kmod-sangam-atm-annexb
kmod-ppp
kmod-pppoe
kmod-wlcompat
libgcc
linux-atm
mtd
nvram
ppp
ppp-mod-pppoe
uclibc
wireless-tools
wificonf
zlib

View File

@ -0,0 +1,23 @@
base-files
base-files-brcm
bridge
busybox
dnsmasq
dropbear
ipkg
iptables
kmod-brcm-et
kmod-brcm-wl
kmod-diag
kmod-ppp
kmod-pppoe
kmod-wlcompat
libgcc
mtd
nvram
ppp
ppp-mod-pppoe
uclibc
wireless-tools
wificonf
zlib

View File

@ -0,0 +1,18 @@
base-files
base-files-ar7
bridge
busybox
dnsmasq
dropbear
ipkg
iptables
kmod-cpmac
kmod-wlcompat
libgcc
linux-atm
mtd
nvram
uclibc
wireless-tools
wificonf
zlib

View File

@ -0,0 +1,19 @@
base-files
base-files-brcm
bridge
busybox
dnsmasq
dropbear
ipkg
iptables
kmod-brcm-et
kmod-brcm-wl
kmod-diag
kmod-wlcompat
libgcc
mtd
nvram
uclibc
wireless-tools
wificonf
zlib

View File

@ -0,0 +1,23 @@
base-files
base-files-brcm
bridge
busybox
dnsmasq
dropbear
ipkg
iptables
kmod-brcm-et
kmod-brcm-wl
kmod-diag
kmod-ppp
kmod-gre
kmod-wlcompat
libgcc
mtd
nvram
ppp
pptp
uclibc
wireless-tools
wificonf
zlib