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

Commit 87698b4

Browse files
Merge pull request #28 from hypriot/update-build
Update the build steps and installed versions
2 parents c6497b5 + ed04689 commit 87698b4

14 files changed

+131
-110
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.img
22
*.img.zip
3+
*.img.zip.sha256
34
*.tar.gz
45
.vagrant/

.travis.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ branches:
1111
- /^v\d.*$/
1212
deploy:
1313
provider: releases
14-
api_key:
15-
secure: ZxbGrH2fjRBSFrCy3Q7kqOBZs/qeZ8QYXz3ZrbGBaoZlZuz9lZbrpBxwcaUbruyKvxx/J7iNeVBuSobz36K+qWQCe5OxOKkg14KzY0EOE6dLeIXWkTYX2ywYGgvlpzEhooly5KC6eJu5i3jyWjpUCBYOndZrAj4Zokx5v8hBQoLwf0LZB/KRQx7YAuz3f8jOkI881e+ic2rV+SNGPbocyNpcUZEBxeH2tsM+tBui7dThtSXzdc4QsJXnrsMrd+UAlrWqG+DTM+f+o9MWQbIOvY28pwHg2cdaIpd6+Y8tt1v+oT1nWThsaKQRYrk8wzi3SjoHTanaVuBa9jGaW4zzzl7zjGn385WN5FCwPoO3FTi+xOOzpWwucASXjs5LtQkgYfObk4Eo0LRdrjpfQZTlIzmoXElYSWWhhvQQh1gpagG/mCHGv/Vk09DDNHExk+U3KCR7BZISHiJ5F8Km3/1Gm27ewsO5cA8aGL6C6AwzynB7hkQgGvbnYr8MoeI2cfxKAKE1cH3zebdimas1gs/zsTDFIjrmu4bruZYf5V/I4MGsG3B/pwWsdWmRKRdOpylNNM/R791w3Ln/36oDqwQhHj5v7tlrNOqDa6hNg9YuKpOOBZMMHElxmqID0SepJzOZPv2EjFVOV5p7cpPL8z5NTy6mL9ZXpw4pj5s/6UjYzmk=
14+
skip_cleanup: true
15+
api_key: ${GITHUB_TOKEN}
1616
file:
17-
- sd-card-odroid-c1-${TRAVIS_TAG}.img.zip
17+
- hypriotos-odroid-c1-${TRAVIS_TAG}.img.zip
18+
- hypriotos-odroid-c1-${TRAVIS_TAG}.img.zip.sha256
1819
on:
1920
tags: true
2021
repo: hypriot/image-builder-odroid-c1

Dockerfile

+3-23
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,13 @@
1-
FROM debian:jessie
1+
FROM hypriot/image-builder:latest
22

