1
0
mirror of https://github.com/rancher/os.git synced 2025-07-31 06:32:09 +00:00

Initial build, copied from rpi32

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
This commit is contained in:
Sven Dowideit 2017-03-22 04:17:51 +00:00
parent abaecf4e44
commit 272f3942f1
7 changed files with 133 additions and 1 deletions

View File

@ -54,10 +54,15 @@ qcows:
NAME=digitalocean ../../../.dapper
cp ./scripts/images/openstack/dist/*.img dist/artifacts/
rpi: release
rpi:
# scripts/images/raspberry-pi-hypriot/dist/rancheros-raspberry-pi.zip
cp dist/artifacts/rootfs_arm.tar.gz scripts/images/raspberry-pi-hypriot/
cd scripts/images/raspberry-pi-hypriot/ \
rpi64:
# scripts/images/raspberry-pi-hypriot64/dist/rancheros-raspberry-pi.zip
cp dist/artifacts/rootfs_arm64.tar.gz scripts/images/raspberry-pi-hypriot64/
cd scripts/images/raspberry-pi-hypriot64/ \
&& ../../../.dapper
help:

View File

@ -54,10 +54,12 @@ it would really be bad if somebody did `docker rm -f $(docker ps -qa)` and delet
* https://releases.rancher.com/os/latest/rootfs_arm.tar.gz
* https://releases.rancher.com/os/latest/rootfs_arm64.tar.gz
* https://releases.rancher.com/os/latest/rancheros-raspberry-pi.zip
* https://releases.rancher.com/os/latest/rancheros-raspberry-pi64.zip
* https://releases.rancher.com/os/v1.0.2/rootfs_arm.tar.gz
* https://releases.rancher.com/os/v1.0.2/rootfs_arm64.tar.gz
* https://releases.rancher.com/os/v1.0.2/rancheros-raspberry-pi.zip
* https://releases.rancher.com/os/v1.0.2/rancheros-raspberry-pi64.zip
**Note**: you can use `http` instead of `https` in the above URLs, e.g. for iPXE.

View File

@ -0,0 +1 @@
dist

View File

@ -0,0 +1,2 @@
dist
rootfs_arm64.tar.gz

View File

@ -0,0 +1,28 @@
FROM rancher/os-debianconsole-base
# FROM amd64=debian:jessie arm64=aarch64/debian:jessie arm=armhf/debian:jessie
ENV DAPPER_RUN_ARGS --privileged
ENV DAPPER_OUTPUT dist
RUN apt-get update -y
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates curl dosfstools tree zip
RUN mkdir -p /source/assets
# RancherOS for ARM
#RUN curl -fL https://releases.rancher.com/os/latest/rootfs_arm64.tar.gz > /source/assets/rootfs_arm64.tar.gz
COPY rootfs_arm64.tar.gz /source/assets/rootfs_arm64.tar.gz
ENV URL=https://github.com/DieterReuter/rpi64-kernel/releases/download
ENV VER=v20170303-160601
RUN curl -fL ${URL}/${VER}/4.9.13-bee42-v8.tar.gz > /source/assets/kernel.tar.gz
RUN curl -fL ${URL}/${VER}/bootfiles.tar.gz > /source/assets/bootfiles.tar.gz
RUN curl -fL https://github.com/DieterReuter/rpi-bootloader/releases/download/v20170303-133934/rpi-bootloader.tar.gz > /source/assets/rpi-bootfiles.tar.gz
#ENV RPI_URL=https://github.com/raspberrypi/firmware/raw/master/boot
#RUN curl -fL ${RPI_URL}/bootcode.bin > /source/assets/bootcode.bin
#RUN curl -fL ${RPI_URL}/fixup.dat > /source/assets/fixup.dat
#RUN curl -fL ${RPI_URL}/start.elf > /source/assets/start.elf
WORKDIR /source
CMD ["./scripts/build.sh"]

View File

@ -0,0 +1,11 @@
RaspberryPi 2 Image
===================
Build by running `dapper` in this folder and the build will produce `./dist/rancheros-rpi2.zip`.
This image is compatible with the Raspberry Pi 3 too, but only ARMv7 is supported now.
Build Requirements
==================
This build uses local loopback devices and thus requires to run as a privileged container. So please keep the setting `ENV DAPPER_RUN_ARGS --privileged` from `Dockerfile.dapper` for now. The build is running quite fast and has been tested on OS X with boot2docker.

View File

@ -0,0 +1,83 @@
#!/bin/bash
set -e -x
cd $(dirname $0)/..
# create build directory for assembling our image filesystem
mkdir -p build/{boot,root,basefs} dist
cp assets/*.tar.gz build/
#---build SD card image---
# size of root and boot partion (in MByte)
IMAGE_TOTAL_SIZE=500
BOOT_PARTITION_START=2048
BOOT_PARTITION_SIZE=25
#---don't change here---
BOOT_PARTITION_OFFSET="$((BOOT_PARTITION_START*512))"
BOOT_PARTITION_BYTES="$((BOOT_PARTITION_SIZE*1024*1024))"
BOOT_PARTITION_SECTORS="$((BOOT_PARTITION_SIZE*1024*2))"
ROOT_PARTITION_START="$((BOOT_PARTITION_START+BOOT_PARTITION_SECTORS))"
ROOT_PARTITION_OFFSET="$((ROOT_PARTITION_START*512))"
#---don't change here---
# create image file with two partitions (FAT32, EXT4)
dd if=/dev/zero of=build/run.img bs=1MiB count=$IMAGE_TOTAL_SIZE
echo -e "o\nn\np\n1\n${BOOT_PARTITION_START}\n+${BOOT_PARTITION_SECTORS}\nt\nc\nn\np\n2\n${ROOT_PARTITION_START}\n\nw\n" | fdisk build/run.img
fdisk -l build/run.img
ls -al build/run.img
# partition #1 - Type= c W95 FAT32 (LBA)
losetup
losetup -f
losetup -d /dev/loop0 || /bin/true
losetup --offset $BOOT_PARTITION_OFFSET --sizelimit $BOOT_PARTITION_BYTES /dev/loop0 build/run.img
mkfs.vfat -n RancherOS /dev/loop0
losetup -d /dev/loop0
# partition #2 - Type=83 Linux
losetup -d /dev/loop1 || /bin/true
losetup --offset $ROOT_PARTITION_OFFSET /dev/loop1 build/run.img
mkfs.ext4 -O ^has_journal -b 4096 -L rootfs /dev/loop1
losetup -d /dev/loop1
# mount partitions as loopback devices
mount -t ext4 -o loop=/dev/loop1,offset=$ROOT_PARTITION_OFFSET build/run.img build/root
mkdir -p build/root/boot
mount -t vfat -o loop=/dev/loop0,offset=$BOOT_PARTITION_OFFSET build/run.img build/root/boot
echo "RancherOS: boot partition" > build/root/boot/boot.txt
echo "RancherOS: root partition" > build/root/root.txt
# unpack and cleanup the basefs
#- doing this on a local folder keeps our resulting image clean (no dirty blocks from a delete)
mkdir -p build/basefs
tar -C build/basefs -zxvf build/kernel.tar.gz
tar -C build/basefs -zxvf build/rpi-bootfiles.tar.gz
tar -C build/basefs -zxvf build/bootfiles.tar.gz
# remove RPi1 kernel, we only support RPi2 and RPi3 in ARMv7 mode
rm -fr build/basefs/boot/kernel.img
rm -fr build/basefs/lib/modules/{4.4.27+,4.4.27-hypriotos+}
# populate kernel, bootloader and RancherOS rootfs
cp -R build/basefs/* build/root
tar -xf assets/rootfs_arm64.tar.gz -C build/root
echo "+dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 cgroup-enable=memory swapaccount=1 elevator=deadline rootwait console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty0 rancher.password=rancher rancher.autologin=ttyAMA0 rw init=/init" > build/root/boot/cmdline.txt
# enable serial console mode for rpi3
echo "enable_uart=1" > build/root/boot/config.txt
# show details
tree -a -L 3 build/root
df -h
# unmount partitions (loopback devices will be removed automatically)
umount build/root/boot
umount build/root
# package, compress and export image file
mv build/run.img build/rancheros-raspberry-pi64.img
zip dist/rancheros-raspberry-pi64.zip build/rancheros-raspberry-pi64.img
ls -alh dist
# cleanup build environment
rm -fr build