3 from cross
import CrossBuild
11 #############################################################################
13 #############################################################################
17 #############################################################################
19 #############################################################################
20 rootfs_env
= build
.CrossEnvironment(name
= 'u-tools')
22 rootfs_name
= "initramfs" # rootfs
24 start_addr
= 0x20800000
26 #if rootfs_env.toolchain.type == "gnu":
27 # rootserver_env.scons_env["CC_OPTIMISATIONS"] = "s"
29 rootfs_env
.process_global_config()
31 #if rootfs_env.toolchain.type in ["ads", "rvct"]:
32 #rootfs_env.Package("libs/rvct", buildname="c", filesystem="null")
34 #rootfs_env.Package("libs/c", filesystem="null")
35 # rootfs_env.Package("libs/gcc")
38 #if rootfs_env.machine.__name__ == "s5pc100":
41 # Where is Linux kernel installed ?
42 linux_dir
= get_arg(build
, 'LINUX_DIR', 'linux')
43 if not os
.path
.isabs(linux_dir
):
44 linux_dir
= os
.path
.abspath(os
.path
.join('..', '..', linux_dir
))
46 # Where is default rootfs installed ?
47 project_dir
= get_arg(build
, 'PROJECT_DIR', 'rootfs')
48 if not os
.path
.isabs(project_dir
):
49 project_dir
= os
.path
.abspath(os
.path
.join('..', '..', project_dir
))
52 # nouse liunote parase project config file (now i not use android lib)
53 #cpp_defines=project_config.get_h_project_define(os.path.join(project_dir,"AndroidConfig.h"))
55 # nouse liunote fixme to and group
56 #rootfs_env.scons_env.Append(CPPDEFINES = cpp_defines)
59 ################## Linux ##############################################
61 #assert os.path.exists(linux_dir), "LINUX_DIR: %s: does not exist" % linux_dir
64 #############################################################################
65 ## Customised root filesystem
66 #############################################################################
68 extern_rootfs
= get_arg(build
, 'LINUX_ROOTFS', None)
71 rootfs_path
= Dir(extern_rootfs
).abspath
# liunote is extra rootfs path
72 if extern_rootfs
!= "none" and not os
.path
.exists(rootfs_path
) :
73 raise UserError
, "%s is not a valid path" % rootfs_path
75 Export('extern_rootfs')
77 rootfs_size
= get_int_arg(build
, 'LINUX_ROOTFS_SIZE', 0)
83 def getpathsize(path
):
84 f
= os
.popen("du -s %s" % path
)
85 l
= f
.readline().split()[0]
90 #############################################################################
92 #############################################################################
93 #linux_apps = [app for app in os.listdir(os.path.join(project_dir, 'apps')) if
94 # (not app.startswith(".") and (app != 'busybox'))] + [None]
95 #extra_linux_apps = get_option_arg(build, 'LINUX_APPS', None, linux_apps, True)
96 #Export('extra_linux_apps')
97 #extra_linux_apps =["e2fsprogs","liblog","libcutils","libpixelflinger","libminui","libdiskconfig","diskinstaller","hello"] #
98 #extra_linux_apps =["e2fsprogs","libdiskconfig","libshtest","hello","adb"] # ,"diskinstaller"
99 #extra_linux_apps =["e2fsprogs","libdiskconfig","libshtest","ltp","hello","adb","diskinstaller"] # libdiskconfig_usb for dwn
100 extra_linux_apps
=["e2fsprogs","libdiskconfig","libshtest","hello","adb","diskinstaller"] # libdiskconfig_usb for dwn
102 # liu add mytest for syscall
103 #extra_linux_apps +=["mytest"]
104 extra_linux_apps
+=["usbinit"]
105 #extra_linux_apps +=["tslib"]
106 extra_linux_apps
+=["newfs_dos"]
107 extra_linux_apps
+=["fsck_msdos"]
108 extra_linux_apps
+=["tar"]
109 extra_linux_apps
+=["bzip2"]
112 #run_gstreamertest = False
113 #Export('run_gstreamertest')
119 ltp_set
= get_arg(build
, 'LTP_SET', 'set1') #'all')
123 # build linux kernel and modules
124 #linux_env = build.CrossEnvironment("linux", LINKCOM="$UNADORNED_LINKCOM", LINUX_DIR=linux_dir)
125 #linux_env.process_global_config()
127 # no liunote images generate
128 #images_env = build.CrossEnvironment("images")
130 #kernel,modules = rootfs_env.Package(os.path.join(linux_dir, "kernel" ),
131 # linux_config=linux_config) )
133 # Clean the ramdisk contents if it exists liunote !!! ??? this python not suport disutils
134 inst_dir
= Dir(rootfs_env
.builddir
+ "/install").abspath
135 #if os.path.exists(inst_dir):
136 # distutils.dir_util.remove_tree(inst_dir)
140 build
.expect_test_data
= []
142 #liunote last package first build
145 # Create an external rootfs if supplied, otherwise create default rootfs
146 if extern_rootfs
== "none":
148 # error if rootfs_size is defined
150 raise UserError
, "Don't define the rootfs size if you're not using one!"
152 # skip all the filesystem code below!
160 # Use customised rootfs
162 print "Installing root filesystem from %s" % rootfs_path
163 distutils
.dir_util
.copy_tree(rootfs_path
, inst_dir
, preserve_symlinks
=True)
165 # Don't allow linux applications to be bundled together
166 assert extra_linux_apps
is None, "Can't bundle extra Linux apps when using external rootfs"
168 paths_size
+= getpathsize(extern_rootfs
)
176 #rootfs = rootfs_env.Package(os.path.join(project_dir, "rootfs%s" % rootfs_version))
177 rootfs
= rootfs_env
.Package(os
.path
.join(project_dir
, rootfs_name
))
179 paths_size
= 4000 #4M
181 if extra_linux_apps
is not None:
182 if 'lmbench' in extra_linux_apps
:
184 if 'ltp' in extra_linux_apps
:
188 paths_size
+= 4000 #10000
190 for app
in extra_linux_apps
:
191 extra
= rootfs_env
.Package(os
.path
.join(project_dir
, 'apps', app
))
195 #print os.path.basename(str(extra))
197 if app
== "diskinstaller":
200 # rootfs_env.Depends(extra, rootfs) # liunote remove for depends err at e2fsprog install to rootfs install :
201 # scons: *** Source `build_out/u-tools/e2fsprogs_install/lib/libblkid.so.1' not found, needed by target `build_out/u-tools/install/lib/libblkid.so.1'. Stop.
202 # scons: building terminated because of errors
207 # Always include BusyBox
208 busybox
= rootfs_env
.Package(os
.path
.join(project_dir
, "apps", "busybox"))
210 if rootfs
is not None:
211 rootfs_env
.Depends(busybox
, rootfs
)
213 #if rootfs is not None:
214 # linux_env.scons_env.AddPostAction(kernel, modules)
216 if rootfs_size
is None:
217 disk_size
= int(paths_size
* 1.4)
220 # if rootfs_size < paths_size:
222 # "Suggested filesystem image size of %s is insufficient for " \
223 # "rootfs at %s, which is %s blocks in size" \
224 # % (rootfs_size, rootfs_path, paths_size)
226 # disk_size = rootfs_size
228 print "disk_size is %s" % disk_size
230 devfs_file
= os
.path
.join(project_dir
, rootfs_name
, "dev.txt")
233 #fs = rootfs_env.Ext2FS(disk_size, devfs_file)
234 cpio_rmdisk
= rootfs_env
.MakeInitRamfs()
236 uboot_rmdisk
= rootfs_env
.MakeRamdisk(start_addr
)
238 if rootfs
is not None:
239 #rootfs_env.Depends(fs,busybox)
240 #rootfs_env.Depends(uboot_rmdisk,fs)
243 rootfs_env
.Depends(cpio_rmdisk
,extra_last
)
244 #rootfs_env.Depends(extra_first,busybox)
245 rootfs_env
.Depends(cpio_rmdisk
,extra_first
)
246 rootfs_env
.Depends(cpio_rmdisk
,busybox
)
247 rootfs_env
.Depends(uboot_rmdisk
,cpio_rmdisk
)
249 # linux_env.Depends(kernel, rootfs)
250 # linux_env.scons_env.Depends(fs, kernel)
251 # rootserver_env.add_file(wombat, fs, 'rootfs')
252 # rootserver_env.apps.append(fs)
255 # endif extern_rootfs is "none"
258 build
.expect_test_data
= []
260 build
.expect_test_data
.append( ("Linux user startup!", None) )
264 if extra_linux_apps is not None:
265 if 'disktest' in extra_linux_apps:
266 build.expect_test_data.append( ("/ #", "sh /disktest/disktest.sh") )
267 build.expect_test_data.append( ("disktest completed... exiting", None) )
269 #just check we got a prompt if not running ltp or lmbench
270 build.expect_test_data.append( ("Please press Enter to activate this console.", "\n") )
271 build.expect_test_data.append( ("/ #", "uname -a") )
275 if extern_rootfs
== "none":
276 build
.expect_test_data
= [("Assertion failed", None)]
278 # liunote test remove
280 if run_gstreamertest == True:
281 build.expect_test_data = [("GStreamer test result: pass", None)]
284 if rootfs_size
is not None:
285 build
.expect_test_data
= [("Linux user startup!", None),
286 ("Please press Enter to activate this console.", "\n"),
287 ("/ #", "/usr/bin/check_rootfs_size.sh 8000"),