diff --git a/docker/images/builder7/1.0/Dockerfile b/docker/images/builder7/1.0/Dockerfile new file mode 100644 index 00000000..466ff7ed --- /dev/null +++ b/docker/images/builder7/1.0/Dockerfile @@ -0,0 +1,136 @@ +FROM debian:7.8 +MAINTAINER Rob Sherwood + +# First round of dependences +RUN apt-get update && apt-get install -y \ + apt \ + apt-cacher-ng \ + apt-file \ + apt-utils \ + autoconf \ + automake1.9 \ + autotools-dev \ + bash-completion \ + bc \ + bind9-host \ + binfmt-support \ + binfmt-support \ + bison \ + bsdmainutils \ + build-essential \ + ccache \ + cdbs \ + cpio \ + debhelper \ + debhelper \ + debhelper \ + device-tree-compiler \ + devscripts \ + devscripts \ + dialog \ + dosfstools \ + dpkg-sig \ + emacs \ + file \ + flex \ + gcc \ + genisoimage \ + ifupdown \ + iproute \ + iputils-ping \ + kmod \ + less \ + libc6-dev \ + libedit-dev \ + libevent-dev \ + libi2c-dev \ + libpam-dev \ + libsnmp-dev \ + libtool \ + locales \ + lsof \ + make \ + mingetty \ + mtd-utils \ + mtools \ + multistrap \ + nano \ + ncurses-dev \ + netbase \ + net-tools \ + nfs-common \ + openssh-server \ + pkg-config \ + pkg-config \ + procps \ + psmisc \ + python \ + python-dnspython \ + python-yaml \ + qemu \ + qemu-user-static \ + realpath \ + realpath \ + rsyslog \ + rubygems \ + screen \ + squashfs-tools \ + sshpass \ + sudo \ + syslinux \ + texinfo=4.13a.dfsg.1-10 \ + traceroute \ + uboot-mkimage \ + vim-tiny \ + wget \ + xapt \ + zile \ + zip && \ + gem install --version 1.3.3 fpm + +# Now the unstable deps and cross compilers +# NOTE 1: texinfo 5.x and above breaks the buildroot build, thus the specific 4.x version +# NOTE 2: this cp is needed to fix an i2c compile problem +# NOTE 3: the /etc/apt/apt.conf.d/docker-* options break multistrap so +# that it can't find. Essential packages or resolve apt.opennetlinux.org +# NOTE 4: the default qemu-user-static (1.2) dies with a segfault in +# `make onl-powerpc`; use 1.4 instead + +RUN echo 'APT::Get::AllowUnauthenticated "true";\nAPT::Get::Assume-Yes "true";' | tee /etc/apt/apt.conf.d/99opennetworklinux && \ + echo "deb http://apt.opennetlinux.org/debian/ unstable main" | tee /etc/apt/sources.list.d/opennetlinux.list && \ + dpkg --add-architecture powerpc && \ + apt-get update && \ + apt-get install -y \ + binutils-powerpc-linux-gnu=2.22-7.1 \ + gcc-4.7-powerpc-linux-gnu \ + libc6-dev-powerpc-cross \ + libgomp1-powerpc-cross=4.7.2-4 && \ + xapt -a powerpc libedit-dev ncurses-dev libsensors4-dev libwrap0-dev libssl-dev libsnmp-dev libevent-dev libpam-dev && \ + update-alternatives --install /usr/bin/powerpc-linux-gnu-gcc powerpc-linux-gnu-gcc /usr/bin/powerpc-linux-gnu-gcc-4.7 10 && \ + rm /etc/apt/apt.conf.d/docker-* && \ + wget "https://launchpad.net/ubuntu/+source/qemu/1.4.0+dfsg-1expubuntu3/+build/4336762/+files/qemu-user-static_1.4.0%2Bdfsg-1expubuntu3_amd64.deb" && \ + dpkg -i qemu-user-static_1.4.0+dfsg-1expubuntu3_amd64.deb && \ + apt-get install python-pyroute2 + +# +# The i2c-dev.h user/kernel header conflict is a nightmare. +# +# The ONLP implementation expects a new file called to be in place which contains the correct user-space driver definitions. +# This should be manually populated here after the toolchains have been installed. +# +RUN cp /usr/include/linux/i2c-dev.h /usr/include/linux/i2c-devices.h && \ + cp /usr/include/linux/i2c-dev.h /usr/powerpc-linux-gnu/include/linux/i2c-devices.h + + +# +# Necessary toolchain symlinks +# +RUN ln -s /usr/bin/ar /usr/bin/x86_64-linux-gnu-ar && \ + ln -s /usr/bin/ld /usr/bin/x86_64-linux-gnu-ld && \ + ln -s /usr/bin/objcopy /usr/bin/x86_64-linux-gnu-objcopy + +# +# Docker shell and other container tools. +# +COPY docker_shell /bin/docker_shell +COPY container-id /bin/container-id diff --git a/docker/images/builder7/1.0/Makefile b/docker/images/builder7/1.0/Makefile new file mode 100644 index 00000000..1b75e3c5 --- /dev/null +++ b/docker/images/builder7/1.0/Makefile @@ -0,0 +1,20 @@ +VERSION=1.0 +USER=opennetworklinux +REPO=builder7 + +TOOLS=../../../tools/docker_shell ../../../tools/container-id + +build: check_version + cp $(TOOLS) . + docker build -t $(USER)/$(REPO):$(VERSION) . + rm -rf $(notdir $(TOOLS)) + +# +# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites +# when a new image is built but the VERSION variable is not updated. +# +check_version: + + +push: + docker push $(USER)/$(REPO):$(VERSION) diff --git a/docker/images/builder8/1.0/Dockerfile b/docker/images/builder8/1.0/Dockerfile new file mode 100644 index 00000000..ce5e623e --- /dev/null +++ b/docker/images/builder8/1.0/Dockerfile @@ -0,0 +1,149 @@ +FROM debian:8.2 +MAINTAINER Rob Sherwood + +# First round of dependences +RUN apt-get update && apt-get install -y \ + apt \ + apt-cacher-ng \ + apt-file \ + apt-utils \ + autoconf \ + automake \ + autotools-dev \ + bash-completion \ + bc \ + binfmt-support \ + binfmt-support \ + bison \ + bsdmainutils \ + build-essential \ + ccache \ + cdbs \ + cpio \ + debhelper \ + debhelper \ + debhelper \ + device-tree-compiler \ + devscripts \ + devscripts \ + dialog \ + dosfstools \ + dpkg-sig \ + file \ + flex \ + gcc \ + genisoimage \ + git \ + ifupdown \ + iproute \ + iputils-ping \ + isolinux \ + kmod \ + less \ + libc6-dev \ + libcurl4-nss-dev \ + libdouble-conversion-dev \ + libedit-dev \ + libevent-dev \ + libgoogle-glog-dev \ + libi2c-dev \ + libkrb5-dev \ + libnuma-dev \ + libsasl2-dev \ + libsnappy-dev \ + libssl-dev \ + libstdc++6=4.9.2-10 \ + libtool \ + locales \ + lsof \ + make \ + mingetty \ + mtd-utils \ + mtools \ + multistrap \ + nano \ + ncurses-dev \ + netbase \ + net-tools \ + nfs-common \ + openssh-server \ + pkg-config \ + pkg-config \ + procps \ + psmisc \ + python \ + python-debian \ + python-yaml \ + qemu \ + qemu-user-static \ + realpath \ + realpath \ + rsyslog \ + ruby \ + ruby-dev \ + rubygems \ + screen \ + squashfs-tools \ + sudo \ + syslinux-utils \ + traceroute \ + u-boot-tools \ + vim-tiny \ + wget \ + zile \ + zip +RUN gem install --version 1.3.3 fpm + +# Now the unstable deps and cross compilers +# NOTE 1: texinfo 5.x and above breaks the buildroot build, thus the specific 4.x version +# NOTE 2: this cp is needed to fix an i2c compile problem +# NOTE 3: the /etc/apt/apt.conf.d/docker-* options break multistrap so +# that it can't find. Essential packages or resolve apt.opennetlinux.org +# NOTE 4: the default qemu-user-static (1.2) dies with a segfault in +# `make onl-powerpc`; use 1.4 instead + +RUN echo 'APT::Get::AllowUnauthenticated "true";\nAPT::Get::Assume-Yes "true";' | tee /etc/apt/apt.conf.d/99opennetworklinux && \ + echo "deb http://apt.opennetlinux.org/debian/ unstable main" | tee /etc/apt/sources.list.d/opennetlinux.list && \ + curl http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | sudo apt-key add - && \ + echo "deb http://emdebian.org/tools/debian/ jessie main" | tee /etc/apt/sources.list.d/embedian-jessie.list && \ + dpkg --add-architecture powerpc && \ + apt-get update && \ + apt-get install -y \ + binutils-powerpc-linux-gnu \ + libc6-dev-powerpc-cross \ + crossbuild-essential-powerpc \ + cross-gcc-dev \ + folly \ + fbthrift \ + wangle \ + libgomp1-powerpc-cross && \ + wget "http://ftp.us.debian.org/debian/pool/main/t/texinfo/texinfo_4.13a.dfsg.1-10_amd64.deb" && \ + dpkg -i texinfo_4.13a.dfsg.1-10_amd64.deb && \ + wget "http://ftp.us.debian.org/debian/pool/main/e/emdebian-crush/xapt_2.2.19_all.deb" && \ + dpkg -i xapt_2.2.19_all.deb && \ + + xapt -a powerpc libedit-dev ncurses-dev libsensors4-dev libwrap0-dev libssl-dev libsnmp-dev +# update-alternatives --install /usr/bin/powerpc-linux-gnu-gcc powerpc-linux-gnu-gcc 10 && + +# +# The i2c-dev.h user/kernel header conflict is a nightmare. +# +# The ONLP implementation expects a new file called to be in place which contains the correct user-space driver definitions. +# This should be manually populated here after the toolchains have been installed. +# +RUN cp /usr/include/linux/i2c-dev.h /usr/include/linux/i2c-devices.h && \ + cp /usr/include/linux/i2c-dev.h /usr/powerpc-linux-gnu/include/linux/i2c-devices.h + +RUN rm /etc/apt/apt.conf.d/docker-* && \ + wget "https://launchpad.net/ubuntu/+source/qemu/1.4.0+dfsg-1expubuntu3/+build/4336762/+files/qemu-user-static_1.4.0%2Bdfsg-1expubuntu3_amd64.deb" && \ + dpkg -i qemu-user-static_1.4.0+dfsg-1expubuntu3_amd64.deb + +# +# Copy the docker shell init script to /bin +# +COPY docker_shell /bin/docker_shell +COPY container-id /bin/container-id + +RUN apt-get install -y \ + libstdc++6=4.9.2-10 --force-yes +RUN apt-get install libboost-all-dev cmake diff --git a/docker/images/builder8/1.0/Makefile b/docker/images/builder8/1.0/Makefile new file mode 100644 index 00000000..8ada33c8 --- /dev/null +++ b/docker/images/builder8/1.0/Makefile @@ -0,0 +1,16 @@ +VERSION=1.0 +USER=opennetworklinux +REPO=builder8 + +TOOLS=../../../tools/docker_shell ../../../tools/container-id + +build: check_version + cp $(TOOLS) . + docker build -t $(USER)/$(REPO):$(VERSION) . + rm -rf $(notdir $(TOOLS)) + +# +# Todo: Query remote repository to see if the request version already exists to avoid accidental overwrites +# when a new image is built but the VERSION variable is not updated. +# +check_version: diff --git a/docker/tools/Makefile b/docker/tools/Makefile new file mode 100644 index 00000000..f71f79d4 --- /dev/null +++ b/docker/tools/Makefile @@ -0,0 +1,3 @@ +deb: + rm -rf packages + @MAKE=$(MAKE) ../../tools/onlpm.py --packagedirs=`pwd` --no-pkg-cache --build all --repo . diff --git a/docker/tools/PKG.yml b/docker/tools/PKG.yml new file mode 100644 index 00000000..9ad2770d --- /dev/null +++ b/docker/tools/PKG.yml @@ -0,0 +1,14 @@ +common: + arch: all + version: 1.0.0 + copyright: Copyright 2013, 2014, 2015 Big Switch Networks + maintainer: support@bigswitch.com + +packages: + - name: onl-docker-tools + summary: Open Network Linux Docker Build Tools + + files: + onlbuilder : /usr/local/bin/onlbuilder + + changelog: Initial diff --git a/docker/tools/container-id b/docker/tools/container-id new file mode 100755 index 00000000..c9e34827 --- /dev/null +++ b/docker/tools/container-id @@ -0,0 +1,16 @@ +#!/usr/bin/python +# -*- python -*- + +import re +import sys + +for line in open('/proc/self/cgroup').readlines(): + m = re.search(r'docker-(?P[0-9a-f]{64})', line) + if m: + print m.group('id')[0:12] + sys.exit(0) + +sys.exit(1) + + + diff --git a/docker/tools/docker_shell b/docker/tools/docker_shell new file mode 100755 index 00000000..9c49883e --- /dev/null +++ b/docker/tools/docker_shell @@ -0,0 +1,159 @@ +#!/usr/bin/python + +import os +import sys +import argparse +import datetime +import subprocess +import pwd +import logging +import re + +logging.basicConfig() +logger = logging.getLogger('docker_shell') +logger.setLevel(logging.INFO) + +g_dry = False + +def fatal(msg, rc=1): + logger.critical(msg) + sys.exit(rc) + +def execute(cmd, msg=None): + logger.debug('+ %s ...' % cmd) + rc = 0 + if not g_dry: + rc = subprocess.call(cmd, shell=True) + if rc == 0: + logger.debug('+ %s [OK]' % cmd) + else: + logger.debug('+ %s [FAILED (%d)]' % (cmd, rc)) + if msg: + fatal(msg) + else: + logger.debug('+ %s [DRY]' % cmd) + return rc + +class User(object): + + default_shell="/bin/bash" + default_user="root:0" + + def __init__(self, uspec): + + (self.name, c, rest) = uspec.partition(':') + self.validate_name() + + (self.uid, c, rest) = rest.partition(':') + self.validate_uid() + + (self.shell, c, rest) = rest.partition(':') + if self.shell == '': + self.shell = User.default_shell + if not os.path.exists(self.shell): + fatal("Requested shell '%s' does not exist." % self.shell) + + (self.home, c, rest) = rest.partition(':') + + logger.debug("User(%s) initialized." % self) + + def __str__(self): + return "%s:%s:%s" % (self.name, self.uid, self.shell) + + def validate_name(self): + NAME_REGEX=r"[a-z][-a-z0-9]*" + if re.match(NAME_REGEX, self.name) is None: + fatal("'%s' is not a valid username." % self.name) + logger.debug("username %s is validated." % self.name) + + def validate_uid(self): + try: + self.uid = int(self.uid) + logger.debug("uid %d is validated." % self.uid) + except: + if self.uid == '': + if self.name == 'root': + self.uid = 0 + else: + fatal("A user id is required for user '%s'" % self.name) + else: + fatal("'%s' is not a valid user id." % self.uid) + + + def add(self): + logger.debug("Process user %s ..." % self) + existing_user = None + try: + existing_user = pwd.getpwnam(self.name) + if existing_user and existing_user.pw_uid != self.uid: + fatal("User %s already exists with a different uid (%d).\n" % (self.name, existing_user.pw_uid)) + except KeyError: + logger.debug("User %s does not exist." % self.name) + + try: + existing_uid = pwd.getpwuid(self.uid) + if existing_uid and existing_uid.pw_name != self.name: + fatal("UID %d already exists with a different user (%s).\n" % (self.uid, existing_uid.pw_name)) + except KeyError: + logger.debug("UID %d does not exist." % self.uid) + + if existing_user: + logger.debug("User %s already exists." % self) + else: + logger.debug("Creating user %s ..." % (self)) + cmd = "useradd %s --uid %s --shell %s" % (self.name, self.uid, self.shell) + if self.home not in [ None, '' ]: + cmd += " -d %s" % (self.home) + execute(cmd, "User creation failed for user %s" % self) + + if not g_dry and self.name != 'root': + with open("/etc/sudoers.d/%s" % self.name, "w") as f: + f.write("%s ALL=(ALL:ALL) NOPASSWD:ALL\n" % self.name) + + +############################################################ + +ap = argparse.ArgumentParser("ONL Docker Shell Build and Development Container Init Script.") + +ap.add_argument("--user", "-u", + help="Run as the given user:uid. The user is created if necessary. The default is %s" % User.default_user, + default=User.default_user, + metavar="USERNAME:UID[:SHELL]") +ap.add_argument("--addusers", "-a", + help="Add additional users.", + nargs='+', + metavar="USERNAME:UID[:SHELL]", + default=[]) +ap.add_argument("--verbose", "-v", + help="Set verbose logging.", + action='store_true') +ap.add_argument("--start-cacher", + help="Start apt-cacher-ng in the container. It does not run by default.", + action='store_true') +ap.add_argument("--dry", + help="Dry run.", + action='store_true') +ap.add_argument('--command', '-c', + help="The command to run. All arguments after this option are considered part of the command.", + nargs=argparse.REMAINDER, + default=["/bin/bash"]) + +ops = ap.parse_args() +opsdict = vars(ops) +g_dry = ops.dry + +if ops.verbose or ops.dry: + logger.setLevel(logging.DEBUG) + +g_user = User(ops.user) +g_user.add() + +for u in ops.addusers: + User(u).add() + +if ops.start_cacher: + execute("/etc/init.d/apt-cacher-ng start", "The apt-cacher-ng service could not be started.") + +# Fixme: change this to os.execvp() +c = "/usr/bin/sudo -E -u %s %s" % (g_user.name, " ".join(ops.command)) +sys.exit(execute(c)) diff --git a/docker/tools/onlbuilder b/docker/tools/onlbuilder new file mode 100755 index 00000000..07c34f36 --- /dev/null +++ b/docker/tools/onlbuilder @@ -0,0 +1,155 @@ +#!/usr/bin/python + +import os +import sys +import argparse +import datetime +import getpass +import subprocess +import logging +import pwd + +logging.basicConfig() +logger = logging.getLogger('onlbuilder') +logger.setLevel(logging.INFO) + +g_current_user = getpass.getuser() +g_current_uid = os.getuid() +g_timestamp = datetime.datetime.now().strftime("%Y-%m-%d.%H%M%S") + +g_default_image_name="opennetworklinux/builder7:1.0" +g_default_container_name = "%s_%s" % (g_current_user, g_timestamp) +g_default_user="%s:%s" % (g_current_user, g_current_uid) + +ap = argparse.ArgumentParser("ONL Docker Build") + +ap.add_argument("--dry", + help="Dry run.", + action='store_true') + +ap.add_argument("--verbose", "-v", + help="Verbose logging.", + action='store_true') + +ap.add_argument("--image", "-i", + help="The docker image to use. The default is %s." % g_default_image_name, + default=g_default_image_name) + +ap.add_argument("--exec", "-e", + help="Execute in running container instead of starting a new one.", + metavar='CONTAINER|NAME', + dest='exec_') + +ap.add_argument("--user", "-u", + help="Run as the given user:uid. Create if necessary. The default is you (%s)" % g_default_user, + default=g_default_user, + metavar='USERNAME:UID') + +ap.add_argument("--adduser", "-a", + help="Add additional user(s). These users will only be added to the container.", + nargs="+", + metavar='USENAME:UID') + +ap.add_argument("--name", "-n", + help="Set the container name. The default will be your username concatenated with the current timestamp (%s)." % g_default_container_name, + default=g_default_container_name) + +ap.add_argument("--workdir", "-w", + help="Set the working directory. The default will be the current working directory.", + default=os.getcwd()) + +ap.add_argument("--no-ssh", + help="Do not include current SSH Agent credentials. The default is to include them if present.", + action='store_true') + +ap.add_argument("--use-running", "-r", + help="Use an existing, matching, running container instead of starting a new one (if available).", + action='store_true'), + +ap.add_argument("--isolate", + help="Build isolation mode. Only the isolate directories are mounted, and a new network namespace is used. The --hostname becomes active in this mode.", + nargs='*') + +ap.add_argument("--hostname", + help="Change hostname in isolation mode.") +ap.add_argument("--non-interactive", + help="Non-interactive mode.", + action='store_true') + +ap.add_argument("--volumes", + help="Mount additional volumes.", + nargs='+', + metavar='DIRECTORY', + default=[]) + +ap.add_argument("--command", "-c", + help="Explicit command to run. All arguments after -c are considered to be part of the command.", + nargs=argparse.REMAINDER, + default=['bash']) + +ops = ap.parse_args() + +if ops.verbose or ops.dry: + logger.setLevel(logging.DEBUG) + +logger.debug('arguments: %s\n' % vars(ops)) + +if ops.use_running: + sys.stderr.write("The --r option is not yet implemented.") + # Todo -- query running containers that match and set ops.exec_cid + sys.exit(1) + +g_ssh_options = '' +g_ssh_auth_sock = os.getenv('SSH_AUTH_SOCK') +if g_ssh_auth_sock and not ops.no_ssh: + g_ssh_dir = os.path.dirname(g_ssh_auth_sock) + g_ssh_options = '-v %s:%s -e SSH_AUTH_SOCK=%s' % (g_ssh_dir, g_ssh_dir, g_ssh_auth_sock) + +g_arg_d=vars(ops) + +g_arg_d['username'] = g_arg_d['user'].split(':')[0] +g_arg_d['ssh_options'] = g_ssh_options +g_arg_d['interactive'] = " " if ops.non_interactive else " -i " +g_arg_d['commands'] = " ".join(ops.command) + +# Get the home directory of the requested user. +try: + passwd = pwd.getpwnam(g_arg_d['username']) + g_arg_d['home'] = passwd.pw_dir +except KeyError: + # Not a local user. Just skip setting $HOME + pass + +if ops.exec_: + g_docker_arguments = "docker exec %(interactive)s -t %(exec_)s /bin/docker_shell --user %(user)s" % g_arg_d +else: + + ops.volumes += [ '/lib/modules' ] + g_arg_d['volume_options'] = " ".join( [ " -v %s:%s " % (v, v) for v in ops.volumes ] ) + + g_docker_arguments = "docker run --privileged %(interactive)s -t -e DOCKER_IMAGE=%(image)s --name %(name)s %(ssh_options)s %(volume_options)s " % g_arg_d + + if ops.isolate is not None: + if len(ops.isolate) is 0: + ops.isolate.append(os.getcwd()) + + isolates = [ os.path.abspath(i) for i in ops.isolate ] + g_docker_arguments += " -e HOME=%s -w %s " % (isolates[0], isolates[0]) + for d in isolates: + g_docker_arguments += " -v %s:%s " % (d,d) + + if ops.hostname: + g_docker_arguments += " -h %s" % ops.hostname + + else: + # Development host mode + g_docker_arguments += "-e USER=%(username)s --net host -w %(workdir)s " % g_arg_d + if 'home' in g_arg_d: + g_docker_arguments += " -e HOME=%(home)s -v %(home)s:%(home)s" % g_arg_d + +g_docker_arguments += " %(image)s /bin/docker_shell --user %(user)s -c %(commands)s" % g_arg_d + +g_docker_arguments = " ".join(g_docker_arguments.split()) +logger.debug("running: %s" % g_docker_arguments) +if not ops.dry: + sys.exit(subprocess.call(g_docker_arguments, shell=True)) diff --git a/docs/Building.md b/docs/Building.md new file mode 100644 index 00000000..a2e8038c --- /dev/null +++ b/docs/Building.md @@ -0,0 +1,107 @@ +#How to Build Open Network Linux + +In case you are not interested in building ONL from scratch +(it takes a while) you can download pre-compiled binaries from +http://opennetlinux.org/binaries . + + +Build Hosts and Environments +------------------------------------------------------------ +ONL builds with Docker so the only requirements on the build system is: + +- docker # to grab the build workspace +- binfmt-support # kernel support for ppc builds +- About 40G of disk free space # to build all images + +All of the testing is done with Debian, other Linux distributions may work, but we suggest using Debian 8. + # apt-get install lxc-docker binfmt-support + + +Build ONL Summary +------------------------------------------------------------ + #> git clone https://github.com/opencomputeproject/OpenNetworkLinux + #> cd OpenNetworkLinux + #> make docker # enter the docker workspace + user@system:/path/to/OpenNetworkLinux$ source setup.env # import variables necessary to build OpenNetworkLinux + #> make onl-x86 onl-powerpc # make onl for $platform (currently x86 or powerpc) +The resulting ONIE installers are in +$ONL/builds/installer/$ARCH/all/onl-$VERSION-all.installer, +and the SWI files (if you want them) are in +$ONL/builds/swi/$ARCH/all/onl-$VERSION-all.swi. + + + +#Installing Docker Gotchas + +Docker installer oneliner (for reference: see docker.com for details) + + # apt-get install -y lxc-docker +or + + # wget -qO- https://get.docker.com/ | sh + + +Common docker related issues: + +- Check out http://docs.docker.com/installation/debian/ for detailed instructions +- You may have to update your kernel to 3.10+ +- Beware that `apt-get install docker` installs a dock application not docker :-) You want the lxc-docker package instead. +- Some versions of docker are unhappy if you use a local DNS caching resolver: + - e.g., you have 127.0.0.1 in your /etc/resolv.conf + - if you have this, specify DNS="--dns 8.8.8.8" when you enter the docker environment + - e.g., `make DNS="--dns 8.8.8.8" docker` + +Consider enabling builds for non-privileged users with: + +- `sudo usermod -aG docker $USER` +- If you run as non-root without this, you will get errors like "..: dial unix /var/run/docker.sock: permission denied" +- Building as root is fine as well (it immediately jumps into a root build shell), so this optional + +#Additional Build Details +---------------------------------------------------------- + +The rest of this guide talks about how to build specific +sub-components of the ONL ecosystem and tries to overview +all of the various elements of the build. + +Build all .deb packages for all architectures +---------------------------------------------------------- + #> cd $ONL/packages + #> make + #> find $ONL/REPO -name \*.deb # all of the .deb files end up here + +A number of things will happen automatically, including: + +- git submodule checkouts and updates for kernel, loader, and additional code repositories +- automatic builds of all debian packages and their dependencies +- automatic download of binary-only .deb packages from apt.opennetlinux.org + +After all components have been built, your can build an ONL +Software Image from those components. + +Adding/Removing packages from a SWI: +------------------------------------------------------------ + +The list of packages for a given SWI are in + + $ONL/packages/base/any/rootfs/common/$ARCH-packages.yml # for $ARCH specific packages + $ONL/packages/base/any/rootfs/common/common-packages.yml # for $ARCH-independent packages + +Build a software image (SWI) for all powerpc platforms: +------------------------------------------------------------ + #> cd $ONL/builds/swi/powerpc/all + #> make + #> ls *.swi + onl-27f67f6-powerpc-all-2014.01.27.10.59.swi onl-27f67f6-powerpc-all.swi + #> + +Build an ONIE-compatible installer for all powerpc platforms. +This will incorporate the SWI you just built or build it dynamically if not. + +This installer image can be served to ONIE on Quanta or Accton platforms: +------------------------------------------------------------ + #> cd $ONL/builds/installer/powerpc/all + #> make + #> ls *.installer + latest.installer onl-27f67f6-powerpc-all.2014.01.27.11.05.installer + #> diff --git a/packages/base/any/initrds/buildroot/builds/buildroot.config-powerpc b/packages/base/any/initrds/buildroot/builds/buildroot.config-powerpc index ec76348d..74334564 100644 --- a/packages/base/any/initrds/buildroot/builds/buildroot.config-powerpc +++ b/packages/base/any/initrds/buildroot/builds/buildroot.config-powerpc @@ -84,9 +84,9 @@ BR2_HOST_DIR="$(BASE_DIR)/host" # # Mirrors and Download locations # -BR2_PRIMARY_SITE="http://switch-nfs/export/buildroot-download-cache/dl" +BR2_PRIMARY_SITE="$(BUILDROOTMIRROR)" BR2_PRIMARY_SITE_ONLY=n -BR2_BACKUP_SITE="http://sources.buildroot.net/" +BR2_BACKUP_SITE="https://raw.githubusercontent.com/opennetworklinux/buildroot-download-cache/master/dl" BR2_KERNEL_MIRROR="http://www.kernel.org/pub/" BR2_GNU_MIRROR="http://ftp.gnu.org/pub/gnu" BR2_DEBIAN_MIRROR="http://ftp.debian.org" diff --git a/packages/base/any/initrds/buildroot/builds/buildroot.config-x86_64 b/packages/base/any/initrds/buildroot/builds/buildroot.config-x86_64 index c8aaefd3..0f008093 100644 --- a/packages/base/any/initrds/buildroot/builds/buildroot.config-x86_64 +++ b/packages/base/any/initrds/buildroot/builds/buildroot.config-x86_64 @@ -59,9 +59,9 @@ BR2_HOST_DIR="$(BASE_DIR)/host" # # Mirrors and Download locations # -BR2_PRIMARY_SITE="http://switch-nfs/export/buildroot-download-cache/dl" +BR2_PRIMARY_SITE="$(BUILDROOTMIRROR)" # BR2_PRIMARY_SITE_ONLY is not set -BR2_BACKUP_SITE="http://sources.buildroot.net/" +BR2_BACKUP_SITE="https://raw.githubusercontent.com/opennetworklinux/buildroot-download-cache/master/dl" BR2_KERNEL_MIRROR="http://www.kernel.org/pub/" BR2_GNU_MIRROR="http://ftp.gnu.org/pub/gnu" BR2_DEBIAN_MIRROR="http://ftp.debian.org" diff --git a/setup.env b/setup.env index d07696ef..43ecfa57 100755 --- a/setup.env +++ b/setup.env @@ -29,5 +29,9 @@ $ONL/tools/submodules.py $ONL sm/bigcode # Version files $ONL/tools/make-versions.py --import-file=$ONL/tools/onlvi --class-name=OnlVersionImplementation --output-dir $ONL/make +# +# buildroot download mirror. We suggest you setup a local repository containing these contents for faster local builds. +# +export BUILDROOTMIRROR=${BUILDROOTMIRROR:-"http://buildroot.hw.bigswitch.com/dl"}