3-
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
4-
python-pip \
5-
build-essential \
6-
libguestfs-tools \
7-
libncurses5-dev \
8-
tree \
3+
RUN apt-get update && \
4+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
95
binfmt-support \
106
qemu \
117
qemu-user-static \
12-
debootstrap \
13-
kpartx \
14-
lvm2 \
15-
dosfstools \
16-
zip \
17-
unzip \
18-
pigz \
19-
awscli \
20-
ruby \
21-
ruby-dev \
22-
shellcheck \
238
--no-install-recommends && \
249
rm -rf /var/lib/apt/lists/*
2510

26-
RUN gem update --system && \
27-
gem install --no-document serverspec && \
28-
gem install --no-document pry-byebug && \
29-
gem install --no-document bundler
30-
3111
COPY builder/ /builder/
3212

3313
# build sd card image

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ testshell: build
1313
docker run -ti --privileged -v $(shell pwd)/builder:/builder -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules image-builder-odroid-c1 bash
1414

1515
test:
16-
VERSION=dirty docker run --rm -ti --privileged -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules -e VERSION image-builder-odroid-c1 bash -c "unzip /workspace/sd-card-odroid-c1-dirty.img.zip && rspec --format documentation --color /workspace/builder/test/*_spec.rb"
16+
VERSION=dirty docker run --rm -ti --privileged -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules -e VERSION image-builder-odroid-c1 bash -c "unzip /workspace/hypriotos-odroid-c1-dirty.img.zip && rspec --format documentation --color /workspace/builder/test/*_spec.rb"
1717

1818
shellcheck: build
1919
VERSION=dirty docker run --rm -ti -v $(shell pwd):/workspace image-builder-odroid-c1 bash -c 'shellcheck /workspace/builder/*.sh /workspace/builder/files/etc/firstboot.d/*'

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ eval $(docker-machine env image-builder-odroid-c1)
3636

3737
### Build the SD card image
3838

39-
From here you can just make the SD card image. The output will be written and compressed to `sd-card-odroid-c1-dirty.img.zip`.
39+
From here you can just make the SD card image. The output will be written and compressed to `hypriotos-odroid-c1-dirty.img.zip`.
4040

4141
```bash
4242
make sd-image
@@ -55,7 +55,7 @@ make test
5555
Now flash the SD card image and boot up a ODROID C1. Run the [Serverspec](http://serverspec.org) integration tests in `builder/test-integration/` folder against your ODROID C1. Set the environment variable `BOARD` to the IP address or host name of your running ODROID C1.
5656

5757
```bash
58-
flash sd-card-odroid-c1-dirty.img.zip
58+
flash hypriotos-odroid-c1-dirty.img.zip
5959
BOARD=black-pearl.local make test-integration
6060
```
6161

builder/build.sh

+42-32
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,86 @@
11
#!/bin/bash
22
set -ex
33
# This script should be run only inside of a Docker container
4-
if [ ! -f /.dockerinit ]; then
4+
if [ ! -f /.dockerenv ]; then
55
echo "ERROR: script works only in a Docker container!"
66
exit 1
77
fi
88

9+
# get versions for software that needs to be installed
10+
source /workspace/versions.config
11+
912
### setting up some important variables to control the build process
1013

1114
# where to store our created sd-image file
1215
BUILD_RESULT_PATH="/workspace"
16+
17+
# place to build our sd-image
1318
BUILD_PATH="/build"
1419

15-
# where to store our base file system
16-
HYPRIOT_OS_VERSION="v0.7.2"
17-
ROOTFS_TAR="rootfs-armhf-${HYPRIOT_OS_VERSION}.tar.gz"
20+
ROOTFS_TAR="rootfs-armhf-debian-${HYPRIOT_OS_VERSION}.tar.gz"
1821
ROOTFS_TAR_PATH="$BUILD_RESULT_PATH/$ROOTFS_TAR"
1922

23+
# Show TRAVSI_TAG in travis builds
24+
echo TRAVIS_TAG="${TRAVIS_TAG}"
25+
2026
# size of root and boot partion
2127
ROOT_PARTITION_SIZE="800M"
2228

2329
# device specific settings
2430
HYPRIOT_IMAGE_VERSION=${VERSION:="dirty"}
25-
HYPRIOT_IMAGE_NAME="sd-card-odroid-c1-${HYPRIOT_IMAGE_VERSION}.img"
31+
HYPRIOT_IMAGE_NAME="hypriotos-odroid-c1-${HYPRIOT_IMAGE_VERSION}.img"
2632
IMAGE_ROOTFS_PATH="/image-rootfs.tar.gz"
2733
QEMU_ARCH="arm"
2834
export HYPRIOT_IMAGE_VERSION
2935

30-
# specific versions of kernel/firmware and docker tools
31-
export KERNEL_VERSION="142-1"
32-
export DOCKER_ENGINE_VERSION="1.10.1-1"
33-
export DOCKER_COMPOSE_VERSION="1.6.0-27"
34-
export DOCKER_MACHINE_VERSION="0.4.1-72"
35-
3636
# create build directory for assembling our image filesystem
37-
rm -rf $BUILD_PATH
38-
mkdir -p $BUILD_PATH
37+
rm -rf ${BUILD_PATH}
38+
mkdir ${BUILD_PATH}
3939

4040
# download our base root file system
41-
if [ ! -f $ROOTFS_TAR_PATH ]; then
42-
wget -q -O $ROOTFS_TAR_PATH https://github.com/hypriot/os-rootfs/releases/download/$HYPRIOT_OS_VERSION/$ROOTFS_TAR
41+
if [ ! -f "${ROOTFS_TAR_PATH}" ]; then
42+
wget -q -O "${ROOTFS_TAR_PATH}" "https://github.com/hypriot/os-rootfs/releases/download/${HYPRIOT_OS_VERSION}/${ROOTFS_TAR}"
4343
fi
4444

45+
# verify checksum of our root filesystem
46+
echo "${ROOTFS_TAR_CHECKSUM} ${ROOTFS_TAR_PATH}" | sha256sum -c -
47+
4548
# extract root file system
46-
tar -xzf $ROOTFS_TAR_PATH -C $BUILD_PATH
49+
tar xf "${ROOTFS_TAR_PATH}" -C "${BUILD_PATH}"
4750

4851
# register qemu-arm with binfmt
4952
update-binfmts --enable qemu-$QEMU_ARCH
5053

51-
# set up mount points for pseudo filesystems
52-
mkdir -p $BUILD_PATH/{proc,sys,dev/pts}
54+
# set up mount points for the pseudo filesystems
55+
mkdir -p ${BUILD_PATH}/{proc,sys,dev/pts}
5356

54-
mount -o bind /dev $BUILD_PATH/dev
55-
mount -o bind /dev/pts $BUILD_PATH/dev/pts
56-
mount -t proc none $BUILD_PATH/proc
57-
mount -t sysfs none $BUILD_PATH/sys
57+
mount -o bind /dev ${BUILD_PATH}/dev
58+
mount -o bind /dev/pts ${BUILD_PATH}/dev/pts
59+
mount -t proc none ${BUILD_PATH}/proc
60+
mount -t sysfs none ${BUILD_PATH}/sys
5861

59-
#---modify image---
6062
# modify/add image files directly
61-
cp -R /builder/files/* $BUILD_PATH/
63+
# e.g. root partition resize script
64+
cp -R /builder/files/* ${BUILD_PATH}/
6265

63-
# modify image in chroot environment
64-
chroot $BUILD_PATH /bin/bash </builder/chroot-script.sh
65-
#---modify image---
66+
# make our build directory the current root
67+
# and install the kernel packages, docker tools
68+
# and some customizations for Odroid C2.
69+
chroot $BUILD_PATH /bin/bash < /builder/chroot-script.sh
6670

67-
umount -l $BUILD_PATH/sys || true
68-
umount -l $BUILD_PATH/proc || true
69-
umount -l $BUILD_PATH/dev/pts || true
70-
umount -l $BUILD_PATH/dev || true
71+
# unmount pseudo filesystems
72+
umount -l $BUILD_PATH/sys
73+
umount -l $BUILD_PATH/proc
74+
umount -l $BUILD_PATH/dev/pts
75+
umount -l $BUILD_PATH/dev
7176

7277
# package image rootfs
7378
tar -czf $IMAGE_ROOTFS_PATH -C $BUILD_PATH .
7479

80+
# package image filesytem into two tarballs - one for bootfs and one for rootfs
81+
# ensure that there are no leftover artifacts in the pseudo filesystems
82+
rm -rf ${BUILD_PATH}/{dev,sys,proc}/*
83+
7584
# create the image and add a single ext4 filesystem
7685
# --- important settings for ODROID SD card
7786
# - initialise the partion with MBR
@@ -117,7 +126,8 @@ fdisk -l "/$HYPRIOT_IMAGE_NAME"
117126
umask 0000
118127

119128
# compress image
120-
pigz --zip -c "$HYPRIOT_IMAGE_NAME" > "$BUILD_RESULT_PATH/$HYPRIOT_IMAGE_NAME.zip"
129+
zip "${BUILD_RESULT_PATH}/${HYPRIOT_IMAGE_NAME}.zip" "${HYPRIOT_IMAGE_NAME}"
130+
cd ${BUILD_RESULT_PATH} && sha256sum "${HYPRIOT_IMAGE_NAME}.zip" > "${HYPRIOT_IMAGE_NAME}.zip.sha256" && cd -
121131

122132
# test sd-image that we have built
123133
VERSION=${HYPRIOT_IMAGE_VERSION} rspec --format documentation --color /builder/test

builder/chroot-script.sh

+8-15
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,25 @@ apt-get update
2424

2525
# install Hypriot packages for using Docker
2626
apt-get install -y \
27-
"docker-hypriot=${DOCKER_ENGINE_VERSION}" \
2827
"docker-compose=${DOCKER_COMPOSE_VERSION}" \
2928
"docker-machine=${DOCKER_MACHINE_VERSION}"
3029

31-
#FIXME: should be handled in .deb package
32-
# setup Docker default configuration for ODROID C1
33-
rm -f /etc/init.d/docker # we're using a pure systemd init, remove sysvinit script
34-
rm -f /etc/default/docker
35-
# --get upstream config
36-
wget -q -O /etc/default/docker https://github.com/docker/docker/raw/master/contrib/init/sysvinit-debian/docker.default
37-
# --enable aufs by default
38-
sed -i "/#DOCKER_OPTS/a \
39-
DOCKER_OPTS=\"--storage-driver=aufs -D\"" /etc/default/docker
40-
41-
#FIXME: should be handled in .deb package
42-
# enable Docker systemd service
43-
systemctl enable docker
44-
4530
# install ODROID kernel
4631

4732
apt-get install -y u-boot-tools initramfs-tools
4833

34+
# set up Docker APT repository and install docker-engine package
35+
#TODO: pin package version to ${DOCKER_ENGINE_VERSION}
36+
curl -sSL https://get.docker.com | /bin/sh
37+
4938
# make the kernel package create a copy of the current kernel here
5039
touch /boot/uImage
5140
apt-get install -y "linux-image-c1=${KERNEL_VERSION}"
5241

42+
# cleanup APT cache and lists
43+
apt-get clean
44+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
45+
5346
# set device label and version number
5447
echo "HYPRIOT_DEVICE=\"$HYPRIOT_DEVICE\"" >> /etc/os-release
5548
echo "HYPRIOT_IMAGE_VERSION=\"$HYPRIOT_IMAGE_VERSION\"" >> /etc/os-release

builder/test-integration/spec/hypriotos-image/base/release_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
it { should be_file }
55
it { should be_owned_by 'root' }
66
its(:content) { should match 'HYPRIOT_OS="HypriotOS/armhf"' }
7-
its(:content) { should match 'HYPRIOT_OS_VERSION="v0.7.2"' }
7+
its(:content) { should match 'HYPRIOT_OS_VERSION="v1.1.1"' }
88
its(:content) { should match 'HYPRIOT_DEVICE="ODROID C1/C1\+"' }
99
its(:content) { should match 'HYPRIOT_IMAGE_VERSION=' }
1010
end

builder/test-integration/spec/hypriotos-image/docker-compose_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
describe command('dpkg -l docker-compose') do
88
its(:stdout) { should match /ii docker-compose/ }
9-
its(:stdout) { should match /1.6.0-27/ }
9+
its(:stdout) { should match /1.9.0-23/ }
1010
its(:exit_status) { should eq 0 }
1111
end
1212

@@ -17,6 +17,6 @@
1717
end
1818

1919
describe command('docker-compose --version') do
20-
its(:stdout) { should match /1.6.0/m }
20+
its(:stdout) { should match /1.9.0/m }
2121
its(:exit_status) { should eq 0 }
2222
end

builder/test-integration/spec/hypriotos-image/docker-machine_spec.rb

+2-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
describe command('dpkg -l docker-machine') do
88
its(:stdout) { should match /ii docker-machine/ }
9-
its(:stdout) { should match /0.4.1-72/ }
9+
its(:stdout) { should match /0.9.0-39/ }
1010
its(:exit_status) { should eq 0 }
1111
end
1212

@@ -17,17 +17,6 @@
1717
end
1818

1919
describe command('docker-machine --version') do
20-
its(:stdout) { should match /0.4.1/m }
21-
its(:stderr) { should match /^$/ }
20+
its(:stdout) { should match /0.9.0/m }
2221
its(:exit_status) { should eq 0 }
2322
end
24-
25-
describe command('docker-machine create --help') do
26-
its(:stdout) { should match /Available drivers:.*hypriot/ }
27-
its(:stdout) { should match /--hypriot-ip-address/ }
28-
its(:stdout) { should match /--hypriot-ssh-key/ }
29-
its(:stdout) { should match /--hypriot-ssh-port/ }
30-
its(:stdout) { should match /--hypriot-ssh-user/ }
31-
its(:stderr) { should match /^$/ }
32-
its(:exit_status) { should eq 0 }
33-
end

0 commit comments

Comments
 (0)