Unverified Commit 0ff142f1 authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

fix build: sdimage (#337886)

parents d3894eda 0c848e9e
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -58,10 +58,18 @@ pkgs.stdenv.mkDerivation {
      # Make a crude approximation of the size of the target image.
      # If the script starts failing, increase the fudge factors here.
      numInodes=$(find ./rootImage | wc -l)
      numDataBlocks=$(du -s -c -B 4096 --apparent-size ./rootImage | tail -1 | awk '{ print int($1 * 1.10) }')
      numDataBlocks=$(du -s -c -B 4096 --apparent-size ./rootImage | tail -1 | awk '{ print int($1 * 1.20) }')
      bytes=$((2 * 4096 * $numInodes + 4096 * $numDataBlocks))
      echo "Creating an EXT4 image of $bytes bytes (numInodes=$numInodes, numDataBlocks=$numDataBlocks)"

      mebibyte=$(( 1024 * 1024 ))
      # Round up to the nearest mebibyte.
      # This ensures whole 512 bytes sector sizes in the disk image
      # and helps towards aligning partitions optimally.
      if (( bytes % mebibyte )); then
        bytes=$(( ( bytes / mebibyte + 1) * mebibyte ))
      fi

      truncate -s $bytes $img

      faketime -f "1970-01-01 00:00:01" fakeroot mkfs.ext4 -L ${volumeLabel} -U ${uuid} -d ./rootImage $img