diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-06-23 04:37:36 +0200 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-06-23 04:37:36 +0200 |
commit | 9113afff3a538a6e9a7f788189028778aa75fe1f (patch) | |
tree | 644be7e1698812eec85adaa6884643f2a775b7e6 | |
parent | 2268a65ba8edf92400ea185a36e784365de2e853 (diff) | |
parent | 85bc557f4c458c08b096abfd5100cc324a2a2ee0 (diff) | |
download | vyos-build-9113afff3a538a6e9a7f788189028778aa75fe1f.tar.gz vyos-build-9113afff3a538a6e9a7f788189028778aa75fe1f.zip |
Merge branch 'current'
127 files changed, 2480 insertions, 68 deletions
@@ -1,2 +1,5 @@ build/* *.pyc +packer_build/* +packer_cache/* +key/* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..773dd113 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,141 @@ +[submodule "packages/vyatta-bash"] + path = packages/vyatta-bash + url = https://github.com/vyos/vyatta-bash.git +[submodule "packages/vyatta-cfg"] + path = packages/vyatta-cfg + url = https://github.com/vyos/vyatta-cfg.git +[submodule "packages/vyatta-op"] + path = packages/vyatta-op + url = https://github.com/vyos/vyatta-op.git +[submodule "packages/vyatta-cfg-system"] + path = packages/vyatta-cfg-system + url = https://github.com/vyos/vyatta-cfg-system.git +[submodule "packages/vyatta-cfg-firewall"] + path = packages/vyatta-cfg-firewall + url = https://github.com/vyos/vyatta-cfg-firewall.git +[submodule "packages/vyatta-op-firewall"] + path = packages/vyatta-op-firewall + url = https://github.com/vyos/vyatta-op-firewall.git +[submodule "packages/vyatta-cfg-vpn"] + path = packages/vyatta-cfg-vpn + url = https://github.com/vyos/vyatta-cfg-vpn.git +[submodule "packages/vyatta-op-vpn"] + path = packages/vyatta-op-vpn + url = https://github.com/vyos/vyatta-op-vpn.git +[submodule "packages/vyatta-cfg-qos"] + path = packages/vyatta-cfg-qos + url = https://github.com/vyos/vyatta-cfg-qos.git +[submodule "packages/vyatta-op-qos"] + path = packages/vyatta-op-qos + url = https://github.com/vyos/vyatta-op-qos.git +[submodule "packages/vyatta-cfg-op-pppoe"] + path = packages/vyatta-cfg-op-pppoe + url = https://github.com/vyos/vyatta-cfg-op-pppoe.git +[submodule "packages/vyatta-openvpn"] + path = packages/vyatta-openvpn + url = https://github.com/vyos/vyatta-openvpn.git +[submodule "packages/vyatta-conntrack"] + path = packages/vyatta-conntrack + url = https://github.com/vyos/vyatta-conntrack.git +[submodule "packages/vyatta-conntrack-sync"] + path = packages/vyatta-conntrack-sync + url = https://github.com/vyos/vyatta-conntrack-sync.git +[submodule "packages/vyatta-nat"] + path = packages/vyatta-nat + url = https://github.com/vyos/vyatta-nat.git +[submodule "packages/vyatta-config-mgmt"] + path = packages/vyatta-config-mgmt + url = https://github.com/vyos/vyatta-config-mgmt.git +[submodule "packages/vyatta-config-migrate"] + path = packages/vyatta-config-migrate + url = https://github.com/vyos/vyatta-config-migrate.git +[submodule "packages/vyatta-zone"] + path = packages/vyatta-zone + url = https://github.com/vyos/vyatta-zone.git +[submodule "packages/vyatta-cluster"] + path = packages/vyatta-cluster + url = https://github.com/vyos/vyatta-cluster.git +[submodule "packages/vyatta-vrrp"] + path = packages/vyatta-vrrp + url = https://github.com/vyos/vyatta-vrrp.git +[submodule "packages/vyatta-eventwatch"] + path = packages/vyatta-eventwatch + url = https://github.com/vyos/vyatta-eventwatch.git +[submodule "packages/vyatta-webproxy"] + path = packages/vyatta-webproxy + url = https://github.com/vyos/vyatta-webproxy.git +[submodule "packages/vyatta-webgui"] + path = packages/vyatta-webgui + url = https://github.com/vyos/vyatta-webgui.git +[submodule "packages/vyatta-cfg-quagga"] + path = packages/vyatta-cfg-quagga + url = https://github.com/vyos/vyatta-cfg-quagga.git +[submodule "packages/vyatta-op-quagga"] + path = packages/vyatta-op-quagga + url = https://github.com/vyos/vyatta-op-quagga.git +[submodule "packages/vyatta-cfg-dhcp-server"] + path = packages/vyatta-cfg-dhcp-server + url = https://github.com/vyos/vyatta-cfg-dhcp-server.git +[submodule "packages/vyatta-cfg-dhcp-relay"] + path = packages/vyatta-cfg-dhcp-relay + url = https://github.com/vyos/vyatta-cfg-dhcp-relay.git +[submodule "packages/vyatta-op-dhcp-server"] + path = packages/vyatta-op-dhcp-server + url = https://github.com/vyos/vyatta-op-dhcp-server.git +[submodule "packages/vyatta-wireless"] + path = packages/vyatta-wireless + url = https://github.com/vyos/vyatta-wireless.git +[submodule "packages/vyatta-wirelessmodem"] + path = packages/vyatta-wirelessmodem + url = https://github.com/vyos/vyatta-wirelessmodem.git +[submodule "packages/vyatta-wanloadbalance"] + path = packages/vyatta-wanloadbalance + url = https://github.com/vyos/vyatta-wanloadbalance.git +[submodule "packages/vyatta-netflow"] + path = packages/vyatta-netflow + url = https://github.com/vyos/vyatta-netflow.git +[submodule "packages/vyatta-lldp"] + path = packages/vyatta-lldp + url = https://github.com/vyos/vyatta-lldp.git +[submodule "packages/vyatta-ipv6-rtradv"] + path = packages/vyatta-ipv6-rtradv + url = https://github.com/vyos/vyatta-ipv6-rtradv.git +[submodule "packages/vyatta-ravpn"] + path = packages/vyatta-ravpn + url = https://github.com/vyos/vyatta-ravpn.git +[submodule "packages/vyos-pppoe-server"] + path = packages/vyos-pppoe-server + url = https://github.com/vyos/vyos-pppoe-server.git +[submodule "packages/vyos-nhrp"] + path = packages/vyos-nhrp + url = https://github.com/vyos/vyos-nhrp.git +[submodule "packages/vyos-igmpproxy"] + path = packages/vyos-igmpproxy + url = https://github.com/vyos/vyos-igmpproxy.git +[submodule "packages/vyatta-util"] + path = packages/vyatta-util + url = https://github.com/vyos/vyatta-util.git +[submodule "packages/vyos-world"] + path = packages/vyos-world + url = https://github.com/vyos/vyos-world.git +[submodule "packages/vyos-kernel"] + path = packages/vyos-kernel + url = https://github.com/vyos/vyos-kernel.git +[submodule "packages/vyos-1x"] + path = packages/vyos-1x + url = https://github.com/vyos/vyos-1x.git +[submodule "packages/mdns-repeater"] + path = packages/mdns-repeater + url = https://github.com/vyos/mdns-repeater.git +[submodule "packages/udp-broadcast-relay"] + path = packages/udp-broadcast-relay + url = https://github.com/vyos/udp-broadcast-relay.git +[submodule "packages/vyos-keepalived"] + path = packages/vyos-keepalived + url = https://github.com/vyos/vyos-keepalived.git +[submodule "packages/vyatta-iproute"] + path = packages/vyatta-iproute + url = https://github.com/vyos/vyatta-iproute.git +[submodule "packages/vyatta-quagga"] + path = packages/vyatta-quagga + url = https://github.com/vyos/vyatta-quagga.git diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..924ddb12 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,33 @@ +# Must be run with --privileged flag +# Recommended to run the container with a volume mapped +# in order to easy exprort images built to "external" world +FROM debian:jessie + +RUN apt-get update &&\ + apt-get install -y \ + vim \ + git \ + make \ + live-build \ + pbuilder \ + devscripts \ + python3-pystache \ + squashfs-tools \ + autoconf \ + dpkg-dev \ + syslinux \ + genisoimage \ + lsb-release \ + fakechroot \ + kernel-package \ + libtool \ + libglib2.0-dev \ + libboost-filesystem-dev \ + libapt-pkg-dev \ + flex \ + bison \ + libperl-dev \ + libnfnetlink-dev \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR ~ @@ -5,33 +5,90 @@ all: @echo "Make what specifically?" @echo "The most common target is 'iso'" +.PHONY: check_build_config +check_build_config: + @scripts/check-config + .PHONY: prepare prepare: + @set -e @echo "Starting VyOS ISO image build" - @scripts/check-build-env - @scripts/check-config - + rm -rf build/config/* + mkdir -p build/config + cp -r data/live-build-config/* build/config/ @scripts/live-build-config - cp -r data/includes.chroot/* build/config/includes.chroot/ - cp -r data/package-lists/common/* build/config/package-lists/ + @scripts/import-local-packages + + @scripts/make-version-file + + @scripts/build-flavour .PHONY: iso .ONESHELL: -iso: prepare +iso: check_build_config clean prepare + @set -e @echo "It's not like I'm building this specially for you or anything!" cd $(build_dir) lb build 2>&1 | tee build.log - @echo "VyOS ISO build successful" + cd .. + @scripts/copy-image + +.PHONY: prepare-package-env +.ONESHELL: +prepare-package-env: + @set -e + @scripts/pbuilder-config + @scripts/pbuilder-setup + +.PHONY: qemu +.ONESHELL: +qemu: + @set -e + @scripts/check-vm-build-env + @scripts/build-qemu-image + +.PHONY: vagrant-libvirt +.ONESHELL: +vagrant-libvirt: + @set -e + @scripts/check-vm-build-env + @scripts/build-vagrant-libvirt-box + +.PHONY: vmware +.ONESHELL: +vmware: + @set -e + @scripts/check-vm-build-env + @scripts/build-vmware-image + +.PHONY: hyperv +.ONESHELL: +hyperv: + @set -e + @scripts/check-vm-build-env + @scripts/build-hyperv-image + +.PHONY: clearfog +.ONESHELL: +clearfog: clean prepare + @set -e + @echo "It's not like I'm building this specially for you or anything!" + cd $(build_dir) + @../scripts/build-clearfog-image .PHONY: clean .ONESHELL: clean: + @set -e cd $(build_dir) lb clean rm -f config/binary config/bootstrap config/chroot config/common config/source rm -f build.log + rm -f vyos-*.iso + rm -f *.img + rm -f *.xz .PHONY: purge purge: @@ -1,18 +1,22 @@ VyOS toplevel build =================== -# WARNING +# Important! + +This repository is for building the VyOS version 1.2.0 and above. +For VyOS 1.1.x, use the build-iso repository. -This is repository is for the ongoing work on porting VyOS to Debian Jessie. It is not yet ready to use. -For building stable release images, refer to the vyos/build-iso repository. # What is VyOS VyOS is an open source operating system for network devices (routers, firewalls and so on). -If you want to use it in your network, check out download and installation instructions at http://vyos.net +If you want to use it in your network, check out download and installation instructions at https://vyos.io If you want to modify VyOS and/or join its development, read on. +VyOS is not new. It is a fork of Vyatta Core that was created when the open source version of it was +discontinued. If you are a Vyatta Core user, you can upgrade your installation to VyOS. + # What is this repository? VyOS is a GNU/Linux distribution based on Debian. Just like any other distribution, it consists of multiple @@ -39,17 +43,120 @@ There are several directories with their own purpose: ## Prerequisites -To build a VyOS image, you need a machine that runs Debian Jessie. Other build hosts are not supported. - -Several packages are required for building the ISO and all packages, namely live-build, pbuilder, and dev-scripts. -Individual packages may have other build dependencies. If some packages are missing, build scripts will tell you. +To build a VyOS image, you need Debian 8 "Jessie" environment (with jessie-backports repository). You can create it with [debootstrap](https://wiki.debian.org/Debootstrap) on Debian, Ubuntu and many other distributions. To create a Debian 8 "Jessie" environment under vyos-chroot directory, run these commands: + +``` +$ sudo apt-get install debootstrap # (Note: This is on Debian/Ubuntu, adjust it for your favorite distro package manager) +$ sudo debootstrap jessie vyos-chroot +$ sudo chroot vyos-chroot + +# echo "deb http://deb.debian.org/debian jessie-backports main" >> /etc/apt/sources.list +# apt-get update +``` + +Several packages are required for building the ISO: python3, live-build, pbuilder, python3-pystache. The ./configure script +will warn you if any dependencies are missing. +Individual packages may have other build dependencies. If some dependencies are missing, package build scripts will tell you. + +## Building the ISO image inside a docker container + +Using Dockerfile you can create your own docker container that can be used to build a VyOS ISO image. +The Dockerfile contains some of the most used packages needed for a VyOS build ISO process. + +``` +squashfs-tools # Required for squashfs file system +git # Required, for cloning the source +autoconf # Required, for generating build scripts +dpkg-dev # Required, used in build scripts +live-helper # Required, for ISO build +syslinux # Required, for ISO build +genisoimage # Required, for ISO build +make # Required, for ISO build +lsb-release # Required, used by configure script +fakechroot # Required, for ISO build +devscripts # Optional, for building submodules (kernel etc) +kernel-package # Optional, for building the kernel +libtool # Optional, for building certain packages (eg vyatta-op-vpn) +libglib2.0-dev # Optional, for building vyatta-cfg +libboost-filesystem-dev # Optional, for building vyatta-cfg +libapt-pkg-dev # Optional, for building vyatta-cfg +flex # Optional, for building vyatta-cfg +bison # Optional, for building vyatta-cfg +libperl-dev # Optional, for building vyatta-cfg +libnfnetlink-dev # Optional, for building vyatta-cfg-vpn +vim # Optional, vim, vi, nano or other text editor +``` + +To build the docker image: + +``` +docker build -t vyos-builder $PATH_TO_Dockerfile +``` + +To run the docker image: + +``` +docker run --privileged -v /HOST_PATH/images:/vyos --name=vyos_node_builder -d vyos-builder bash +``` +* docker container must be run with --privileged flag +* is recommended to run the container with a volume mapped in order to easy export built VyOS ISO images +to the "external" world + +To connect to the docker image once is running: +``` +docker exec -it vyos_node_builder bash +``` + +After the docker container is running you can git clone the vyos-build repository inside the container +and follow up the bellow instructions in order to build the VyOS ISO image ## Building the ISO image Before you can build an image, you need to configure your build. To build an image, use the following commands: - ./configure - make iso + +``` +./configure +make iso +``` The ./configure script has a number of options that you can see by calling it with --help + +## Building the images for virtualization platforms + +* QEMU + +Run following command after building the ISO image. + +``` +make qemu +``` + +* VMware + +Run following command after building the QEMU image. + +``` +make vmware +``` + +# Development process + +## git branches + +The default branch that contains the most recent VyOS code is called 'current' rather than 'master'. +We know if'ts confusing, but it's not easy to fix. +In a nutshell, the code we inherited from Vyatta Core had its master branch so out of sync with everything +it was beyong any repair. Vyatta developers used to create a new branch not when a release is ready for +code freeze, but rather before starting to work on a new release. +This is hard to change in existing code, so this is just the way it is, for now. + +All new code goes to the 'current' branch. When it's time for a code freeze, a new branch is created +for the release, and new code from 'current' is backported to the release branch as needed. + +In packages that originate from VyOS the master branch is kept in sync with "current", but we still use +"current" as default branch for uniformity. When the last legacy package is gone, we will switch to using +the master branch and retire "current". + +For branch naming we use chemical elements (hydrogen, helium, ...). diff --git a/data/includes.chroot/etc/fuse.conf b/data/includes.chroot/etc/fuse.conf deleted file mode 100644 index a439ab82..00000000 --- a/data/includes.chroot/etc/fuse.conf +++ /dev/null @@ -1 +0,0 @@ -user_allow_other diff --git a/data/live-build-config/archives/vyos.key.chroot b/data/live-build-config/archives/vyos.key.chroot new file mode 100644 index 00000000..a6522e36 --- /dev/null +++ b/data/live-build-config/archives/vyos.key.chroot @@ -0,0 +1,32 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.12 (GNU/Linux) + +mQENBFOQPGwBCADjm8Oq3kaJQh0rI33XVfd9mNq5ffay884SlDCbG1hkLVf8tnGV +cjH7/nFfJdW/6Gr4dj4LQuHHnin5QeWnlHfuOySlOEsJCNP5dm14oEjy7epSXOv2 +A3m2tPDDqwMgfrOyw1gN+Clit9QIujiRzbcakqearyNxcVNvinIVunNiWbAyIhvc +uI6yfMjno4q/O83c7e1zBqJj9t9guQjBuqaJrmZVf985/6ue9yWzSI4JtzxVmhKI +dfCxHWE7BiEt2hnZPSVGcb4q6cBrkpcra7Ny55eoyN51wQGokPv3a9/8b3r5speR +gene2MTvD/3eZOtTvMN000f/gJX4E6o8xx+fABEBAAG0R1Z5T1MgTWFpbnRhaW5l +cnMgKERldmVsb3BtZW50IGFuZCB0ZXN0aW5nIHJlcG9zKSA8bWFpbnRhaW5lcnNA +dnlvcy5uZXQ+iQE4BBMBAgAiBQJTkDxsAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIe +AQIXgAAKCRAywkm9DfBLXJbHB/4xlwn+6cZGEWWNZgXwUTMeHubZItl1o3Tbrzaa +E3EqYyHJMYb3gBLOomlw7JLw5qT/247tlPC8ricl+BpeE5vYA3a08mIpcymROFh6 +pKJLNvdZHjrVN9yH2xYifI5sIDyuPga8Bgq/BMRiB1ragS/on2aUs75+tsEI32NI +JO8+jIav0Nd6n/Wmw55ioTXS3fx6VDb64D80luOf1ve5LFDs8Oz2I+ZjSf7mPMY/ +b9qQHNb/300k/tIeK2F4G7LFu6o/1YMlrv0Ry7j9BsLzIkmTh0pX4mSVvF6IrxsZ +WJRKu3uQDH2qccjptZDq4jHo/ow+aWT8rakjOgL9nJgKD5u/uQENBFOQPGwBCAC0 +zHpsmcfUIDyflGL+vwHV/3L02/vItHXfIkugL+wFB9C9i6nWA1KqNJwqNflJLGQF +y+vHXs0oa3oMKj7S3p2zTbuU8s9Vz2Cg5c15sy7yGjh/LTwVOR5ZJrgbRJxTTp9K +j5bkrx/DbDjIQ5szyjZ5N1ZAUyUx5Z/xMB3mTnLxDASvaoq+/F6WNcYY7NzjI7M0 +SFtnZLj6MFUVTmSbyYdGQc/Cxu5Utl7WKJUqHW5z10vJruZsdKV2+vf98yqhAJ+v +wPhKUoVD+KtCH/CrHFrVq0hCKIMtyPLtaTeR/QnCNDEsV4p82HB9KQOYEADEL3/A +a7Dntf3Xi+5eO/3MlnshABEBAAGJAR8EGAECAAkFAlOQPGwCGwwACgkQMsJJvQ3w +S1z+wwf9GnVn9GhbB1FhKQdavljp9rUzz8FvH3tRpftdhhJ8B0PVAMl4QRcIXrgD +nyd1K9ggzyWa4Z/9PygvH0Njv4YWlZh900wei9uVD8am1ncgQ/Jqlb36WvXyr8W/ +VPzQDtKAOkUz6RhKQ4V6I0PBK9nGeqeFkeH1bF1uGXkKpa0hGWffyOT1VasaZVXT +UN4VAYNzBwkoU0mIYK73CPi7e4YJrtOp/i8MGDL3pxKaZEEZJdc4/dZassqBuwSG +MRr2kecj9f53KWI0jLQdLgTMJQxscotfzhsWoF/842sUCbezwV3/4FtBhlNeqUHA +c9HOeh3wbjjt4uONvxeleE+jM9v63Q== +=gflA +-----END PGP PUBLIC KEY BLOCK----- + diff --git a/data/live-build-config/hooks/00-manifest.binary b/data/live-build-config/hooks/00-manifest.binary new file mode 100755 index 00000000..6db8b6f3 --- /dev/null +++ b/data/live-build-config/hooks/00-manifest.binary @@ -0,0 +1,4 @@ +#!/bin/sh + +echo I: Backwards compat packages.txt +echo "ii vyatta-version " > binary/live/packages.txt diff --git a/data/live-build-config/hooks/00-mk_buildid.chroot b/data/live-build-config/hooks/00-mk_buildid.chroot new file mode 100755 index 00000000..087addad --- /dev/null +++ b/data/live-build-config/hooks/00-mk_buildid.chroot @@ -0,0 +1,22 @@ +#!/bin/sh +# create the buildid file + +etcdir=/opt/vyatta/etc + +[ -d $etcdir ] || mkdir -p -m 0755 $etcdir +rm -f $etcdir/build.txt $etcdir/iso-build.txt $etc/iso-submodules.txt + +## NOTE: on live image build, these files are in the chroot/root +## however, during install, these are in /cdrom +for f in iso-build.txt iso-submodules.txt ; do + if [ -f /cdrom/$f ] ; then + cp /cdrom/$f $etcdir + elif [ -f /$f ] ; then + cp /$f $etcdir + else + >$etcdir/$f + fi +done + +# backwards compatible symlink +ln -s iso-build.txt $etcdir/build.txt diff --git a/data/live-build-config/hooks/01-interfaces.chroot b/data/live-build-config/hooks/01-interfaces.chroot new file mode 100755 index 00000000..8d218ea4 --- /dev/null +++ b/data/live-build-config/hooks/01-interfaces.chroot @@ -0,0 +1,12 @@ +#!/bin/sh + +if ! grep '^auto lo' /etc/network/interfaces &> /dev/null ; then + mkdir -p -m 0755 /etc/network + cat >> /etc/network/interfaces <<-EOF + + # The loopback network interface + auto lo + iface lo inet loopback + + EOF +fi diff --git a/data/live-build-config/hooks/02-issue.chroot b/data/live-build-config/hooks/02-issue.chroot new file mode 100755 index 00000000..732ebeb0 --- /dev/null +++ b/data/live-build-config/hooks/02-issue.chroot @@ -0,0 +1,10 @@ +#!/bin/sh + +echo I: Rewriting /etc/issue and /etc/issue.net +cat <<EOF > etc/issue +Welcome to VyOS - \n \l + +EOF +cat <<EOF > etc/issue.net +Welcome to VyOS +EOF diff --git a/data/live-build-config/hooks/03-root_bash_completion.chroot b/data/live-build-config/hooks/03-root_bash_completion.chroot new file mode 100755 index 00000000..b7ea8f52 --- /dev/null +++ b/data/live-build-config/hooks/03-root_bash_completion.chroot @@ -0,0 +1,10 @@ +#!/bin/sh + +grep -q '\(^[^#]*\)\(\.\|source\) /etc/bash_completion' root/.bashrc || \ + cat <<-EOF >> root/.bashrc + + source /etc/bash_completion + EOF + +sed -i 's/set $BASH_COMPLETION_ORIGINAL_V_VALUE/builtin set $BASH_COMPLETION_ORIGINAL_V_VALUE/g' /usr/share/bash-completion/bash_completion + diff --git a/data/live-build-config/hooks/04-locale.chroot b/data/live-build-config/hooks/04-locale.chroot new file mode 100755 index 00000000..89a5f954 --- /dev/null +++ b/data/live-build-config/hooks/04-locale.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +echo I: Set default locale +cat <<EOF >etc/default/locale +LANG=en_US.UTF-8 +LC_ALL=C +EOF + +sed -i 's/AcceptEnv LANG LC_\*/# AcceptEnv LANG LC_\*/g' /etc/ssh/sshd_config diff --git a/data/live-build-config/hooks/05-event_tty.chroot b/data/live-build-config/hooks/05-event_tty.chroot new file mode 100755 index 00000000..a00167f7 --- /dev/null +++ b/data/live-build-config/hooks/05-event_tty.chroot @@ -0,0 +1,34 @@ +#!/bin/sh + +if [ -r etc/event.d/tty1 ] ; then + echo I: Delay getty until rcX completes + sed -i 's/start on runlevel /start on stopped rc/' \ + etc/event.d/tty[1-6] + if [ ! -r etc/event.d/ttyS0 ] && [ -c dev/ttyS0 ] ; then + echo I: Enable serial console login + cat <<-EOF > etc/event.d/ttyS0 + # ttyS0 - getty + # + # This service maintains a getty on ttyS0 from the point the system is + # started until it is shut down again. + + start on stopped rc2 + start on stopped rc3 + start on stopped rc4 + start on stopped rc5 + + stop on runlevel 0 + stop on runlevel 1 + stop on runlevel 6 + + respawn + exec /sbin/getty 9600 ttyS0 vt100 + + EOF + fi +fi + +if [ -r etc/inittab ] && [ -c dev/ttyS0 ] && grep -q '^#T0:.*getty.*ttyS0' etc/inittab ; then + echo I: Enable serial console login + sed -i '/^#T0:/s|^#.*$|T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100|' etc/inittab +fi diff --git a/data/live-build-config/hooks/07-apt.chroot b/data/live-build-config/hooks/07-apt.chroot new file mode 100755 index 00000000..8db33a78 --- /dev/null +++ b/data/live-build-config/hooks/07-apt.chroot @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ -e /cdrom/vyatta-pubkey.gpg ] ; then + apt-key add /cdrom/vyatta-pubkey.gpg +elif [ -e /vyatta-pubkey.gpg ] ; then + apt-key add /vyatta-pubkey.gpg + rm -f /vyatta-pubkey.gpg +fi diff --git a/data/live-build-config/hooks/08-sysconf.chroot b/data/live-build-config/hooks/08-sysconf.chroot new file mode 100755 index 00000000..b0399027 --- /dev/null +++ b/data/live-build-config/hooks/08-sysconf.chroot @@ -0,0 +1,47 @@ +#!/bin/sh + +for conf in motd.tail syslog.conf; do + cp -f /opt/vyatta/etc/$conf /etc/$conf +done + +cp -f /opt/vyatta/etc/default_ssh /etc/default/ssh +>/etc/pam_radius_auth.conf + +update_sysctl_conf () +{ + var=$1 + val=$2 + comment=$3 + sysctl_conf=/etc/sysctl.conf + + if grep -q "^${var}[[:space:]]*=" $sysctl_conf ; then + sed -i "/^${var}[[:space:]]*=/ s,=.*,= ${val}," $sysctl_conf + elif grep -q "^#[[:space:]]*${var}[[:space:]]*=" $sysctl_conf ; then + sed -i "/^#[[:space:]]*${var}[[:space:]]*=/ { s,^#[[:space:]]*,, ; s,[[:space:]]*=.*, = ${val},} " $sysctl_conf + else + cat <<-EOF >> $sysctl_conf + + # $comment + $var = $val + EOF + fi +} + +update_sysctl_conf kernel.printk "4 4 1 7" \ + "the following stops low-level messages on console" +update_sysctl_conf net.ipv4.conf.default.arp_filter 1 \ + "reset promiscous arp response" +update_sysctl_conf net.ipv4.conf.all.promote_secondaries 1 \ + "promote secondaries with removal of primary address" +update_sysctl_conf net.ipv4.ip_forward 1 \ + "enable ipv4 forwarding" +# FIXME! need to load or staticly link ipv6 module before adding this. +# update_sysctl_conf net.ipv6.conf.all.forwarding 1 \ +# "enable ipv6 forwarding" +update_sysctl_conf net.core.rmem_max 223232 \ + "maximize netlink buffers" + +# Local Variables: +# mode: shell-script +# sh-indentation: 4 +# End: diff --git a/data/live-build-config/hooks/09-live.chroot b/data/live-build-config/hooks/09-live.chroot new file mode 100755 index 00000000..f19f0ae6 --- /dev/null +++ b/data/live-build-config/hooks/09-live.chroot @@ -0,0 +1,11 @@ +#!/bin/sh + +# hack live script that tries to mount ext[23] floppies as root +# remove user settings live config scripts + +sed -e '/ln -s "${devname}"/,/return 0/ s/^/: FIXME/' \ + -i /usr/share/initramfs-tools/scripts/live + +rm -rf /lib/live/config/0030-live-debconfig_passwd +rm -rf /lib/live/config/0030-user-setup +rm -rf /lib/live/config/0040-sudo diff --git a/data/live-build-config/hooks/10-unmountfs.chroot b/data/live-build-config/hooks/10-unmountfs.chroot new file mode 100755 index 00000000..7992a4d2 --- /dev/null +++ b/data/live-build-config/hooks/10-unmountfs.chroot @@ -0,0 +1,12 @@ +#!/bin/sh + +# hack umountfs script to cleanly unmount live systems + +sed \ + -e '/proc|procfs|linprocfs/ s/)/|squashfs|iso9660)/' \ + -e '/tmpfs)/ a\ + [ "$MTPT" != "/media" ] && \ + [ "$MTPT" != "/live" ] && \ + [ "$MTPT" != "/live/cow" ] && +' \ + -i /etc/init.d/umountfs diff --git a/data/live-build-config/hooks/11-busybox.chroot b/data/live-build-config/hooks/11-busybox.chroot new file mode 100755 index 00000000..fecce616 --- /dev/null +++ b/data/live-build-config/hooks/11-busybox.chroot @@ -0,0 +1,183 @@ +#!/bin/sh + +# create busybox alternatives + +bb=`which busybox` +applets=$(busybox | sed '1,/^Currently defined functions:/d; s/[\[,]//g; s/ / /g; s/$/ /g') + +bb_alternative () +{ + full=$1 + full_bb=${full}.bb + app=${full##*/} + if [ ! -x $full ] && (echo -n "$applets" | grep -q " $app "); then + ln -s $bb $full_bb + update-alternatives --install $full $app $full_bb 10 + fi +} + +bb_alternative /bin/bunzip2 +bb_alternative /bin/bzcat +bb_alternative /bin/cat +bb_alternative /bin/chgrp +bb_alternative /bin/chmod +bb_alternative /bin/chown +bb_alternative /bin/cp +bb_alternative /bin/cpio +bb_alternative /bin/date +bb_alternative /bin/dd +bb_alternative /bin/df +bb_alternative /bin/dmesg +bb_alternative /bin/echo +bb_alternative /bin/egrep +bb_alternative /bin/false +bb_alternative /bin/fgrep +bb_alternative /bin/grep +bb_alternative /bin/gunzip +bb_alternative /bin/gzip +bb_alternative /bin/hostname +bb_alternative /bin/ip +bb_alternative /bin/kill +bb_alternative /bin/ln +bb_alternative /bin/login +bb_alternative /bin/ls +bb_alternative /bin/mkdir +bb_alternative /bin/mknod +bb_alternative /bin/mktemp +bb_alternative /bin/more +bb_alternative /bin/mount +bb_alternative /bin/mt +bb_alternative /bin/mv +bb_alternative /bin/nc +bb_alternative /bin/netstat +bb_alternative /bin/pidof +bb_alternative /bin/ping +bb_alternative /bin/ping6 +bb_alternative /bin/ps +bb_alternative /bin/pwd +bb_alternative /bin/readlink +bb_alternative /bin/rm +bb_alternative /bin/rmdir +bb_alternative /bin/run-parts +bb_alternative /bin/sed +bb_alternative /bin/sh +bb_alternative /bin/sleep +bb_alternative /bin/stty +bb_alternative /bin/sync +bb_alternative /bin/tar +bb_alternative /bin/touch +bb_alternative /bin/true +bb_alternative /bin/umount +bb_alternative /bin/uname +bb_alternative /bin/uncompress +bb_alternative /bin/which +bb_alternative /bin/zcat + +bb_alternative /sbin/ifconfig +bb_alternative /sbin/ip +bb_alternative /sbin/iptunnel +bb_alternative /sbin/klogd +bb_alternative /sbin/losetup +bb_alternative /sbin/nameif +bb_alternative /sbin/route +bb_alternative /sbin/start-stop-daemon +bb_alternative /sbin/swapoff +bb_alternative /sbin/swapon +bb_alternative /sbin/syslogd + +bb_alternative /usr/bin/adjtimex +bb_alternative /usr/bin/ar +bb_alternative /usr/bin/arping +bb_alternative /usr/bin/awk +bb_alternative /usr/bin/basename +bb_alternative /usr/bin/cal +bb_alternative /usr/bin/chvt +bb_alternative /usr/bin/clear +bb_alternative /usr/bin/cmp +bb_alternative /usr/bin/cut +bb_alternative /usr/bin/dc +bb_alternative /usr/bin/deallocvt +bb_alternative /usr/bin/dirname +bb_alternative /usr/bin/dos2unix +bb_alternative /usr/bin/dumpkmap +bb_alternative /usr/bin/du +bb_alternative /usr/bin/env +bb_alternative /usr/bin/expr +bb_alternative /usr/bin/find +bb_alternative /usr/bin/fold +bb_alternative /usr/bin/free +bb_alternative /usr/bin/ftpget +bb_alternative /usr/bin/ftpput +bb_alternative /usr/bin/getopt +bb_alternative /usr/bin/head +bb_alternative /usr/bin/hexdump +bb_alternative /usr/bin/hostid +bb_alternative /usr/bin/id +bb_alternative /usr/bin/ipaddr +bb_alternative /usr/bin/ipcalc +bb_alternative /usr/bin/iplink +bb_alternative /usr/bin/iproute +bb_alternative /usr/bin/killall +bb_alternative /usr/bin/last +bb_alternative /usr/bin/loadfont +bb_alternative /usr/bin/loadkmap +bb_alternative /usr/bin/logger +bb_alternative /usr/bin/logname +bb_alternative /usr/bin/logread +bb_alternative /usr/bin/md5sum +bb_alternative /usr/bin/mkfifo +bb_alternative /usr/bin/nslookup +bb_alternative /usr/bin/od +bb_alternative /usr/bin/openvt +bb_alternative /usr/bin/patch +bb_alternative /usr/bin/printf +bb_alternative /usr/bin/rdate +bb_alternative /usr/bin/realpath +bb_alternative /usr/bin/rpm +bb_alternative /usr/bin/rpm2cpio +bb_alternative /usr/bin/renice +bb_alternative /usr/bin/reset +bb_alternative /usr/bin/setkeycodes +bb_alternative /usr/bin/sha1sum +bb_alternative /usr/bin/sort +bb_alternative /usr/bin/strings +bb_alternative /usr/bin/tail +bb_alternative /usr/bin/tee +bb_alternative /usr/bin/test +bb_alternative /usr/bin/tftp +bb_alternative /usr/bin/time +bb_alternative /usr/bin/top +bb_alternative /usr/bin/touch +bb_alternative /usr/bin/tr +bb_alternative /usr/bin/traceroute +bb_alternative /usr/bin/tty +bb_alternative /usr/bin/uniq +bb_alternative /usr/bin/unix2dos +bb_alternative /usr/bin/unzip +bb_alternative /usr/bin/uptime +bb_alternative /usr/bin/usleep +bb_alternative /usr/bin/uudecode +bb_alternative /usr/bin/uuencode +bb_alternative /usr/bin/vi +bb_alternative /usr/bin/watch +bb_alternative /usr/bin/wc +bb_alternative /usr/bin/wget +bb_alternative /usr/bin/which +bb_alternative /usr/bin/who +bb_alternative /usr/bin/whoami +bb_alternative /usr/bin/xargs +bb_alternative /usr/bin/yes + +bb_alternative /usr/sbin/chroot +bb_alternative /usr/sbin/dumpleases +bb_alternative /usr/sbin/httpd +bb_alternative /usr/sbin/telnetd +bb_alternative /usr/sbin/traceroute +bb_alternative /usr/sbin/udhcpc +bb_alternative /usr/sbin/udhcpd +bb_alternative /usr/sbin/watchdog + +# Local Variables: +# mode: shell-script +# sh-indentation: 4 +# End: diff --git a/data/live-build-config/hooks/12-udev-initramfs.chroot b/data/live-build-config/hooks/12-udev-initramfs.chroot new file mode 100755 index 00000000..13bdfb89 --- /dev/null +++ b/data/live-build-config/hooks/12-udev-initramfs.chroot @@ -0,0 +1,9 @@ +#!/bin/sh + +# this was a "local patch" but patch generates a .orig file if it doesn't +# apply cleanly, which is not good when all files in the hook directory are +# executed. just use sed to hack the udev hook here. + +sed -i 's/^\(mount -n -o move \/dev .*\/dev\)$/\1 2>\/dev\/null/' \ + /usr/share/initramfs-tools/scripts/init-bottom/udev + diff --git a/data/live-build-config/hooks/13-vyos_replace.chroot b/data/live-build-config/hooks/13-vyos_replace.chroot new file mode 100755 index 00000000..dcb00ff6 --- /dev/null +++ b/data/live-build-config/hooks/13-vyos_replace.chroot @@ -0,0 +1,3 @@ +#!/bin/sh + +apt-get -y install vyos-replace diff --git a/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot b/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot new file mode 100755 index 00000000..887831cc --- /dev/null +++ b/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot @@ -0,0 +1,12 @@ +#!/bin/sh + +cp /etc/apt/sources.list /etc/apt/sources.list.d/non-free.list +sed -i 's/main/non-free/g' /etc/apt/sources.list.d/non-free.list + +if [ -e /etc/apt/sources.list.d/zz-sources.list ] ; then + cp /etc/apt/sources.list /etc/apt/sources.list.d/zz-non-free.list + sed -i 's/main/non-free/g' /etc/apt/sources.list.d/zz-non-free.list +fi + +apt-get update +apt-get -y install firmware-linux-nonfree diff --git a/data/live-build-config/hooks/15-sources_list.chroot b/data/live-build-config/hooks/15-sources_list.chroot new file mode 100755 index 00000000..956f9bba --- /dev/null +++ b/data/live-build-config/hooks/15-sources_list.chroot @@ -0,0 +1,4 @@ +#!/bin/sh + +rm -f /etc/apt/sources.list.d/*.list >/dev/null 2>&1 || true + diff --git a/data/live-build-config/hooks/16-fuse.chroot b/data/live-build-config/hooks/16-fuse.chroot new file mode 100755 index 00000000..126dc626 --- /dev/null +++ b/data/live-build-config/hooks/16-fuse.chroot @@ -0,0 +1,4 @@ +#!/bin/sh + +sed -i 's/#user_allow_other/user_allow_other/g' /etc/fuse.conf +chmod a+r /etc/fuse.conf diff --git a/data/live-build-config/hooks/17-gen_initramfs.chroot b/data/live-build-config/hooks/17-gen_initramfs.chroot new file mode 100755 index 00000000..aced728a --- /dev/null +++ b/data/live-build-config/hooks/17-gen_initramfs.chroot @@ -0,0 +1,4 @@ +#!/bin/sh + +echo I: Create initramfs if it does not exist. +update-initramfs -c -k `ls /boot | grep vmlinuz- | sed 's/vmlinuz-//g'` diff --git a/data/live-build-config/hooks/18-enable-disable_services.chroot b/data/live-build-config/hooks/18-enable-disable_services.chroot new file mode 100755 index 00000000..fe30c95f --- /dev/null +++ b/data/live-build-config/hooks/18-enable-disable_services.chroot @@ -0,0 +1,34 @@ +#!/bin/sh + +echo I: Enabling/Disabling services. +systemctl disable exim4 +/usr/sbin/update-rc.d -f exim4 remove +systemctl disable isc-dhcp-server +/usr/sbin/update-rc.d -f isc-dhcp-server remove +systemctl disable isc-dhcp-relay +/usr/sbin/update-rc.d -f isc-dhcp-relay remove +systemctl disable nfacctd +/usr/sbin/update-rc.d -f nfacctd remove +systemctl disable pmacctd +/usr/sbin/update-rc.d -f pmacctd remove +systemctl disable sfacctd +/usr/sbin/update-rc.d -f sfacctd remove +systemctl disable uacctd +/usr/sbin/update-rc.d -f uacctd remove +systemctl disable lighttpd +/usr/sbin/update-rc.d -f lighttpd remove +systemctl disable ssh +/usr/sbin/update-rc.d -f ssh remove +systemctl disable openvpn +/usr/sbin/update-rc.d -f openvpn remove +systemctl disable lldpd +/usr/sbin/update-rc.d -f lldpd remove +systemctl enable ssh-session-cleanup +systemctl disable conntrackd +/usr/sbin/update-rc.d -f conntrackd remove +systemctl disable mdns-repeater +/usr/sbin/update-rc.d -f mdns-repeater remove +systemctl disable udp-broadcast-relay{1.99} +/usr/sbin/update-rc.d -f udp-broadcast-relay remove +systemctl disable pdns-recursor +/usr/sbin/update-rc.d -f pdns-recursor remove diff --git a/data/live-build-config/hooks/19-kernel_symlinks.chroot b/data/live-build-config/hooks/19-kernel_symlinks.chroot new file mode 100755 index 00000000..e63ca263 --- /dev/null +++ b/data/live-build-config/hooks/19-kernel_symlinks.chroot @@ -0,0 +1,6 @@ +#!/bin/sh + +echo I: Creating kernel symlinks. +cd /boot +ln -s initrd.img-* initrd.img +ln -s vmlinuz-* vmlinuz diff --git a/data/live-build-config/hooks/20-rm_ddclient_hook.chroot b/data/live-build-config/hooks/20-rm_ddclient_hook.chroot new file mode 100755 index 00000000..173b4e5c --- /dev/null +++ b/data/live-build-config/hooks/20-rm_ddclient_hook.chroot @@ -0,0 +1,3 @@ +#!/bin/sh + +rm -f /etc/dhcp/dhclient-exit-hooks.d/ddclient diff --git a/data/live-build-config/hooks/21-pam_mkhomedir.chroot b/data/live-build-config/hooks/21-pam_mkhomedir.chroot new file mode 100755 index 00000000..af155ba4 --- /dev/null +++ b/data/live-build-config/hooks/21-pam_mkhomedir.chroot @@ -0,0 +1,16 @@ +#!/bin/sh + +echo I: Create home directory on login. + +cat > /usr/share/pam-configs/mkhomedir <<EOF +Name: Create home directory during login +Default: yes +Priority: 900 +Session-Type: Additional +Session: + required pam_mkhomedir.so umask=0022 skel=/etc/skel +EOF +sync +sed -i '/mkhomedir/d' /var/lib/pam/seen +pam-auth-update --package + diff --git a/data/live-build-config/hooks/99-cleanup-packages.chroot b/data/live-build-config/hooks/99-cleanup-packages.chroot new file mode 100755 index 00000000..63be7df6 --- /dev/null +++ b/data/live-build-config/hooks/99-cleanup-packages.chroot @@ -0,0 +1,14 @@ +#!/bin/sh + +# Clean up packages that were installed for dependencies but are no longer needed +# and packages installed by metapackages that we'll never need + +UNWANTED_PKGS="dahdi-firmware-nonfree \ + firmware-crystalhd firmware-ivtv \ + firmware-samsung" + +for p in $UNWANTED_PKGS; do + apt-get -y remove $p +done + +#apt-get -y autoremove diff --git a/data/live-build-config/includes.binary/isolinux/isolinux.cfg b/data/live-build-config/includes.binary/isolinux/isolinux.cfg new file mode 100644 index 00000000..ede2b6e1 --- /dev/null +++ b/data/live-build-config/includes.binary/isolinux/isolinux.cfg @@ -0,0 +1,11 @@ +include menu.cfg +default vesamenu.c32 +prompt 0 + +# Ignore the Shift/Alt/Caps Lock/Scroll Lock escape +noescape 1 + +# Wait 10 seconds unless the user types something, but +# always boot after 5 minutes. +timeout 100 +totaltimeout 3000 diff --git a/data/live-build-config/includes.binary/isolinux/menu.cfg b/data/live-build-config/includes.binary/isolinux/menu.cfg new file mode 100644 index 00000000..135b2e96 --- /dev/null +++ b/data/live-build-config/includes.binary/isolinux/menu.cfg @@ -0,0 +1,8 @@ +menu hshift 0 +menu width 82 + +menu title VyOS - Boot Menu +include stdmenu.cfg +include live.cfg + +menu clear diff --git a/data/live-build-config/includes.binary/isolinux/splash.png b/data/live-build-config/includes.binary/isolinux/splash.png Binary files differnew file mode 100644 index 00000000..e2c9bfa4 --- /dev/null +++ b/data/live-build-config/includes.binary/isolinux/splash.png diff --git a/data/live-build-config/includes.chroot/etc/systemd/journald.conf b/data/live-build-config/includes.chroot/etc/systemd/journald.conf new file mode 100644 index 00000000..5aecf4f8 --- /dev/null +++ b/data/live-build-config/includes.chroot/etc/systemd/journald.conf @@ -0,0 +1,43 @@ +# This file is managed in vyos-build +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# Entries in this file show the compile time defaults. +# You can change settings by editing this file. +# Defaults can be restored by simply deleting this file. +# +# See journald.conf(5) for details. + +[Journal] +#Storage=persistent +#Compress=yes +#Seal=yes +#SplitMode=uid +#SyncIntervalSec=5m +#RateLimitIntervalSec=30s +#RateLimitBurst=1000 +#SystemMaxUse= +#SystemKeepFree= +#SystemMaxFileSize= +#SystemMaxFiles=100 +#RuntimeMaxUse= +#RuntimeKeepFree= +#RuntimeMaxFileSize= +#RuntimeMaxFiles=100 +#MaxRetentionSec= +#MaxFileSec=1month +ForwardToSyslog=yes +#ForwardToKMsg=no +#ForwardToConsole=no +#ForwardToWall=yes +#TTYPath=/dev/console +#MaxLevelStore=debug +MaxLevelSyslog=debug +#MaxLevelKMsg=notice +#MaxLevelConsole=info +#MaxLevelWall=emerg diff --git a/data/live-build-config/includes.chroot/etc/systemd/system.conf b/data/live-build-config/includes.chroot/etc/systemd/system.conf new file mode 100644 index 00000000..91af4090 --- /dev/null +++ b/data/live-build-config/includes.chroot/etc/systemd/system.conf @@ -0,0 +1,55 @@ +# This file is managed in vyos-build +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. +# +# See systemd-system.conf(5) for details + +[Manager] +#LogLevel=info +#LogTarget=journal-or-kmsg +#LogColor=yes +#LogLocation=no +#DumpCore=yes +#CrashShell=no +ShowStatus=yes +#CrashChVT=1 +#CPUAffinity=1 2 +#JoinControllers=cpu,cpuacct net_cls,net_prio +#RuntimeWatchdogSec=0 +#ShutdownWatchdogSec=10min +#CapabilityBoundingSet= +#SystemCallArchitectures= +#TimerSlackNSec= +#DefaultTimerAccuracySec=1min +#DefaultStandardOutput=journal +#DefaultStandardError=inherit +#DefaultTimeoutStartSec=90s +#DefaultTimeoutStopSec=90s +#DefaultRestartSec=100ms +#DefaultStartLimitInterval=10s +#DefaultStartLimitBurst=5 +#DefaultEnvironment= +#DefaultCPUAccounting=no +#DefaultBlockIOAccounting=no +#DefaultMemoryAccounting=no +#DefaultLimitCPU= +#DefaultLimitFSIZE= +#DefaultLimitDATA= +#DefaultLimitSTACK= +#DefaultLimitCORE= +#DefaultLimitRSS= +#DefaultLimitNOFILE= +#DefaultLimitAS= +#DefaultLimitNPROC= +#DefaultLimitMEMLOCK= +#DefaultLimitLOCKS= +#DefaultLimitSIGPENDING= +#DefaultLimitMSGQUEUE= +#DefaultLimitNICE= +#DefaultLimitRTPRIO= +#DefaultLimitRTTIME= diff --git a/data/live-build-config/includes.chroot/etc/systemd/system/getty@.service.d/aftervyos.conf b/data/live-build-config/includes.chroot/etc/systemd/system/getty@.service.d/aftervyos.conf new file mode 100644 index 00000000..7eee7bd3 --- /dev/null +++ b/data/live-build-config/includes.chroot/etc/systemd/system/getty@.service.d/aftervyos.conf @@ -0,0 +1,2 @@ +[Unit] +After=vyatta-router.service diff --git a/data/live-build-config/includes.chroot/etc/systemd/system/getty@tty1.service.d/noclear.conf b/data/live-build-config/includes.chroot/etc/systemd/system/getty@tty1.service.d/noclear.conf new file mode 100644 index 00000000..52671c75 --- /dev/null +++ b/data/live-build-config/includes.chroot/etc/systemd/system/getty@tty1.service.d/noclear.conf @@ -0,0 +1,2 @@ +[Service] +TTYVTDisallocate=no diff --git a/data/live-build-config/includes.chroot/lib/systemd/system/ssh-session-cleanup.service b/data/live-build-config/includes.chroot/lib/systemd/system/ssh-session-cleanup.service new file mode 100644 index 00000000..b8672722 --- /dev/null +++ b/data/live-build-config/includes.chroot/lib/systemd/system/ssh-session-cleanup.service @@ -0,0 +1,13 @@ +[Unit] +Description=OpenBSD Secure Shell session cleanup +Wants=network.target +After=network.target + +[Service] +ExecStart=/bin/true +ExecStop=/usr/lib/openssh/ssh-session-cleanup +RemainAfterExit=yes +Type=oneshot + +[Install] +WantedBy=multi-user.target diff --git a/data/includes.chroot/opt/vyatta/etc/config.boot.default b/data/live-build-config/includes.chroot/opt/vyatta/etc/config.boot.default index f5ec2b5d..0a75716b 100644 --- a/data/includes.chroot/opt/vyatta/etc/config.boot.default +++ b/data/live-build-config/includes.chroot/opt/vyatta/etc/config.boot.default @@ -1,4 +1,5 @@ system { + host-name vyos login { user vyos { authentication { diff --git a/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry b/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry new file mode 100644 index 00000000..4107e459 --- /dev/null +++ b/data/live-build-config/includes.chroot/opt/vyatta/etc/grub/default-union-grub-entry @@ -0,0 +1,20 @@ +menuentry "VyOS (KVM console)" { + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=ttyS0,9600 console=tty0 + initrd /boot//initrd.img +} + +menuentry "VyOS (Serial console)" { + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=tty0 console=ttyS0,9600 + initrd /boot//initrd.img +} + +menuentry "Lost password change (KVM console)" { + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=ttyS0,9600 console=tty0 init=/opt/vyatta/sbin/standalone_root_pw_reset + initrd /boot//initrd.img +} + +menuentry "Lost password change (Serial console)" { + linux /boot//vmlinuz boot=live quiet vyos-union=/boot/ console=tty0 console=ttyS0,9600 init=/opt/vyatta/sbin/standalone_root_pw_reset + initrd /boot//initrd.img +} + diff --git a/data/live-build-config/includes.chroot/opt/vyatta/etc/install-image/postinst b/data/live-build-config/includes.chroot/opt/vyatta/etc/install-image/postinst new file mode 100755 index 00000000..d807fa9b --- /dev/null +++ b/data/live-build-config/includes.chroot/opt/vyatta/etc/install-image/postinst @@ -0,0 +1,17 @@ +#!/bin/bash + +source /opt/vyatta/sbin/install-functions + +NEWVER=`mount | grep /mnt/inst_root` +NEWVER=${NEWVER#*upperdir=/live/image/boot/} +NEWVER=${NEWVER%/live-rw*} +DISK_LABEL=`mount | grep /live/image | awk '{print $1}' | grep dev` + +if [ -d "/live/image" ]; then + e2label "${DISK_LABEL}" persistence + if [ ! -f /live/image/persistence.conf ]; then + echo "/ union" > /live/image/persistence.conf + fi + rm -f /live/image/boot/"${NEWVER}"/live-rw/etc/fstab + mv /live/image/boot/"${NEWVER}"/live-rw /live/image/boot/"${NEWVER}"/rw +fi diff --git a/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup b/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup new file mode 100755 index 00000000..f283cc96 --- /dev/null +++ b/data/live-build-config/includes.chroot/usr/lib/openssh/ssh-session-cleanup @@ -0,0 +1,11 @@ +#! /bin/sh + +ssh_session_pattern='sshd: \S.*@pts/[0-9]+' + +IFS="$IFS@" +pgrep -a -f "$ssh_session_pattern" | while read pid daemon user pty; do + echo "Found ${daemon%:} session $pid on $pty; sending SIGTERM" + kill "$pid" || true +done + +exit 0 diff --git a/data/package-lists/common/vyos-base.list.chroot b/data/live-build-config/package-lists/vyos-base.list.chroot index 6e5c1122..225af33a 100644 --- a/data/package-lists/common/vyos-base.list.chroot +++ b/data/live-build-config/package-lists/vyos-base.list.chroot @@ -1,3 +1,4 @@ debconf gpgv gnupg +vyos-world diff --git a/data/live-build-config/package-lists/vyos-utils.list.chroot b/data/live-build-config/package-lists/vyos-utils.list.chroot new file mode 100644 index 00000000..94a90cf6 --- /dev/null +++ b/data/live-build-config/package-lists/vyos-utils.list.chroot @@ -0,0 +1,21 @@ +nmap +dnsutils +ipcalc +sipcalc +mtr-tiny +whois +netcat +netcat6 +socat +telnet +nano +vim-tiny +screen +minicom +wakeonlan +iperf +iperf3 +iftop +lsof +openssh-client +nmap diff --git a/data/package-lists/common/vyos-utils.list.chroot b/data/package-lists/common/vyos-utils.list.chroot deleted file mode 100644 index 3d1a3b2a..00000000 --- a/data/package-lists/common/vyos-utils.list.chroot +++ /dev/null @@ -1,10 +0,0 @@ -nmap -dnsutils -sipcalc -mtr-tiny -whois -netcat -netcat6 -socat -telnet -tcpdump diff --git a/data/package-lists/vyos-arm.list.chroot b/data/package-lists/vyos-arm.list.chroot new file mode 100644 index 00000000..41fcddf8 --- /dev/null +++ b/data/package-lists/vyos-arm.list.chroot @@ -0,0 +1 @@ +grub-efi-arm diff --git a/data/package-lists/vyos-dev.list.chroot b/data/package-lists/vyos-dev.list.chroot new file mode 100644 index 00000000..d057008f --- /dev/null +++ b/data/package-lists/vyos-dev.list.chroot @@ -0,0 +1,2 @@ +gdb +strace diff --git a/data/package-lists/vyos-x86.list.chroot b/data/package-lists/vyos-x86.list.chroot new file mode 100644 index 00000000..300f97dd --- /dev/null +++ b/data/package-lists/vyos-x86.list.chroot @@ -0,0 +1,8 @@ +grub2 +grub-pc +open-vm-tools +qemu-guest-agent + +mlnx-ofed-kernel-modules +iser-modules +ofed-scripts diff --git a/data/versions b/data/versions new file mode 100644 index 00000000..3d0c2871 --- /dev/null +++ b/data/versions @@ -0,0 +1,3 @@ +{ + "current": "1.2.0" +} diff --git a/packages/.gitignore b/packages/.gitignore new file mode 100644 index 00000000..ed11cabe --- /dev/null +++ b/packages/.gitignore @@ -0,0 +1,5 @@ +*.dsc +*.tar.gz +*.deb +*.build +*.changes diff --git a/packages/mdns-repeater b/packages/mdns-repeater new file mode 160000 +Subproject 051977458f4078a06008bb6c6fd338cd994cf56 diff --git a/packages/udp-broadcast-relay b/packages/udp-broadcast-relay new file mode 160000 +Subproject 13127cbd62e69be2d186c9d76d112729ea95a1e diff --git a/packages/vyatta-bash b/packages/vyatta-bash new file mode 160000 +Subproject 001f9b1a9bd2b307bca94510ce05bc067e34f84 diff --git a/packages/vyatta-cfg b/packages/vyatta-cfg new file mode 160000 +Subproject c56e20b98438e33822244315249e3edf0e35659 diff --git a/packages/vyatta-cfg-dhcp-relay b/packages/vyatta-cfg-dhcp-relay new file mode 160000 +Subproject 85c7b8b985685e859067ff75afebdb6fa64ed8e diff --git a/packages/vyatta-cfg-dhcp-server b/packages/vyatta-cfg-dhcp-server new file mode 160000 +Subproject 7440cf0c153d3f6484c96c32d4e02157fb938e2 diff --git a/packages/vyatta-cfg-firewall b/packages/vyatta-cfg-firewall new file mode 160000 +Subproject 5248dbcc34eb6b041af928a0451ea866fc77488 diff --git a/packages/vyatta-cfg-op-pppoe b/packages/vyatta-cfg-op-pppoe new file mode 160000 +Subproject 2de6ecd6068e6a9debb032a074395398f2dc4df diff --git a/packages/vyatta-cfg-qos b/packages/vyatta-cfg-qos new file mode 160000 +Subproject 0a5049b38b0830b289d0052a1fa2ce64785bc6b diff --git a/packages/vyatta-cfg-quagga b/packages/vyatta-cfg-quagga new file mode 160000 +Subproject 82dd077c98131a8a4b3383139e782f534bc310a diff --git a/packages/vyatta-cfg-system b/packages/vyatta-cfg-system new file mode 160000 +Subproject 2f9b0ecaf33c8598dc1a74ac0fb4f34abaad97c diff --git a/packages/vyatta-cfg-vpn b/packages/vyatta-cfg-vpn new file mode 160000 +Subproject 5c1672341b33dc726da5d7845725bd74e3cc7cb diff --git a/packages/vyatta-cluster b/packages/vyatta-cluster new file mode 160000 +Subproject 1881e2ef2fb041e7836db90b12450d63c162847 diff --git a/packages/vyatta-config-mgmt b/packages/vyatta-config-mgmt new file mode 160000 +Subproject a47cd02bca9cb25125e14fe1b731029fb985d89 diff --git a/packages/vyatta-config-migrate b/packages/vyatta-config-migrate new file mode 160000 +Subproject 28f7ce91358975ba9b36ac2874f6b47482815aa diff --git a/packages/vyatta-conntrack b/packages/vyatta-conntrack new file mode 160000 +Subproject 362135271f8bd647d8fa772f775d26c1edcac7c diff --git a/packages/vyatta-conntrack-sync b/packages/vyatta-conntrack-sync new file mode 160000 +Subproject 4f6ae97660e512d90f1d4ac9822cdc1172f0fdf diff --git a/packages/vyatta-eventwatch b/packages/vyatta-eventwatch new file mode 160000 +Subproject ab07c835d1b09ab5424190dd240dfa65e77b81f diff --git a/packages/vyatta-iproute b/packages/vyatta-iproute new file mode 160000 +Subproject 0b78fea66ab7d8ae84da7345650965e1752e1c2 diff --git a/packages/vyatta-ipv6-rtradv b/packages/vyatta-ipv6-rtradv new file mode 160000 +Subproject 809508f4b3248e8dc4bfbcb527084d3bac4c78f diff --git a/packages/vyatta-lldp b/packages/vyatta-lldp new file mode 160000 +Subproject b7c70732793bfd88c23ffb424bf44fd65b0bf8b diff --git a/packages/vyatta-nat b/packages/vyatta-nat new file mode 160000 +Subproject 52fb9ab3f8a1d1aeda0149946b1e1b77617bc6c diff --git a/packages/vyatta-netflow b/packages/vyatta-netflow new file mode 160000 +Subproject 22b60a0e4dc9ff7d4001b55bf1f17e55e526738 diff --git a/packages/vyatta-op b/packages/vyatta-op new file mode 160000 +Subproject 6152bc3abd0cb1dc6c7717a653558a1c3393fe3 diff --git a/packages/vyatta-op-dhcp-server b/packages/vyatta-op-dhcp-server new file mode 160000 +Subproject 2c8c4ae26ea671cd48c80335b127bbac7ad0783 diff --git a/packages/vyatta-op-firewall b/packages/vyatta-op-firewall new file mode 160000 +Subproject 7ad3f22bedd1ce169b076fd3fabb32761082b66 diff --git a/packages/vyatta-op-qos b/packages/vyatta-op-qos new file mode 160000 +Subproject ec1c87ec516d0814d1f4b6115dd93b4287f3055 diff --git a/packages/vyatta-op-quagga b/packages/vyatta-op-quagga new file mode 160000 +Subproject 24189c4533bc9147ac3c780ce80bf49194beb67 diff --git a/packages/vyatta-op-vpn b/packages/vyatta-op-vpn new file mode 160000 +Subproject 0ec07e891b0191b24185ea09c6f33f6502597df diff --git a/packages/vyatta-openvpn b/packages/vyatta-openvpn new file mode 160000 +Subproject 5f754cd2c2660f3fd58210c92d5847225fc2b6b diff --git a/packages/vyatta-quagga b/packages/vyatta-quagga new file mode 160000 +Subproject b721e84e0915406cb5458fea7f444b45b5d1196 diff --git a/packages/vyatta-ravpn b/packages/vyatta-ravpn new file mode 160000 +Subproject 6fb662b78e2b688d2a00d0221821904ef841b39 diff --git a/packages/vyatta-util b/packages/vyatta-util new file mode 160000 +Subproject 22ee60e33a9e5fc4dc372ae8798b4f05d1b520c diff --git a/packages/vyatta-vrrp b/packages/vyatta-vrrp new file mode 160000 +Subproject c6411d8c4c1a11f0305ddee2824d7081cd2654a diff --git a/packages/vyatta-wanloadbalance b/packages/vyatta-wanloadbalance new file mode 160000 +Subproject c4ad578e0d82b688d5ed60b649604982eae8350 diff --git a/packages/vyatta-webgui b/packages/vyatta-webgui new file mode 160000 +Subproject 30133ba0fd68b0c3726127f195e1058c427fe58 diff --git a/packages/vyatta-webproxy b/packages/vyatta-webproxy new file mode 160000 +Subproject 4a86d4a3f886b8b42311dabd0ddceabdf8cdd51 diff --git a/packages/vyatta-wireless b/packages/vyatta-wireless new file mode 160000 +Subproject 5b92a6e5a446b3b74ad78832ea82f977d6bba32 diff --git a/packages/vyatta-wirelessmodem b/packages/vyatta-wirelessmodem new file mode 160000 +Subproject 8022e5ca50591afa2db948fd9454ce4f4cfb406 diff --git a/packages/vyatta-zone b/packages/vyatta-zone new file mode 160000 +Subproject f8f40ba6bf5a95a5b147f9cd0e7e425cdb9c015 diff --git a/packages/vyos-1x b/packages/vyos-1x new file mode 160000 +Subproject 4022a8820ccf0539f2eb5c19d9abd777810a48b diff --git a/packages/vyos-igmpproxy b/packages/vyos-igmpproxy new file mode 160000 +Subproject 97db97216f05756b6428449412e35f8b06dc73f diff --git a/packages/vyos-keepalived b/packages/vyos-keepalived new file mode 160000 +Subproject dc8ade02407f836873e78887f4b3c94b6540a57 diff --git a/packages/vyos-kernel b/packages/vyos-kernel new file mode 160000 +Subproject 123087671203ad50989a2ff0c91d0df2dc4d32e diff --git a/packages/vyos-nhrp b/packages/vyos-nhrp new file mode 160000 +Subproject aae14502e55b41e822d890ba08e3460609454cd diff --git a/packages/vyos-pppoe-server b/packages/vyos-pppoe-server new file mode 160000 +Subproject 566709144fb119d32cc029615cff2e688a8a755 diff --git a/packages/vyos-world b/packages/vyos-world new file mode 160000 +Subproject 5055f0b8215df93c2973d8b35ac40fa8b526d0a diff --git a/scripts/Vagrantfile b/scripts/Vagrantfile new file mode 100644 index 00000000..7c89422d --- /dev/null +++ b/scripts/Vagrantfile @@ -0,0 +1,12 @@ +Vagrant.configure("2") do |config| + config.vm.synced_folder './', '/vagrant', + type: "rsync", + owner: 'vyos', + group: 'users', + mount_options: ['dmode=775,fmode=775'] + config.ssh.username = "vyos" + config.ssh.password = "vyos" + config.vm.provider :libvirt do |libvirt| + libvirt.driver = "kvm" + end +end diff --git a/scripts/build-clearfog-image b/scripts/build-clearfog-image new file mode 100755 index 00000000..0ef6d323 --- /dev/null +++ b/scripts/build-clearfog-image @@ -0,0 +1,158 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 or later as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-clearfog-image +# Purpose: +# Build VyOS image for for Solidrun clearfog. + +lb bootstrap +lb chroot +lb installer +lb binary_chroot +lb chroot_devpts install +lb chroot_proc install +lb chroot_selinuxfs install +lb chroot_sysfs install +lb chroot_hosts install +lb chroot_resolv install +lb chroot_hostname install +lb chroot_sysv-rc install +lb chroot_upstart install +lb chroot_apt install-binary +lb chroot_archives chroot install +lb binary_rootfs +lb binary_manifest +lb binary_package-lists +lb binary_linux-image +lb binary_memtest +lb binary_grub +lb binary_grub2 +lb binary_syslinux +lb binary_disk +lb binary_loadlin +lb binary_win32-loader +lb binary_includes +lb binary_hooks +lb binary_checksums + +# get vyos build version +version=$(cat version) +dateymd=$(date +%Y%m%d) + +# create sd-card image and partition it +qemu-img create -f raw sr-a38x-cf-vyos-"$dateymd"-testing.img 1.8G +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img mklabel msdos +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img mkpart primary fat16 8192s 60 +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img mkpart primary ext2 60 1900 +parted --script sr-a38x-cf-vyos-"$dateymd"-testing.img set 1 boot on + +# mount image and create filesystems +losetup /dev/loop0 sr-a38x-cf-vyos-"$dateymd"-testing.img +partprobe /dev/loop0 +mkfs.vfat -n EFI -F 16 -I /dev/loop0p1 +mkfs.ext2 -L persistence /dev/loop0p2 + +# mount image partitions +mkdir -p /boot/efi +mount /dev/loop0p1 /boot/efi +mkdir -p /mnt +mount /dev/loop0p2 /mnt + +# setup files on image +mkdir -p /mnt/boot/grub +mkdir -p /mnt/boot/"$version"/rw +echo "/ union" > /mnt/persistence.conf +cp binary/live/filesystem.squashfs /mnt/boot/"$version"/"$version.squashfs" +cp binary/live/initrd.img-* /mnt/boot/"$version"/initrd.img +cp binary/live/vmlinuz-* /mnt/boot/"$version"/vmlinuz +cp ../tools/armada-388-clearfog.dtb /boot/efi/armada-388-clearfog.dtb + +# create boot script +cat > /boot/efi/boot.script << EOF +# load DTB +echo "Loading armada-388-clearfog.dtb" +load mmc 0:1 \$fdt_addr_r armada-388-clearfog.dtb +fdt addr \$fdt_addr_r 20000 + +# load efi +echo "Loading EFI image ..." +load mmc 0:1 \$loadaddr EFI/debian/grubarm.efi + +# Sleep a while so the MMC driver can settle down +echo "Sleeping 5 seconds ..." +sleep 5 + +# boot +echo "Booting ..." +bootefi \$loadaddr +EOF + +# compile boot script for u-boot +mkimage -A arm -O linux -T script -C none -a 0 -e 0 -d /boot/efi/boot.script /boot/efi/boot.scr + +# create grub config file to include +cat > load.cfg << EOF +set root=(hd0,msdos2) +set prefix=(hd0,msdos2)/boot/grub +devicetree (hd0,msdos1)/armada-388-clearfog.dtb +insmod normal +normal +EOF + +# create grub menu +cat > /mnt/boot/grub/grub.cfg << EOF +set default=0 +set timeout=5 + +echo -n Press ESC to enter the Grub menu... +if sleep --verbose --interruptible 5 ; then + terminal_input console serial +fi + + +menuentry "VyOS $version (Serial console)" { + linux /boot/"$version"/vmlinuz boot=live quiet vyos-union=/boot/"$version" console=ttyS0,115200n8 + initrd /boot/"$version"/initrd.img +} + +menuentry "Lost password change $version (Serial console)" { + linux /boot/"$version"/vmlinuz boot=live quiet vyos-union=/boot/"$version" console=ttyS0,115200n8 init=/opt/vyatta/sbin/standalone_root_pw_reset + initrd /boot/"$version"/initrd.img +} +EOF + +# install efi grub to image +grub-install --efi-directory /boot/efi --boot-directory /mnt/boot -d /usr/lib/grub/arm-efi /dev/loop0 + +# create grub efi executable +grub-mkimage -O arm-efi -p /boot/grub -d /usr/lib/grub/arm-efi -c load.cfg \ +ext2 iso9660 linux echo configfile \ +search_label search_fs_file search \ +search_fs_uuid ls normal gzio \ +png fat gettext font minicmd \ +gfxterm gfxmenu video video_fb \ +part_msdos part_gpt > /boot/efi/EFI/debian/grubarm.efi + +# unmount image partitions +umount /mnt +umount /boot/efi + +# write u-boot to image +dd if=../tools/u-boot-spl.kwb of=/dev/loop0 bs=512 seek=1 + +# unmount image +sudo losetup -D + +# compress image +xz -v sr-a38x-cf-vyos-"$dateymd"-testing.img diff --git a/scripts/build-config b/scripts/build-config index 7d1aa66b..27a6c7ba 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -1,4 +1,27 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# +# Copyright (C) 2018, VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-config +# Purpose: +# This script serves the same purpose as ./configure in traditional +# autoconf setups. +# It takes build configuration options from command line, checks them, +# builds a config dictionary, augments it with some default and/or +# computed values and saves it to build/build-config.json +# for other build scripts to read. import argparse import re @@ -19,28 +42,80 @@ def field_to_option(s): def get_default_build_by(): return "{user}@{host}".format(user= getpass.getuser(), host=platform.node()) +def get_validator(optdict, name): + try: + return optdict[name][2] + except KeyError: + return None + +# Options dict format: +# '$option_name_without_leading_dashes': { ('$help_string', $default_value_generator_thunk, $value_checker_thunk) } options = { - 'architecture': ('Image target architecture (amd64 or i586)', lambda: 'amd64', lambda x: x in ['amd64', 'i586']), - 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None) + 'architecture': ('Image target architecture (amd64 or i586 or armhf)', lambda: 'amd64', lambda x: x in ['amd64', 'i586', 'armhf']), + 'build-by': ('Builder identifier (e.g. jrandomhacker@example.net)', get_default_build_by, None), + 'debian-mirror': ('Debian repository mirror for ISO build', lambda: defaults.DEBIAN_MIRROR, None), + 'debian-security-mirror': ('Debian security updated mirror', lambda: defaults.DEBIAN_SECURITY_MIRROR, None), + 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), + 'vyos-mirror': ('VyOS package mirror', lambda: defaults.VYOS_MIRROR, None), + 'build-type': ('Build type, release or development', lambda: 'development', lambda x: x in ['release', 'development']), + 'version': ('Version number (release builds only)', None, None) } # Create the option parser parser = argparse.ArgumentParser() for k, v in options.items(): - parser.add_argument('--' + k, type=str, help=v[0], default=v[1]()) + help_string, default_value_thunk = v[0], v[1] + if default_value_thunk is None: + parser.add_argument('--' + k, type=str, help=help_string) + else: + parser.add_argument('--' + k, type=str, help=help_string, default=default_value_thunk()) + +# The debug option is a bit special since it's different type +parser.add_argument('--debug', help="Enable debug output", action='store_true') args = vars(parser.parse_args()) # Validate options for k, v in args.items(): key = field_to_option(k) - func = options[key][2] + func = get_validator(options, k) if func is not None: if not func(v): print("{v} is not a valid value for --{o} option".format(o=key, v=v)) sys.exit(1) +# Some fixup for mirror settings. +# The idea is: if --debian-mirror is specified but --pbuilder-debian-mirror is not, +# use the --debian-mirror value for both lb and pbuilder bootstrap +if (args['debian_mirror'] != defaults.DEBIAN_MIRROR) and \ + (args['pbuilder_debian_mirror'] == defaults.DEBIAN_MIRROR): + args['pbuilder_debian_mirror'] = args['debian_mirror'] + +# Version can only be set for release builds, +# for dev builds it hardly makes any sense +if args['build_type'] == 'development': + if args['version'] is not None: + print("Version can only be set for release builds") + print("Use --build-type=release option if you want to set version number") + sys.exit(1) + +# Populate some defaults that are not configurable, +# but that are handy to have in the options hash +args['distribution'] = defaults.DEBIAN_DISTRIBUTION +args['build_dir'] = os.path.join(os.getcwd(), defaults.BUILD_DIR) +args['pbuilder_config'] = defaults.PBUILDER_CONFIG +args['vyos_branch'] = defaults.VYOS_BRANCH + +# Check the build environment and dependencies +env_check_retval = os.system("scripts/check-build-env") +if env_check_retval > 0: + print("Build environment check failed, fix the issues and retry") + + # Save to file +os.makedirs(defaults.BUILD_DIR, exist_ok=True) +print("Saving the build config to {0}".format(defaults.BUILD_CONFIG)) with open(defaults.BUILD_CONFIG, 'w') as f: - json.dump(args, f) + json.dump(args, f, indent=4, sort_keys=True) + print("\n", file=f) diff --git a/scripts/build-flavour b/scripts/build-flavour new file mode 100755 index 00000000..c14f5735 --- /dev/null +++ b/scripts/build-flavour @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-flavour +# Purpose: Adds various data files to the build config +# depending on the build flavour. + + +BUILD_TYPE=$(scripts/query-json build/build-config.json build_type) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) + +# Add debug tools if it's a development image +if [ $BUILD_TYPE = "development" ]; then + cp data/package-lists/vyos-dev.list.chroot build/config/package-lists/ +fi + +# Install grub-pc if it's an x86 build +if [ $BUILD_ARCH = 'amd64' -o $BUILD_ARCH = 'i686' ]; then + cp data/package-lists/vyos-x86.list.chroot build/config/package-lists/ +fi + +# Install grub-efi-arm if it's an arm build +if [ $BUILD_ARCH = 'armhf' -o $BUILD_ARCH = 'armel' -o $BUILD_ARCH = 'arm' ]; then + cp data/package-lists/vyos-arm.list.chroot build/config/package-lists/ +fi diff --git a/scripts/build-hyperv-image b/scripts/build-hyperv-image new file mode 100755 index 00000000..40c0c828 --- /dev/null +++ b/scripts/build-hyperv-image @@ -0,0 +1,32 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-hyperv-image +# Purpose: +# Build VyOS image for Hyper-V. + +export PACKER_BUILD_DIR=packer_build + +DST_DIR=${PACKER_BUILD_DIR}/hyperv +mkdir -p ${DST_DIR} + +# Convert raw image to VHD +source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img +vhd=${DST_DIR}/vyos_hyperv_image.vhd +qemu-img convert -f raw ${source_image} -O vpc ${vhd} +if [ "$?" = "0" ]; then + echo "Hyper-V image successfully created to ./${vhd}" +fi diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image new file mode 100755 index 00000000..29cb6cf1 --- /dev/null +++ b/scripts/build-qemu-image @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-qemu-image +# Purpose: +# Build VyOS raw image for qemu. + +BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) +export VERSION=$(cat $BUILD_DIR/version) + +export ISO_IMAGE=./build/live-image-$BUILD_ARCH.hybrid.iso +export ISO_MD5_SUM=$(md5sum ${ISO_IMAGE} | awk '{print $1}') +export PACKER_BUILD_DIR=packer_build +export PACKER_LOG_PATH=${PACKER_BUILD_DIR}/build.log +export PACKER_LOG=1 + +mkdir -p ${PACKER_BUILD_DIR} + +packer build -only=qemu-image scripts/packer.json diff --git a/scripts/build-vagrant-libvirt-box b/scripts/build-vagrant-libvirt-box new file mode 100755 index 00000000..6db77c2a --- /dev/null +++ b/scripts/build-vagrant-libvirt-box @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-vagrant-libvirt-box +# Purpose: +# Build VyOS Vagrant libvirt box. + +export PACKER_BUILD_DIR=packer_build + +DST_DIR=${PACKER_BUILD_DIR}/vagrant-libvirt +BOX_DIR=${DST_DIR}/box +mkdir -p ${BOX_DIR} + +# Copy qcow2 image +cp -p packer_build/qemu/vyos_qemu_image.img ${BOX_DIR}/box.img + +# Put metadata.json and Vagrantfile +echo '{"format":"qcow2","provider":"libvirt","virtual_size":4}' > ${BOX_DIR}/metadata.json +cat <<EOF > ${BOX_DIR}/Vagrantfile +Vagrant.configure("2") do |config| + config.vm.synced_folder './', '/vagrant', + type: "rsync", + owner: 'vyos', + group: 'users', + mount_options: ['dmode=775,fmode=775'] + config.ssh.username = "vyos" + config.ssh.password = "vyos" + config.vm.provider :libvirt do |libvirt| + libvirt.driver = "kvm" + end +end +EOF + +# Create box +box=${DST_DIR}/vyos_vagrant_libvirt.box +tar -C ${BOX_DIR} -czvf ${box} metadata.json Vagrantfile box.img +if [ "$?" = "0" ]; then + echo "Vagrant libvirt box successfully created to ./${box}" +fi + +PROVIDER=libvirt + +# Create version +major=$(cat build/version | cut -d'+' -f2 | cut -d'-' -f1 | rev | cut -c 5- | rev) +sub=$(cat build/version | cut -d'+' -f2 | cut -d'-' -f1 | rev | cut -c 3-4 | rev) +minor=$(cat build/version | cut -d'+' -f2 | cut -d'-' -f1 | rev | cut -c 1-2 | rev) +version=$(echo "$major.$sub.$minor") +curl -XPOST -d "version[version]=${version}" \ + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/versions?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} +echo + +# Create provider +urlencoded_version=$(cat build/version | sed 's/+/%2B/') +curl -XPOST -d "provider[name]=${PROVIDER}" -d "provider[url]=${VAGRANT_BOX_BASE_URL}/vyos-${urlencoded_version}-vagrant-${PROVIDER}.box" \ + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${version}/providers?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} +echo + +# Release version +curl -XPUT \ + https://app.vagrantup.com/api/v1/box/${VAGRANT_BOX_NAME}/version/${version}/release?access_token=${VAGRANT_CLOUD_ACCESS_TOKEN} +echo diff --git a/scripts/build-vmware-image b/scripts/build-vmware-image new file mode 100755 index 00000000..1730d7a3 --- /dev/null +++ b/scripts/build-vmware-image @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: build-vmware-image +# Purpose: +# Build VyOS OVA and OVF for VMware. + +if [ ! $(which vmdk-convert) ]; then + echo "Your system doesn't have vmdk-convert. Please install it from https://github.com/vmware/open-vmdk." + exit 1 +else + echo "Your system has vmdk-convert." +fi + +if [ ! $(which ovftool) ]; then + echo "Your system doesn't have ovftool. Please install it from https://www.vmware.com/support/developer/ovf/." + exit 1 +else + echo "Your system has ovftool." +fi + +export PACKER_BUILD_DIR=packer_build + +DST_DIR=${PACKER_BUILD_DIR}/vmware +mkdir -p ${DST_DIR} + +# Convert qcow2 image to VMDK +source_image=${PACKER_BUILD_DIR}/qemu/vyos_qemu_image.img +tmp_vmdk=${DST_DIR}/tmp.vmdk +vmdk=${DST_DIR}/vyos_vmware_image.vmdk +ovf=${DST_DIR}/vyos_vmware_image.ovf +qemu-img convert -f qcow2 ${source_image} -O vmdk -o adapter_type=lsilogic ${tmp_vmdk} +vmdk-convert ${tmp_vmdk} ${vmdk} + +# Generate OVF +echo 'Generating OVF file...' +vmdk_file_size=$(du --bytes ${vmdk} | cut -f1) +vmdk_populated_size=$(vmdk-convert -i ${vmdk} | jq .used) +version=$(cat build/version) +sed scripts/template.ovf \ + -e "s/{{vmdk_file_size}}/${vmdk_file_size}/" \ + -e "s/{{vmdk_populated_size}}/${vmdk_populated_size}/" \ + -e "s/{{version}}/${version}/" \ + > ${ovf} + +# Generate manifest file +cd ${DST_DIR} +openssl sha1 *.vmdk *.ovf > vyos_vmware_image.mf + +# Convert the OVF to signed OVA... +echo 'Converting the OVF to signed OVA...' +private_key=${PRIVATE_KEY_PATH:-"../../key/privatekey.pem"} +if [ ! -f ${private_key} ]; then + echo 'Please put your key to "key/privatekey.pem" in repository root, or set PRIVATE_KEY_PATH to environment variables.' + exit 1 +fi +ovftool --privateKey=${PRIVATE_KEY_PATH} vyos_vmware_image.ovf vyos_vmware_image-signed.ova + +# Convert the OVF to signed OVF... +echo 'Converting the OVF to signed OVF...' +ovftool --privateKey=${PRIVATE_KEY_PATH} vyos_vmware_image.ovf vyos_vmware_image-signed.ovf diff --git a/scripts/check-build-env b/scripts/check-build-env index 11e1c66b..7377be64 100755 --- a/scripts/check-build-env +++ b/scripts/check-build-env @@ -1,35 +1,54 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: check-build-env +# Purpose: +# Checks if packages required for package and ISO image build +# are installed. + import os import sys -required_packages = [ - 'make', - 'live-build', - 'pbuilder', - 'devscripts', - 'python-pystache' -] - - -def is_installed(name): - result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) - return True if result == 0 else False - - -missing_packages = [] +import util + +deps = { + 'packages': [ + 'sudo', + 'make', + 'live-build', + 'pbuilder', + 'devscripts', + 'python3-pystache', + 'python3-git' + ], + 'binaries': [] +} print("Checking if packages required for VyOS image build are installed") -for p in required_packages: - if not is_installed(p): - missing_packages.append(p) +checker = util.DependencyChecker(deps) -if missing_packages: - print("Your system does not have some of the required packages installed.") - print("Please install the following packages:") - print(" ".join(missing_packages)) - sys.exit(1) -else: - print("All required packages are installed") +missing = checker.get_missing_dependencies() +if not missing: + print("All dependencies are installed") sys.exit(0) +else: + checker.print_missing_deps() + sys.exit(1) + +sys.exit(0) + diff --git a/scripts/check-config b/scripts/check-config index 3949869b..d2236619 100755 --- a/scripts/check-config +++ b/scripts/check-config @@ -1,14 +1,38 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: check-config +# Purpose: +# Checks if the build config file (build/build-config.json) exists. +# This is to prevent accidental execution of plumbing make targets +# from going too far and failing with confusing errors. + import sys -import os +import json import defaults print("Checking build configuration") -if not os.path.exists(defaults.BUILD_CONFIG): - print("Build config does not exist") +try: + with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) +except: + print("Build config does not exist or is not a valid JSON file") print("Please run the ./configure script and try again") sys.exit(1) diff --git a/scripts/check-vm-build-env b/scripts/check-vm-build-env new file mode 100755 index 00000000..8efab848 --- /dev/null +++ b/scripts/check-vm-build-env @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: check-vm-build-env +# Purpose: +# Checks if packages required for VM image build are installed. + + +import os +import sys + +import util + +deps = { + 'packages': [ + 'jq', + 'qemu-system-x86', + 'qemu-utils' + ], + 'binaries': ['packer'] +} + +print("Checking if packages required for VyOS image build are installed") + +checker = util.DependencyChecker(deps) + +missing = checker.get_missing_dependencies() +if not missing: + print("All dependencies are installed") + sys.exit(0) +else: + checker.print_missing_deps() + if 'packer' in missing['binaries']: + print("Your system does not have Packer.") + print("Please install Packer from https://www.packer.io/downloads.html.") + sys.exit(1) + +sys.exit(0) diff --git a/scripts/copy-image b/scripts/copy-image new file mode 100755 index 00000000..01af511d --- /dev/null +++ b/scripts/copy-image @@ -0,0 +1,7 @@ +#!/bin/sh + +BUILD_DIR=$(scripts/query-json build/build-config.json build_dir) +BUILD_ARCH=$(scripts/query-json build/build-config.json architecture) +VERSION=$(cat $BUILD_DIR/version) + +ln -nsf $BUILD_DIR/live-image-$BUILD_ARCH.hybrid.iso $BUILD_DIR/vyos-$VERSION-$BUILD_ARCH.iso diff --git a/scripts/defaults.py b/scripts/defaults.py index 96dfcc98..93eadc30 100644 --- a/scripts/defaults.py +++ b/scripts/defaults.py @@ -1,4 +1,40 @@ +# Copyright (C) 2018 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: defaults.py +# Purpose: Various default values for use in build scripts. + + import os BUILD_DIR = 'build' BUILD_CONFIG = os.path.join(BUILD_DIR, 'build-config.json') + +# The default mirror was chosen entirely at random +DEBIAN_MIRROR = 'http://deb.debian.org/debian' +DEBIAN_SECURITY_MIRROR = 'http://deb.debian.org/debian-security' + +DEBIAN_DISTRIBUTION = 'jessie' + +PBUILDER_CONFIG = os.path.join(BUILD_DIR, 'pbuilderrc') +PBUILDER_DIR = os.path.join(BUILD_DIR, 'pbuilder') + +LB_CONFIG_DIR = os.path.join(BUILD_DIR, 'config') +CHROOT_INCLUDES_DIR = os.path.join(LB_CONFIG_DIR, 'includes.chroot') + +VYOS_MIRROR = 'http://dev.packages.vyos.net/repositories/current' + +VYOS_BRANCH = 'current' + +VYOS_REPO_FILE = 'config/archives/vyos.list.chroot' diff --git a/scripts/import-local-packages b/scripts/import-local-packages new file mode 100755 index 00000000..70b4c365 --- /dev/null +++ b/scripts/import-local-packages @@ -0,0 +1,13 @@ +#!/bin/sh + +LOCAL_PKG_DIR=build/config/packages.chroot + +mkdir -p $LOCAL_PKG_DIR + +FILES=packages/*.deb +for f in $FILES +do + if [ -e "$f" ]; then + cp $f $LOCAL_PKG_DIR + fi +done diff --git a/scripts/live-build-config b/scripts/live-build-config index 59f0bbb2..b1a77b4c 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -1,4 +1,24 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# +# Copyright (C) 2018 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: live-build-config +# Purpose: +# Creates a live-build config command from template using the build config +# and executes it, to prepare the system for building the installation ISO. + import sys import os @@ -14,7 +34,9 @@ util.check_build_config() lb_config_tmpl = """ lb config noauto \ --architectures {{architecture}} \ - --bootappend-live "boot=live components hostname=vyos username=live" \ + --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ + --linux-flavours {{architecture}}-vyos \ + --linux-packages linux-image-4.14.26 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ @@ -22,18 +44,48 @@ lb config noauto \ --iso-application "VyOS" \ --iso-publisher "{{build_by}}" \ --iso-volume "VyOS" \ - --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown" \ + --debootstrap-options "--variant=minbase --exclude=isc-dhcp-client,isc-dhcp-common,ifupdown --include=apt-transport-https" \ + --mirror-bootstrap {{debian_mirror}} \ + --mirror-chroot {{debian_mirror}} \ + --mirror-chroot-security {{debian_security_mirror}} \ + --mirror-binary {{debian_mirror}} \ + --mirror-binary-security {{debian_security_mirror}} \ + --archive-areas "main contrib non-free" \ + --firmware-chroot true \ + --updates true \ + --security true \ + --apt-indices false "${@}" """ with open(defaults.BUILD_CONFIG, 'r') as f: build_config = json.load(f) +debug = build_config['debug'] + +# Add the additional repositories to package lists +print("Setting up additional APT entries") +vyos_repo_entry = "deb {0}/vyos {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) +vyos_debian_repo_entry = "deb {0}/debian {1} main\n".format(build_config['vyos_mirror'], build_config['vyos_branch']) + +apt_file = os.path.join(build_config['build_dir'], defaults.VYOS_REPO_FILE) + +if debug: + print("Adding these entries to {0}:".format(apt_file)) + print("\t", vyos_repo_entry) + print("\t", vyos_debian_repo_entry) + +with open(apt_file, 'w') as f: + f.write(vyos_repo_entry) + f.write(vyos_debian_repo_entry) + +# Configure live-build + lb_config_command = pystache.render(lb_config_tmpl, build_config) print("Configuring live-build") -os.chdir(defaults.BUILD_DIR) +os.chdir(defaults.BUILD_DIR) result = os.system(lb_config_command) if result > 0: print("live-build config failed") diff --git a/scripts/make-version-file b/scripts/make-version-file new file mode 100755 index 00000000..95574722 --- /dev/null +++ b/scripts/make-version-file @@ -0,0 +1,89 @@ +#!/usr/bin/python3 +# +# Copyright (C) 2018 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: make-version-file +# Purpose: +# Creates version file in live-build chroot includes dir +# that is included in the image and used by 'show version' command +# and install/upgrade scripts. + +import os +import datetime +import json +import uuid + +import git + +import defaults +import util + +# Load the build config +util.check_build_config() +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +# Create a build timestamp +now = datetime.datetime.today() +build_timestamp = now.strftime("%Y%m%d%H%M") + +# FIXME: use aware rather than naive object +build_date = now.strftime("%a %d %b %Y %H:%M UTC") + +# Assign a (hopefully) unique identifier to the build (UUID) +build_id = str(uuid.uuid4()) + +# Create a build version +if build_config['build_type'] == 'development': + try: + # Load the branch to version mapping file + with open('data/versions') as f: + version_mapping = json.load(f) + + repo = git.Repo('.') + git_branch = repo.active_branch.name + branch_version = version_mapping[git_branch] + + version = "{0}-rolling+{1}".format(branch_version, build_timestamp) + except Exception as e: + print("Could not build a version string specific to git branch, falling back to default: {0}".format(str(e))) + version = "999.{0}".format(build_timestamp) +else: + # Release build, use the version from ./configure arguments + version = build_config['version'] + +version_data = { + 'version': version, + 'built_by': build_config['build_by'], + 'built_on': build_date, + 'build_id': build_id +} + + +os.makedirs(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/share/vyos'), exist_ok=True) +with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'usr/share/vyos/version.json'), 'w') as f: + json.dump(version_data, f) + +# For backwards compatibility with 'add system image' script from older versions +# we need a file in old format so that script can find out the version of the image +# for upgrade +with open(os.path.join(defaults.CHROOT_INCLUDES_DIR, 'opt/vyatta/etc/version'), 'w') as f: + print("Version: {0}".format(version), file=f) + +# Leaky abstraction: we want ISO file name include version number, +# but we probably don't want to have a separate build step just for this, +# neither we want to use lengthy paths in makefiles +with open(os.path.join(defaults.BUILD_DIR, 'version'), 'w') as f: + print(version, file=f) diff --git a/scripts/packer-scripts/vmware.sh b/scripts/packer-scripts/vmware.sh new file mode 100644 index 00000000..60c4db7e --- /dev/null +++ b/scripts/packer-scripts/vmware.sh @@ -0,0 +1,29 @@ +#!/bin/vbash +source /opt/vyatta/etc/functions/script-template + +# Add Debian Jessie repository +set system package repository jessie url 'http://ftp.nl.debian.org/debian/' +set system package repository jessie distribution 'jessie' +set system package repository jessie components 'main contrib non-free' +commit +save + +# Install open-vm-tools +sudo apt-get update +sudo apt-get -y install open-vm-tools + +# Delete Debian Jessie repository +delete system package repository jessie +commit +save + +# Removing leftover leases and persistent rules +sudo rm -f /var/lib/dhcp3/* + +# Removing apt caches +sudo rm -rf /var/cache/apt/* + +# Removing hw-id +delete interfaces ethernet eth0 hw-id +commit +save diff --git a/scripts/packer.json b/scripts/packer.json new file mode 100644 index 00000000..218b2a85 --- /dev/null +++ b/scripts/packer.json @@ -0,0 +1,62 @@ +{ + "variables": { + "iso_url": "{{env `ISO_IMAGE`}}", + "iso_checksum": "{{env `ISO_MD5_SUM`}}", + "output_directory": "{{env `PACKER_BUILD_DIR`}}" + }, + "builders": + [ + { + "name": "qemu-image", + "type": "qemu", + "iso_url": "{{user `iso_url`}}", + "iso_checksum": "{{user `iso_checksum`}}", + "iso_checksum_type": "md5", + "output_directory": "{{user `output_directory`}}/qemu", + "shutdown_command": "sudo halt -p", + "disk_size": 4096, + "format": "qcow2", + "headless": true, + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + "ssh_username": "vyos", + "ssh_password": "vyos", + "ssh_port": 22, + "ssh_wait_timeout": "300s", + "vm_name": "vyos_qemu_image.img", + "net_device": "virtio-net", + "disk_interface": "virtio", + "boot_wait": "5s", + "boot_command": + [ + "<enter><wait3m>", + "vyos<enter><wait5>", + "vyos<wait><enter><wait10>", + "install image<enter><wait5>", + "<enter><wait5>", + "<enter><wait5>", + "<enter><wait5>", + "Yes<enter><wait5>", + "<enter><wait10>", + "<enter><wait5>", + "<enter><wait5>", + "vyos<enter><wait5>", + "vyos<enter><wait10>", + "<enter><wait10><wait10>", + "reboot<enter><wait5>", + "Yes<enter><wait3m>", + "vyos<enter><wait5>", + "vyos<enter><wait10>", + "configure<enter><wait5>", + "set interface ethernet eth0 address dhcp<enter><wait5>", + "set service ssh<enter><wait5>", + "commit<enter><wait5>", + "save<enter><wait5>", + "delete interface ethernet eth0 hw-id<enter><wait5>", + "commit<enter><wait5>", + "save<enter><wait5>", + "exit<enter><wait5>" + ] + } + ] +} diff --git a/scripts/pbuilder-config b/scripts/pbuilder-config new file mode 100755 index 00000000..06e14cbf --- /dev/null +++ b/scripts/pbuilder-config @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: pbuilder-config +# Purpose: +# Generates a pbuilderrc file for use by package build scripts. + + +import sys +import os +import json + +import pystache + +import defaults +import util + +util.check_build_config() + +pbuilder_config_tmpl = """ + +BASETGZ={{build_dir}}/base.tgz +BUILDPLACE={{build_dir}}/pbuilder/ +MIRRORSITE={{pbuilder_debian_mirror}} +BUILDRESULT={{build_dir}}/pbuilder/result/ + +DISTRIBUTION={{distribution}} + +ARCHITECTURE={{architecture}} + +""" + +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +pbuilder_config = pystache.render(pbuilder_config_tmpl, build_config) + +print("Configuring pbuilder") + +with open(defaults.PBUILDER_CONFIG, 'w+') as f: + f.write(pbuilder_config) diff --git a/scripts/pbuilder-setup b/scripts/pbuilder-setup new file mode 100755 index 00000000..a89348b8 --- /dev/null +++ b/scripts/pbuilder-setup @@ -0,0 +1,52 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: pbuilder-setup +# Purpose: +# Bootstraps a Debian environment for use by pbuilder. + + +import sys +import os +import json +import distutils.dir_util + +import pystache + +import defaults +import util + +util.check_build_config() + +pbuilder_create_cmd_tmpl= """ + sudo pbuilder --create \ + --configfile {{pbuilder_config}} +""" + +with open(defaults.BUILD_CONFIG, 'r') as f: + build_config = json.load(f) + +pbuilder_create_command = pystache.render(pbuilder_create_cmd_tmpl, build_config) + +print("Creating a pbuilder environment") +#os.chdir(defaults.BUILD_DIR) + +distutils.dir_util.mkpath(defaults.PBUILDER_DIR) + +result = os.system(pbuilder_create_command) +if result > 0: + print("pbuilder environment bootstrap failed") + sys.exit(1) diff --git a/scripts/pbuilder/hooks/C10shell b/scripts/pbuilder/hooks/C10shell new file mode 100755 index 00000000..f56f9f7f --- /dev/null +++ b/scripts/pbuilder/hooks/C10shell @@ -0,0 +1,6 @@ +#!/bin/sh +# invoke shell if build fails. + +apt-get install -y --force-yes vim nano less bash +cd /tmp/buildd/*/debian/.. +/bin/bash < /dev/tty > /dev/tty 2> /dev/tty diff --git a/scripts/query-json b/scripts/query-json new file mode 100755 index 00000000..2f1ea32f --- /dev/null +++ b/scripts/query-json @@ -0,0 +1,42 @@ +#!/usr/bin/python3 +# +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: query-config +# Purpose: Extracts field values from a flat JSON file, +# for use in languages that can't handle JSON easily, +# (I'm looking at you, Bourne shell!) + + +import sys +import json + +import defaults +import util + +if len(sys.argv) < 3: + print("Usage: {0} <flat JSON file> <config field name>".format(sys.argv[0])) + sys.exit(1) + +# Note: lack of error handling is deliberate, if some field is expected to be there +# but isn't, it's better if the failure will be obvious and spectacular + +file = sys.argv[1] +key = sys.argv[2] + +with open(file, 'r') as f: + json_data = json.load(f) + +print(json_data[key]) diff --git a/scripts/template.ovf b/scripts/template.ovf new file mode 100644 index 00000000..f3624339 --- /dev/null +++ b/scripts/template.ovf @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Envelope vmw:buildId="build-3018522" xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <References> + <File ovf:href="vyos_vmware_image.vmdk" ovf:id="file1" ovf:size="{{vmdk_file_size}}"/> + </References> + <DiskSection> + <Info>Virtual disk information</Info> + <Disk ovf:capacity="4" ovf:capacityAllocationUnits="byte * 2^30" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="{{vmdk_populated_size}}"/> + </DiskSection> + <NetworkSection> + <Info>The list of logical networks</Info> + <Network ovf:name="VM Network"> + <Description>The VM Network network</Description> + </Network> + </NetworkSection> + <VirtualSystem ovf:id="vm"> + <Info>A virtual machine</Info> + <Name>vyos</Name> + <OperatingSystemSection ovf:id="1" vmw:osType="other26xLinux64Guest"> + <Info>The kind of installed guest operating system</Info> + </OperatingSystemSection> + <VirtualHardwareSection> + <Info>Virtual hardware requirements</Info> + <System> + <vssd:ElementName>Virtual Hardware Family</vssd:ElementName> + <vssd:InstanceID>0</vssd:InstanceID> + <vssd:VirtualSystemIdentifier>vyos</vssd:VirtualSystemIdentifier> + <vssd:VirtualSystemType>vmx-09</vssd:VirtualSystemType> + </System> + <Item> + <rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits> + <rasd:Description>Number of Virtual CPUs</rasd:Description> + <rasd:ElementName>1 virtual CPU(s)</rasd:ElementName> + <rasd:InstanceID>1</rasd:InstanceID> + <rasd:ResourceType>3</rasd:ResourceType> + <rasd:VirtualQuantity>1</rasd:VirtualQuantity> + </Item> + <Item> + <rasd:AllocationUnits>byte * 2^30</rasd:AllocationUnits> + <rasd:Description>Memory Size</rasd:Description> + <rasd:ElementName>1GB of memory</rasd:ElementName> + <rasd:InstanceID>2</rasd:InstanceID> + <rasd:ResourceType>4</rasd:ResourceType> + <rasd:VirtualQuantity>1</rasd:VirtualQuantity> + </Item> + <Item> + <rasd:Address>0</rasd:Address> + <rasd:Description>SCSI Controller</rasd:Description> + <rasd:ElementName>scsiController0</rasd:ElementName> + <rasd:InstanceID>3</rasd:InstanceID> + <rasd:ResourceSubType>lsilogic</rasd:ResourceSubType> + <rasd:ResourceType>6</rasd:ResourceType> + </Item> + <Item> + <rasd:Address>1</rasd:Address> + <rasd:Description>IDE Controller</rasd:Description> + <rasd:ElementName>ideController1</rasd:ElementName> + <rasd:InstanceID>4</rasd:InstanceID> + <rasd:ResourceType>5</rasd:ResourceType> + </Item> + <Item ovf:required="false"> + <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> + <rasd:ElementName>serial0</rasd:ElementName> + <rasd:InstanceID>5</rasd:InstanceID> + <rasd:ResourceType>21</rasd:ResourceType> + <vmw:Config ovf:required="false" vmw:key="yieldOnPoll" vmw:value="false"/> + </Item> + <Item ovf:required="false"> + <rasd:AddressOnParent>0</rasd:AddressOnParent> + <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> + <rasd:ElementName>cdrom0</rasd:ElementName> + <rasd:InstanceID>6</rasd:InstanceID> + <rasd:Parent>5</rasd:Parent> + <rasd:ResourceType>15</rasd:ResourceType> + </Item> + <Item> + <rasd:AddressOnParent>0</rasd:AddressOnParent> + <rasd:ElementName>disk0</rasd:ElementName> + <rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource> + <rasd:InstanceID>7</rasd:InstanceID> + <rasd:Parent>3</rasd:Parent> + <rasd:ResourceType>17</rasd:ResourceType> + </Item> + <Item> + <rasd:AddressOnParent>2</rasd:AddressOnParent> + <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation> + <rasd:Connection>VM Network</rasd:Connection> + <rasd:Description>VmxNet3 ethernet adapter on "VM Network"</rasd:Description> + <rasd:ElementName>ethernet0</rasd:ElementName> + <rasd:InstanceID>8</rasd:InstanceID> + <rasd:ResourceSubType>VmxNet3</rasd:ResourceSubType> + <rasd:ResourceType>10</rasd:ResourceType> + <vmw:Config ovf:required="false" vmw:key="wakeOnLanEnabled" vmw:value="false"/> + </Item> + <Item ovf:required="false"> + <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> + <rasd:ElementName>video</rasd:ElementName> + <rasd:InstanceID>9</rasd:InstanceID> + <rasd:ResourceType>24</rasd:ResourceType> + </Item> + <Item ovf:required="false"> + <rasd:AutomaticAllocation>false</rasd:AutomaticAllocation> + <rasd:ElementName>vmci</rasd:ElementName> + <rasd:InstanceID>10</rasd:InstanceID> + <rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType> + <rasd:ResourceType>1</rasd:ResourceType> + </Item> + <vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="true"/> + <vmw:Config ovf:required="false" vmw:key="memoryHotAddEnabled" vmw:value="true"/> + <vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft"/> + <vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft"/> + <vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="soft"/> + </VirtualHardwareSection> + <ProductSection> + <Info>VyOS is a Linux-based network operating system that provides software-based network routing, firewall, and VPN functionality.</Info> + <Product>VyOS</Product> + <Vendor>VyOS maintainers and contributors</Vendor> + <Version>{{version}}</Version> + </ProductSection> + </VirtualSystem> +</Envelope> diff --git a/scripts/util.py b/scripts/util.py index 740d4ccc..7cc33364 100644 --- a/scripts/util.py +++ b/scripts/util.py @@ -1,5 +1,25 @@ +# Copyright (C) 2015 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: util.py +# Purpose: +# Various common functions for use in build scripts. + + import sys import os +from distutils.spawn import find_executable import defaults @@ -8,3 +28,38 @@ def check_build_config(): print("Build config file ({file}) does not exist".format(file=defaults.BUILD_CONFIG)) print("If you are running this script by hand, you should better not. Run 'make iso' instead.") sys.exit(1) + + +class DependencyChecker(object): + def __init__(self, spec): + missing_packages = self._get_missing_packages(spec['packages']) + missing_binaries = self._get_missing_binaries(spec['binaries']) + self.__missing = {'packages': missing_packages, 'binaries': missing_binaries} + + + def _package_installed(self, name): + result = os.system("dpkg-query -W --showformat='${{Status}}\n' {name} 2>&1 | grep 'install ok installed' >/dev/null".format(name=name)) + return True if result == 0 else False + + def _get_missing_packages(self, packages): + missing_packages = [] + for p in packages: + if not self._package_installed(p): + missing_packages.append(p) + return missing_packages + + def _get_missing_binaries(self, binaries): + missing_binaries = [] + for b in binaries: + if not find_executable(b): + missing_binaries.append(b) + return missing_binaries + + def get_missing_dependencies(self): + if self.__missing['packages'] or self.__missing['binaries']: + return self.__missing + return None + + def print_missing_deps(self): + print("Missing packages: " + " ".join(self.__missing['packages'])) + print("Missing binaries: " + " ".join(self.__missing['binaries'])) diff --git a/tools/armada-388-clearfog.dtb b/tools/armada-388-clearfog.dtb Binary files differnew file mode 100755 index 00000000..cc25d96f --- /dev/null +++ b/tools/armada-388-clearfog.dtb diff --git a/tools/get_latest_iso.py b/tools/get_latest_iso.py new file mode 100755 index 00000000..4a2ea9a8 --- /dev/null +++ b/tools/get_latest_iso.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import os +import sys +from lxml import html +from urllib.parse import unquote +import requests + +BASE_URL = 'https://downloads.vyos.io/' +PAGE_URL = BASE_URL+'?dir=rolling/current/amd64' + + +def download(): + page = requests.get(PAGE_URL) + tree = html.fromstring(page.content) + path = '//*[@id="directory-listing"]/li/a[1]/@href' + isos = [x for x in tree.xpath(path) if os.path.splitext(x)[1] == '.iso'] + latest_iso_url = os.path.join(BASE_URL, isos[-1]) + filename = unquote(os.path.basename(latest_iso_url)) + print(filename) + if os.path.exists(filename): + print("{} already exists".format(filename)) + sys.exit(0) + r = requests.get(latest_iso_url) + with open(filename, 'wb') as fd: + for chunk in r.iter_content(chunk_size=128): + fd.write(chunk) + + +if __name__ == '__main__': + download() diff --git a/tools/gpl-header-template b/tools/gpl-header-template new file mode 100644 index 00000000..63be9d9a --- /dev/null +++ b/tools/gpl-header-template @@ -0,0 +1,17 @@ +# Copyright (C) 2016 VyOS maintainers and contributors +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 or later as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# File: +# Purpose: + diff --git a/tools/run-qemu-image.sh b/tools/run-qemu-image.sh new file mode 100755 index 00000000..b021ebd6 --- /dev/null +++ b/tools/run-qemu-image.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +VM_NAME='vyos_qemu' +VM_IMAGE='./packer_build/qemu/vyos_qemu_image.img' +MEMORY_SIZE='1024' +NCPUS=1 +SSH_PORT=2222 + +qemu-system-x86_64 \ + -name "${VM_NAME}" \ + -m ${MEMORY_SIZE} \ + -net nic,vlan=0,model=virtio \ + -net user,vlan=0,hostfwd=tcp::"${SSH_PORT}"-:22,hostname="${VM_NAME}" \ + -drive if=virtio,file=${VM_IMAGE} \ + -machine accel=kvm \ + -cpu host -smp ${NCPUS} diff --git a/tools/submod-mk b/tools/submod-mk new file mode 100644 index 00000000..eb61da18 --- /dev/null +++ b/tools/submod-mk @@ -0,0 +1,84 @@ +#!/bin/bash +# +# **** License **** +# +# Copyright (C) 2013 Vyatta, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# **** End License **** + +progname=${0##*/} +shopt -s nullglob +shopt -s extglob +cd packages + +info=echo +trace= +noclean="-nc" +build="debuild -i -b -uc -us" + +declare -a submodule +declare -a debs +for debian in !(installer|linux-kernel-di-i386-2.6)/debian ; do + smod=${debian%/*} + debs=( ${smod}_*.deb ) + if [ ${#debs[@]} -eq 0 ] ; then + submodule+=( $smod ) + fi +done + +while [ $# -gt 0 ] ; do + case "$1" in + -h | --help ) + cat <<-EOF +Usage: $progname [Options] [ SUBMODULE... ] +Options: + -n | --do-nothing DonĀ“t actually remove or build anything, + just show what would be done + -q | --quiet Quiet, don't print progress info + -c | --clean Clean build + -b | --binary Skip source package build (default) + -s | --source Build binary and source packages + -S | --signed-source Build and sign packages + +If no SUBMODULE(s) given, build all checked-out submodules w/o debs. +EOF + exit 0;; + -n | --do-nothing ) + trace=echo + shift;; + -q | --quiet ) + info='#' + shift;; + -c | --clean ) + noclean= + shift;; + -b | --binary ) + shift ;; # default + -s | --source ) + build="git buildpackage -uc -us" + shift;; + -S | --signed-source ) + build="git buildpackage" + shift;; + * ) + submodule=( $@ ) + break;; + esac +done + +for (( i=0; i<${#submodule[@]}; i++)) ; do + eval $info P: ${submodule[i]} + ( cd ${submodule[i]} && eval $trace $build $noclean ) || exit $? +done diff --git a/tools/u-boot-spl.kwb b/tools/u-boot-spl.kwb Binary files differnew file mode 100644 index 00000000..1ea4d759 --- /dev/null +++ b/tools/u-boot-spl.kwb |