@@ -262,6 +262,11 @@ actions:
262262 # work dir that will be thrown away
263263 mkdir -v build
264264
265+ # mirror template variables in shell variables to keep the action body
266+ # in shell syntax
267+ buildid="{{$buildid}}"
268+ target_boards="{{$target_boards}}"
269+
265270 # path to unpacked qcom-ptool tarball
266271 QCOM_PTOOL="$(ls -d "${ROOTDIR}/../qcom-ptool.tar.gz.d/qcom-ptool-"*)"
267272
@@ -276,7 +281,7 @@ actions:
276281 # optional list of board names to build
277282 targets_file="build/targets.txt"
278283 rm -f "${targets_file}"
279- case "{{ $target_boards }} " in
284+ case "$target_boards" in
280285 all)
281286 # no override; build all possible boards (default)
282287 touch "${targets_file}"
@@ -285,7 +290,7 @@ actions:
285290{{- end }}
286291 ;;
287292 *)
288- echo "{{ $target_boards }} " |
293+ echo "$target_boards" |
289294 tr ',' '\n' |
290295 sed '/^$/d' |
291296 sort -u >"${targets_file}"
@@ -296,96 +301,91 @@ actions:
296301 # ## board: {{ $board.name }}
297302 # ## silicon family: {{ $board.silicon_family }}
298303
304+ # mirror template variables in shell variables to keep the action body
305+ # in shell syntax
306+ board_name="{{$board.name}}"
307+ board_dtb="{{$board.dtb}}"
308+ boot_binaries_filename="{{$board.boot_binaries_download.filename}}"
309+ board_cdt_download_filename=""
310+ board_cdt_filename=""
311+ board_u_boot_file=""
312+ {{- if $board.cdt_download }}
313+ board_cdt_download_filename="{{$board.cdt_download.filename}}"
314+ board_cdt_filename="{{$board.cdt_filename}}"
315+ {{- end }}
316+ {{- if $board.u_boot_file }}
317+ board_u_boot_file="{{$board.u_boot_file}}"
318+ {{- end }}
319+
299320 # set skip_board if board isn't listed
300321 skip_board=false
301- if ! grep -Fxq "{{ $board.name }} " "${targets_file}"; then
322+ if ! grep -Fxq "$board_name " "${targets_file}"; then
302323 skip_board=true
303- echo "Skipping board {{ $board.name } } : not in target list"
324+ echo "Skipping board ${board_name } : not in target list"
304325 fi
305326
306327 # set skip_board if board dtb isn't present
307- if ! grep -Fxq "{{ $board.dtb }} " "${dtbs_file}"; then
328+ if ! grep -Fxq "$board_dtb " "${dtbs_file}"; then
308329 skip_board=true
309- echo "Skipping board {{ $board.name }} : dtb not available"
330+ echo "Skipping board ${board_name} : dtb ${board_dtb} not available"
310331 fi
311332
312-
313333 # unpack boot binaries
314- mkdir -v build/{{ $board.name }} _boot-binaries
315- unzip "${ROOTDIR}/../{{ $board.boot_binaries_download.filename } }" \
316- -d build/{{ $board.name } }_boot-binaries/unpack
334+ mkdir -v " build/${board_name} _boot-binaries"
335+ unzip "${ROOTDIR}/../${boot_binaries_filename }" \
336+ -d build/${board_name }_boot-binaries/unpack
317337 # strip top directories
318- mv build/{{ $board.name }}_boot-binaries/unpack/*/* build/{{ $board.name }}_boot-binaries
319- rmdir -v build/{{ $board.name }}_boot-binaries/unpack/* build/{{ $board.name }}_boot-binaries/unpack
338+ mv "build/${board_name}_boot-binaries/unpack"/*/* \
339+ " build/${board_name}_boot-binaries"
340+ rmdir -v "build/${board_name}_boot-binaries/unpack"/* \
341+ " build/${board_name}_boot-binaries/unpack"
320342
321- {{- if $board.cdt_download }}
322343 if [ "${skip_board}" = false ]; then
323- # unpack board CDT
324- unzip "${ROOTDIR}/../{{ $board.cdt_download.filename }}" \
325- -d build/{{ $board.name }}_cdt
326- fi
327- {{- end }}
344+ if [ -n "$board_cdt_download_filename" ]; then
345+ # unpack board CDT
346+ unzip "${ROOTDIR}/../${board_cdt_download_filename}" \
347+ -d "build/${board_name}_cdt"
348+ fi
328349
329350{{- range $platform := $board.ptool_platforms }}
330- # ## platform: {{ $platform }}
331-
332- # generate ptool files - various XML files for flashing, GPT data etc.
333- mkdir -vp build/ptool/{{ $platform }}
334- (
335- cd build/ptool/{{ $platform }}
336- conf="${QCOM_PTOOL}/platforms/{{ $platform }}/partitions.conf"
351+ # ## platform: {{ $platform }}
352+ platform="{{$platform}}"
353+ # infer storage from ptool platform dir; first strip leading directory
354+ storage_use_case="${platform#*/}"
355+ # then strip trailing use case (after first dash)
356+ disk_type="${storage_use_case%%-*}"
337357
338- {{- if $board.cdt_download }}
339- " ${RECIPEDIR}/../scripts/override-partition-conf.sh" " {{ $board.cdt_filename }}" <"$conf" >partitions.conf
340- {{- else }}
341- " ${RECIPEDIR}/../scripts/override-partition-conf.sh" " " <"$conf" >partitions.conf
342- {{- end }}
358+ # generate ptool files - various XML files for flashing, GPT data etc.
359+ mkdir -vp "build/ptool/${platform}"
360+ (
361+ cd "build/ptool/${platform}"
362+ " ${RECIPEDIR}/../scripts/gen-ptool.sh" \
363+ " $QCOM_PTOOL" \
364+ " $platform" \
365+ " $board_cdt_filename" \
366+ " $buildid" \
367+ " $disk_type" \
368+ )
343369
344- contents="${QCOM_PTOOL}/platforms/{{ $platform }}/contents.xml.in"
345- # generate ptool-partitions.xml from partitions.conf
346- " ${QCOM_PTOOL}/gen_partition.py" -i partitions.conf \
347- -o ptool-partitions.xml
348- # generate contents.xml from ptool-partitions.xml and contents.xml.in
349- if [ -e "$contents" ]; then
350- " ${QCOM_PTOOL}/gen_contents.py" -p ptool-partitions.xml \
351- -t "$contents" \
352- -b "{{$buildid}}" \
353- -o contents.xml
354- fi
355- # generate flashing files from qcom-partitions.xml
356- " ${QCOM_PTOOL}/ptool.py" -x ptool-partitions.xml
357- )
358-
359- if [ "${skip_board}" = false ]; then
360- disk_type=$(cat build/ptool/{{ $platform }}/disk_type)
361370 # create board-specific flash directory
362- flash_dir="${ARTIFACTDIR}/flash_{{ $board.name } }_${disk_type}"
371+ flash_dir="${ARTIFACTDIR}/flash_${board_name }_${disk_type}"
363372 rm -rf "${flash_dir}"
364373 mkdir -v "${flash_dir}"
365374 # copy platform partition files
366- cp --preserve=mode,timestamps -v \
367- build/ptool/{{ $platform }}/* "${flash_dir}"
368- # adjust paths in contents.xml to use board-specific flash_* subdir
369- if [ -e "${flash_dir}/contents.xml" ]; then
370- # one set of backslashes for shell quoting, another one for sed
371- # parsing
372- windows_path=".\\\\flash_{{ $board.name }}_${disk_type}\\\\"
373- linux_path="./flash_{{ $board.name }}_${disk_type}/"
374- sed -i \
375- -e "s:<windows_root_path>.*:<windows_root_path>${windows_path}</windows_root_path>:" \
376- -e "s:<linux_root_path>.*:<linux_root_path>${linux_path}</linux_root_path>:" \
377- " ${flash_dir}/contents.xml"
378- fi
375+ cp --preserve=all --no-dereference -v \
376+ " build/ptool/${platform}" /* "${flash_dir}"
377+
379378 # remove BLANK_GPT, WIPE_PARTITIONS and wipe_rawprogram files as
380379 # it's common for people to run "qdl rawprogram*.xml" or pcat,
381380 # mistakingly including these; perhaps ptool should have a flag
382381 # not to generate these
383382 rm -v "${flash_dir}"/rawprogram*_BLANK_GPT.xml
384383 rm -v "${flash_dir}"/rawprogram*_WIPE_PARTITIONS.xml
385384 rm -v "${flash_dir}"/wipe_rawprogram*.xml
385+
386386 # copy silicon family boot binaries; these shouldn't ship partition
387387 # files, but make sure not to accidentally clobber any such file
388- find build/{{ $board.name }} _boot-binaries \
388+ find " build/${board_name} _boot-binaries" \
389389 -not -name 'gpt_*' \
390390 -not -name 'patch*.xml' \
391391 -not -name 'rawprogram*.xml' \
@@ -402,31 +402,22 @@ actions:
402402 -or -name '*.fv' \
403403 -or -name '*.mbn' \
404404 \) \
405- -exec cp --preserve=mode,timestamps -v '{}' "${flash_dir}" \;
405+ -exec cp --preserve=all --no-dereference -v '{}' "${flash_dir}" \;
406406
407- # remove the temporary disk_type file from the flash dir
408- rm -f "${flash_dir}/disk_type"
409- fi
410- {{- if $board.u_boot_file }}
411- if [ "${skip_board}" = false ]; then
412- # copy U-Boot binary to boot.img;
413- # qcom-ptool/platforms/*/partitions.conf uses filename=boot.img
414- # boot_a and boot_b partitions
415- cp --preserve=mode,timestamps -v \
416- " ${ARTIFACTDIR}/{{ $board.u_boot_file }}" " ${flash_dir}/boot.img"
417- fi
418- {{- end }}
407+ if [ -n "${board_u_boot_file}" ]; then
408+ # copy U-Boot binary to boot.img; qcom-ptool partitions.conf
409+ # files use filename=boot.img for boot_a and boot_b partitions
410+ cp --preserve=all --no-dereference -v \
411+ " ${ARTIFACTDIR}/${board_u_boot_file}" " ${flash_dir}/boot.img"
412+ fi
419413
420- {{- if $board.cdt_download }}
421- if [ "${skip_board}" = false ]; then
422- # copy just the CDT data; no partition or flashing files
423- cp --preserve=mode,timestamps -v \
424- build/{{ $board.name }}_cdt/{{ $board.cdt_filename }} \
425- " ${flash_dir}"
426- fi
427- {{- end }}
414+ if [ -n "$board_cdt_filename" ]; then
415+ # copy just the CDT data; no partition or flashing files
416+ cp --preserve=all --no-dereference -v \
417+ " build/${board_name}_cdt/${board_cdt_filename}" \
418+ " ${flash_dir}"
419+ fi
428420
429- if [ "${skip_board}" = false ]; then
430421 # generate a dtb.bin FAT partition with just a single dtb for the
431422 # current board; long-term this should really be a set of dtbs and
432423 # overlays as to share dtb.bin across boards
@@ -441,12 +432,11 @@ actions:
441432 mkfs.vfat -S 4096 -C "${dtb_bin}" 4096
442433 # extract board device tree from the root filesystem provided
443434 # tarball
444- tar -C build -xvf "${ARTIFACTDIR}/dtbs.tar.gz" "{{ $board.dtb }} "
435+ tar -C build -xvf "${ARTIFACTDIR}/dtbs.tar.gz" "$board_dtb "
445436 # copy into the FAT as combined-dtb.dtb
446- mcopy -vmp -i "${dtb_bin}" "build/{{ $board.dtb }}" \
447- ::/combined-dtb.dtb
448- fi
437+ mcopy -vmp -i "${dtb_bin}" "build/${board_dtb}" ::/combined-dtb.dtb
449438{{- end }}
439+ fi
450440{{- end }}
451441
452442 # cleanup
0 commit comments