Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/embedded Fix fallout from mkimage rev 1.76.



details:   https://anonhg.NetBSD.org/src/rev/af8548fe4fec
branches:  trunk
changeset: 958092:af8548fe4fec
user:      rin <rin%NetBSD.org@localhost>
date:      Wed Dec 23 10:35:18 2020 +0000

description:
Fix fallout from mkimage rev 1.76.

For mkimage:

- Update "size" if auto-calculated.
- Use "dd bs=1" instead of non-portable "head -c".
- Some style nits.

For MD make_label() functions:

- Stop using "newsize" as image size in MB, use "size" instead.

diffstat:

 distrib/utils/embedded/conf/evbarm.conf  |   4 ++--
 distrib/utils/embedded/conf/evbmips.conf |   4 ++--
 distrib/utils/embedded/conf/x86.conf     |   4 ++--
 distrib/utils/embedded/mkimage           |  13 +++++++------
 4 files changed, 13 insertions(+), 12 deletions(-)

diffs (86 lines):

diff -r 828eed3eb72f -r af8548fe4fec distrib/utils/embedded/conf/evbarm.conf
--- a/distrib/utils/embedded/conf/evbarm.conf   Wed Dec 23 10:32:07 2020 +0000
+++ b/distrib/utils/embedded/conf/evbarm.conf   Wed Dec 23 10:35:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: evbarm.conf,v 1.37 2020/07/17 15:16:34 jmcneill Exp $
+# $NetBSD: evbarm.conf,v 1.38 2020/12/23 10:35:18 rin Exp $
 # evbarm shared config
 #
 image=$HOME/${board}.img
@@ -23,7 +23,7 @@
 
 make_label_evbarm() {
        # compute all sizes in terms of sectors
-       local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
+       local totalsize=$(( ${size} / 512 ))
 
        local bootsize=$(( ${boot} * 1024 ))
 
diff -r 828eed3eb72f -r af8548fe4fec distrib/utils/embedded/conf/evbmips.conf
--- a/distrib/utils/embedded/conf/evbmips.conf  Wed Dec 23 10:32:07 2020 +0000
+++ b/distrib/utils/embedded/conf/evbmips.conf  Wed Dec 23 10:35:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: evbmips.conf,v 1.1 2020/07/17 15:16:34 jmcneill Exp $
+# $NetBSD: evbmips.conf,v 1.2 2020/12/23 10:35:18 rin Exp $
 # evbmips shared config
 #
 image=$HOME/${board}.img
@@ -23,7 +23,7 @@
 
 make_label_evbmips() {
        # compute all sizes in terms of sectors
-       local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
+       local totalsize=$(( ${size} / 512 ))
 
        local bootsize=$(( ${boot} * 1024 ))
 
diff -r 828eed3eb72f -r af8548fe4fec distrib/utils/embedded/conf/x86.conf
--- a/distrib/utils/embedded/conf/x86.conf      Wed Dec 23 10:32:07 2020 +0000
+++ b/distrib/utils/embedded/conf/x86.conf      Wed Dec 23 10:35:18 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: x86.conf,v 1.8 2017/11/28 02:56:44 kre Exp $
+# $NetBSD: x86.conf,v 1.9 2020/12/23 10:35:18 rin Exp $
 # x86 shared config
 #
 
@@ -15,7 +15,7 @@
 
 make_label() {
        # compute all sizes in terms of sectors
-       local totalsize=$(( ${newsize} * 1024 * 2 / 512 ))
+       local totalsize=$(( ${size} / 512 ))
 
        local aoffset=${init}
        local asize=$(( ${totalsize} - ${aoffset} ))
diff -r 828eed3eb72f -r af8548fe4fec distrib/utils/embedded/mkimage
--- a/distrib/utils/embedded/mkimage    Wed Dec 23 10:32:07 2020 +0000
+++ b/distrib/utils/embedded/mkimage    Wed Dec 23 10:35:18 2020 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: mkimage,v 1.76 2020/12/21 16:38:02 riastradh Exp $
+# $NetBSD: mkimage,v 1.77 2020/12/23 10:35:18 rin Exp $
 #
 # Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -259,15 +259,16 @@
            -F "$tmp/selected_sets" ${image} "${release}" "${mnt}"
 fi
 
-cursize="$(getsize "${image}")"
 if [ "${size}" = 0 ]; then
-       size="${cursize}"
+       size="$(getsize "${image}")"
        # Round up to a multiple of 4m and add 1m of slop.
        alignunit=$((4*1024*1024))
-       alignsize=$((alignunit*((cursize + alignunit - 1)/alignunit)))
+       alignsize=$((alignunit*((size + alignunit - 1)/alignunit)))
        alignsize=$((alignsize + 1024*1024))
-       if [ $cursize -lt $alignsize ]; then
-               head -c "$((alignsize - cursize))" < /dev/zero >> "${image}"
+       if [ "${size}" -lt "${alignsize}" ]; then
+               dd bs=1 count="$((alignsize - size))" if=/dev/zero \
+                       >> "${image}" 2> /dev/null
+               size="${alignsize}"
        fi
 fi
 



Home | Main Index | Thread Index | Old Index