-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bonneville-container #4
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d8db21f
Add bonneville-container
fdawg4l 8f8174b
Merge OS specific files into packages
fdawg4l 8533436
Refer to syslinux and isolinux to build iso
fdawg4l 7003c2a
Add license verbiage to all .go files
fdawg4l fafc638
Update package paths to reflect github.com/vmware/vic
fdawg4l File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
|
||
[ -n "$DEBUG" ] && set -x | ||
|
||
NAME=container | ||
|
||
# set default SRCDIR & BINDIR for local builds | ||
if [ "${SRCDIR}" == "" ]; then | ||
SRCDIR="$(cd `dirname "$0"` && pwd)" | ||
fi | ||
|
||
if [ "${BINDIR}" == "" ]; then | ||
BINDIR=${SRCDIR}/../binary | ||
fi | ||
BINBASE=$(basename $BINDIR) | ||
|
||
# allow building of specific targets | ||
if [ "$#" == 0 ]; then | ||
TARGETS="${SRCDIR}/targets/*" | ||
elif [ "$#" == 1 ]; then | ||
TARGETS="${SRCDIR}/targets/$1" | ||
else | ||
TARGETS="${SRCDIR}/targets/$1" | ||
shift | ||
for arg in "$@"; do | ||
TARGETS+=" ${SRCDIR}/targets/$arg" | ||
done | ||
fi | ||
|
||
export JOB=${JOB_NAME:-$NAME}_${BUILD_NUMBER:-local_build} | ||
DATE=$(date -u +%Y/%m/%d_@_%H:%M:%S) | ||
|
||
echo SRCDIR=${SRCDIR} | ||
echo BINDIR=${BINDIR} | ||
mkdir -p ${BINDIR} | ||
|
||
for i in $TARGETS; do | ||
TNAME=${NAME}-$(basename $i) | ||
|
||
git_args="--git-dir=$SRCDIR/.git --work-tree=$SRCDIR" | ||
branch_name="$(git $git_args symbolic-ref HEAD 2>/dev/null)" || | ||
branch_name="detached_head" # detached HEAD | ||
BRANCH=${branch_name##refs/heads/} | ||
SHA=$(git $git_args rev-parse --short HEAD) | ||
|
||
cp -r ${SRCDIR}/tether ${i}/tether | ||
|
||
# if there is a base build, run that | ||
if [ -d ${i}/base ]; then | ||
docker build -t ${TNAME}-base ${i}/base || ( echo "Base build failed for $i" && break ) | ||
if [ $? -ne 0 ]; then | ||
echo "Base build failed for $i: $?" | ||
break | ||
fi | ||
fi | ||
docker build --no-cache -t ${TNAME}-build ${i} | ||
SUCCESS=$? | ||
|
||
|
||
if [ $SUCCESS -eq 0 ]; then | ||
BUILD_ID="$DATE@$BRANCH:$SHA" | ||
docker run --name=$JOB-${TNAME} -e BUILD_ID=$BUILD_ID -e BINBASE=${BINBASE} -e ISOOUT=/binary/${TNAME}.iso ${TNAME}-build:latest && { | ||
docker cp ${JOB}-${TNAME}:/tmp/${BINBASE} ${BINDIR}/.. | ||
} | ||
|
||
SUCCESS=$? | ||
fi | ||
|
||
# clean up now the build's complete | ||
rm -fr ${i}/tether | ||
docker rm -v ${JOB}-${TNAME} | ||
|
||
if [ $SUCCESS -ne 0 ]; then | ||
echo "Build failed for $i: $SUCCESS" | ||
break | ||
fi | ||
done | ||
|
||
# make the return value for the script reflect the status | ||
test $SUCCESS -eq 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- etc/udev/rules.d/60-persistent-storage.rules 2015-03-18 20:00:03.947462040 +0000 | ||
+++ etc/udev/rules.d/60-persistent-storage.rules 2015-03-18 19:59:42.043458703 +0000 | ||
@@ -38,8 +38,9 @@ | ||
KERNEL!="sr*", OPTIONS+="watch" | ||
|
||
# by-label/by-uuid links (filesystem metadata) | ||
+IMPORT{program}="/sbin/blkid -o udev -p $tempnode" | ||
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" | ||
-ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" | ||
+ ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}", RUN+="/bin/mknod /mnt/.tether/volumes/$env{ID_FS_LABEL_ENC} b $major $minor" | ||
|
||
# by-id (World Wide Name) | ||
ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBSYSTEM=="cpu", ACTION=="add", DEVPATH=="/devices/system/cpu/cpu[0-9]*", TEST=="online", ATTR{online}="1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SUBSYSTEM=="memory", ACTION=="add", DEVPATH=="/devices/system/memory/memory[0-9]*", TEST=="state", ATTR{state}="online" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
FROM container-linux-base | ||
|
||
COPY 60-persistent-storage.rules.diff /tmp/ | ||
RUN patch --unified -d $ROOTFS -p 0 --input=/tmp/60-persistent-storage.rules.diff | ||
|
||
COPY 99-vmware-memhotplug.rules $ROOTFS/etc/udev/rules.d/ | ||
COPY 99-vmware-cpuhotplug.rules $ROOTFS/etc/udev/rules.d/ | ||
|
||
COPY isolinux $BOOTFS/isolinux | ||
RUN cp /usr/lib/ISOLINUX/isolinux.bin $BOOTFS/isolinux/isolinux.bin | ||
RUN cp /usr/lib/syslinux/modules/bios/ldlinux.c32 $BOOTFS/isolinux/ldlinux.c32 | ||
COPY vmfork.sh $ROOTFS/ | ||
|
||
#RUN git clone https://ghicken@enatai-gerrit.eng.vmware.com/bonneville-container $TETHER && cd $TETHER && git checkout proxy | ||
# install the generic tether dependencies | ||
COPY tether $TETHER/tether/ | ||
RUN cd $TETHER/tether && gpm install | ||
|
||
# Enable SSH debug | ||
#RUN sed -i -e 's/const debugMux = false/const debugMux = true/' /go/src/golang.org/x/crypto/ssh/mux.go && sed -i -e 's/const debugHandshake = false/const debugHandshake = true/' /go/src/golang.org/x/crypto/ssh/handshake.go | ||
|
||
RUN cd $TETHER/tether && \ | ||
GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go test -a -x -tags netgo -installsuffix netgo -v ./... | ||
|
||
RUN cd $TETHER/tether/cmd/tether && \ | ||
GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -a -x -tags netgo -installsuffix netgo -o tether-linux && \ | ||
ldd tether-linux | grep -q 'not a dynamic executable' && \ | ||
cp -f tether-linux $ROOTFS/bin/tether && \ | ||
ln -sf ../bin/tether $ROOTFS/sbin/init && return 0 || \ | ||
echo "error: tether is not static" && return 1 | ||
|
||
COPY rpctool.go $TETHER/ | ||
RUN cd $TETHER/ && \ | ||
GOARCH=amd64 GOOS=linux go build -a -x -o $ROOTFS/sbin/rpctool --ldflags '-extldflags "-static"' rpctool.go | ||
|
||
COPY init $ROOTFS/init | ||
|
||
ENTRYPOINT ["/bin/bash"] | ||
|
||
# construct a script to generate the rootfs and iso - we can't do it as a command as docker gets | ||
# confused by something and it doesn't parse as a valid json array | ||
RUN echo "sed -i -e \"s!BUILD_ID!\$BUILD_ID!\" $BOOTFS/isolinux/boot.msg && \ | ||
cd $ROOTFS && find | cpio -o -H newc | gzip --fast > $BOOTFS/core.gz && \ | ||
xorriso -publisher 'VMware Inc.' -as mkisofs -V bonneville-tcl \ | ||
-l -J -R -no-emul-boot -boot-load-size 4 -boot-info-table \ | ||
-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \ | ||
-o \$ISOOUT /bootfs && \ | ||
mv /binary /tmp/\$BINBASE" > /tmp/generate.sh && chmod a+x /tmp/generate.sh | ||
|
||
# Construct root filesystem and generate the ISO to stdout | ||
# To write the iso to a file, set ISOOUT to the target path (directory must exist) | ||
CMD ["/tmp/generate.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
FROM golang:1.5.3 | ||
|
||
RUN apt-get update && apt-get -y install curl cpio ssh-client squashfs-tools xorriso git gcc make vim patch rpm busybox-static isolinux syslinux | ||
RUN cd /tmp && git clone https://github.com/pote/gpm.git && cd gpm && ./configure && make install | ||
|
||
# Prepare kernel | ||
ENV TCL_BASE http://tinycorelinux.net/6.x | ||
ENV TCL_BASE http://ftp.nluug.nl/os/Linux/distr/tinycorelinux/6.x | ||
ENV TCL_CORE $TCL_BASE/x86_64/release/distribution_files | ||
ENV TCL_TCZ $TCL_BASE/x86_64/tcz | ||
ENV TCL_TCZ_X86 $TCL_BASE/x86/tcz | ||
|
||
ENV PHOTON_RPM_REPO http://bonneville.eng.vmware.com:8080/job/bonneville-kernel/lastSuccessfulBuild/artifact/binary/ | ||
ENV PHOTON_KERNEL_RPM linux-esx-4.2.0-10.x86_64.rpm | ||
|
||
ENV ROOTFS /rootfs | ||
ENV BOOTFS /bootfs/boot | ||
ENV KERNEL_TREE /linux_tree | ||
ENV ISOOUT stdio:/dev/fd/1 | ||
|
||
# Extract the kernel rpm contents | ||
RUN mkdir -p $KERNEL_TREE && cd $KERNEL_TREE && \ | ||
curl -L $PHOTON_RPM_REPO/$PHOTON_KERNEL_RPM -o /tmp/$PHOTON_KERNEL_RPM && \ | ||
rpm2cpio /tmp/$PHOTON_KERNEL_RPM | cpio -id | ||
|
||
# Copy the kernel to the boot folder | ||
RUN mkdir -p $BOOTFS && cd $BOOTFS && \ | ||
mv $KERNEL_TREE/boot/vmlinuz-esx-4.2.0 vmlinuz64 | ||
|
||
# Install the TCZ dependencies | ||
ENV TCZ_DEPS iproute2.tcz libtirpc.tcz | ||
|
||
# Install the TCZ dependencies | ||
RUN mkdir -p $ROOTFS && cd $ROOTFS && \ | ||
curl -L $TCL_CORE/corepure64.gz | gunzip | cpio -id && \ | ||
for dep in $TCZ_DEPS; do \ | ||
echo "Download $TCL_TCZ/$dep" &&\ | ||
(curl -L -o /tmp/$dep $TCL_TCZ/$dep || exit 1) && \ | ||
(unsquashfs -f -d $ROOTFS /tmp/$dep || exit 1) && \ | ||
rm -f /tmp/$dep ;\ | ||
done | ||
|
||
RUN ssh-keygen -t rsa -b 1024 -f $ROOTFS/id_rsa -N "" | ||
|
||
# Replace the modules with what came from the photon kernel rpm. | ||
RUN rm -rf $ROOTFS/lib/modules/ $ROOTFS/lib/firmware/ && \ | ||
mkdir -p $ROOTFS/lib/modules/ && \ | ||
mv $KERNEL_TREE/lib/modules/ $ROOTFS/lib/ | ||
|
||
# Copy static busybox binary into rootfs | ||
RUN cp /bin/busybox $ROOTFS/bin/busybox.static | ||
COPY default.script $ROOTFS/etc/udhcpc/default.script | ||
|
||
# Location of the tether build | ||
ENV TETHER /go/src/github.com/vmware/vic/bootstrap | ||
|
||
RUN mkdir -p /binary | ||
|
||
# install the target specific dependencies | ||
COPY Godeps $TETHER/ | ||
RUN cd $TETHER && gpm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
golang.org/x/crypto/ssh | ||
github.com/docker/docker/pkg/term | ||
github.com/kr/pty | ||
github.com/vishvananda/netlink | ||
github.com/Sirupsen/logrus | ||
github.com/vmware/vmw-guestinfo/rpcvmx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/sh | ||
# Busybox udhcpc dispatcher script. Copyright (C) 2009 by Axel Beckert. | ||
# | ||
# Based on the busybox example scripts and the old udhcp source | ||
# package default.* scripts. | ||
# | ||
# Modified by Project Bonneville Authors | ||
|
||
RESOLV_CONF="/etc/resolv.conf" | ||
|
||
TETHER_DIR="/.tether" | ||
|
||
case $1 in | ||
bound|renew) | ||
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" | ||
[ -n "$subnet" ] && NETMASK="netmask $subnet" | ||
|
||
$TETHER_DIR/ifconfig $interface $ip $BROADCAST $NETMASK | ||
|
||
if [ -n "$router" ]; then | ||
echo "$0: Resetting default routes" | ||
while $TETHER_DIR/route del default gw 0.0.0.0 dev $interface; do :; done | ||
|
||
metric=0 | ||
for i in $router; do | ||
$TETHER_DIR/route add default gw $i dev $interface metric $metric | ||
metric=$(($metric + 1)) | ||
done | ||
fi | ||
|
||
# Update resolver configuration file | ||
R="" | ||
[ -n "$domain" ] && R="domain $domain | ||
" | ||
for i in $dns; do | ||
echo "$0: Adding DNS $i" | ||
R="${R}nameserver $i | ||
" | ||
done | ||
|
||
echo -n "$R" > "$RESOLV_CONF" | ||
;; | ||
|
||
deconfig) | ||
$TETHER_DIR/ifconfig $interface 0.0.0.0 | ||
;; | ||
|
||
leasefail) | ||
echo "$0: Lease failed: $message" | ||
;; | ||
|
||
nak) | ||
echo "$0: Received a NAK: $message" | ||
;; | ||
|
||
*) | ||
echo "$0: Unknown udhcpc command: $1"; | ||
exit 1; | ||
;; | ||
esac |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal URL, does it matter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does. Thanks for pointing it out. I'll modify this in another PR. The goal of this PR is just to copy the bits on bonneville-container, strip the stuff that violates the license, and do a bit of cleanup.
I'll make an issue to capture this and assign it to myself. I'll take care of this in the very near future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hickeng Is there a public rpm repo which this bonneville.eng repo is mirrored to?