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

Commit 7174e6c

Browse files
Merge pull request #32 from bspeice/master
WIP: Bring odroid-c2 back up to date
2 parents 44e313b + 50bd29b commit 7174e6c

File tree

13 files changed

+193
-81
lines changed

13 files changed

+193
-81
lines changed

.circleci/config.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: 2
2+
jobs:
3+
build:
4+
machine: true
5+
steps:
6+
- checkout
7+
8+
- run:
9+
name: Run Shellcheck
10+
command: |
11+
make shellcheck
12+
13+
- run:
14+
name: Create SD image
15+
command: |
16+
VERSION=${CIRCLE_TAG} make sd-image
17+
- run:
18+
name: Prepare artifacts
19+
command: |
20+
mkdir -p output
21+
cp hypriotos* output/
22+
- store_artifacts:
23+
path: /home/circleci/project/output
24+
25+
- deploy:
26+
name: Deploy
27+
command: |
28+
if [ "$CIRCLE_TAG" != "" ]; then
29+
curl -sSL https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_linux_amd64.zip -o ghr.zip
30+
unzip ghr.zip
31+
if [[ $CIRCLE_TAG = *"rc"* ]]; then
32+
pre=-prerelease
33+
fi
34+
./ghr $pre -u hypriot $CIRCLE_TAG output/
35+
fi
36+
workflows:
37+
version: 2
38+
build_and_deploy:
39+
jobs:
40+
- build:
41+
filters:
42+
tags:
43+
only: /.*/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
*.img.zip.sha256
44
*.tar.gz
55
*.xz
6+
*-console.log
67
.vagrant/

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# image-builder-odroid-c2
22
[![Join the chat at https://gitter.im/hypriot/talk](https://badges.gitter.im/hypriot/talk.svg)](https://gitter.im/hypriot/talk?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
3-
[![Build Status](https://travis-ci.org/hypriot/image-builder-odroid-c2.svg)](https://travis-ci.org/hypriot/image-builder-odroid-c2)
3+
[![CircleCI](https://circleci.com/gh/hypriot/image-builder-odroid-c2.svg?style=svg)](https://circleci.com/gh/hypriot/image-builder-odroid-c2)
44

55
This repo builds the SD card image with HypriotOS for the ODROID C2 ARM 64bit board. To build this SD card image we have to
66

Vagrantfile

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- mode: ruby -*-
22
# vi: set ft=ruby :
3+
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
34

45
Vagrant.configure(2) do |config|
5-
config.vm.box = "boxcutter/ubuntu1404"
6+
config.vm.box = "ubuntu/xenial64"
67

7-
config.vm.network "forwarded_port", guest: 2376, host: 2376, auto_correct: true
8+
config.vm.network "forwarded_port", guest: 2375, host: 2375, auto_correct: true
89
config.vm.synced_folder ".", "#{`pwd`.chomp}"
910

1011
config.vm.provider "vmware_fusion" do |v|
@@ -15,13 +16,31 @@ Vagrant.configure(2) do |config|
1516
config.vm.provider "virtualbox" do |vb|
1617
# Customize the amount of memory on the VM:
1718
vb.memory = "2048"
19+
vb.cpus = 4
1820
end
1921

2022
config.vm.provision "shell", inline: <<-SHELL
21-
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
22-
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list
23-
sudo apt-get update
24-
sudo apt-get install -y linux-image-extra-$(uname -r)
25-
sudo apt-get install -y docker-engine
23+
sudo apt-get update
24+
sudo apt-get install -y \
25+
apt-transport-https \
26+
ca-certificates \
27+
curl \
28+
software-properties-common
29+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
30+
sudo add-apt-repository \
31+
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
32+
$(lsb_release -cs) \
33+
stable"
34+
sudo apt-get update
35+
sudo apt-get install docker-ce -y
36+
mkdir -p /etc/systemd/system/docker.service.d/
37+
# https://docs.docker.com/engine/admin/#troubleshoot-conflicts-between-the-daemonjson-and-startup-scripts
38+
echo "[Service]
39+
ExecStart=
40+
ExecStart=/usr/bin/dockerd" > /etc/systemd/system/docker.service.d/docker.conf
41+
echo '{ "hosts": ["tcp://0.0.0.0:2375"] }' > /etc/docker/daemon.json
42+
sudo systemctl daemon-reload
43+
sudo systemctl enable docker
44+
sudo systemctl restart docker
2645
SHELL
2746
end

builder/build.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if [ ! -f /.dockerenv ]; then
88
fi
99

1010
# get versions for software that needs to be installed
11+
# shellcheck disable=SC1091
1112
source /workspace/versions.config
1213

1314
### setting up some important variables to control the build process
@@ -21,15 +22,21 @@ BUILD_PATH="/build"
2122
ROOTFS_TAR="rootfs-arm64-debian-${HYPRIOT_OS_VERSION}.tar.gz"
2223
ROOTFS_TAR_PATH="$BUILD_RESULT_PATH/$ROOTFS_TAR"
2324

24-
# Show TRAVSI_TAG in travis builds
25-
echo TRAVIS_TAG="${TRAVIS_TAG}"
25+
# Show CIRCLE_TAG in travis builds
26+
echo CIRCLE_TAG="${TRAVIS_TAG}"
2627

2728
# name of the sd-image we gonna create
2829
HYPRIOT_IMAGE_VERSION=${VERSION:="dirty"}
2930
HYPRIOT_IMAGE_NAME="hypriotos-odroid-c2-${HYPRIOT_IMAGE_VERSION}.img"
3031
QEMU_ARCH="aarch64"
3132
export HYPRIOT_IMAGE_VERSION
3233

34+
# fix a buggy version of supermin
35+
# TODO(bspeice): Should be fixed at image-builder level, not here
36+
echo "deb http://httpredir.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/stretch-backports.list
37+
apt-get update
38+
apt-get install supermin=5.1.19-1~bpo9+1
39+
3340
# create build directory for assembling our image filesystem
3441
rm -rf $BUILD_PATH
3542
mkdir -p $BUILD_PATH
@@ -119,9 +126,6 @@ guestfish -a "/${HYPRIOT_IMAGE_NAME}" << _EOF_
119126
copy-file-to-device /boot/u-boot.bin /dev/sda destoffset:49664 sparse:true
120127
_EOF_
121128

122-
# ensure that the travis-ci user can access the SD card image file
123-
umask 0000
124-
125129
# compress image
126130
pigz --zip -c "${HYPRIOT_IMAGE_NAME}" > "${BUILD_RESULT_PATH}/${HYPRIOT_IMAGE_NAME}.zip"
127131
cd ${BUILD_RESULT_PATH} && sha256sum "${HYPRIOT_IMAGE_NAME}.zip" > "${HYPRIOT_IMAGE_NAME}.zip.sha256" && cd -

builder/chroot-script.sh

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ function clean_print(){
3939
fi
4040
}
4141

42+
function try_gpg_receive(){
43+
set +e
44+
45+
GPG_KEY="$1"
46+
47+
counter=0;
48+
status=1;
49+
50+
while [[ $counter -lt 5 && $status -ne 0 ]]; do
51+
apt-key adv --keyserver "$KEYSERVER" --recv-keys "$GPG_KEY"
52+
status=$?
53+
((counter+=1))
54+
55+
if [[ $status -ne 0 ]]; then
56+
sleep 1
57+
fi
58+
done
59+
60+
set -e
61+
62+
return $status
63+
}
64+
4265

4366
function get_gpg(){
4467
GPG_KEY="${1}"
@@ -53,8 +76,7 @@ function get_gpg(){
5376
wget -q -O "${KEY_FILE}" "${KEY_URL}"
5477
elif [[ -z "${KEY_URL}" ]]; then
5578
echo "no source given try to load from key server"
56-
# gpg --keyserver "${KEYSERVER}" --recv-keys "${GPG_KEY}"
57-
apt-key adv --keyserver "${KEYSERVER}" --recv-keys "${GPG_KEY}"
79+
try_gpg_receive "$GPG_KEY"
5880
return $?
5981
else
6082
echo "keyfile given"
@@ -100,36 +122,38 @@ mkdir -p "$(dirname "${DEST}")"
100122
echo "nameserver 8.8.8.8" > "${DEST}"
101123

102124
# set up debian jessie backports
103-
echo "deb http://httpredir.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list
125+
echo "deb http://httpredir.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/jessie-backports.list
126+
127+
# update all apt repository lists
128+
export DEBIAN_FRONTEND=noninteractive
129+
apt-get update
130+
apt-get upgrade -y
131+
132+
# dirmngr needed for gpg
133+
apt-get -y install --no-install-recommends dirmngr
104134

105135
# set up ODROID repository
106136
ODROID_KEY_ID=AB19BAC9
107137
get_gpg $ODROID_KEY_ID
108138
echo "deb http://deb.odroid.in/c2/ xenial main" > /etc/apt/sources.list.d/odroid.list
109139

110-
# set up hypriot arm repository for odroid packages
111-
PACKAGECLOUD_FPR=418A7F2FB0E1E6E7EABF6FE8C2E73424D59097AB
112-
PACKAGECLOUD_KEY_URL=https://packagecloud.io/gpg.key
113-
get_gpg "${PACKAGECLOUD_FPR}" "${PACKAGECLOUD_KEY_URL}"
114-
115-
# set up hypriot schatzkiste repository for generic packages
116-
echo 'deb https://packagecloud.io/Hypriot/Schatzkiste/debian/ jessie main' >> /etc/apt/sources.list.d/hypriot.list
140+
# set up Docker engine repository
141+
DOCKER_KEY_ID=0EBFCD88
142+
get_gpg $DOCKER_KEY_ID
143+
echo "deb https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker.list
117144

118-
# add armhf as additional architecure (see below)
119-
dpkg --add-architecture armhf
120-
121-
# update all apt repository lists
122-
export DEBIAN_FRONTEND=noninteractive
145+
# update apt after adding repositories
123146
apt-get update
124-
apt-get upgrade -y
125147

126-
# define packages to install
148+
# packages needed for the rest of the system
127149
packages=(
128150
# as the Odroid C2 does not have a hardware clock we need a fake one
129151
fake-hwclock
130152

131-
# install device-init
132-
device-init:armhf=${DEVICE_INIT_VERSION}
153+
# make sure some extra kernel tools are prepared
154+
initramfs-tools
155+
156+
cloud-init
133157

134158
# install dependencies for docker-tools
135159
lxc
@@ -142,18 +166,26 @@ packages=(
142166

143167
# required to install docker-compose
144168
python-pip
169+
python-setuptools
170+
python-wheel
145171
)
146172

147-
apt-get -y install --no-install-recommends ${packages[*]}
173+
apt-get -y install --no-install-recommends "${packages[@]}"
174+
175+
# set up cloud-init
176+
sed -i '/disable_root: true/a apt_preserve_sources_list: true' /etc/cloud/cloud.cfg
177+
178+
mkdir -p /var/lib/cloud/seed/nocloud-net
179+
ln -s /boot/user-data /var/lib/cloud/seed/nocloud-net/user-data
180+
ln -s /boot/meta-data /var/lib/cloud/seed/nocloud-net/meta-data
148181

149182
# install docker-engine
150-
DOCKER_DEB=$(mktemp)
151-
wget -q -O "$DOCKER_DEB" "$DOCKER_DEB_URL"
152-
echo "${DOCKER_DEB_CHECKSUM} ${DOCKER_DEB}" | sha256sum -c -
153-
dpkg -i "$DOCKER_DEB"
183+
apt-get -y install docker-ce="${DOCKER_CE_VERSION}"
184+
curl -sSL https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker
154185

155186
# install docker-compose
156187
pip install docker-compose=="${DOCKER_COMPOSE_VERSION}"
188+
curl -sSL "https://raw.githubusercontent.com/docker/compose/${DOCKER_COMPOSE_VERSION}/contrib/completion/bash/docker-compose" -o /etc/bash_completion.d/docker-compose
157189

158190
# install docker-machine
159191
curl -L "https://github.com/docker/machine/releases/download/v${DOCKER_MACHINE_VERSION}/docker-machine-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-machine

builder/files/boot/boot.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ setenv monitor_onoff "false" # true or false
100100
# Server Mode (aka. No Graphics)
101101
# Setting nographics to 1 will disable all video subsystem
102102
# This mode is ideal of server type usage. (Saves ~300Mb of RAM)
103-
setenv nographics "0"
103+
# setenv nographics "1"
104104

105105
# Meson Timer
106106
# 1 - Meson Timer

builder/files/boot/device-init.yaml

Lines changed: 0 additions & 9 deletions
This file was deleted.

builder/files/boot/meta-data

Whitespace-only changes.

0 commit comments

Comments
 (0)