1
0
mirror of https://github.com/rancher/os.git synced 2025-08-29 11:34:42 +00:00

Merge pull request #735 from imikushin/multiarch

Multi-arch build: amd64, arm
This commit is contained in:
Darren Shepherd 2016-02-08 18:57:24 -07:00
commit 1e0125c508
18 changed files with 531 additions and 73 deletions

View File

@ -1,9 +1,9 @@
FROM debian:jessie
FROM ubuntu:15.10
RUN apt-get update && \
apt-get -y install locales sudo vim less curl wget git rsync build-essential syslinux isolinux xorriso \
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/bin/genisoimage /usr/bin/mkisofs
libblkid-dev libmount-dev libselinux1-dev cpio genisoimage qemu-kvm python-pip ca-certificates
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV PATH $PATH:/usr/local/go/bin
@ -14,8 +14,8 @@ ENV GO15VENDOREXPERIMENT 1
RUN pip install tox
RUN curl -sSL https://storage.googleapis.com/golang/go1.5.3.linux-amd64.tar.gz | tar -xz -C /usr/local
RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/bin/docker
RUN chmod +x /usr/bin/docker
RUN curl -sL https://get.docker.com/builds/Linux/x86_64/docker-1.9.1 > /usr/local/bin/docker
RUN chmod +x /usr/local/bin/docker
ENV DAPPER_DOCKER_SOCKET true
ENV DAPPER_SOURCE /go/src/github.com/rancher/os
@ -25,3 +25,33 @@ ENV SHELL /bin/bash
WORKDIR ${DAPPER_SOURCE}
COPY .dockerignore.docker .dockerignore
RUN cd /usr/local/src && \
for i in libselinux pcre3 util-linux; do \
apt-get build-dep -y $i && \
apt-get source -y $i \
;done
RUN apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
RUN cd /usr/local/src/pcre3-* && \
autoreconf && \
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ./configure --host=arm-linux-gnueabihf --prefix=/usr/arm-linux-gnueabihf && \
make -j$(nproc) && \
make install
RUN cd /usr/local/src/libselinux-* && \
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ make CFLAGS=-Wall && \
make PREFIX=/usr/arm-linux-gnueabihf DESTDIR=/usr/arm-linux-gnueabihf install
RUN cd /usr/local/src/util-linux-* && \
autoreconf && \
CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ ./configure --host=arm-linux-gnueabihf --prefix=/usr/arm-linux-gnueabihf \
--disable-all-programs \
--enable-libmount \
--enable-libblkid \
--enable-libuuid \
--enable-mount && \
make -j$(nproc) && \
make install
CMD make all

View File

