merge of 425cf1b391611c169a1c3b78f1fe86df088902b9
[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 = "r41"
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 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 SLUGOS_KERNEL ?= ""
73
74 SLUGOS_EXTRA_RDEPENDS ?= ""
75
76 RDEPENDS = "kernel ixp4xx-npe \
77         base-files base-passwd netbase \
78         busybox initscripts-slugos slugos-init \
79         update-modules sysvinit tinylogin \
80         module-init-tools modutils-initscripts \
81         ipkg-collateral ipkg ipkg-link \
82         portmap \
83         dropbear \
84         beep \
85         e2fsprogs-blkid \
86         util-linux-mount \
87         util-linux-umount \
88         util-linux-swaponoff \
89         util-linux-losetup \
90         ${SLUGOS_SUPPORT} \
91         ${SLUGOS_KERNEL} \
92         ${SLUGOS_EXTRA_RDEPENDS}"
93
94 IPKG_INSTALL = "${RDEPENDS}"
95
96 inherit image_ipk
97
98 python () {
99     # Don't build slugos images unless the configuration is set up
100     # for an image build!
101     if bb.data.getVar("SLUGOS_IMAGENAME", d, 1) == '' or bb.data.getVar("SLUGOS_IMAGESEX", d, 1) == '':
102         raise bb.parse.SkipPackage("absent or broken SlugOS configuration")
103 }
104
105 #--------------------------------------------------------------------------------
106 # NSLU2 specific
107 #
108 #NOTE: you do not actually need the boot loader in normal use because it is
109 # *not* overwritten by a standard upslug upgrade, so you can make an image with
110 # just non-LinkSys software which can be flashed into the NSLU2.  Because
111 # LinkSys have made "EraseAll" available, however, (this does overwrite RedBoot)
112 # it is a bad idea to produce flash images without a valid RedBoot - that allows
113 # an innocent user upgrade attempt to instantly brick the NSLU2.
114 PACK_IMAGE += "${@['', 'nslu2_pack_image;'][bb.data.getVar('SLUGOS_FLASH_IMAGE', d, 1) == 'nslu2']}"
115 PACK_IMAGE_DEPENDS += "${@['', 'slugimage-native nslu2-linksys-firmware apex ixp4xx-npe'][bb.data.getVar('SLUGOS_FLASH_IMAGE', d, 1) == 'nslu2']}"
116
117 NSLU2_SLUGIMAGE_ARGS ?= ""
118
119 nslu2_pack_image() {
120         if test '${SLUGOS_FLASH_IMAGE}' = nslu2
121         then
122                 install -d ${DEPLOY_DIR_IMAGE}/slug
123                 install -m 0644 ${STAGING_LIBDIR}/nslu2-binaries/RedBoot \
124                                 ${STAGING_LIBDIR}/nslu2-binaries/Trailer \
125                                 ${STAGING_LIBDIR}/nslu2-binaries/SysConf \
126                                 ${DEPLOY_DIR_IMAGE}/slug/
127                 install -m 0644 ${STAGING_LOADER_DIR}/apex.bin ${DEPLOY_DIR_IMAGE}/slug/
128                 install -m 0644 ${DEPLOY_DIR_IMAGE}/zImage-nslu2${ARCH_BYTE_SEX} \
129                         ${DEPLOY_DIR_IMAGE}/slug/vmlinuz
130                 install -m 0644 ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.jffs2 \
131                         ${DEPLOY_DIR_IMAGE}/slug/flashdisk.jffs2
132                 install -m 0644 ${STAGING_FIRMWARE_DIR}/NPE-B ${DEPLOY_DIR_IMAGE}/slug/
133                 cd ${DEPLOY_DIR_IMAGE}/slug
134                 slugimage -p -b RedBoot -s SysConf -L apex.bin -k vmlinuz \
135                         -r Flashdisk:flashdisk.jffs2 -m NPE-B -t Trailer \
136                         -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.flashdisk.img \
137                         ${NSLU2_SLUGIMAGE_ARGS}
138                 rm -rf ${DEPLOY_DIR_IMAGE}/slug
139         fi
140 }
141
142 # upslug2 (in tmp/work/upslug2-native-*) is the program to write the NSLU2 flash
143 IMAGE_TOOLS_nslu2 = "upslug2-native"