1212--
1313-- Copyright (C) 2023-2023 RT-Thread Development Team
1414--
15- -- @author xqyjlj
15+ -- @author xqyjlj
1616-- @file on_run.lua
1717--
1818-- Change Logs:
@@ -33,19 +33,33 @@ function create_dir(dir)
3333 end
3434end
3535
36+ function make_link (srcpath , dstpath )
37+ print (dstpath )
38+ if not os .exists (dstpath ) then
39+ os .ln (srcpath , dstpath )
40+ end
41+ end
42+
3643function create_rootfs (rootfs )
3744 create_dir (path .join (rootfs , " bin" ))
3845 create_dir (path .join (rootfs , " dev" ))
46+ create_dir (path .join (rootfs , " dev" , " shm" ))
3947 create_dir (path .join (rootfs , " etc" ))
40- create_dir (path .join (rootfs , " kernel" ))
4148 create_dir (path .join (rootfs , " lib" ))
4249 create_dir (path .join (rootfs , " proc" ))
4350 create_dir (path .join (rootfs , " mnt" ))
4451 create_dir (path .join (rootfs , " services" ))
4552 create_dir (path .join (rootfs , " tmp" ))
4653 create_dir (path .join (rootfs , " usr" ))
47- create_dir (path .join (rootfs , " var" , " persistence" ))
48- create_dir (path .join (rootfs , " var" , " run" ))
54+ create_dir (path .join (rootfs , " var" ))
55+ create_dir (path .join (rootfs , " run" ))
56+ create_dir (path .join (rootfs , " root" ))
57+
58+ if os .host () == " linux" then
59+ local olddir = os .cd (rootfs )
60+ make_link (" ../run" , path .join (rootfs , " var" , " run" ))
61+ os .cd (olddir )
62+ end
4963end
5064
5165function deploy_package (rootfs )
@@ -66,7 +80,7 @@ function deploy_package(rootfs)
6680 local package_rootfs = path .join (repodir , " packages" , packagename :sub (1 , 1 ), packagename , " rootfs" )
6781 if os .isdir (package_rootfs ) then
6882 for _ , filedir in ipairs (os .filedirs (package_rootfs .. " /*" )) do
69- os .vrunv (" cp" , {" -rfv" , filedir , rootfs })
83+ os .vrunv (" cp" , {" -rfv" , filedir , rootfs }) -- TODO: need support windows
7084 end
7185 end
7286 end
@@ -97,7 +111,14 @@ function deploy_target(rootfs)
97111 local srcpath = target :targetfile ()
98112 local artifact_dir = path .join (config .buildir (), config .plat (), config .arch (), config .mode ())
99113 targetfile = path .relative (targetfile , artifact_dir )
100- local dstpath = path .join (rootfs , " bin" , targetfile )
114+
115+ local prefixdir = target :values (" rt.rootfs.prefixdir" )
116+ local dstpath
117+ if prefixdir then
118+ dstpath = path .join (rootfs , prefixdir , targetfile )
119+ else
120+ dstpath = path .join (rootfs , " bin" , targetfile )
121+ end
101122 cprint (" ${dim}> copy %s to %s" , srcpath , dstpath )
102123 os .cp (srcpath , dstpath )
103124 end
0 commit comments