@ -1,16 +1,22 @@
include build.conf
FORCE_PULL := 0
DEV_BUILD := 0
ARCH := amd64
include build.conf
include build.conf.$(ARCH)
installer: minimal
docker build -t $(IMAGE_NAME):$(VERSION) .
bin/rancheros:
bin/ros:
mkdir -p $(dir $@)
go build -tags netgo -installsuffix netgo -ldflags "-X github.com/rancher/os/config.VERSION=$(VERSION) -linkmode external -extldflags -static" -o $@
strip --strip-all $@
ARCH=$(ARCH) VERSION=$(VERSION) ./scripts/mk-ros.sh $@
build/host_ros: bin/ros
mkdir -p $(dir $@)
ifeq "$(ARCH)" "amd64"
ln -sf ../bin/ros $@
else
ARCH=amd64 VERSION=$(VERSION) ./scripts/mk-ros.sh $@
endif
pwd := $(shell pwd)
include scripts/build-common
@ -22,6 +28,11 @@ assets/docker:
chmod +x $@
ifdef COMPILED_KERNEL_URL
installer: minimal
docker build -t $(IMAGE_NAME):$(VERSION) .
$(DIST)/artifacts/vmlinuz: $(BUILD)/kernel/
mkdir -p $(dir $@)
mv $(BUILD)/kernel/boot/vmlinuz* $@
@ -29,21 +40,41 @@ $(DIST)/artifacts/vmlinuz: $(BUILD)/kernel/
$(BUILD)/kernel/:
mkdir -p $@
([ -e "$(COMPILED_KERNEL_URL)" ] && cat "$(COMPILED_KERNEL_URL)" || curl -L "$(COMPILED_KERNEL_URL)") | tar -xzf - -C $@
curl -L "$(COMPILED_KERNEL_URL)" | tar -xzf - -C $@
$(BUILD)/images.tar: bin/rancheros
FORCE_PULL=$(FORCE_PULL) ./scripts/mk-images-tar.sh
$(DIST)/artifacts/initrd: bin/rancheros assets/docker $(BUILD)/kernel/ $(BUILD)/images.tar
$(DIST)/artifacts/initrd: bin/ros assets/docker $(BUILD)/kernel/ $(BUILD)/images.tar
mkdir -p $(dir $@)
DFS_IMAGE=$(DFS_IMAGE) DEV_BUILD=$(DEV_BUILD) ./scripts/mk-initrd.sh
ARCH=$(ARCH) DFS_IMAGE=$(DFS_IMAGE) DEV_BUILD=$(DEV_BUILD) ./scripts/mk-initrd.sh $@
$(DIST)/artifacts/rancheros.iso: minimal
./scripts/mk-rancheros-iso.sh
all: minimal installer iso
initrd: $(DIST)/artifacts/initrd
minimal: initrd $(DIST)/artifacts/vmlinuz
iso: $(DIST)/artifacts/rancheros.iso $(DIST)/artifacts/iso-checksums.txt
test: minimal
cd tests/integration && tox
.PHONY: all minimal initrd iso installer test
endif
$(BUILD)/images.tar: build/host_ros
ARCH=$(ARCH) FORCE_PULL=$(FORCE_PULL) ./scripts/mk-images-tar.sh
$(DIST)/artifacts/rootfs.tar.gz: bin/ros assets/docker $(BUILD)/images.tar
mkdir -p $(dir $@)
ARCH=$(ARCH) DFS_IMAGE=$(DFS_IMAGE) DEV_BUILD=$(DEV_BUILD) IS_ROOTFS=1 ./scripts/mk-initrd.sh $@
$(DIST)/artifacts/iso-checksums.txt: $(DIST)/artifacts/rancheros.iso
./scripts/mk-iso-checksums-txt.sh
@ -52,13 +83,6 @@ $(DIST)/artifacts/iso-checksums.txt: $(DIST)/artifacts/rancheros.iso
version:
@echo $(VERSION)
all: minimal installer iso
rootfs: $(DIST)/artifacts/rootfs.tar.gz
minimal: $(DIST)/artifacts/initrd $(DIST)/artifacts/vmlinuz
iso: $(DIST)/artifacts/rancheros.iso $(DIST)/artifacts/iso-checksums.txt
test: minimal
cd tests/integration && tox
.PHONY: build-all minimal iso installer version bin/rancheros integration-tests
.PHONY: rootfs version bin/ros

View File

@ -1,6 +1,3 @@
IMAGE_NAME=rancher/os
VERSION=v0.4.3-dev
DOCKER_BINARY_URL=https://get.docker.com/builds/Linux/x86_64/docker-1.10.0
COMPILED_KERNEL_URL=https://github.com/rancher/os-kernel/releases/download/Ubuntu-4.2.0-28.33-rancher/linux-4.2.8-ckt3-rancher-x86.tar.gz
DFS_IMAGE=rancher/docker:1.10.0

2
build.conf.amd64 Normal file
View File

@ -0,0 +1,2 @@
COMPILED_KERNEL_URL=https://github.com/rancher/os-kernel/releases/download/Ubuntu-4.2.0-28.33-rancher/linux-4.2.8-ckt3-rancher-x86.tar.gz
DOCKER_BINARY_URL=https://get.docker.com/builds/Linux/x86_64/docker-1.10.0

