Skip to content

Commit

Permalink
fix compiling on Mac with non-GZIP kernel compressions
Browse files Browse the repository at this point in the history
  * Non-GZIP compressions do not include the size in the file. Makefile.lib
    uses the stat command to determine the size of the file and then append
    the file size to the end of the image.
  * On BSD systems like Mac, stat does not recognize -c "%s" instead it
    needs -f "%z". This resulted in a non-booting kernel since the appended
    file size was either corrupt or 0.
  * Run both forms of stat, using whichever does not error out.

Change-Id: I95fd913074db90bb2b4afd8a2667246bea4a62e3
  • Loading branch information
dferg authored and shareefalis committed Sep 1, 2012
1 parent 131e4df commit 5122983
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/Makefile.lib
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $<

# Bzip2 and LZMA do not include size in file... so we have to fake that;
# append the size as a 32-bit littleendian number as gzip does.
# -- the first stat call is for GNU stat, the second for BSD stat
size_append = printf $(shell \
dec_size=0; \
for F in $1; do \
fsize=$$(stat -c "%s" $$F); \
fsize=$$(stat -c "%s" $$F 2>/dev/null || stat -f "%z" $$F); \
dec_size=$$(expr $$dec_size + $$fsize); \
done; \
printf "%08x\n" $$dec_size | \
Expand Down

0 comments on commit 5122983

Please sign in to comment.