diff --git a/Dockerfile b/Dockerfile index e35a0de..43a9315 100644 --- a/Dockerfile +++ b/Dockerfile @@ -45,6 +45,7 @@ RUN apt-get update && apt-get install -yq \ qemu-utils \ qemu-user-static \ rsync \ + squashfs-tools \ swig \ u-boot-tools \ unzip \ diff --git a/scripts/01_pre_docker.sh b/scripts/01_pre_docker.sh index c97d2c8..7490de7 100755 --- a/scripts/01_pre_docker.sh +++ b/scripts/01_pre_docker.sh @@ -14,13 +14,6 @@ else mkdir ${build_path} fi -# Extract the goodies -${scripts_path}/ubnt-fw-parse.py "${root_path}/unifi-firmware/${firmware_filename}" "${build_path}/fw-extract/${firmware_filename%.bin}" - -# Extract the squashfs rootfs -echo "Extracting unifi rootfs as root..." -sudo unsquashfs -f -d "${build_path}/fw-extract/${BOARD}-rootfs" "${build_path}/fw-extract/${firmware_filename%.bin}/rootfs.bin" - # Always build to pickup changes/updates/improvements debug_msg "Building ${docker_tag}" docker build -t ${docker_tag} ${root_path} diff --git a/scripts/03_docker.sh b/scripts/03_docker.sh index 720ebec..4a7bd87 100755 --- a/scripts/03_docker.sh +++ b/scripts/03_docker.sh @@ -14,6 +14,10 @@ if [ ! -d ${build_path}/toolchain ]; then tar -xf ${root_path}/downloads/${toolchain_filename} -C ${build_path}/toolchain fi +# Do our firmware extraction +debug_msg "Docker: Extracting Firmware..." +docker run --ulimit nofile=1024 --rm -v "${root_path}:/repo:Z" -e BOARD="${BOARD}" -it ${docker_tag} /repo/scripts/docker/extract_firmware.sh + if [ ! -d ${build_path}/kernel ]; then debug_msg "Docker: Building Kernel..." docker run --ulimit nofile=1024 --rm -v "${root_path}:/repo:Z" -it ${docker_tag} /repo/scripts/docker/build_kernel.sh diff --git a/scripts/docker/extract_firmware.sh b/scripts/docker/extract_firmware.sh new file mode 100755 index 0000000..43695a0 --- /dev/null +++ b/scripts/docker/extract_firmware.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +scripts_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )" +. ${scripts_path}/vars.sh + +# Extract the goodies +${scripts_path}/ubnt-fw-parse.py "${root_path}/unifi-firmware/${firmware_filename}" "${build_path}/fw-extract/${firmware_filename%.bin}" + +# Extract the squashfs rootfs +if ! [ -d "${build_path}/fw-extract/${BOARD}-rootfs" ]; then + echo "Extracting unifi rootfs as root..." + unsquashfs -f -d "${build_path}/fw-extract/${BOARD}-rootfs" "${build_path}/fw-extract/${firmware_filename%.bin}/rootfs.bin" +fi