Image Generator (Image Builder)
準備:
安裝 package:
apt-get install build-essential squashfs-tools
下載 Source:
mkdir /usr/src/openwrt
cd /usr/src/openwrt
[ 351.8 Mbyte ]
# V12
axel http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/Op...
Source Tree
packages:
*.ipk
target/linux/
- x86
- ar71xx
bin/ar71xx/ <-- build 好的東西在這目錄裡
md5sums openwrt-ar71xx-generic-rootfs.tar.gz openwrt-ar71xx-generic-root.jffs2-128k openwrt-ar71xx-generic-root.jffs2-256k openwrt-ar71xx-generic-root.jffs2-64k openwrt-ar71xx-generic-root.squashfs openwrt-ar71xx-generic-root.squashfs-64k openwrt-ar71xx-generic-tl-wr740n-v1-jffs2-factory.bin openwrt-ar71xx-generic-tl-wr740n-v1-jffs2-sysupgrade.bin openwrt-ar71xx-generic-tl-wr740n-v1-squashfs-factory.bin openwrt-ar71xx-generic-tl-wr740n-v1-squashfs-sysupgrade.bin openwrt-ar71xx-generic-tl-wr740n-v3-jffs2-factory.bin openwrt-ar71xx-generic-tl-wr740n-v3-jffs2-sysupgrade.bin openwrt-ar71xx-generic-tl-wr740n-v3-squashfs-factory.bin openwrt-ar71xx-generic-tl-wr740n-v3-squashfs-sysupgrade.bin openwrt-ar71xx-generic-tl-wr740n-v4-jffs2-factory.bin openwrt-ar71xx-generic-tl-wr740n-v4-jffs2-sysupgrade.bin openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-factory.bin openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-sysupgrade.bin openwrt-ar71xx-generic-uImage-gzip.bin openwrt-ar71xx-generic-uImage-lzma.bin openwrt-ar71xx-generic-vmlinux.bin openwrt-ar71xx-generic-vmlinux.elf openwrt-ar71xx-generic-vmlinux.gz openwrt-ar71xx-generic-vmlinux.lzma openwrt-ar71xx-generic-vmlinux-lzma.elf
Usage
make image PROFILE=XXX PACKAGES="pkg1 pkg2 -pkg4" FILES=files/
make image
create a minimal image with just essential packages included
make info
list of defined profiles
Current Target: "ar71xx (Generic)" Default Packages: base-files libc libgcc busybox dropbear mtd uci opkg hotplug2 netifd kmod-leds-gpio kmod-gpio-button-hotplug kmod-wdt-ath79 swconfig kmod-ledtrig-default-on kmod-ledtrig-timer kmod-ledtrig-netdev kmod-ath9k wpad-mini uboot-envtools dnsmasq iptables ppp ppp-mod-pppoe kmod-ipt-nathelper firewall .............. TLWR740: TP-LINK TL-WR740N/ND Packages: .............. TLWR842: TP-LINK TL-WR842N/ND Packages: kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev ..............
Profiles 放在:
./target/linux/ar71xx/generic/profiles/tp-link.mk
Example:
....................................... define Profile/TLWR740 NAME:=TP-LINK TL-WR740N/ND PACKAGES:= endef define Profile/TLWR740/Description Package set optimized for the TP-LINK TL-WR740N/ND. endef $(eval $(call Profile,TLWR740)) .......................................
List installed Package on working router
opkg list_installed
740N - 12.09
base-files - 117-r36088 busybox - 1.19.4-6 dnsmasq - 2.62-2 dropbear - 2011.54-2 firewall - 2-55.1 hotplug2 - 1.0-beta-4 iptables - 1.4.10-4 iw - 3.6-1 jshn - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8 kernel - 3.3.8-1-d6597ebf6203328d3519ea3c3371a493 kmod-ath - 3.3.8+2012-09-07-3 kmod-ath9k - 3.3.8+2012-09-07-3 kmod-ath9k-common - 3.3.8+2012-09-07-3 kmod-cfg80211 - 3.3.8+2012-09-07-3 kmod-crypto-aes - 3.3.8-1 kmod-crypto-arc4 - 3.3.8-1 kmod-crypto-core - 3.3.8-1 kmod-gpio-button-hotplug - 3.3.8-1 kmod-ipt-conntrack - 3.3.8-1 kmod-ipt-core - 3.3.8-1 kmod-ipt-nat - 3.3.8-1 kmod-ipt-nathelper - 3.3.8-1 kmod-leds-gpio - 3.3.8-1 kmod-ledtrig-default-on - 3.3.8-1 kmod-ledtrig-netdev - 3.3.8-1 kmod-ledtrig-timer - 3.3.8-1 kmod-ledtrig-usbdev - 3.3.8-1 kmod-lib-crc-ccitt - 3.3.8-1 kmod-mac80211 - 3.3.8+2012-09-07-3 kmod-nls-base - 3.3.8-1 kmod-ppp - 3.3.8-1 kmod-pppoe - 3.3.8-1 kmod-pppox - 3.3.8-1 kmod-usb-core - 3.3.8-1 kmod-usb-ohci - 3.3.8-1 kmod-usb2 - 3.3.8-1 kmod-wdt-ath79 - 3.3.8-1 libblobmsg-json - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8 libc - 0.9.33.2-1 libgcc - 4.6-linaro-1 libip4tc - 1.4.10-4 libiwinfo - 36 libiwinfo-lua - 36 libjson - 0.9-2 liblua - 5.1.4-8 libnl-tiny - 0.1-3 libubox - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8 libubus - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50 libubus-lua - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50 libuci - 2013-01-04.1-1 libuci-lua - 2013-01-04.1-1 libxtables - 1.4.10-4 lua - 5.1.4-8 luci - 0.11.1-1 luci-app-firewall - 0.11.1-1 luci-i18n-english - 0.11.1-1 luci-lib-core - 0.11.1-1 luci-lib-ipkg - 0.11.1-1 luci-lib-nixio - 0.11.1-1 luci-lib-sys - 0.11.1-1 luci-lib-web - 0.11.1-1 luci-mod-admin-core - 0.11.1-1 luci-mod-admin-full - 0.11.1-1 luci-proto-core - 0.11.1-1 luci-proto-ppp - 0.11.1-1 luci-sgi-cgi - 0.11.1-1 luci-theme-base - 0.11.1-1 luci-theme-openwrt - 0.11.1-1 mtd - 18.1 netifd - 2013-01-29.2-4bb99d4eb462776336928392010b372236ac3c93 opkg - 618-3 ppp - 2.4.5-8 ppp-mod-pppoe - 2.4.5-8 swconfig - 10 uboot-envtools - 2012.04.01-1 ubus - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50 ubusd - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50 uci - 2013-01-04.1-1 uhttpd - 2012-10-30-e57bf6d8bfa465a50eea2c30269acdfe751a46fd wpad-mini - 20120910-1
File
mkdir -p files/etc/config
內有 file
network wireless firewall
# clean up temporary build files and generated images
make clean
Example
make image PROFILE=TLWR740 PACKAGES="luci -ppp -ppp-mod-pppoe"
拆開 bin
找出 squashfs 的開始位置:
hexdump -C openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-sysupgrade.bin | grep hsqs
000e9ce0 64 37 a0 07 00 ff ff ff 68 73 71 73 e2 03 00 00 |d7......hsqs....|
dd 出所需部份:
e9ce8 = 957672 byte
dd skip=957672 bs=1 if=openwrt-ar71xx-generic-tl-wr740n-v4-squashfs-sysupgrade.bin of=tmp.bin
測試:
file tmp.bin
tmp.bin: Squashfs filesystem, little endian, version 4.0, 1790665 bytes, 994 inodes, blocksize: 262144 bytes, created: Fri Dec 13 16:32:37 2013