]> xenbits.xensource.com Git - people/sstabellini/mojo.git/.git/commitdiff
Parametrize the alpine-dom0 build
authorStefano Stabellini <sstabellini@kernel.org>
Mon, 20 Nov 2017 21:30:24 +0000 (13:30 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Mon, 20 Nov 2017 21:54:50 +0000 (13:54 -0800)
Use a series file to get the build order, rather than hardcoding it in
build.sh.

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
alpine-dom0/build.sh
alpine-dom0/dom0/build.docker [new file with mode: 0644]
alpine-dom0/dom0/udhcpc.script [new file with mode: 0755]
alpine-dom0/runtime/runtime.docker [deleted file]
alpine-dom0/runtime/udhcpc.script [deleted file]
alpine-dom0/series [new file with mode: 0644]

index 97591d3e4288de9b6b8a683569c9827b175ceaa5..73e12676ff7f45d68aacfea792bf6b1f613a057e 100755 (executable)
@@ -1,34 +1,10 @@
 #!/bin/sh
 
-XEN_LABEL="xen-builder"
-QEMU_LABEL="qemu-builder"
-LINUX_LABEL="linux-builder"
-DOM0_LABEL="dom0"
-
-# Build Xen, create $XEN_LABEL
-exists=`docker images $XEN_LABEL | grep $XEN_LABEL`
-if test -z "$exists"
-then
-    docker build -f alpine-dom0/$XEN_LABEL/build.docker -t $XEN_LABEL .
-fi
-
-# Build QEMU, based on $XEN_LABEL, create $QEMU_LABEL
-exists=`docker images $QEMU_LABEL | grep $QEMU_LABEL`
-if test -z "$exists"
-then
-    docker build -f alpine-dom0/$QEMU_LABEL/build.docker -t $QEMU_LABEL .
-fi
-
-# Build Linux, based on $QEMU_LABEL, create $LINUX_LABEL
-exists=`docker images $LINUX_LABEL | grep $LINUX_LABEL`
-if test -z "$exists"
-then
-    docker build -f alpine-dom0/$LINUX_LABEL/build.docker -t $LINUX_LABEL .
-fi
-
-# Create Dom0, takes build artifacts from $LINUX_LABEL
-exists=`docker images $DOM0_LABEL | grep $DOM0_LABEL`
-if test -z "$exists"
-then
-    docker build -f alpine-dom0/runtime/runtime.docker -t $DOM0_LABEL .
-fi
+for label in `cat alpine-dom0/series`
+do
+    exists=`docker images $label | grep $label`
+    if test -z "$exists"
+    then
+        docker build -f alpine-dom0/$label/build.docker -t $label .
+    fi
+done
diff --git a/alpine-dom0/dom0/build.docker b/alpine-dom0/dom0/build.docker
new file mode 100644 (file)
index 0000000..2f6e8d5
--- /dev/null
@@ -0,0 +1,42 @@
+FROM alpine as dom0
+
+RUN \
+       apk update && \
+       apk add openrc
+
+ADD alpine-dom0/dom0/udhcpc.script /usr/share/udhcpc/default.script
+COPY --from=linux-builder /out/ /
+
+RUN \
+       rc-update add networking sysinit && \
+       rc-update add loopback sysinit && \
+       rc-update add bootmisc boot && \
+       rc-update add devfs sysinit && \
+       rc-update add dmesg sysinit && \
+       rc-update add hostname boot && \
+       rc-update add hwclock boot && \
+       rc-update add hwdrivers sysinit && \
+       rc-update add killprocs shutdown && \
+       rc-update add modloop sysinit && \
+       rc-update add modules boot && \
+       rc-update add mount-ro shutdown && \
+       rc-update add savecache shutdown && \
+       rc-update add sysctl boot && \
+       rc-update add local default && \
+       echo "nameserver 8.8.8.8" > /etc/resolv.conf && \
+       echo "auto lo" > /etc/network/interfaces && \
+       echo "auto eth0" >> /etc/network/interfaces && \
+       echo "iface eth0 inet dhcp" >> /etc/network/interfaces && \
+       echo "ttyS0" >> /etc/securetty && \
+       echo "hvc0" >> /etc/securetty && \
+       echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab && \
+       echo "hvc0::respawn:/sbin/getty -L hvc0 115200 vt100" >> /etc/inittab && \
+# Xen run deps
+       apk add python2 gettext zlib ncurses dev86 texinfo yajl curl libaio autoconf automake iasl make xz-dev bash util-linux argp-standalone && \
+       echo "/etc/init.d/xencommons start" > /etc/local.d/xencommons.start && \
+       chmod +x /etc/local.d/xencommons.start && \
+       rc-update add xencommons default && \
+# QEMU run deps
+       apk add glib pixman libcap libattr
+
+ENTRYPOINT ["/bin/sh"]
diff --git a/alpine-dom0/dom0/udhcpc.script b/alpine-dom0/dom0/udhcpc.script
new file mode 100755 (executable)
index 0000000..6a78bba
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/busybox sh
+
+# udhcp sample script by Gabriel Somlo (somlo at cmu edu)
+#      - uses 'ip' instead of 'ifconfig' and 'route'
+#      - make minimal changes, and only if required by changing dhcp options
+
+[ -z "$1" ] && echo 'Error: should be called from udhcpc' && exit 1
+
+# where to save config information for $interface:
+CFG="/var/run/udhcpc.${interface}.cfg"
+
+# names of files we might need to touch:
+RESOLV_CONF='/etc/resolv.conf'
+NTP_CONF='/etc/ntp.conf'
+
+# which interface configures DNS and NTP ? Comment out if none:
+#PEERDNS_IF=eth0
+#PEERNTP_IF=eth0
+
+case "$1" in
+  deconfig)
+    # bring interface up, but with no IP configured:
+    ip addr flush dev $interface
+    ip link set $interface up
+    # remove any stored config info for this $interface:
+    rm -f $CFG
+    # restore any pre-dhcp config files:
+    if [ "$interface" == "$PEERDNS_IF" ] ; then
+      [ -f ${RESOLV_CONF}.dhcsave ] && mv -f ${RESOLV_CONF}.dhcsave $RESOLV_CONF
+    fi
+    if [ "$interface" == "$PEERNTP_IF" ] ; then
+      [ -f ${NTP_CONF}.dhcsave ] && mv -f ${NTP_CONF}.dhcsave $NTP_CONF
+    fi
+    ;;
+  bound)
+    # save config info for $interface:
+    set > $CFG
+    # configure interface and routes:
+    ip addr flush dev $interface
+    ip addr add ${ip}/${mask} dev $interface
+    [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
+    # save pre-dhcp config files and generate new ones:
+    if [ "$interface" == "$PEERDNS_IF" ] ; then
+      [ -f $RESOLV_CONF ] && mv -f $RESOLV_CONF ${RESOLV_CONF}.dhcsave
+      [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
+      for i in $dns ; do
+        echo nameserver $i >> $RESOLV_CONF
+      done
+    fi
+    if [ "$interface" == "$PEERNTP_IF" ] ; then
+      [ -f $NTP_CONF ] && mv -f $NTP_CONF ${NTP_CONF}.dhcsave
+      > $NTP_CONF
+      for i in $ntpsrv ; do
+        echo server $i >> $NTP_CONF
+      done
+    fi
+    ;;
+  renew)
+    # compare new vs. previous config info:
+    set > ${CFG}.new
+    for i in $(diff -U1 $CFG ${CFG}.new | grep -E ^[+-] \
+                                        | tail +3 \
+                                        | awk -F[+-=] '{print $2}') ; do
+      case "$i" in
+        ip|mask|router)
+          REDO_NET='yes'
+          ;;
+        domain|dns)
+          REDO_DNS='yes'
+          ;;
+        ntpsrv)
+          REDO_NTP='yes'
+          ;;
+      esac
+    done
+    # save new config info:
+    mv -f ${CFG}.new $CFG
+    # make only necessary changes, as per config comparison:
+    if [ -n "$REDO_NET" ] ; then
+      ip addr flush dev $interface
+      ip addr add ${ip}/${mask} dev $interface
+      [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
+    fi
+    if [ -n "$REDO_DNS" -a "$interface" == "$PEERDNS_IF" ] ; then
+      [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
+      for i in $dns ; do
+        echo nameserver $i >> $RESOLV_CONF
+      done
+    fi
+    if [ -n "$REDO_NTP" -a "$interface" == "$PEERNTP_IF" ] ; then
+      > $NTP_CONF
+      for i in $ntpsrv ; do
+        echo server $i >> $NTP_CONF
+      done
+      # FIXME: RELOAD NTP DAEMON HERE
+    fi
+    ;;
+esac
+
+exit 0
+
diff --git a/alpine-dom0/runtime/runtime.docker b/alpine-dom0/runtime/runtime.docker
deleted file mode 100644 (file)
index 1bf7022..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-FROM alpine as dom0
-
-RUN \
-       apk update && \
-       apk add openrc
-
-ADD alpine-dom0/runtime/udhcpc.script /usr/share/udhcpc/default.script
-COPY --from=linux-builder /out/ /
-
-RUN \
-       rc-update add networking sysinit && \
-       rc-update add loopback sysinit && \
-       rc-update add bootmisc boot && \
-       rc-update add devfs sysinit && \
-       rc-update add dmesg sysinit && \
-       rc-update add hostname boot && \
-       rc-update add hwclock boot && \
-       rc-update add hwdrivers sysinit && \
-       rc-update add killprocs shutdown && \
-       rc-update add modloop sysinit && \
-       rc-update add modules boot && \
-       rc-update add mount-ro shutdown && \
-       rc-update add savecache shutdown && \
-       rc-update add sysctl boot && \
-       rc-update add local default && \
-       echo "nameserver 8.8.8.8" > /etc/resolv.conf && \
-       echo "auto lo" > /etc/network/interfaces && \
-       echo "auto eth0" >> /etc/network/interfaces && \
-       echo "iface eth0 inet dhcp" >> /etc/network/interfaces && \
-       echo "ttyS0" >> /etc/securetty && \
-       echo "hvc0" >> /etc/securetty && \
-       echo "ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab && \
-       echo "hvc0::respawn:/sbin/getty -L hvc0 115200 vt100" >> /etc/inittab && \
-# Xen run deps
-       apk add python2 gettext zlib ncurses dev86 texinfo yajl curl libaio autoconf automake iasl make xz-dev bash util-linux argp-standalone && \
-       echo "/etc/init.d/xencommons start" > /etc/local.d/xencommons.start && \
-       chmod +x /etc/local.d/xencommons.start && \
-       rc-update add xencommons default && \
-# QEMU run deps
-       apk add glib pixman libcap libattr
-
-ENTRYPOINT ["/bin/sh"]
diff --git a/alpine-dom0/runtime/udhcpc.script b/alpine-dom0/runtime/udhcpc.script
deleted file mode 100755 (executable)
index 6a78bba..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/busybox sh
-
-# udhcp sample script by Gabriel Somlo (somlo at cmu edu)
-#      - uses 'ip' instead of 'ifconfig' and 'route'
-#      - make minimal changes, and only if required by changing dhcp options
-
-[ -z "$1" ] && echo 'Error: should be called from udhcpc' && exit 1
-
-# where to save config information for $interface:
-CFG="/var/run/udhcpc.${interface}.cfg"
-
-# names of files we might need to touch:
-RESOLV_CONF='/etc/resolv.conf'
-NTP_CONF='/etc/ntp.conf'
-
-# which interface configures DNS and NTP ? Comment out if none:
-#PEERDNS_IF=eth0
-#PEERNTP_IF=eth0
-
-case "$1" in
-  deconfig)
-    # bring interface up, but with no IP configured:
-    ip addr flush dev $interface
-    ip link set $interface up
-    # remove any stored config info for this $interface:
-    rm -f $CFG
-    # restore any pre-dhcp config files:
-    if [ "$interface" == "$PEERDNS_IF" ] ; then
-      [ -f ${RESOLV_CONF}.dhcsave ] && mv -f ${RESOLV_CONF}.dhcsave $RESOLV_CONF
-    fi
-    if [ "$interface" == "$PEERNTP_IF" ] ; then
-      [ -f ${NTP_CONF}.dhcsave ] && mv -f ${NTP_CONF}.dhcsave $NTP_CONF
-    fi
-    ;;
-  bound)
-    # save config info for $interface:
-    set > $CFG
-    # configure interface and routes:
-    ip addr flush dev $interface
-    ip addr add ${ip}/${mask} dev $interface
-    [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
-    # save pre-dhcp config files and generate new ones:
-    if [ "$interface" == "$PEERDNS_IF" ] ; then
-      [ -f $RESOLV_CONF ] && mv -f $RESOLV_CONF ${RESOLV_CONF}.dhcsave
-      [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
-      for i in $dns ; do
-        echo nameserver $i >> $RESOLV_CONF
-      done
-    fi
-    if [ "$interface" == "$PEERNTP_IF" ] ; then
-      [ -f $NTP_CONF ] && mv -f $NTP_CONF ${NTP_CONF}.dhcsave
-      > $NTP_CONF
-      for i in $ntpsrv ; do
-        echo server $i >> $NTP_CONF
-      done
-    fi
-    ;;
-  renew)
-    # compare new vs. previous config info:
-    set > ${CFG}.new
-    for i in $(diff -U1 $CFG ${CFG}.new | grep -E ^[+-] \
-                                        | tail +3 \
-                                        | awk -F[+-=] '{print $2}') ; do
-      case "$i" in
-        ip|mask|router)
-          REDO_NET='yes'
-          ;;
-        domain|dns)
-          REDO_DNS='yes'
-          ;;
-        ntpsrv)
-          REDO_NTP='yes'
-          ;;
-      esac
-    done
-    # save new config info:
-    mv -f ${CFG}.new $CFG
-    # make only necessary changes, as per config comparison:
-    if [ -n "$REDO_NET" ] ; then
-      ip addr flush dev $interface
-      ip addr add ${ip}/${mask} dev $interface
-      [ -n "$router" ] && ip route add default via ${router%% *} dev $interface
-    fi
-    if [ -n "$REDO_DNS" -a "$interface" == "$PEERDNS_IF" ] ; then
-      [ -n "$domain" ] && echo search $domain > $RESOLV_CONF
-      for i in $dns ; do
-        echo nameserver $i >> $RESOLV_CONF
-      done
-    fi
-    if [ -n "$REDO_NTP" -a "$interface" == "$PEERNTP_IF" ] ; then
-      > $NTP_CONF
-      for i in $ntpsrv ; do
-        echo server $i >> $NTP_CONF
-      done
-      # FIXME: RELOAD NTP DAEMON HERE
-    fi
-    ;;
-esac
-
-exit 0
-
diff --git a/alpine-dom0/series b/alpine-dom0/series
new file mode 100644 (file)
index 0000000..0f07248
--- /dev/null
@@ -0,0 +1,4 @@
+xen-builder
+qemu-builder
+linux-builder
+dom0