Skip to content
This repository was archived by the owner on Aug 14, 2023. It is now read-only.

Commit f0e05fa

Browse files
committed
Merge pull request #2 from hypriot/improve-builder
Improve builder
2 parents b4a4c1e + 45fefe4 commit f0e05fa

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
FROM debian:jessie
22

33
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
4-
build-essential \
4+
dosfstools \
55
kpartx \
6-
zip \
76
ruby \
8-
ruby-dev \
9-
dosfstools \
7+
zip \
108
--no-install-recommends && \
119
rm -rf /var/lib/apt/lists/*
1210

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.PHONY: build
21
default: build
32

43
build:
@@ -8,7 +7,10 @@ rpi-raw-image: build
87
docker run --rm --privileged -v $(shell pwd):/workspace image-builder-raw /workspace/builder/rpi/build.sh
98

109
shell: build
11-
docker run -ti --privileged -v $(shell pwd):/workspace image-builder-raw bash
10+
docker run --rm -ti --privileged -v $(shell pwd):/workspace image-builder-raw bash
11+
12+
testshell: build
13+
docker run --rm -ti --privileged -v $(shell pwd)/builder:/builder -v $(shell pwd):/workspace image-builder-raw bash
1214

1315
tag:
1416
git tag ${TAG}

builder/rpi/build.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,18 @@ IMAGE_PATH="rpi-raw.img"
1212
SD_CARD_SIZE="1500"
1313
BOOT_PARTITION_SIZE="64"
1414

15+
# Create empty BOOT/ROOTFS image file
16+
# - SD_CARD_SIZE in MByte
17+
# - DD uses 256 Bytes
18+
# - sector block size is 512Bytes
19+
# - MBR size is 512 Bytes, so we start at sector 2048 (1MByte reserved space)
1520
BOOTFS_START=2048
1621
BOOTFS_SIZE=$(expr ${BOOT_PARTITION_SIZE} \* 2048)
1722
ROOTFS_START=$(expr ${BOOTFS_SIZE} + ${BOOTFS_START})
18-
SD_MINUS_DD=$(expr ${SD_CARD_SIZE} - 256) # old config: 1280 - 256 = 1024 for rootfs
19-
ROOTFS_SIZE=$(expr ${SD_MINUS_DD} \* 1000000 / 512 - ${ROOTFS_START})
23+
SD_MINUS_DD=$(expr ${SD_CARD_SIZE} \* 1024 \* 1024 - 256)
24+
ROOTFS_SIZE=$(expr ${SD_MINUS_DD} / 512 - ${ROOTFS_START})
2025

21-
dd if=/dev/zero of=${IMAGE_PATH} bs=1MB count=${SD_CARD_SIZE}
26+
dd if=/dev/zero of=${IMAGE_PATH} bs=1MiB count=${SD_CARD_SIZE}
2227

2328
DEVICE=$(losetup -f --show ${IMAGE_PATH})
2429

builder/rpi/test/image_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,13 @@
2424
it "has a root-partition with a sda2 Linux filesystem" do
2525
expect(stdout).to contain('^.*\.img2 .*Linux$')
2626
end
27+
28+
it "partition sda1 starts at sector 2048" do
29+
expect(stdout).to contain('^.*\.img1\ *2048 .*$')
30+
end
31+
32+
it "partition sda1 has a size of 64M" do
33+
expect(stdout).to contain('^.*\.img1.* 64M c.*$')
34+
end
2735
end
2836
end

0 commit comments

Comments
 (0)