Skip to content

Commit 7ecf399

Browse files
committed
mlcustomize/firstboot.ml: Use quoted string literals for firstboot
Targeted replacement of quoted string with quoted string literals (added in OCaml 4.02) for the two firstboot scripts in this file. In theory this should leave the binary completely identical. I tested this, and it doesn't, but the differences appear to be in unrelated changes to timestamps and the symbol table. The firstboot files are the same.
1 parent 89f1eb2 commit 7ecf399

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

mlcustomize/firstboot.ml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ let sanitize_name =
3535
module Linux = struct
3636
let firstboot_dir = "/usr/lib/virt-sysprep"
3737

38-
let firstboot_sh = sprintf "\
39-
#!/bin/sh -
38+
let firstboot_sh = sprintf {|#!/bin/sh -
4039

4140
### BEGIN INIT INFO
4241
# Provides: virt-sysprep
@@ -57,14 +56,14 @@ d=%s/scripts
5756
d_done=%s/scripts-done
5857
logfile=~root/virt-sysprep-firstboot.log
5958

60-
echo \"$0\" \"$@\" 2>&1 | tee -a $logfile
61-
echo \"Scripts dir: $d\" 2>&1 | tee -a $logfile
59+
echo "$0" "$@" 2>&1 | tee -a $logfile
60+
echo "Scripts dir: $d" 2>&1 | tee -a $logfile
6261

63-
if test \"$1\" = \"start\"
62+
if test "$1" = "start"
6463
then
6564
mkdir -p $d_done
6665
for f in $d/* ; do
67-
if test -x \"$f\"
66+
if test -x "$f"
6867
then
6968
# move the script to the 'scripts-done' directory, so it is not
7069
# executed again at the next boot
@@ -75,7 +74,7 @@ then
7574
done
7675
rm -f $d_done/*
7776
fi
78-
" firstboot_dir firstboot_dir
77+
|} firstboot_dir firstboot_dir
7978

8079
let systemd_target = "multi-user.target"
8180

@@ -282,38 +281,37 @@ module Windows = struct
282281
* XXX It would be better to use powershell here. For some ideas see
283282
* https://github.com/HCK-CI/HLK-Setup-Scripts/
284283
*)
285-
let firstboot_script = sprintf "\
286-
@echo off
284+
let firstboot_script = sprintf {|@echo off
287285

288286
setlocal EnableDelayedExpansion
289287
set firstboot=%s
290-
set log=%%firstboot%%\\log.txt
288+
set log=%%firstboot%%\log.txt
291289

292-
set scripts=%%firstboot%%\\scripts
293-
set scripts_done=%%firstboot%%\\scripts-done
290+
set scripts=%%firstboot%%\scripts
291+
set scripts_done=%%firstboot%%\scripts-done
294292

295-
call :main >> \"%%log%%\" 2>&1
293+
call :main >> "%%log%%" 2>&1
296294
exit /b
297295

298296
:main
299297
echo starting firstboot service
300298

301-
if not exist \"%%scripts_done%%\" (
302-
mkdir \"%%scripts_done%%\"
299+
if not exist "%%scripts_done%%" (
300+
mkdir "%%scripts_done%%"
303301
)
304302

305303
:: Pick the next script to run.
306-
for %%%%f in (\"%%scripts%%\"\\*.bat) do (
307-
echo running \"%%%%f\"
308-
pushd \"%%scripts%%\"
309-
call \"%%%%~nf\"
304+
for %%%%f in ("%%scripts%%"\*.bat) do (
305+
echo running "%%%%f"
306+
pushd "%%scripts%%"
307+
call "%%%%~nf"
310308
set elvl=!errorlevel!
311309
echo .... exit code !elvl!
312310
popd
313311

314312
if !elvl! NEQ 249 (
315313
echo Script succeeded, moving to scripts-done
316-
move \"%%%%f\" \"%%scripts_done%%\"
314+
move "%%%%f" "%%scripts_done%%"
317315
) else (
318316
echo Script failed, will retry on next boot
319317
)
@@ -329,8 +327,8 @@ for %%%%f in (\"%%scripts%%\"\\*.bat) do (
329327

330328
:: Fallthrough here if there are no scripts.
331329
echo uninstalling firstboot service
332-
\"%%firstboot%%\\%s\" -s firstboot uninstall
333-
" firstboot_dir_win srvany in
330+
"%%firstboot%%\%s" -s firstboot uninstall
331+
|} firstboot_dir_win srvany in
334332

335333
g#write (firstboot_dir // "firstboot.bat")
336334
(String.unix2dos firstboot_script);

0 commit comments

Comments
 (0)