From 90ca7062c19e7237d9e4f3fe9f442db2a99a7048 Mon Sep 17 00:00:00 2001 From: Daniil Baturin <daniil@baturin.org> Date: Sat, 26 Dec 2015 20:14:08 -0500 Subject: Add license headers to scripts. Some people rightfully complained about their absense already. --- tools/gpl-header-template | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tools/gpl-header-template (limited to 'tools') diff --git a/tools/gpl-header-template b/tools/gpl-header-template new file mode 100644 index 00000000..f3f82192 --- /dev/null +++ b/tools/gpl-header-template @@ -0,0 +1,17 @@ +# 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: +# Purpose: + -- cgit v1.2.3 From cac38de1cb46ac6001f2a5a8c09865685e13cfa5 Mon Sep 17 00:00:00 2001 From: Daniil Baturin <daniil@baturin.org> Date: Wed, 3 Feb 2016 10:28:33 -0500 Subject: Fix some dates. --- scripts/query-config | 2 +- tools/gpl-header-template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/scripts/query-config b/scripts/query-config index 7d7146e0..cfd26cc3 100755 --- a/scripts/query-config +++ b/scripts/query-config @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright (C) 2015 VyOS maintainers and contributors +# 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 diff --git a/tools/gpl-header-template b/tools/gpl-header-template index f3f82192..63be9d9a 100644 --- a/tools/gpl-header-template +++ b/tools/gpl-header-template @@ -1,4 +1,4 @@ -# Copyright (C) 2015 VyOS maintainers and contributors +# 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 -- cgit v1.2.3 From 3e56d7456e55b46ceb1dbca6a8f5cbc5150e18f5 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe <yuya.kusakabe@gmail.com> Date: Fri, 4 Mar 2016 14:33:32 +0900 Subject: Add qemu image build scripts --- .gitignore | 2 ++ Makefile | 7 ++++++ scripts/build-qemu-image | 30 ++++++++++++++++++++++ scripts/check-vm-build-env | 61 +++++++++++++++++++++++++++++++++++++++++++++ scripts/packer.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++ tools/run-qemu-image.sh | 16 ++++++++++++ 6 files changed, 178 insertions(+) create mode 100755 scripts/build-qemu-image create mode 100755 scripts/check-vm-build-env create mode 100644 scripts/packer.json create mode 100755 tools/run-qemu-image.sh (limited to 'tools') diff --git a/.gitignore b/.gitignore index a0114d35..889ab43d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build/* *.pyc +packer_build/* +packer_cache/* diff --git a/Makefile b/Makefile index 0a0cb2dd..86f0c27d 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,13 @@ prepare-package-env: @scripts/pbuilder-config @scripts/pbuilder-setup +.PHONY: qemu +.ONESHELL: +qemu: + @set -e + @scripts/check-vm-build-env + @scripts/build-qemu-image + .PHONY: clean .ONESHELL: clean: diff --git a/scripts/build-qemu-image b/scripts/build-qemu-image new file mode 100755 index 00000000..8643508a --- /dev/null +++ b/scripts/build-qemu-image @@ -0,0 +1,30 @@ +#!/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. + + +export ISO_IMAGE=./build/live-image-amd64.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 scripts/packer.json diff --git a/scripts/check-vm-build-env b/scripts/check-vm-build-env new file mode 100755 index 00000000..290b28c8 --- /dev/null +++ b/scripts/check-vm-build-env @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# 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 +from distutils.spawn import find_executable + +required_packages = [ + 'make', + 'qemu-system-x86', + 'qemu-utils' +] + + +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 = [] + +print("Checking if packages required for VyOS VM image build are installed") + +for p in required_packages: + if not is_installed(p): + missing_packages.append(p) + +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") + +if find_executable("packer"): + print("Your system has Packer.") +else: + 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/packer.json b/scripts/packer.json new file mode 100644 index 00000000..5d5f201e --- /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": + [ + { + "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": "raw", + "headless": true, + "accelerator": "kvm", + "ssh_host_port_min": 2222, + "ssh_host_port_max": 2229, + "ssh_username": "vyos", + "ssh_password": "vyos", + "ssh_port": 22, + "ssh_wait_timeout": "30s", + "vm_name": "vyos_qemu_image.img", + "net_device": "virtio-net", + "disk_interface": "virtio", + "boot_wait": "5s", + "boot_command": + [ + "<enter><wait10><wait10>", + "vyos<enter><wait>", + "vyos<enter><wait>", + "install image<enter><wait>", + "<enter><wait>", + "<enter><wait>", + "<enter><wait>", + "Yes<enter><wait>", + "<enter><wait10>", + "<enter><wait>", + "<enter><wait>", + "vyos<enter><wait>", + "vyos<enter><wait>", + "<enter><wait10>", + "reboot<enter><wait>", + "Yes<enter><wait10><wait10><wait10>", + "vyos<enter><wait>", + "vyos<enter><wait>", + "configure<enter><wait>", + "delete system console<enter><wait>", + "set interface ethernet eth0 address dhcp<enter><wait>", + "set service ssh<enter><wait>", + "commit<enter><wait>", + "save<enter><wait>", + "exit<enter><wait>", + "reboot<enter><wait>", + "Yes<enter><wait10><wait10><wait10><wait10><wait10>" + ] + } + ] +} 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} -- cgit v1.2.3 From 826fa1a973ffdfee54691bae7a3cb6a51ecaf230 Mon Sep 17 00:00:00 2001 From: Kim Hagen <kim.sidney@gmail.com> Date: Tue, 24 May 2016 10:00:20 +0000 Subject: add build options for clearfog --- Makefile | 10 ++ data/live-build-config/archives/vyos.list.chroot | 1 + .../hooks/14-firmware-linux-nonfree.chroot | 6 + data/package-lists/vyos-arm.list.chroot | 1 + scripts/build-clearfog-image | 158 +++++++++++++++++++++ scripts/build-config | 2 +- scripts/build-flavour | 5 + tools/armada-388-clearfog.dtb | Bin 0 -> 18814 bytes tools/u-boot-spl.kwb | Bin 0 -> 550316 bytes 9 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 data/package-lists/vyos-arm.list.chroot create mode 100755 scripts/build-clearfog-image create mode 100755 tools/armada-388-clearfog.dtb create mode 100644 tools/u-boot-spl.kwb (limited to 'tools') diff --git a/Makefile b/Makefile index 2e6dd9ad..44e3c139 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,14 @@ vmware: @scripts/check-vm-build-env @scripts/build-vmware-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-legacy + .PHONY: clean .ONESHELL: clean: @@ -61,6 +69,8 @@ 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: diff --git a/data/live-build-config/archives/vyos.list.chroot b/data/live-build-config/archives/vyos.list.chroot index 2b117386..664b408c 100644 --- a/data/live-build-config/archives/vyos.list.chroot +++ b/data/live-build-config/archives/vyos.list.chroot @@ -1 +1,2 @@ deb http://dev.packages.vyos.net/vyos current main +deb http://security.debian.org/ jessie/updates main diff --git a/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot b/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot index 3cb7dc6b..887831cc 100755 --- a/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot +++ b/data/live-build-config/hooks/14-firmware-linux-nonfree.chroot @@ -2,5 +2,11 @@ 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/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/scripts/build-clearfog-image b/scripts/build-clearfog-image new file mode 100755 index 00000000..30bc1cb4 --- /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 vyatta-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 vyatta-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 3b39befe..c5d1ab5f 100755 --- a/scripts/build-config +++ b/scripts/build-config @@ -46,7 +46,7 @@ def get_default_build_by(): # 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']), + '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), 'pbuilder-debian-mirror': ('Debian repository mirror for pbuilder env bootstrap', lambda: defaults.DEBIAN_MIRROR, None), diff --git a/scripts/build-flavour b/scripts/build-flavour index 389be980..c14f5735 100755 --- a/scripts/build-flavour +++ b/scripts/build-flavour @@ -30,3 +30,8 @@ fi 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/tools/armada-388-clearfog.dtb b/tools/armada-388-clearfog.dtb new file mode 100755 index 00000000..71d28b83 Binary files /dev/null and b/tools/armada-388-clearfog.dtb differ diff --git a/tools/u-boot-spl.kwb b/tools/u-boot-spl.kwb new file mode 100644 index 00000000..b7dd4c8d Binary files /dev/null and b/tools/u-boot-spl.kwb differ -- cgit v1.2.3 From 5f83afa7815e866c9539feb1a58269d4555e33fc Mon Sep 17 00:00:00 2001 From: Kim Hagen <kim.sidney@gmail.com> Date: Fri, 2 Sep 2016 08:08:32 +0000 Subject: update kernel version to 4.4.15 update files needed for clearfog build --- scripts/live-build-config | 2 +- tools/armada-388-clearfog.dtb | Bin 18814 -> 19429 bytes tools/u-boot-spl.kwb | Bin 550316 -> 557788 bytes 3 files changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/scripts/live-build-config b/scripts/live-build-config index 52660571..7c51744c 100755 --- a/scripts/live-build-config +++ b/scripts/live-build-config @@ -36,7 +36,7 @@ lb config noauto \ --architectures {{architecture}} \ --bootappend-live "boot=live components hostname=vyos username=live nopersistence noautologin nonetworking union=overlay" \ --linux-flavours {{architecture}}-vyos \ - --linux-packages linux-image-4.4.5 \ + --linux-packages linux-image-4.4.15 \ --bootloader syslinux \ --binary-images iso-hybrid \ --debian-installer false \ diff --git a/tools/armada-388-clearfog.dtb b/tools/armada-388-clearfog.dtb index 71d28b83..cc25d96f 100755 Binary files a/tools/armada-388-clearfog.dtb and b/tools/armada-388-clearfog.dtb differ diff --git a/tools/u-boot-spl.kwb b/tools/u-boot-spl.kwb index b7dd4c8d..1ea4d759 100644 Binary files a/tools/u-boot-spl.kwb and b/tools/u-boot-spl.kwb differ -- cgit v1.2.3 From 9d5ab697ada2d156631be4c802ebe8a640f4a723 Mon Sep 17 00:00:00 2001 From: mtudosoiu <marian.tudosoiu@1and1.ro> Date: Tue, 20 Feb 2018 22:33:19 +0200 Subject: task #T555 add tools/submod-mk to vyos-build repository https://phabricator.vyos.net/T555 --- tools/submod-mk | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 tools/submod-mk (limited to 'tools') 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 -- cgit v1.2.3 From 135fb07d959741dbe9a3a4e5e1919de0e7c5bc44 Mon Sep 17 00:00:00 2001 From: Yuya Kusakabe <yuya.kusakabe@gmail.com> Date: Tue, 15 May 2018 10:34:14 +0900 Subject: Add tools/get_latest_iso.py --- tools/get_latest_iso.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 tools/get_latest_iso.py (limited to 'tools') 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() -- cgit v1.2.3