1
build.conf.arm Normal file
View File

@ -0,0 +1 @@
DOCKER_BINARY_URL=https://github.com/rancher/docker/releases/download/v1.10.0-ros_arm/docker-1.10.0

View File

@ -8,9 +8,9 @@ if [ "$1" != "--dev" ]; then
echo
echo For \"developer\" builds, run ./build.sh --dev
echo
dapper -k make all
dapper make all
else
dapper -k make DEV_BUILD=1 all
dapper make DEV_BUILD=1 all
fi

View File

@ -1,7 +1,6 @@
package init
import (
"os"
"syscall"
"fmt"
@ -61,7 +60,7 @@ func stopDocker(c chan interface{}) error {
c <- struct{}{}
<-c
return os.RemoveAll(config.DOCKER_SYSTEM_HOME)
return nil
}
func bootstrap(cfg *config.CloudConfig) error {

View File

@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"strings"
"syscall"
log "github.com/Sirupsen/logrus"
"github.com/rancher/docker-from-scratch"
@ -17,6 +18,9 @@ import (
const (
STATE string = "/state"
TMPFS_MAGIC int64 = 0x01021994
RAMFS_MAGIC int64 = 0x858458f6
)
var (
@ -140,6 +144,7 @@ func tryMountState(cfg *config.CloudConfig) error {
}
func tryMountAndBootstrap(cfg *config.CloudConfig) (*config.CloudConfig, error) {
if isInitrd() {
if err := tryMountState(cfg); !cfg.Rancher.State.Required && err != nil {
return cfg, nil
} else if err != nil {
@ -150,6 +155,7 @@ func tryMountAndBootstrap(cfg *config.CloudConfig) (*config.CloudConfig, error)
if err := switchRoot(STATE, cfg.Rancher.State.Directory, cfg.Rancher.RmUsr); err != nil {
return cfg, err
}
}
return mountOem(cfg)
}
@ -170,10 +176,21 @@ func getLaunchConfig(cfg *config.CloudConfig, dockerCfg *config.DockerConfig) (*
return &launchConfig, args
}
func isInitrd() bool {
var stat syscall.Statfs_t
syscall.Statfs("/", &stat)
return int64(stat.Type) == TMPFS_MAGIC || int64(stat.Type) == RAMFS_MAGIC
}
func RunInit() error {
os.Setenv("PATH", "/sbin:/usr/sbin:/usr/bin")
if isInitrd() {
log.Debug("Booting off an in-memory filesystem")
// Magic setting to tell Docker to do switch_root and not pivot_root
os.Setenv("DOCKER_RAMDISK", "true")
} else {
log.Debug("Booting off a persistent filesystem")
}
initFuncs := []config.CfgFunc{
func(c *config.CloudConfig) (*config.CloudConfig, error) {

View File

@ -27,7 +27,7 @@ func findImages(cfg *config.CloudConfig) ([]string, error) {
dir, err := os.Open(config.IMAGES_PATH)
if os.IsNotExist(err) {
log.Debugf("Not loading images, %s does not exist")
log.Debugf("Not loading images, %s does not exist", config.IMAGES_PATH)
return result, nil
}
if err != nil {

View File

@ -56,7 +56,10 @@ func main() {
registerCmd("/usr/sbin/wait-for-network", waitfornetwork.Main)
registerCmd("/usr/sbin/wait-for-docker", wait.Main)
if !reexec.Init() {
reexec.Register(os.Args[0], control.Main)
if !reexec.Init() {
log.Fatalf("Failed to find an entry point for %s", os.Args[0])
}
}
}

View File

@ -1,3 +1,4 @@
hostname: rancher
rancher:
bootstrap:
state-script:

328
os-config_arm.yml Normal file
View File

@ -0,0 +1,328 @@
hostname: rancher
rancher:
bootstrap:
state-script:
image: rancher/os-statescript:v0.4.3-dev_arm
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
io.rancher.os.after: udev-bootstrap
log_driver: json-file
net: host
uts: host
privileged: true
volumes:
- /dev:/host/dev
- /lib/modules:/lib/modules
- /lib/firmware:/lib/firmware
- /usr/bin/ros:/usr/bin/ros:ro
- /usr/share/ros:/usr/share/ros:ro
udev-bootstrap:
image: rancher/os-udev:v0.4.3-dev_arm
environment:
- BOOTSTRAP=true
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
log_driver: json-file
net: host
uts: host
privileged: true
volumes:
- /dev:/host/dev
- /lib/modules:/lib/modules
- /lib/firmware:/lib/firmware
autoformat:
autoformat:
image: rancher/os-autoformat:v0.4.3-dev_arm
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
log_driver: json-file
net: none
privileged: true
udev-autoformat:
image: rancher/os-udev:v0.4.3-dev_arm
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
io.rancher.os.after: autoformat
log_driver: json-file
net: host
uts: host
privileged: true
volumes:
- /dev:/host/dev
- /lib/modules:/lib/modules
- /lib/firmware:/lib/firmware
bootstrap_docker:
args: [daemon, -s, overlay, -b, none, --restart=false, -g, /var/lib/system-docker,
-G, root, -H, 'unix:///var/run/system-docker.sock', --userland-proxy=false]
cloud_init:
datasources:
- configdrive:/media/config-2
network:
dns:
nameservers: [8.8.8.8, 8.8.4.4]
interfaces:
eth*:
dhcp: true
lo:
address: 127.0.0.1/8
repositories:
core:
url: https://raw.githubusercontent.com/rancher/os-services/v0.4.3-dev_arm
state:
fstype: auto
dev: LABEL=RANCHER_STATE
oem_fstype: auto
oem_dev: LABEL=RANCHER_OEM
services:
all-volumes:
image: rancher/os-state:v0.4.3-dev_arm
labels:
io.rancher.os.createonly: "true"
io.rancher.os.scope: system
log_driver: json-file
net: none
privileged: true
read_only: true
volumes_from:
- container-data-volumes
- command-volumes
- user-volumes
- system-volumes
cloud-init:
image: rancher/os-cloudinit:v0.4.3-dev_arm
labels:
io.rancher.os.detach: "false"
io.rancher.os.reloadconfig: "true"
io.rancher.os.scope: system
io.rancher.os.after: cloud-init-pre, wait-for-network
net: host
uts: host
privileged: true
volumes_from:
- command-volumes
- system-volumes
cloud-init-pre:
image: rancher/os-cloudinit:v0.4.3-dev_arm
environment:
- CLOUD_INIT_NETWORK=false
labels:
io.rancher.os.detach: "false"
io.rancher.os.reloadconfig: "true"
io.rancher.os.scope: system
io.rancher.os.after: preload-system-images
net: host
uts: host
privileged: true
volumes_from:
- command-volumes
- system-volumes
command-volumes:
image: rancher/os-state:v0.4.3-dev_arm
labels:
io.rancher.os.createonly: "true"
io.rancher.os.scope: system
log_driver: json-file
net: none
privileged: true
read_only: true
volumes:
- /usr/bin/docker:/usr/bin/docker.dist:ro
- /usr/bin/ros:/usr/bin/dockerlaunch:ro
- /usr/bin/ros:/usr/bin/user-docker:ro
- /usr/bin/ros:/usr/bin/system-docker:ro
- /usr/bin/ros:/sbin/poweroff:ro
- /usr/bin/ros:/sbin/reboot:ro
- /usr/bin/ros:/sbin/halt:ro
- /usr/bin/ros:/sbin/shutdown:ro
- /usr/bin/ros:/usr/bin/respawn:ro
- /usr/bin/ros:/usr/bin/ros:ro
- /usr/bin/ros:/usr/bin/cloud-init:ro
- /usr/bin/ros:/usr/sbin/netconf:ro
- /usr/bin/ros:/usr/sbin/wait-for-network:ro
- /usr/bin/ros:/usr/sbin/wait-for-docker:ro
console:
image: rancher/os-console:v0.4.3-dev_arm
labels:
io.rancher.os.scope: system
io.rancher.os.after: cloud-init
io.docker.compose.rebuild: always
net: host
uts: host
pid: host
ipc: host
privileged: true
restart: always
volumes_from:
- all-volumes
volumes:
- /usr/bin/iptables:/sbin/iptables:ro
container-data-volumes:
image: rancher/os-state:v0.4.3-dev_arm
labels:
io.rancher.os.createonly: "true"
io.rancher.os.scope: system
log_driver: json-file
net: none
privileged: true
read_only: true
volumes:
- /var/lib/docker:/var/lib/docker
- /var/lib/rkt:/var/lib/rkt
network:
image: rancher/os-network:v0.4.3-dev_arm
labels:
io.rancher.os.scope: system
io.rancher.os.after: cloud-init-pre
net: host
uts: host
pid: host
privileged: true
volumes_from:
- command-volumes
- system-volumes
wait-for-network:
image: rancher/os-network:v0.4.3-dev_arm
command: wait-for-network
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
io.rancher.os.after: network
pid: host
privileged: true
volumes_from:
- command-volumes
- system-volumes
ntp:
image: rancher/os-ntp:v0.4.3-dev_arm
labels:
io.rancher.os.scope: system
io.rancher.os.after: cloud-init, wait-for-network
net: host
uts: host
privileged: true
restart: always
preload-system-images:
image: rancher/os-preload:v0.4.3-dev_arm
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
privileged: true
volumes:
- /var/run/system-docker.sock:/var/run/docker.sock
- /var/lib/system-docker/preload:/mnt/preload
volumes_from:
- command-volumes
- system-volumes
preload-user-images:
image: rancher/os-preload:v0.4.3-dev_arm
labels:
io.rancher.os.detach: "false"
io.rancher.os.scope: system
io.rancher.os.after: console
privileged: true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/preload:/mnt/preload
volumes_from:
- command-volumes
- system-volumes
syslog:
image: rancher/os-syslog:v0.4.3-dev_arm
labels:
io.rancher.os.scope: system
log_driver: json-file
net: host
uts: host
privileged: true
restart: always
volumes_from:
- system-volumes
system-volumes:
image: rancher/os-state:v0.4.3-dev_arm
labels:
io.rancher.os.createonly: "true"
io.rancher.os.scope: system
log_driver: json-file
net: none
privileged: true
read_only: true
volumes:
- /dev:/host/dev
- /etc/docker:/etc/docker
- /etc/hosts:/etc/hosts
- /etc/resolv.conf:/etc/resolv.conf
- /etc/rkt:/etc/rkt
- /etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt.rancher
- /lib/firmware:/lib/firmware
- /lib/modules:/lib/modules
- /run:/run
- /usr/share/ros:/usr/share/ros
- /var/lib/rancher/conf:/var/lib/rancher/conf
- /var/lib/rancher:/var/lib/rancher
- /var/log:/var/log
- /var/run:/var/run
udev-cold:
image: rancher/os-udev:v0.4.3-dev_arm
labels:
io.rancher.os.scope: system
io.rancher.os.before: udev
net: host
uts: host
privileged: true
volumes_from:
- system-volumes
udev:
image: rancher/os-udev:v0.4.3-dev_arm
environment:
- DAEMON=true
labels:
io.rancher.os.detach: "true"
io.rancher.os.scope: system
net: host
uts: host
privileged: true
restart: always
volumes_from:
- system-volumes
user-volumes:
image: rancher/os-state:v0.4.3-dev_arm
labels:
io.rancher.os.createonly: "true"
io.rancher.os.scope: system
log_driver: json-file
net: none
privileged: true
read_only: true
volumes:
- /home:/home
- /opt:/opt
docker:
image: rancher/os-docker:v0.4.3-dev_arm
labels:
io.rancher.os.scope: system
io.rancher.os.after: console
net: host
pid: host
ipc: host
uts: host
privileged: true
restart: always
volumes_from:
- all-volumes
volumes:
- /sys/fs/cgroup:/host/sys/fs/cgroup
system_docker:
args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -b, docker-sys,
--fixed-cidr, 172.18.42.1/16, --restart=false, -g, /var/lib/system-docker, -G, root,
-H, 'unix:///var/run/system-docker.sock', --userland-proxy=false]
upgrade:
url: https://releases.rancher.com/os/releases_arm.yml
image: rancher/os
docker:
tls_args: [--tlsverify, --tlscacert=/etc/docker/tls/ca.pem, --tlscert=/etc/docker/tls/server-cert.pem, --tlskey=/etc/docker/tls/server-key.pem,
'-H=0.0.0.0:2376']
args: [daemon, --log-opt, max-size=25m, --log-opt, max-file=2, -s, overlay, -G, docker, -H, 'unix:///var/run/docker.sock', --userland-proxy=false]

View File

@ -3,4 +3,5 @@ available:
- rancher/os:v0.4.0
- rancher/os:v0.4.1
- rancher/os:v0.4.2
current: rancher/os:v0.4.2
- rancher/os:v0.4.3
current: rancher/os:v0.4.3

4
releases_arm.yml Normal file
View File

@ -0,0 +1,4 @@
---
available:
- rancher/os:v0.4.3_arm
current: rancher/os:v0.4.3_arm

View File

@ -1,13 +1,15 @@
#!/bin/bash
set -ex
suffix=""
[ "$ARCH" == "amd64" ] || suffix="_${ARCH}"
cd $(dirname $0)/..
. scripts/build-common
ln -sf bin/rancheros ./ros
for i in `./ros c images -i os-config.yml`; do
images="$(build/host_ros c images -i os-config${suffix}.yml)"
for i in ${images}; do
[ "${FORCE_PULL}" != "1" ] && docker inspect $i >/dev/null 2>&1 || docker pull $i;
done
docker save `./ros c images -i os-config.yml` > ${BUILD}/images.tar
docker save ${images} > ${BUILD}/images.tar

View File

@ -1,6 +1,17 @@
#!/bin/bash
set -ex
TARGET=${1}
ARCH=${ARCH:-"amd64"}
DFS_IMAGE=${DFS_IMAGE:?"DFS_IMAGE not set"}
IS_ROOTFS=${IS_ROOTFS:-0}
suffix=""
[ "$ARCH" == "amd64" ] || suffix="_${ARCH}"
DFS_ARCH_IMAGE=${DFS_IMAGE}${suffix}
cd $(dirname $0)/..
. scripts/build-common
@ -8,18 +19,25 @@ INITRD_DIR=${BUILD}/initrd
rm -rf ${INITRD_DIR}/{usr,init}
mkdir -p ${INITRD_DIR}/usr/{bin,share/ros}
mkdir -p ${INITRD_DIR}/var/lib/system-docker
cp -rf ${BUILD}/kernel/lib ${INITRD_DIR}/usr
if [ "$IS_ROOTFS" == "0" ]; then
cp -rf ${BUILD}/kernel/lib ${INITRD_DIR}/usr/
fi
cp assets/docker ${INITRD_DIR}/usr/bin/docker
cp ${BUILD}/images.tar ${INITRD_DIR}/usr/share/ros
cp os-config.yml ${INITRD_DIR}/usr/share/ros/
cp bin/rancheros ${INITRD_DIR}/usr/bin/ros
if [ "$IS_ROOTFS" == "0" ]; then
cp ${BUILD}/images.tar ${INITRD_DIR}/usr/share/ros/
fi
cp os-config${suffix}.yml ${INITRD_DIR}/usr/share/ros/os-config.yml
cp bin/ros ${INITRD_DIR}/usr/bin/
ln -s usr/bin/ros ${INITRD_DIR}/init
ln -s bin ${INITRD_DIR}/usr/sbin
ln -s usr/sbin ${INITRD_DIR}/sbin
DFS=$(docker create ${DFS_IMAGE})
trap "docker rm -fv ${DFS}" EXIT
docker export ${DFS} | tar xvf - -C ${INITRD_DIR} --exclude=usr/bin/dockerlaunch \
DFS_ARCH=$(docker create ${DFS_ARCH_IMAGE})
trap "docker rm -fv ${DFS_ARCH}" EXIT
docker export ${DFS_ARCH} | tar xvf - -C ${INITRD_DIR} --exclude=usr/bin/dockerlaunch \
--exclude=usr/bin/docker \
--exclude=usr/share/git-core \
--exclude=usr/bin/git \
@ -27,10 +45,22 @@ docker export ${DFS} | tar xvf - -C ${INITRD_DIR} --exclude=usr/bin/dockerlaunc
--exclude=usr/libexec/git-core \
usr
if [ "$DEV_BUILD" == "1" ]; then
COMPRESS="gzip -1"
if [ "$IS_ROOTFS" == "1" ]; then
DFS=$(docker run -d --privileged -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) ${DFS_IMAGE})
trap "docker rm -fv ${DFS_ARCH} ${DFS}" EXIT
docker exec -i ${DFS} docker load < ${BUILD}/images.tar
docker stop ${DFS}
docker run --rm --volumes-from=${DFS} debian:jessie tar -c -C /var/lib/docker ./image | tar -x -C ${INITRD_DIR}/var/lib/system-docker
docker run --rm --volumes-from=${DFS} debian:jessie tar -c -C /var/lib/docker ./overlay | tar -x -C ${INITRD_DIR}/var/lib/system-docker
cd ${INITRD_DIR}
tar -czf ${TARGET} .
else
COMPRESS=lzma
fi
[ "$DEV_BUILD" == "1" ] && COMPRESS="gzip -1"
cd ${INITRD_DIR} && find | cpio -H newc -o | ${COMPRESS} > ${DIST}/artifacts/initrd
cd ${INITRD_DIR}
find | cpio -H newc -o | ${COMPRESS} > ${TARGET}
fi

19
scripts/mk-ros.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/bash
set -ex
ros="$1"
ARCH=${ARCH:?"ARCH not set"}
VERSION=${VERSION:?"VERSION not set"}
cd $(dirname $0)/..
strip_bin=$(which strip)
if [ "${ARCH}" == "arm" ]; then
export GOARM=6
export CC=/usr/bin/arm-linux-gnueabihf-gcc
export CGO_ENABLED=1
strip_bin=/usr/arm-linux-gnueabihf/bin/strip
fi
GOARCH=${ARCH} go build -tags netgo -installsuffix netgo -ldflags "-X github.com/rancher/os/config.VERSION=${VERSION} -linkmode external -extldflags -static" -o ${ros}
${strip_bin} --strip-all ${ros}

View File

@ -101,8 +101,8 @@ if [ "$REBUILD" == "1" ]; then
ln -s ${INITRD_TMP} ${INITRD_CURRENT}
mkdir -p ${INITRD_TMP}/usr/{bin,share/ros}
cp bin/rancheros ${INITRD_TMP}/usr/bin/ros
cp -f os-config.yml ${INITRD_TMP}/usr/share/ros
cp bin/ros ${INITRD_TMP}/usr/bin/
cp -f os-config.yml ${INITRD_TMP}/usr/share/ros/
pushd ${INITRD_TMP}
find . | cpio -H newc -o | gzip > ${INITRD_TEST}