Skip to content

Commit

Permalink
build: Generate directory and ZIP archive alongside sdcard.img
Browse files Browse the repository at this point in the history
When updating an existing mountable SD card it may be useful to have
access to the SD card contents as a local folder, since unpacking
individual files from an SD card image is mildly tedious.

Assemble the SD card contents in a local folder and use this to
construct both the raw disk image file sdcard.img and a ZIP archive
sdcard.zip.

Signed-off-by: Michael Brown <[email protected]>
  • Loading branch information
mcb30 committed Nov 3, 2019
1 parent 2c6f78d commit 92aa5e1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Build/
firmware/
sdcard/
sdcard.img
sdcard.zip
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ before_install:
script:
- docker run -i -t --name pipxe pipxe
- docker cp pipxe:/opt/build/sdcard.img sdcard.img
- docker cp pipxe:/opt/build/sdcard.zip sdcard.zip
- docker container rm pipxe

deploy:
Expand All @@ -19,3 +20,4 @@ deploy:
tags: true
file:
- sdcard.img
- sdcard.zip
29 changes: 20 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ IPXE_EFI := $(IPXE_SRC)/$(IPXE_TGT)
SDCARD_MB := 32
export MTOOLSRC := mtoolsrc

all : sdcard.img
all : sdcard sdcard.img sdcard.zip

submodules :
git submodule update --init --recursive
Expand All @@ -43,24 +43,35 @@ ipxe : $(IPXE_EFI)
$(IPXE_EFI) : submodules
$(MAKE) -C $(IPXE_SRC) CROSS=$(IPXE_CROSS) CONFIG=rpi $(IPXE_TGT)

sdcard.img : firmware efi ipxe
sdcard : firmware efi ipxe
$(RM) -rf sdcard
mkdir -p sdcard
cp -r $(sort $(filter-out firmware/kernel%,$(wildcard firmware/*))) \
sdcard/
cp config.txt $(EFI_FD) edk2/License.txt sdcard/
mkdir -p sdcard/efi/boot
cp $(IPXE_EFI) sdcard/efi/boot/bootaa64.efi
cp ipxe/COPYING* sdcard/

sdcard.img : sdcard
truncate -s $(SDCARD_MB)M $@
mpartition -I -c -b 32 -s 32 -h 64 -t $(SDCARD_MB) -a "z:"
mformat -v "piPXE" "z:"
mcopy -s $(sort $(filter-out firmware/kernel%,$(wildcard firmware/*))) "z:"
mcopy config.txt $(EFI_FD) edk2/License.txt "z:"
mmd "z:/efi" "z:/efi/boot"
mcopy $(IPXE_EFI) "z:/efi/boot/bootaa64.efi"
mcopy ipxe/COPYING* "z:"
mcopy -s sdcard/* "z:"

sdcard.zip : sdcard
$(RM) -f $@
( pushd $< ; zip -q -r ../$@ * ; popd )

update:
git submodule foreach git pull origin master

tag :
git tag v`git show -s --format='%ad' --date=short | tr -d -`

.PHONY : submodules firmware efi efi-basetools $(EFI_FD) ipxe $(IPXE_EFI) sdcard.img
.PHONY : submodules firmware efi efi-basetools $(EFI_FD) ipxe $(IPXE_EFI) \
sdcard sdcard.img

clean :
$(RM) -rf firmware Build sdcard.img
$(RM) -rf firmware Build sdcard sdcard.img sdcard.zip
if [ -d $(IPXE_SRC) ] ; then $(MAKE) -C $(IPXE_SRC) clean ; fi

0 comments on commit 92aa5e1

Please sign in to comment.