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

Add VERSION file and version number to filename #14

Merged
merged 7 commits into from Jan 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -3,13 +3,13 @@ services:
- docker
language: bash
script:
- make sd-image
- VERSION=${TRAVIS_TAG} make sd-image
deploy:
provider: releases
api_key:
secure: ldMoo+75b7ql+d/QcrICL9EpmqSt18Gtlb0Qfwb+xwxBcBmmnM7UpeOeU4K6KnPZ8fAOyfcm4XQLwJF40EUjspov8X7CY8gOxWHMRp6mAebUgbk3toZSjxxRy1BAd7bewG+dcv4ZuDU0802A6LG5dCBcrgZg9q4JhMYBOUzbR7+p7LNm4ZMMpNlV8MpCsZCg5A+rLJ8IxoCamQW2r/IwcMY+/aWjlvBN8FHD7HN4p5hD1qclB9tg5id+Ar2tlXPpVKE+xT4eoAGtFJV56JQ8zQ3dGst4lb3tMWUWAxUjmh2YNrf5yHMoaEV8NkcKP16HaYDdWSThhohf6D+7mDmxB1tYRlpMr0W5gLtDVZP+OEdGYS7cmwpl76dPO8LNtPkbh+k59QRofrxn41UdGKKovZiry3lPzaYnW54OTLJohYSIEo3W5c17XgNkRFSO40B1dhrwmLupk+UQcPIl6MQ4uorG1Wh5RpRnaEA6Z2kP3/E+WusqjH3+e8/Sr4S34hSHVpGq4rkUUDVskEGJ510uEiLEC26oKAXdTOClfQhOtf4rlOoIXkMZUMBDkT3xU6uOwEboqHNhwCTHOXOVG8mmr7VddeE7wJxJsnGDfJRbqO0Dm1K6f9mnavuFXQc5GnrXmBIvw4JlISnBf6124h36stUe3hqCqkNPZCZWQi2C2Zk=
file:
- sd-card-rpi.img.zip
- sd-card-rpi-${TRAVIS_TAG}.img.zip
on:
tags: true
repo: hypriot/image-builder-rpi
4 changes: 1 addition & 3 deletions Dockerfile
Expand Up @@ -22,9 +22,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
rm -rf /var/lib/apt/lists/*

RUN gem update --system && \
gem install --no-document serverspec \
pry-byebug \
bundler
gem install --no-document serverspec

COPY builder/ /builder/

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -4,10 +4,10 @@ build:
docker build -t image-builder-rpi .

sd-image: build
docker run --rm --privileged -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules image-builder-rpi
docker run --rm --privileged -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules -e VERSION image-builder-rpi

shell: build
docker run -ti --privileged -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules image-builder-rpi bash
docker run -ti --privileged -v $(shell pwd):/workspace -v /boot:/boot -v /lib/modules:/lib/modules -e VERSION image-builder-rpi bash

tag:
git tag ${TAG}
Expand Down
16 changes: 15 additions & 1 deletion README.md
Expand Up @@ -36,5 +36,19 @@ make sd-image
```bash
make shell
./build.sh
rspec --format documentation --color test/image_spec.rb
rspec --format documentation --color test/image_spec.rb
```

## CI

### make new releases

Edit the version number and trigger a new release.

```bash
vi VERSION
git add VERSION
git commit -m "[ci skip] update version $(cat VERSION)"
git push
make release
```
13 changes: 7 additions & 6 deletions builder/build.sh
Expand Up @@ -17,14 +17,15 @@ BUILD_PATH="/build"
# config vars for the root file system
ROOTFS_TAR="rootfs-armhf.tar.gz"
ROOTFS_TAR_PATH="${BUILD_RESULT_PATH}/${ROOTFS_TAR}"
ROOTFS_TAR_VERSION="v0.6.0"
ROOTFS_TAR_VERSION="v0.6.1"

# name of the ready made raw image for RPi
RAW_IMAGE="rpi-raw.img"
RAW_IMAGE_VERSION="v0.0.5"
RAW_IMAGE_VERSION="v0.0.6"

# name of the sd-image we gonna create
IMAGE_NAME="sd-card-rpi.img"
IMAGE_VERSION=${VERSION:="dirty"}
IMAGE_NAME="sd-card-rpi-${IMAGE_VERSION}.img"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the image file name requires to change the release deployment in .travis.yml too.


# size of root- and boot-partion in megabytes
ROOT_PARTITION_SIZE="1435"
Expand Down Expand Up @@ -96,11 +97,11 @@ guestfish -a "/${IMAGE_NAME}"<<_EOF_
tar-in /image_with_kernel_boot.tar.gz /boot compress:gzip
_EOF_

# test sd-image that we have built
rspec --format documentation --color /${BUILD_RESULT_PATH}/test

# ensure that the travis-ci user can access the sd-card image file
umask 0000

# compress image
zip ${BUILD_RESULT_PATH}/${IMAGE_NAME}.zip ${IMAGE_NAME}

# test sd-image that we have built
rspec --format documentation --color ${BUILD_RESULT_PATH}/builder/test
21 changes: 10 additions & 11 deletions test/image_spec.rb → builder/test/image_spec.rb
@@ -1,21 +1,16 @@
require 'serverspec'
set :backend, :exec
require_relative 'spec_helper'

describe "SD-Card Image" do
let(:image_path) { return 'sd-card-rpi.img' }

it "exists" do
image_file = file(image_path)

expect(image_file).to exist
end

context "Partition table" do
let(:stdout) { command("guestfish add #{image_path} : run : list-filesystems").stdout }
let(:stdout) { run("list-filesystems").stdout }

it "has two partitions" do
partitions = stdout.split(/\r?\n/)

expect(partitions.size).to be 2
end

Expand All @@ -29,7 +24,7 @@
end

context "Root filesystem" do
let(:stdout) { command("guestfish add #{image_path} : run : mount /dev/sda2 / : cat /etc/os-release").stdout }
let(:stdout) { run_mounted("cat /etc/os-release").stdout }

it "is based on debian" do
expect(stdout).to contain('debian')
Expand All @@ -42,26 +37,30 @@
it "is a HypriotOS" do
expect(stdout).to contain('HypriotOS')
end

it "is not dirty" do
expect(stdout).not_to contain('dirty')
end
end

context "Binary dpkg" do
let(:stdout) { command("guestfish add #{image_path} : run : mount /dev/sda2 / : file-architecture /usr/bin/dpkg").stdout }
let(:stdout) { run_mounted("file-architecture /usr/bin/dpkg").stdout }

it "is compiled for ARM architecture" do
expect(stdout).to contain('arm')
end
end

context "Binary vi" do
let(:stdout) { command("guestfish add #{image_path} : run : mount /dev/sda2 / : file-architecture /usr/bin/dpkg").stdout }
let(:stdout) { run_mounted("file-architecture /usr/bin/dpkg").stdout }

it "is compiled for ARM architecture" do
expect(stdout).to contain('arm')
end
end

context "/etc/fstab" do
let(:stdout) { command("guestfish add #{image_path} : run : mount /dev/sda2 / : cat /etc/fstab").stdout }
let(:stdout) { run_mounted("cat /etc/fstab").stdout }

it "has a vfat boot entry" do
expect(stdout).to contain('/dev/mmcblk0p1 /boot vfat')
Expand Down
14 changes: 14 additions & 0 deletions builder/test/spec_helper.rb
@@ -0,0 +1,14 @@
require 'serverspec'
set :backend, :exec

def image_path
return "sd-card-rpi-#{ENV['VERSION']}.img"
end

def run( cmd )
return command("guestfish add #{image_path} : run : #{cmd}")
end

def run_mounted( cmd )
return run("mount /dev/sda2 / : #{cmd}")
end