git @ Cat's Eye Technologies Funicular / e569658
Begin fleshing out funicular.sh with commented-out scaffolding. Chris Pressey 8 years ago
1 changed file(s) with 281 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
44 DRIVER_DIR=`dirname $0`
55 . ${DRIVER_DIR}/fu-platform-${PLATFORM}.sh
66
7 # soon this will not call the platform_ directly, instead there will be wrapper functions
7 funicular_init() {
8 echo "init"
9 #size = arg[2]
10 #if size == nil then
11 # print "Usage: funicular init <size-in-megabytes>"
12 # os.exit(1)
13 #end
14 #if exists(funicular.system_image) then
15 # print(funicular.system_image .. " already exists! Delete it first.")
16 # return
17 #end
18 #print("init... size: " .. size)
19 #if funicular.platform.architecture.virtual_system_image then
20 # execute(funicular, "mkdir -p ${SYSTEM_IMAGE}")
21 #else
22 # funicular.platform.architecture.create_system_image(funicular, size)
23 #end
24 }
25
26 funicular_install() {
27 echo "install"
28 # print("installing " .. funicular.platform.name .. " onto system image...")
29 # if funicular.install_instructions then
30 # print [[
31 #
32 #=========================
33 #INSTALLATION INSTRUCTIONS
34 #=========================
35 #]]
36 # print(funicular.install_instructions)
37 # end
38 # execute(funicular, funicular.platform.architecture.emulator_mode.install_command)
39 }
40
41 funicular_setup() {
42 echo "setup"
43 # print("creating setup image for " .. funicular.platform.name .. "...")
44 #
45 # execute(funicular, 'mkdir -p distfiles')
46 # for url in string.gmatch(funicular.distfiles or "", "[^%s]+") do
47 # fetch_distfile(funicular, url)
48 # end
49 #
50 # execute(funicular, 'mkdir -p distrepos')
51 # local distrepos_specs = funicular.distrepos_specs or ""
52 #
53 # local distrepos_catalogue = funicular.distrepos_catalogue or ""
54 # if distrepos_catalogue ~= "" then
55 # local file = io.open(distrepos_catalogue)
56 # local line = file:read("*l")
57 # while line do
58 # distrepos_specs = distrepos_specs .. ' ' .. line
59 # line = file:read("*l")
60 # end
61 # file:close()
62 # end
63 #
64 # for spec in string.gmatch(distrepos_specs, "[^%s]+") do
65 # checkout_repo_by_spec(funicular, spec)
66 # end
67 #
68 # execute(funicular, 'rm -rf staging_area')
69 # execute(funicular, 'mkdir -p staging_area')
70 #
71 # for url in string.gmatch(funicular.distfiles or "", "[^%s]+") do
72 # local source_name = basename(url)
73 # local dest_name = source_name
74 # if funicular.name_map and funicular.name_map[source_name] then
75 # dest_name = funicular.name_map[source_name]
76 # end
77 # execute(funicular, 'cp -p distfiles/' .. source_name .. ' staging_area/' .. dest_name)
78 # end
79 #
80 # for spec in string.gmatch(distrepos_specs, "[^%s]+") do
81 # local url = get_url_for_spec(funicular, spec)
82 # local source_name = basename(url)
83 # local dest_name = source_name
84 # local domain = 'bitbucket.org' -- FIXME
85 # local username = 'catseye' -- FIXME
86 # if funicular.name_map and funicular.name_map[source_name] then
87 # dest_name = funicular.name_map[source_name]
88 # end
89 # if funicular.toolshelf_inside then
90 # local tarball_name = domain .. ',' .. username .. ',' .. dest_name .. '-master.tar.gz'
91 # execute(funicular, 'cd distrepos && ' ..
92 # 'tar zcf ../staging_area/' .. tarball_name .. ' ' .. source_name)
93 # elseif funicular.zip_unversioned then
94 # if exists('distrepos/' .. source_name .. '/.hg') then
95 # execute(funicular, 'cd distrepos/' .. source_name ..
96 # ' && hg archive -r tip -t zip ' ..
97 # '-X .hgignore -X .gitignore -X .hgtags -X .hg_archival.txt ' ..
98 # '../../staging_area/' .. dest_name .. '.zip')
99 # else
100 # execute(funicular, 'cd distrepos/' .. source_name ..
101 # ' && git archive --format=zip HEAD ' ..
102 # '--output=../../staging_area/' .. dest_name .. '.zip')
103 # end
104 # else
105 # execute(funicular, 'cd distrepos && tar zcf ../staging_area/' ..
106 # dest_name .. '.tgz ' .. source_name)
107 # end
108 # end
109 #
110 # if exists('skel') then
111 # execute(funicular, 'cp -Rp skel/* staging_area/')
112 # -- execute(funicular, 'chmod 755 staging_area/*.sh')
113 # end
114 #
115 # if funicular.platform.setup_via_script then
116 # if funicular.setup_script == nil then
117 # print("Error: Funicularfile must define a setup_script")
118 # os.exit(1)
119 # end
120 # run_script(funicular, funicular.setup_script)
121 # else
122 # if funicular.platform.setup_command == nil then
123 # print("Error: platform must define a setup_command")
124 # os.exit(1)
125 # end
126 # execute(funicular, funicular.platform.setup_command)
127 # end
128 # execute(funicular, 'rm -rf staging_area')
129 # if funicular.setup_instructions then
130 # print [[
131 #
132 #==================
133 #SETUP INSTRUCTIONS
134 #==================
135 #]]
136 # print(funicular.setup_instructions)
137 # end
138 # execute(funicular, funicular.platform.architecture.emulator_mode.setup_command)
139 }
140
141 funicular_start() {
142 echo "start"
143 platform_start $*
144 }
145
146 funicular_initdist() {
147 echo "initdist"
148 #size = arg[2]
149 #if size == nil then
150 # print "Usage: funicular initdist <size-in-kilobytes>"
151 # os.exit(1)
152 #end
153 #if exists(funicular.dist_image) then
154 # print(funicular.dist_image .. " already exists! Delete it first.")
155 # return
156 #end
157 #print("initdist... size: " .. size)
158 #funicular.platform.architecture.create_dist_image(funicular, size)
159 }
160
161 funicular_builddist() {
162 echo "builddist"
163 # if not funicular.dist_image or not exists(funicular.dist_image) then
164 # print "No distribution image defined or created."
165 # return
166 # end
167 # if funicular.dist_script then
168 # run_script(funicular, funicular.dist_script)
169 # end
170 # if funicular.dist_instructions then
171 # print [[
172 #
173 #=========================
174 #DISTRIBUTION INSTRUCTIONS
175 #=========================
176 #]]
177 # print(funicular.dist_instructions)
178 # end
179 # if funicular.platform.architecture.emulator_mode.dist_command then
180 # print("starting " .. funicular.platform.architecture.emulator_mode.emulator.name .. "...")
181 # execute(funicular, funicular.platform.architecture.emulator_mode.dist_command)
182 # end
183 }
184
185 funicular_distboot() {
186 echo "distboot"
187 #if not funicular.dist_image or not exists(funicular.dist_image) then
188 # print "No distribution image defined or created."
189 # return
190 #end
191 #print("distbooting " .. funicular.platform.architecture.emulator_mode.emulator.name .. "...")
192 #execute(funicular, funicular.platform.architecture.emulator_mode.distboot_command)
193 }
194
195 funicular_backup() {
196 echo "backup"
197 #bup = arg[2]
198 #if bup == nil then
199 # print "Usage: funicular backup <backup-basename>"
200 # os.exit(1)
201 #end
202 #
203 #bup_img_gz = bup .. '.img.gz'
204 #if exists(bup_img_gz) then
205 # print(bup_img_gz .. ' already exists! Delete it or pick a different name.')
206 # os.exit(1)
207 #end
208 #
209 #if funicular.platform.architecture.virtual_system_image then
210 # bup_img_gz = bup .. '.tar.gz'
211 # execute(funicular, "tar zcf " .. bup_img_gz .. " ${SYSTEM_IMAGE}")
212 #else
213 # execute(funicular, "ls -lah ${SYSTEM_IMAGE}")
214 # execute(funicular, "cp ${SYSTEM_IMAGE} " .. bup .. ".img")
215 # execute(funicular, "gzip " .. bup .. ".img")
216 #end
217 #execute(funicular, "ls -lah " .. bup_img_gz)
218 }
219
220 funicular_restore() {
221 echo "restore"
222 #local force = false
223 #bup = arg[2]
224 #if bup == '-f' then
225 # force = true
226 # bup = arg[3]
227 #end
228 #if bup == nil then
229 # print "Usage: funicular restore [-f] <backup-basename>"
230 # os.exit(1)
231 #end
232 #
233 #bup = bup:gsub("^(.-)\.img\.gz$", "%1")
234 #
235 #bup_img_gz = bup .. '.img.gz'
236 #if funicular.platform.architecture.virtual_system_image then
237 # bup_img_gz = bup .. '.tar.gz'
238 #end
239 #
240 #if not exists(bup_img_gz) then
241 # print(bup_img_gz .. ' does not exist.')
242 # os.exit(1)
243 #end
244 #
245 #if force then
246 # execute(funicular, "rm -rf ${SYSTEM_IMAGE}")
247 #end
248 #
249 #if exists(funicular.system_image) then
250 # print(funicular.system_image .. ' still exists, please delete it first.')
251 # os.exit(1)
252 #end
253 #
254 #if funicular.platform.architecture.virtual_system_image then
255 # execute(funicular, "tar zxf " .. bup_img_gz)
256 #else
257 # execute(funicular, "ls -lah " .. bup_img_gz)
258 # execute(funicular, "cp " .. bup_img_gz .. " ${SYSTEM_IMAGE}.gz")
259 # execute(funicular, "gunzip ${SYSTEM_IMAGE}.gz")
260 #end
261 }
262
263 ########
264 # MAIN #
265 ########
266
8267 CMD=$1
9268 shift
10 platform_$CMD $*
269
270 case $CMD in
271 init|install|setup|start|initdist|builddist|distboot|backup|restore)
272 funicular_$CMD $*
273 ;;
274 *)
275 cat <<EOF
276 Usage: funicular <command>
277 where <command> is one of:
278 init
279 install
280 setup
281 start
282 initdist
283 builddist
284 distboot
285 backup
286 restore
287 EOF
288 exit 1
289 esac