388a97583fc8750075d544c962733073a8c1d770
[vuplus_openembedded] / packages / images / slugos-image.bb
1 # This describes a generic SlugOS image, even though the bb file is
2 # called 'slugos-image.bb' the distro specific configuration is
3 # done in conf/distro/${DISTRO}.conf (which should always include
4 # conf/distro/slugos.conf to get the standard settings).
5 #
6 DESCRIPTION = "Generic SlugOS image"
7 HOMEPAGE = "http://www.nslu2-linux.org"
8 LICENSE = "MIT"
9 PR = "r40"
10
11 COMPATIBLE_MACHINE = "nslu2"
12
13 # SLUGOS_IMAGENAME defines the name of the image to be build, if it
14 # is not set this package will be skipped!
15 IMAGE_BASENAME = "${SLUGOS_IMAGENAME}"
16 IMAGE_NAME = "${IMAGE_BASENAME}-${MACHINE}-${DISTRO_VERSION}"
17 IMAGE_FSTYPES = "jffs2"
18 EXTRA_IMAGECMD_jffs2 = "--pad --${SLUGOS_IMAGESEX} --eraseblock=0x20000 -D ${SLUGOS_DEVICE_TABLE}"
19 IMAGE_LINGUAS = ""
20
21 # Setting USE_DEVFS prevents *any* entries being created initially
22 # in /dev
23 USE_DEVFS = "1"
24
25 # This is passed to the image command to build the correct /dev
26 # directory (because only the image program can make actual
27 # dev entries!)
28 SLUGOS_DEVICE_TABLE = "${@bb.which(bb.data.getVar('BBPATH', d, 1), 'files/device_table-slugos.txt')}"
29
30 # IMAGE_PREPROCESS_COMMAND is run before making the image.  In SlugOS the
31 # kernel image is removed from the root file system to recover the space used -
32 # SlugOS is assumed to boot from a separate kernel image in flash (not in the
33 # root file system), if this is not the case the following must not be done!
34 IMAGE_PREPROCESS_COMMAND += "rm ${IMAGE_ROOTFS}/boot/zImage*;"
35 IMAGE_PREPROCESS_COMMAND += "install -c -m 644 ${SLUGOS_DEVICE_TABLE} ${IMAGE_ROOTFS}/etc/device_table;"
36
37 # Building a full image.  If required do a post-process command which builds
38 # the full flash image using slugimage.  At present this only works for NSLU2 images.
39 PACK_IMAGE = ""
40 IMAGE_POSTPROCESS_COMMAND += "${PACK_IMAGE}"
41 PACK_IMAGE_DEPENDS = ""
42 EXTRA_IMAGEDEPENDS += "${PACK_IMAGE_DEPENDS}"
43
44 # This hack removes '${MACHINE}' from the end of the arch.conf for ipk,
45 # preventing _mach.ipk (with no byte sex) taking precedence over everything
46 # else.
47 ROOTFS_POSTPROCESS_COMMAND += "sed -i '$d' '${IMAGE_ROOTFS}/etc/ipkg/arch.conf';"
48
49 # These depends define native utilities - they do not get put in the flash and
50 # are not required to build the image.
51 IMAGE_TOOLS = ""
52 EXTRA_IMAGEDEPENDS += "${IMAGE_TOOLS}"
53
54 # CONFIG:
55 # SLUGOS_EXTRA_RDEPENDS: set in conf, things to add to the image
56 # SLUGOS_SUPPORT:        set to here, see below, added to the image.
57 # SLUGOS_KERNEL:         set here, kernel modules added to the image
58 #
59 # Do not override the last two unless you really know what you
60 # are doing - there is more information below.
61
62 # diff, cpio and find are required for reflash and turnup ram.
63 # Removing these probably leaves the system bootable, but standard
64 # openslug and ucslugc stuff won't work, so only take these out in
65 # very non-standard turnkey slugos builds.
66 #
67 # udev is the default way of handling devices, there is no guarantee
68 # that the static device table is completely correct (it is just
69 # known to be sufficient for boot.)
70 SLUGOS_SUPPORT ?= "diffutils cpio findutils udev"
71
72 # kernel-module-af-packet must be in the image for DHCP to work
73 # kernel-module-netconsole is here because it is small and is
74 # highly useful on minimal systems (which really don't have anywhere
75 # other than the network to output error messages!)
76 SLUGOS_KERNEL ?= "kernel-module-af-packet kernel-module-netconsole"
77
78 RDEPENDS = "kernel ixp4xx-npe \
79         base-files base-passwd netbase \
80         busybox initscripts-slugos slugos-init \
81         update-modules sysvinit tinylogin \
82         module-init-tools modutils-initscripts \
83         ipkg-collateral ipkg ipkg-link \
84         portmap \
85         dropbear \
86         beep \
87         e2fsprogs-blkid \
88         util-linux-mount \
89         util-linux-umount \
90         util-linux-swaponoff \
91         util-linux-losetup \
92         ${SLUGOS_SUPPORT} \
93         ${SLUGOS_KERNEL} \
94         ${SLUGOS_EXTRA_RDEPENDS}"
95
96 IPKG_INSTALL = "${RDEPENDS}"
97
98 inherit image_ipk
99
100 python () {
101     # Don't build slugos images unless the configuration is set up
102     # for an image build!
103     if bb.data.getVar("SLUGOS_IMAGENAME", d, 1) == '' or bb.data.getVar("SLUGOS_IMAGESEX", d, 1) == '':
104         raise bb.parse.SkipPackage("absent or broken SlugOS configuration")
105 }
106
107 #--------------------------------------------------------------------------------
108 # NSLU2 specific
109 #
110 #NOTE: you do not actually need the boot loader in normal use because it is
111 # *not* overwritten by a standard upslug upgrade, so you can make an image with
112 # just non-LinkSys software which can be flashed into the NSLU2.  Because
113 # LinkSys have made "EraseAll" available, however, (this does overwrite RedBoot)
114 # it is a bad idea to produce flash images without a valid RedBoot - that allows
115 # an innocent user upgrade attempt to instantly brick the NSLU2.
116 PACK_IMAGE += "${@['', 'nslu2_pack_image;'][bb.data.getVar('SLUGOS_FLASH_IMAGE', d, 1) == 'nslu2']}"
117 PACK_IMAGE_DEPENDS += "${@['', 'slugimage-native nslu2-linksys-firmware apex ixp4xx-npe'][bb.data.getVar('SLUGOS_FLASH_IMAGE', d, 1) == 'nslu2']}"
118
119 NSLU2_SLUGIMAGE_ARGS ?= ""
120
121 nslu2_pack_image() {
122         if test '${SLUGOS_FLASH_IMAGE}' = nslu2
123         then
124                 install -d ${DEPLOY_DIR_IMAGE}/slug
125                 install -m 0644 ${STAGING_LIBDIR}/nslu2-binaries/RedBoot \
126                                 ${STAGING_LIBDIR}/nslu2-binaries/Trailer \
127                                 ${STAGING_LIBDIR}/nslu2-binaries/SysConf \
128                                 ${DEPLOY_DIR_IMAGE}/slug/
129                 install -m 0644 ${STAGING_LOADER_DIR}/apex.bin ${DEPLOY_DIR_IMAGE}/slug/
130                 install -m 0644 ${DEPLOY_DIR_IMAGE}/zImage-nslu2${ARCH_BYTE_SEX} \
131                         ${DEPLOY_DIR_IMAGE}/slug/vmlinuz
132                 install -m 0644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 \
133                         ${DEPLOY_DIR_IMAGE}/slug/flashdisk.jffs2
134                 install -m 0644 ${STAGING_FIRMWARE_DIR}/NPE-B ${DEPLOY_DIR_IMAGE}/slug/
135                 cd ${DEPLOY_DIR_IMAGE}/slug
136                 slugimage -p -b RedBoot -s SysConf -L apex.bin -k vmlinuz \
137                         -r Flashdisk:flashdisk.jffs2 -m NPE-B -t Trailer \
138                         -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.flashdisk.img \
139                         ${NSLU2_SLUGIMAGE_ARGS}
140                 rm -rf ${DEPLOY_DIR_IMAGE}/slug
141         fi
142 }
143
144 # upslug2 (in tmp/work/upslug2-native-*) is the program to write the NSLU2 flash
145 IMAGE_TOOLS_nslu2 = "upslug2-native"