From c85fd9f33c1765f5abdf297c988caa1491e59ab1 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 2 Feb 2019 23:37:18 -0800 Subject: [PATCH] Revamp image to build dependencies as part of stages (#83) Fixes #17. Stage 2 is fairly minimal, stage 3 builds/installs OpenCV and WPILib et al, and stage 4 builds/installs the FRCVision webdash and adds the vision examples. Other changes: - OpenCV compiled with ffmpeg, OpenBLAS, and libgtk (fixes #79, fixes #80) - OpenBLAS added to image (fixes #65) - C++ Makefile is more easily extensible (fixes #71) - Sources for everything are bundled into image into /usr/src - README updated (fixes #16) - pkg-config files for wpilibc et al are now installed and C++ Makefile uses them (if compiled local to Pi) - Both dynamic and static libs are included in image The only downside of all these changes (particularly the ffmpeg, OpenBLAS, and libgtk inclusion) is the image size is now over 3GB (800MB compressed). The previous image didn't quite fit on a 2GB card however. --- .gitignore | 10 +- .gitmodules | 9 - Dockerfile | 10 +- README.md | 90 ++--- azure-docker/Dockerfile | 2 +- azure-pipelines.yml | 5 +- depends | 8 + deps/01-download.sh | 30 -- deps/02-extract.sh | 55 --- deps/03-build.sh | 138 ------- deps/04-copy.sh | 80 ---- deps/allwpilib | 1 - deps/examples/cpp-multiCameraServer/Makefile | 33 +- deps/pynetworktables | 1 - deps/robotpy-cscore | 1 - deps/tools/Makefile | 113 ------ deps/tools/configServer/Makefile | 54 +++ deps/tools/{ => configServer}/gen_resource.py | 0 .../src}/Application.cpp | 0 .../src}/Application.h | 0 .../src}/DataHistory.h | 0 .../src}/MyHttpConnection.cpp | 0 .../src}/MyHttpConnection.h | 0 .../src}/NetworkSettings.cpp | 0 .../src}/NetworkSettings.h | 0 .../src}/SystemStatus.cpp | 0 .../src}/SystemStatus.h | 0 .../src}/VisionSettings.cpp | 0 .../src}/VisionSettings.h | 0 .../src}/VisionStatus.cpp | 0 .../src}/VisionStatus.h | 0 .../src}/WebSocketHandlers.cpp | 0 .../src}/WebSocketHandlers.h | 0 .../src}/main.cpp | 0 .../src}/resources/frcvision.css | 0 .../src}/resources/frcvision.js | 0 .../src}/resources/index.html | 0 deps/tools/multiCameraServer/Makefile | 12 + .../src}/multiCameraServer.cpp | 0 deps/tools/setuidgids/Makefile | 9 + deps/tools/{ => setuidgids/src}/setuidgids.c | 0 export-image/02-network/01-run.sh | 10 +- export-image/04-finalise/01-run.sh | 6 +- export-image/04-finalise/files/LICENSE.oracle | 72 ---- scripts/common | 2 +- stage2/01-sys-tweaks/01-run.sh | 132 +------ stage3/01-sys-tweaks/00-packages | 8 + stage3/01-sys-tweaks/00-packages-nr | 3 + stage3/01-sys-tweaks/01-run.sh | 361 ++++++++++++++++++ stage3/01-sys-tweaks/files/FindJNI.cmake | 9 + .../files}/arm-pi-gnueabihf.toolchain.cmake | 9 +- .../files/ld.so.conf.d/frc_libs.conf | 0 .../files/pkgconfig/cameraserver.pc | 14 + .../01-sys-tweaks/files/pkgconfig/cscore.pc | 14 + .../01-sys-tweaks/files/pkgconfig/ntcore.pc | 14 + .../01-sys-tweaks/files/pkgconfig/wpilibc.pc | 13 + .../01-sys-tweaks/files/pkgconfig/wpiutil.pc | 13 + .../files/profile.d/frc_pkgconfig.sh | 1 + stage3/prerun.sh | 5 + stage4/01-sys-tweaks/01-run.sh | 132 +++++++ .../01-sys-tweaks/files/camera_log_run | 0 .../01-sys-tweaks/files/camera_run | 0 .../01-sys-tweaks/files/configServer_run | 0 .../01-sys-tweaks/files/frc.json | 0 .../01-sys-tweaks/files/picamera.conf | 0 .../01-sys-tweaks/files/runCamera | 0 .../01-sys-tweaks/files/runInteractive | 0 .../01-sys-tweaks/files/runService | 0 {stage2 => stage4}/02-net-tweaks/00-packages | 0 {stage2 => stage4}/02-net-tweaks/01-run.sh | 11 +- .../02-net-tweaks}/files/raspi-blacklist.conf | 0 .../02-net-tweaks/files/wait.conf | 0 .../02-net-tweaks/files/wpa_supplicant.conf | 0 {stage2 => stage4}/EXPORT_IMAGE | 1 - stage4/prerun.sh | 5 + 75 files changed, 775 insertions(+), 721 deletions(-) delete mode 100644 .gitmodules delete mode 100755 deps/01-download.sh delete mode 100755 deps/02-extract.sh delete mode 100755 deps/03-build.sh delete mode 100755 deps/04-copy.sh delete mode 160000 deps/allwpilib delete mode 160000 deps/pynetworktables delete mode 160000 deps/robotpy-cscore delete mode 100644 deps/tools/Makefile create mode 100644 deps/tools/configServer/Makefile rename deps/tools/{ => configServer}/gen_resource.py (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/Application.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/Application.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/DataHistory.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/MyHttpConnection.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/MyHttpConnection.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/NetworkSettings.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/NetworkSettings.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/SystemStatus.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/SystemStatus.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/VisionSettings.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/VisionSettings.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/VisionStatus.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/VisionStatus.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/WebSocketHandlers.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/WebSocketHandlers.h (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/main.cpp (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/resources/frcvision.css (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/resources/frcvision.js (100%) rename deps/tools/{rpiConfigServer_src => configServer/src}/resources/index.html (100%) create mode 100644 deps/tools/multiCameraServer/Makefile rename deps/tools/{ => multiCameraServer/src}/multiCameraServer.cpp (100%) create mode 100644 deps/tools/setuidgids/Makefile rename deps/tools/{ => setuidgids/src}/setuidgids.c (100%) delete mode 100644 export-image/04-finalise/files/LICENSE.oracle create mode 100644 stage3/01-sys-tweaks/00-packages create mode 100644 stage3/01-sys-tweaks/00-packages-nr create mode 100755 stage3/01-sys-tweaks/01-run.sh create mode 100644 stage3/01-sys-tweaks/files/FindJNI.cmake rename {deps => stage3/01-sys-tweaks/files}/arm-pi-gnueabihf.toolchain.cmake (86%) rename {stage2 => stage3}/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf (100%) create mode 100644 stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc create mode 100644 stage3/01-sys-tweaks/files/pkgconfig/cscore.pc create mode 100644 stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc create mode 100644 stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc create mode 100644 stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc create mode 100644 stage3/01-sys-tweaks/files/profile.d/frc_pkgconfig.sh create mode 100755 stage3/prerun.sh create mode 100755 stage4/01-sys-tweaks/01-run.sh rename {stage2 => stage4}/01-sys-tweaks/files/camera_log_run (100%) rename {stage2 => stage4}/01-sys-tweaks/files/camera_run (100%) rename {stage2 => stage4}/01-sys-tweaks/files/configServer_run (100%) rename {stage2 => stage4}/01-sys-tweaks/files/frc.json (100%) rename {stage2 => stage4}/01-sys-tweaks/files/picamera.conf (100%) rename {stage2 => stage4}/01-sys-tweaks/files/runCamera (100%) rename {stage2 => stage4}/01-sys-tweaks/files/runInteractive (100%) rename {stage2 => stage4}/01-sys-tweaks/files/runService (100%) rename {stage2 => stage4}/02-net-tweaks/00-packages (100%) rename {stage2 => stage4}/02-net-tweaks/01-run.sh (66%) rename {stage2/01-sys-tweaks => stage4/02-net-tweaks}/files/raspi-blacklist.conf (100%) rename {stage2 => stage4}/02-net-tweaks/files/wait.conf (100%) rename {stage2 => stage4}/02-net-tweaks/files/wpa_supplicant.conf (100%) rename {stage2 => stage4}/EXPORT_IMAGE (80%) create mode 100755 stage4/prerun.sh diff --git a/.gitignore b/.gitignore index d44c826..4605aba 100644 --- a/.gitignore +++ b/.gitignore @@ -6,13 +6,9 @@ SKIP_IMAGES .pc *-pc apt-cacher-ng/ -deps/01-download -deps/02-extract -deps/03-build -deps/tools/_cscore.so -deps/tools/rpiConfigServer -deps/tools/setuidgids +deps/tools/configServer/configServer +deps/tools/multiCameraServer/multiCameraServer +deps/tools/setuidgids/setuidgids *.o *.sw? *.debug -stage2/01-sys-tweaks/extfiles diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 811e89b..0000000 --- a/.gitmodules +++ /dev/null @@ -1,9 +0,0 @@ -[submodule "deps/robotpy-cscore"] - path = deps/robotpy-cscore - url = https://github.com/robotpy/robotpy-cscore.git -[submodule "deps/pynetworktables"] - path = deps/pynetworktables - url = https://github.com/robotpy/pynetworktables.git -[submodule "deps/allwpilib"] - path = deps/allwpilib - url = https://github.com/wpilibsuite/allwpilib.git diff --git a/Dockerfile b/Dockerfile index 22797d5..dcd89fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ -FROM debian:stretch +FROM debian:stretch-backports ENV DEBIAN_FRONTEND noninteractive -RUN apt-get -y update && \ - apt-get -y install \ - git vim parted \ +RUN apt-get -y update \ + && apt-get -y install \ + git vim parted pkg-config \ quilt realpath qemu-user-static debootstrap zerofree pxz zip dosfstools \ bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file \ + build-essential cmake python3 ant sudo openjdk-8-jdk \ + && apt-get -y -t stretch-backports install openjdk-11-jdk \ && rm -rf /var/lib/apt/lists/* COPY . /pi-gen/ diff --git a/README.md b/README.md index c0ff51c..c3562a0 100755 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# pi-gen +# FRCVision-pi-gen -_Tool used to create the raspberrypi.org Raspbian images_ +_Tool used to create the FRCVision Raspbian image_ ## Dependencies @@ -13,9 +13,13 @@ To install the required dependencies for pi-gen you should run: ```bash apt-get install quilt parted realpath qemu-user-static debootstrap zerofree pxz zip \ -dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl +dosfstools bsdtar libcap2-bin grep rsync xz-utils file git curl \ +xxd build-essential cmake python3 ant sudo openjdk-8-jdk openjdk-11-jdk ``` +Or better, use build-docker.sh instead of build.sh, as the Docker image will +install the required tools as part of the Docker image build. + The file `depends` contains a list of tools needed. The format of this package is `[:]`. @@ -28,12 +32,12 @@ environment variables. The following environment variables are supported: - * `IMG_NAME` **required** (Default: unset) + * `IMG_NAME` **required** (Default: `'FRCVision'`) The name of the image to build with the current stage directories. Setting - `IMG_NAME=Raspbian` is logical for an unmodified RPi-Distro/pi-gen build, - but you should use something else for a customized version. Export files - in stages may add suffixes to `IMG_NAME`. + `IMG_NAME=FRCVision` is logical for an unmodified + wpilibsuite/FRCVision-pi-gen build, but you should use something else for a + customized version. Export files in stages may add suffixes to `IMG_NAME`. * `APT_PROXY` (Default: unset) @@ -85,14 +89,14 @@ The following environment variables are supported: If these are set, they are use to configure `wpa_supplicant.conf`, so that the raspberry pi can automatically connect to a wifi network on first boot. - * `ENABLE_SSH` (Default: `0`) + * `ENABLE_SSH` (Default: `1`) Setting to `1` will enable ssh server for remote log in. Note that if you are using a common password such as the defaults there is a high risk of attackers taking over you RaspberryPi. -A simple example for building Raspbian: +A simple example for building FRCVision: ```bash -IMG_NAME='Raspbian' +IMG_NAME='FRCVision' ``` The config file can also be specified on the command line as an argument the `build.sh` or `build-docker.sh` scripts. @@ -181,10 +185,10 @@ solution). ## Stage Anatomy -### Raspbian Stage Overview +### FRCVision Raspbian Stage Overview -The build of Raspbian is divided up into several stages for logical clarity -and modularity. This causes some initial complexity, but it simplifies +The build of FRCVision Raspbian is divided up into several stages for logical +clarity and modularity. This causes some initial complexity, but it simplifies maintenance and allows for more easy customization. - **Stage 0** - bootstrap. The primary purpose of this stage is to create a @@ -204,34 +208,28 @@ maintenance and allows for more easy customization. really usable yet in a traditional sense yet. Still, if you want minimal, this is minimal and the rest you could reasonably do yourself as sysadmin. - - **Stage 2** - lite system. This stage produces the Raspbian-Lite image. It - installs some optimized memory functions, sets timezone and charmap - defaults, installs fake-hwclock and ntp, wifi and bluetooth support, - dphys-swapfile, and other basics for managing the hardware. It also - creates necessary groups and gives the pi user access to sudo and the - standard console hardware permission groups. + - **Stage 2** - basic system. It installs some optimized memory functions, + sets timezone and charmap defaults, installs fake-hwclock and ntp, wifi and + bluetooth support, dphys-swapfile, and other basics for managing the + hardware. It also creates necessary groups and gives the pi user access to + sudo and the standard console hardware permission groups. It also does most + of the configuration for a read-only filesystem. There are a few tools that may not make a whole lot of sense here for - development purposes on a minimal system such as basic Python and Lua + development purposes on a minimal system such as basic Python and OpenJDK packages as well as the `build-essential` package. They are lumped right in with more essential packages presently, though they need not be with - pi-gen. These are understandable for Raspbian's target audience, but if - you were looking for something between truly minimal and Raspbian-Lite, - here's where you start trimming. + pi-gen. - - **Stage 3** - desktop system. Here's where you get the full desktop system - with X11 and LXDE, web browsers, git for development, Raspbian custom UI - enhancements, etc. This is a base desktop system, with some development - tools installed. + - **Stage 3** - OpenCV and WPILib system. Here's where you get the full + WPILib libraries for both Java and C++, as well as the required OpenCV + dependencies. The RobotPy NetworkTables and CameraServer libraries are + also built and installed here. - - **Stage 4** - Raspbian system meant to fit on a 4GB card. More development - tools, an email client, learning tools like Scratch, specialized packages - like sonic-pi, system documentation, office productivity, etc. This is the - stage that installs all of the things that make Raspbian friendly to new - users. - - - **Stage 5** - The official Raspbian Desktop image. Right now only adds - Mathematica. + - **Stage 4** - The official FRCVision image. Adds multi camera builtin + application and services, the FRCVision web dashboard, and example vision + programs. This is the stage that builds and installs all of the things that + make FRCVision friendly to new users. ### Stage specification @@ -239,18 +237,9 @@ If you wish to build up to a specified stage (such as building up to stage 2 for a lite system), place an empty file named `SKIP` in each of the `./stage` directories you wish not to include. -Then add an empty file named `SKIP_IMAGES` to `./stage4` (if building up to stage 2) or -to `./stage2` (if building a minimal system). +Then add an empty file named `SKIP_IMAGES` to `./stage4`. -```bash -# Example for building a lite system -echo "IMG_NAME='Raspbian'" > config -touch ./stage3/SKIP ./stage4/SKIP ./stage5/SKIP -touch ./stage4/SKIP_IMAGES ./stage5/SKIP_IMAGES -sudo ./build.sh # or ./build-docker.sh -``` - -If you wish to build further configurations upon (for example) the lite +If you wish to build further configurations upon (for example) the basic system, you can also delete the contents of `./stage3` and `./stage4` and replace with your own contents in the same format. @@ -261,13 +250,14 @@ If you're working on a specific stage the recommended development process is as follows: * Add a file called SKIP_IMAGES into the directories containing EXPORT_* files - (currently stage2, stage4 and stage5) + (currently stage4) * Add SKIP files to the stages you don't want to build. For example, if you're - basing your image on the lite image you would add these to stages 3, 4 and 5. - * Run build.sh to build all stages + basing your image on the WPILib image you would add this to stage 4. + * Run build.sh to build all stages, or if you're using Docker, run ```env PRESERVE_CONTAINER=1 ./build-docker.sh``` * Add SKIP files to the earlier successfully built stages * Modify the last stage - * Rebuild just the last stage using ```sudo CLEAN=1 ./build.sh``` + * Rebuild just the last stage using ```sudo CLEAN=1 ./build.sh```, or if + you're using Docker, using ```env CONTINUE=1 PRESERVE_CONTAINER=1 ./build-docker.sh``` * Once you're happy with the image you can remove the SKIP_IMAGES files and export your image to test diff --git a/azure-docker/Dockerfile b/azure-docker/Dockerfile index 6d4e315..53f694b 100644 --- a/azure-docker/Dockerfile +++ b/azure-docker/Dockerfile @@ -4,7 +4,7 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get -y update \ && apt-get -y install \ - git vim parted \ + git vim parted pkg-config \ quilt realpath qemu-user-static debootstrap zerofree pxz zip dosfstools \ bsdtar libcap2-bin rsync grep udev xz-utils curl xxd file \ build-essential cmake python3 ant sudo openjdk-8-jdk \ diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 69a417f..fbdff9f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,12 +16,9 @@ jobs: steps: - checkout: self submodules: true - - script: | - cd deps && ./01-download.sh && ./02-extract.sh && ./03-build.sh && ./04-copy.sh - displayName: 'Build Image Dependencies' - script: | sudo sh -c 'dpkg-reconfigure qemu-user-static && ./build.sh' - cp deploy/*.zip $BUILD_ARTIFACTSTAGINGDIRECTORY + cp deploy/*.zip deploy/examples/*.zip $BUILD_ARTIFACTSTAGINGDIRECTORY displayName: 'Build Image' - task: PublishBuildArtifacts@1 inputs: diff --git a/depends b/depends index 80db669..df4827a 100644 --- a/depends +++ b/depends @@ -15,3 +15,11 @@ curl xxd file git +pkg-config +gcc:build-essential +cmake +python3 +ant +sudo +java:openjdk-8-jdk +java:openjdk-11-jdk diff --git a/deps/01-download.sh b/deps/01-download.sh deleted file mode 100755 index e067454..0000000 --- a/deps/01-download.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -mkdir -p 01-download -pushd 01-download - -# raspbian toolchain -wget -nc -nv \ - https://github.com/wpilibsuite/raspbian-toolchain/releases/download/v1.2.0/Raspbian9-Linux-Toolchain-6.3.0.tar.gz - -# openjdk binaries -wget -nc -nv \ - https://github.com/wpilibsuite/raspbian-openjdk/releases/download/v2019-11.0.1-1/jdk_11.0.1-strip.tar.gz - -# python headers/libs -wget -nc -nv \ - http://archive.raspbian.org/raspbian/pool/main/p/python3.5/libpython3.5_3.5.3-1+deb9u1_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/python3.5/libpython3.5-dev_3.5.3-1+deb9u1_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/python3.5/libpython3.5-minimal_3.5.3-1+deb9u1_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/python3.5/python3.5-dev_3.5.3-1+deb9u1_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/python3.5/python3.5-minimal_3.5.3-1+deb9u1_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/python3.5/python3.5_3.5.3-1+deb9u1_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/python-numpy/python3-numpy_1.12.1-3_armhf.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/pybind11/python3-pybind11_2.2.4-2_all.deb \ - http://archive.raspbian.org/raspbian/pool/main/p/pybind11/pybind11-dev_2.2.4-2_all.deb - -# opencv sources -wget -nc -nv \ - https://github.com/opencv/opencv/archive/3.4.4.tar.gz - -popd diff --git a/deps/02-extract.sh b/deps/02-extract.sh deleted file mode 100755 index 1bd551e..0000000 --- a/deps/02-extract.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash - -mkdir -p 02-extract -pushd 02-extract - -# raspbian toolchain -tar xzf ../01-download/Raspbian9-Linux-Toolchain-*.tar.gz - -# additional headers/libs -pushd raspbian9/arm-raspbian9-linux-gnueabihf - -# Extract data to toolchain basedir -for var in ../../../01-download/*.deb -do -ar p "$var" data.tar.xz | tar xJf - -done - -# move the arm-linux-gnueabihf libs to just the base "lib" -sh -c 'cd lib && ln -s arm-linux-gnueabihf/* .' -sh -c 'cd usr/lib/debug && ln -s ../arm-linux-gnueabihf/debug/* .' -sh -c 'cd usr/lib && ln -s arm-linux-gnueabihf/* .' - -# change absolute symlinks into relative symlinks -find . -lname '/*' | \ -while read l ; do - echo ln -sf $(echo $(echo $l | sed 's|/[^/]*|/..|g')$(readlink $l) | sed 's/.....//') $l -done | \ -sh - -popd - -# opencv sources -tar xzf ../01-download/3.4.4.tar.gz -mv opencv-3.4.4 opencv -sed -i -e 's/javac sourcepath/javac target="1.8" source="1.8" sourcepath/' opencv/modules/java/jar/build.xml.in -# disable extraneous data warnings; these are common with USB cameras -sed -i -e '/JWRN_EXTRANEOUS_DATA/d' opencv/3rdparty/libjpeg/jdmarker.c -sed -i -e '/JWRN_EXTRANEOUS_DATA/d' opencv/3rdparty/libjpeg-turbo/src/jdmarker.c - -# toolchain setup for opencv and wpilib -cp ../arm-pi-gnueabihf.toolchain.cmake . -tar xzf ../01-download/jdk_11*.tar.gz jdk/include -mkdir -p cmake-modules -cat > cmake-modules/FindJNI.cmake << EOF -set(JNI_INCLUDE_DIRS "${PWD}/jdk/include" "${PWD}/jdk/include/linux") -set(JNI_LIBRARIES ) -set(JNI_FOUND YES) -set(JAVA_AWT_LIBRARY ) -set(JAVA_JVM_LIBRARY ) -set(JAVA_INCLUDE_PATH "${PWD}/jdk/include") -set(JAVA_INCLUDE_PATH2 "${PWD}/jdk/include/linux") -set(JAVA_AWT_INCLUDE_PATH ) -EOF - -popd diff --git a/deps/03-build.sh b/deps/03-build.sh deleted file mode 100755 index 80a4482..0000000 --- a/deps/03-build.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash - -export PATH=${PWD}/02-extract/raspbian9/bin:${PATH} - -split_debug () { - arm-raspbian9-linux-gnueabihf-objcopy --only-keep-debug $1 $1.debug - arm-raspbian9-linux-gnueabihf-strip -g $1 - arm-raspbian9-linux-gnueabihf-objcopy --add-gnu-debuglink=$1.debug $1 -} - -split_debug_so () { - pushd $1 - for lib in *.so - do - split_debug $lib - done - popd -} - -split_debug_exe () { - pushd $1 - for exe in * - do - split_debug $exe - done - popd -} - -# opencv -build_opencv () { - cmake ../../02-extract/opencv \ - -DWITH_CUDA=OFF \ - -DWITH_IPP=OFF \ - -DWITH_ITT=OFF \ - -DWITH_OPENCL=OFF \ - -DWITH_FFMPEG=OFF \ - -DWITH_OPENEXR=OFF \ - -DWITH_GSTREAMER=OFF \ - -DWITH_LAPACK=OFF \ - -DWITH_GTK=ON \ - -DWITH_1394=OFF \ - -DWITH_JASPER=OFF \ - -DWITH_TIFF=OFF \ - -DBUILD_JPEG=ON \ - -DBUILD_PNG=ON \ - -DBUILD_ZLIB=ON \ - -DBUILD_TESTS=OFF \ - -DPython_ADDITIONAL_VERSIONS=3.5 \ - -DWITH_WEBP=OFF \ - -DBUILD_JAVA=$2 \ - -DBUILD_WITH_STATIC_CRT=OFF \ - -DWITH_PROTOBUF=OFF \ - -DWITH_DIRECTX=OFF \ - -DENABLE_CXX11=ON \ - -DBUILD_SHARED_LIBS=$2 \ - -DCMAKE_BUILD_TYPE=$1 \ - -DCMAKE_DEBUG_POSTFIX=d \ - -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ - -DCMAKE_MAKE_PROGRAM=make \ - -DENABLE_NEON=ON \ - -DENABLE_VFPV3=ON \ - -DBUILD_opencv_python3=$2 \ - -DPYTHON3_INCLUDE_PATH=${PWD}/../../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf/usr/include/python3.5m \ - -DPYTHON3_NUMPY_INCLUDE_DIRS=${PWD}/../../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf/usr/include/python3.5m/numpy \ - -DOPENCV_EXTRA_FLAGS_DEBUG=-Og \ - -DCMAKE_MODULE_PATH=${PWD}/../../02-extract/cmake-modules \ - || exit 1 - make -j3 || exit 1 - make install || exit 1 - if [ "$1" == "RelWithDebugInfo" ] - then - cp -p install/share/OpenCV/java/libopencv_java*.so install/lib/ - fi - split_debug_so install/lib -} - -mkdir -p 03-build/opencv-build -pushd 03-build/opencv-build -build_opencv RelWithDebugInfo ON || exit 1 -popd - -mkdir -p 03-build/opencv-build-debug -pushd 03-build/opencv-build-debug -build_opencv Debug ON || exit 1 -popd - -mkdir -p 03-build/opencv-static -pushd 03-build/opencv-static -build_opencv RelWithDebugInfo OFF || exit 1 -popd - -# wpiutil, cscore, ntcore, cameraserver -# always use the release version of opencv jar/jni -build_wpilib () { - cmake ../../allwpilib \ - -DWITHOUT_ALLWPILIB=OFF \ - -DCMAKE_BUILD_TYPE=$1 \ - -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ - -DCMAKE_MODULE_PATH=${PWD}/../../02-extract/cmake-modules \ - -DOPENCV_JAR_FILE=`ls ${PWD}/../opencv-build/install/share/OpenCV/java/opencv-*.jar` \ - -DOPENCV_JNI_FILE=`ls ${PWD}/../opencv-build/install/share/OpenCV/java/libopencv_java*.so` \ - -DOpenCV_DIR=${PWD}/../$2/install/share/OpenCV \ - -DTHREADS_PTHREAD_ARG=-pthread \ - || exit 1 - make -j3 || exit 1 - split_debug_so lib -} - -mkdir -p 03-build/allwpilib-build -pushd 03-build/allwpilib-build -build_wpilib RelWithDebugInfo opencv-build || exit 1 -popd - -mkdir -p 03-build/allwpilib-build-debug -pushd 03-build/allwpilib-build-debug -build_wpilib Debug opencv-build-debug || exit 1 -popd - -# static (for tools) -mkdir -p 03-build/allwpilib-static -pushd 03-build/allwpilib-static -cmake ../../allwpilib \ - -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ - -DCMAKE_TOOLCHAIN_FILE=${PWD}/../../02-extract/arm-pi-gnueabihf.toolchain.cmake \ - -DCMAKE_MODULE_PATH=${PWD}/../../02-extract/cmake-modules \ - -DOpenCV_DIR=${PWD}/../opencv-static/install/share/OpenCV \ - -DWITHOUT_JAVA=ON \ - -DBUILD_SHARED_LIBS=OFF \ - -DTHREADS_PTHREAD_ARG=-pthread \ - || exit 1 -make -j3 || exit 1 -split_debug_exe bin -popd - -# tools -pushd tools -make || exit 1 -popd diff --git a/deps/04-copy.sh b/deps/04-copy.sh deleted file mode 100755 index f86cce7..0000000 --- a/deps/04-copy.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh - -DEST=${PWD}/../stage2/01-sys-tweaks/extfiles - -mkdir -p ${DEST} - -# -# examples -# - -sh -c 'cd examples && zip -r - java-multiCameraServer' > ${DEST}/java-multiCameraServer.zip -sh -c 'cd examples && zip -r - cpp-multiCameraServer' > ${DEST}/cpp-multiCameraServer.zip -sh -c 'cd examples && zip -r - python-multiCameraServer' > ${DEST}/python-multiCameraServer.zip - -# -# tools -# - -cp tools/setuidgids ${DEST}/ -cp tools/_cscore.so ${DEST}/_cscore.cpython-35m-arm-linux-gnueabihf.so -cp tools/_cscore.so.debug ${DEST}/ -cp tools/multiCameraServer ${DEST}/ -cp tools/multiCameraServer.debug ${DEST}/ -cp tools/rpiConfigServer ${DEST}/ -cp tools/rpiConfigServer.debug ${DEST}/ - -# -# openjdk -# - -cp 01-download/jdk_11.0.1-strip.tar.gz ${DEST}/ - -# -# opencv -# - -sh -c 'cd 03-build/opencv-build/install/lib && tar czf - libopencv*' > ${DEST}/libopencv.tar.gz -sh -c 'cd 03-build/opencv-build-debug/install/lib && tar czf - libopencv*' > ${DEST}/libopencv-debug.tar.gz - -sh -c 'cd 03-build/opencv-build/install/include && tar czf - .' > ${DEST}/opencv-include.tar.gz - -cp 03-build/opencv-build/install/share/OpenCV/java/opencv-*.jar ${DEST}/ - -sh -c 'cd 03-build/opencv-build/install/share/OpenCV && tar czf - *.cmake' > ${DEST}/opencv-cmake.tar.gz -sh -c 'cd 03-build/opencv-build-debug/install/share/OpenCV && tar czf - *.cmake' > ${DEST}/opencv-cmake-debug.tar.gz - -# the opencv build names the python .so with the build platform name instead -# of the target platform, so rename it -cp 03-build/opencv-build/install/python/cv2/python-*/cv2.*.so ${DEST}/cv2.cpython-35m-arm-linux-gnueabihf.so - -# -# robotpy-cscore -# - -sh -c 'cd robotpy-cscore && tar czf - cscore' > ${DEST}/robotpy-cscore.tar.gz - -# -# pynetworktables -# - -sh -c 'cd pynetworktables && tar czf - networktables ntcore' > ${DEST}/pynetworktables.tar.gz - -# -# allwpilib -# - -sh -c 'cd 03-build/allwpilib-build/lib && tar czf - lib*' > ${DEST}/wpilib.tar.gz -sh -c 'cd 03-build/allwpilib-build-debug/lib && tar czf - lib*' > ${DEST}/wpilib-debug.tar.gz -sh -c 'cd 03-build/allwpilib-build/hal/gen && tar czf - .' > ${DEST}/hal-gen-include.tar.gz - -cp 03-build/allwpilib-build/jar/*.jar ${DEST}/ - -sh -c 'cd allwpilib/wpiutil/src/main/native/include && tar czf - uv.h uv wpi' > ${DEST}/wpiutil-include.tar.gz -sh -c 'cd allwpilib/cscore/src/main/native/include && tar czf - .' > ${DEST}/cscore-include.tar.gz -sh -c 'cd allwpilib/ntcore/src/main/native/include && tar czf - .' > ${DEST}/ntcore-include.tar.gz -sh -c 'cd allwpilib/cameraserver/src/main/native/include && tar czf - cameraserver vision' > ${DEST}/cameraserver-include.tar.gz -sh -c 'cd allwpilib/hal/src/main/native/include && tar czf - .' > ${DEST}/hal-include.tar.gz -sh -c 'cd allwpilib/wpilibc/src/main/native/include && tar czf - frc' > ${DEST}/wpilibc-include.tar.gz - -sh -c 'cd 03-build/allwpilib-static/bin && tar czf - cscore_* netconsoleTee*' > ${DEST}/wpilib-bin.tar.gz diff --git a/deps/allwpilib b/deps/allwpilib deleted file mode 160000 index 05d6660..0000000 --- a/deps/allwpilib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 05d6660a6be0d37064a9fab44232b8379884ccab diff --git a/deps/examples/cpp-multiCameraServer/Makefile b/deps/examples/cpp-multiCameraServer/Makefile index 3659cc0..556fdc0 100644 --- a/deps/examples/cpp-multiCameraServer/Makefile +++ b/deps/examples/cpp-multiCameraServer/Makefile @@ -1,3 +1,5 @@ +DEPS_CFLAGS?=$(shell env PKG_CONFIG_PATH=/usr/local/frc/lib/pkgconfig pkg-config --cflags wpilibc) +DEPS_LIBS?=$(shell env PKG_CONFIG_PATH=/usr/local/frc/lib/pkgconfig pkg-config --libs wpilibc) EXE=multiCameraServerExample DESTDIR?=/home/pi/ @@ -11,31 +13,10 @@ install: build clean: rm ${EXE} *.o -${EXE}: main.o - ${CXX} -pthread -o $@ $< \ - -L/usr/local/frc/lib \ - -lwpilibc \ - -lwpiHal \ - -lcameraserver \ - -lcscore \ - -lntcore \ - -lwpiutil \ - -lopencv_ml \ - -lopencv_objdetect \ - -lopencv_shape \ - -lopencv_stitching \ - -lopencv_superres \ - -lopencv_videostab \ - -lopencv_calib3d \ - -lopencv_features2d \ - -lopencv_highgui \ - -lopencv_videoio \ - -lopencv_imgcodecs \ - -lopencv_video \ - -lopencv_photo \ - -lopencv_imgproc \ - -lopencv_flann \ - -lopencv_core +OBJS=main.o + +${EXE}: ${OBJS} + ${CXX} -pthread -g -o $@ $^ ${DEPS_LIBS} -Wl,--unresolved-symbols=ignore-in-shared-libs .cpp.o: - ${CXX} -pthread -O -c -o $@ -I/usr/local/frc/include $< + ${CXX} -pthread -g -Og -c -o $@ ${CXXFLAGS} ${DEPS_CFLAGS} $< diff --git a/deps/pynetworktables b/deps/pynetworktables deleted file mode 160000 index 8a42884..0000000 --- a/deps/pynetworktables +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8a4288452be26e26dccad32980f46000e8d97928 diff --git a/deps/robotpy-cscore b/deps/robotpy-cscore deleted file mode 160000 index 2590274..0000000 --- a/deps/robotpy-cscore +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2590274ca4e9ef852093152be34bde4e56d027f3 diff --git a/deps/tools/Makefile b/deps/tools/Makefile deleted file mode 100644 index 1b822d8..0000000 --- a/deps/tools/Makefile +++ /dev/null @@ -1,113 +0,0 @@ -SYSROOT?=../02-extract/raspbian9/arm-raspbian9-linux-gnueabihf -COMPILER?=../02-extract/raspbian9/bin/arm-raspbian9-linux-gnueabihf- -WPILIB_SRC?=../allwpilib -WPILIB_BUILD?=../03-build/allwpilib-build -WPILIB_STATIC_BUILD?=../03-build/allwpilib-static -OPENCV_INSTALL?=../03-build/opencv-build/install -OPENCV_STATIC_INSTALL?=../03-build/opencv-static/install -EXEC_HOME?=/home/pi -FRC_JSON?=/boot/frc.json -DHCPCD_CONF?=/boot/dhcpcd.conf -APP_UID?=1000 -APP_GID?=1000 - -.PHONY: all -.SUFFIXES: - -all: setuidgids _cscore.so multiCameraServer rpiConfigServer - -clean: - rm -f setuidgids - rm -f _cscore.so - rm -f rpiConfigServer - rm -f rpiConfigServer_src/*.o - rm -f rpiConfigServer_src/resources/*.o - -setuidgids: setuidgids.c - ${COMPILER}gcc -O -Wall -D_GNU_SOURCE -o $@ $< - -_cscore.so: ../robotpy-cscore/src/_cscore.cpp ../robotpy-cscore/src/ndarray_converter.cpp - ${COMPILER}g++ -g -O -Wall -fvisibility=hidden -shared -fPIC -o $@ \ - -I${OPENCV_INSTALL}/include \ - -I${WPILIB_SRC}/wpiutil/src/main/native/include \ - -I${WPILIB_SRC}/cscore/src/main/native/include \ - -I${SYSROOT}/usr/include/python3.5 \ - -L${WPILIB_BUILD}/lib \ - -L${OPENCV_INSTALL}/lib \ - ../robotpy-cscore/src/_cscore.cpp \ - ../robotpy-cscore/src/ndarray_converter.cpp \ - -lcscore \ - -lwpiutil \ - -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core - ${COMPILER}objcopy --only-keep-debug $@ $@.debug - ${COMPILER}strip -g $@ - ${COMPILER}objcopy --add-gnu-debuglink=$@.debug $@ - -multiCameraServer: multiCameraServer.cpp - ${COMPILER}g++ -pthread -g -o $@ \ - -I${OPENCV_INSTALL}/include \ - -I${WPILIB_SRC}/wpiutil/src/main/native/include \ - -I${WPILIB_SRC}/cameraserver/src/main/native/include \ - -I${WPILIB_SRC}/cscore/src/main/native/include \ - -I${WPILIB_SRC}/ntcore/src/main/native/include \ - -L${WPILIB_STATIC_BUILD}/lib \ - -L${OPENCV_STATIC_INSTALL}/lib \ - -L${OPENCV_STATIC_INSTALL}/share/OpenCV/3rdparty/lib \ - $< \ - -lcameraserver \ - -lcscore \ - -lntcore \ - -lwpiutil \ - -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core \ - -ltegra_hal -llibpng -llibjpeg-turbo -lzlib - ${COMPILER}objcopy --only-keep-debug $@ $@.debug - ${COMPILER}strip -g $@ - ${COMPILER}objcopy --add-gnu-debuglink=$@.debug $@ - -RPICONFIGSERVER_OBJS= \ - rpiConfigServer_src/main.o \ - rpiConfigServer_src/Application.o \ - rpiConfigServer_src/MyHttpConnection.o \ - rpiConfigServer_src/NetworkSettings.o \ - rpiConfigServer_src/SystemStatus.o \ - rpiConfigServer_src/VisionSettings.o \ - rpiConfigServer_src/VisionStatus.o \ - rpiConfigServer_src/WebSocketHandlers.o \ - rpiConfigServer_src/resources/index.html.o \ - rpiConfigServer_src/resources/frcvision.css.o \ - rpiConfigServer_src/resources/frcvision.js.o - -rpiConfigServer: ${RPICONFIGSERVER_OBJS} - ${COMPILER}g++ -pthread -g -o $@ \ - ${RPICONFIGSERVER_OBJS} \ - -L${WPILIB_STATIC_BUILD}/lib \ - -L${OPENCV_STATIC_INSTALL}/lib \ - -L${OPENCV_STATIC_INSTALL}/share/OpenCV/3rdparty/lib \ - -lcscore \ - -lwpiutil \ - -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_core \ - -ltegra_hal -llibpng -llibjpeg-turbo -lzlib - ${COMPILER}objcopy --only-keep-debug $@ $@.debug - ${COMPILER}strip -g $@ - ${COMPILER}objcopy --add-gnu-debuglink=$@.debug $@ - -%.o: %.cpp - ${COMPILER}g++ -g -O -Wall -c -o $@ \ - -I${WPILIB_SRC}/wpiutil/src/main/native/include \ - -I${WPILIB_SRC}/cscore/src/main/native/include \ - '-DEXEC_HOME="${EXEC_HOME}"' \ - '-DFRC_JSON="${FRC_JSON}"' \ - '-DDHCPCD_CONF="${DHCPCD_CONF}"' \ - '-DAPP_UID=${APP_UID}' \ - '-DAPP_GID=${APP_GID}' \ - $< - -%.html.cpp: %.html - ./gen_resource.py $@ $< - -%.css.cpp: %.css - ./gen_resource.py $@ $< - -%.js.cpp: %.js - ./gen_resource.py $@ $< - diff --git a/deps/tools/configServer/Makefile b/deps/tools/configServer/Makefile new file mode 100644 index 0000000..67990c0 --- /dev/null +++ b/deps/tools/configServer/Makefile @@ -0,0 +1,54 @@ +DEPS_CFLAGS?=$(shell pkg-config --cflags cscore wpiutil) +DEPS_LIBS?=$(shell pkg-config --libs --static cscore wpiutil) +EXEC_HOME?=/home/pi +FRC_JSON?=/boot/frc.json +DHCPCD_CONF?=/boot/dhcpcd.conf +APP_UID?=1000 +APP_GID?=1000 + +.PHONY: all clean +.SUFFIXES: + +all: configServer + +clean: + rm -f configServer + rm -f src/*.o + rm -f src/resources/*.o + +OBJS= \ + src/main.o \ + src/Application.o \ + src/MyHttpConnection.o \ + src/NetworkSettings.o \ + src/SystemStatus.o \ + src/VisionSettings.o \ + src/VisionStatus.o \ + src/WebSocketHandlers.o \ + src/resources/index.html.o \ + src/resources/frcvision.css.o \ + src/resources/frcvision.js.o + +configServer: ${OBJS} + ${CXX} -pthread -g -o $@ ${CXXFLAGS} $^ ${DEPS_LIBS} + +%.o: %.cpp + ${CXX} -g -O -Wall -c -o $@ \ + ${CXXFLAGS} \ + ${DEPS_CFLAGS} \ + '-DEXEC_HOME="${EXEC_HOME}"' \ + '-DFRC_JSON="${FRC_JSON}"' \ + '-DDHCPCD_CONF="${DHCPCD_CONF}"' \ + '-DAPP_UID=${APP_UID}' \ + '-DAPP_GID=${APP_GID}' \ + $< + +%.html.cpp: %.html + ./gen_resource.py $@ $< + +%.css.cpp: %.css + ./gen_resource.py $@ $< + +%.js.cpp: %.js + ./gen_resource.py $@ $< + diff --git a/deps/tools/gen_resource.py b/deps/tools/configServer/gen_resource.py similarity index 100% rename from deps/tools/gen_resource.py rename to deps/tools/configServer/gen_resource.py diff --git a/deps/tools/rpiConfigServer_src/Application.cpp b/deps/tools/configServer/src/Application.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/Application.cpp rename to deps/tools/configServer/src/Application.cpp diff --git a/deps/tools/rpiConfigServer_src/Application.h b/deps/tools/configServer/src/Application.h similarity index 100% rename from deps/tools/rpiConfigServer_src/Application.h rename to deps/tools/configServer/src/Application.h diff --git a/deps/tools/rpiConfigServer_src/DataHistory.h b/deps/tools/configServer/src/DataHistory.h similarity index 100% rename from deps/tools/rpiConfigServer_src/DataHistory.h rename to deps/tools/configServer/src/DataHistory.h diff --git a/deps/tools/rpiConfigServer_src/MyHttpConnection.cpp b/deps/tools/configServer/src/MyHttpConnection.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/MyHttpConnection.cpp rename to deps/tools/configServer/src/MyHttpConnection.cpp diff --git a/deps/tools/rpiConfigServer_src/MyHttpConnection.h b/deps/tools/configServer/src/MyHttpConnection.h similarity index 100% rename from deps/tools/rpiConfigServer_src/MyHttpConnection.h rename to deps/tools/configServer/src/MyHttpConnection.h diff --git a/deps/tools/rpiConfigServer_src/NetworkSettings.cpp b/deps/tools/configServer/src/NetworkSettings.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/NetworkSettings.cpp rename to deps/tools/configServer/src/NetworkSettings.cpp diff --git a/deps/tools/rpiConfigServer_src/NetworkSettings.h b/deps/tools/configServer/src/NetworkSettings.h similarity index 100% rename from deps/tools/rpiConfigServer_src/NetworkSettings.h rename to deps/tools/configServer/src/NetworkSettings.h diff --git a/deps/tools/rpiConfigServer_src/SystemStatus.cpp b/deps/tools/configServer/src/SystemStatus.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/SystemStatus.cpp rename to deps/tools/configServer/src/SystemStatus.cpp diff --git a/deps/tools/rpiConfigServer_src/SystemStatus.h b/deps/tools/configServer/src/SystemStatus.h similarity index 100% rename from deps/tools/rpiConfigServer_src/SystemStatus.h rename to deps/tools/configServer/src/SystemStatus.h diff --git a/deps/tools/rpiConfigServer_src/VisionSettings.cpp b/deps/tools/configServer/src/VisionSettings.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/VisionSettings.cpp rename to deps/tools/configServer/src/VisionSettings.cpp diff --git a/deps/tools/rpiConfigServer_src/VisionSettings.h b/deps/tools/configServer/src/VisionSettings.h similarity index 100% rename from deps/tools/rpiConfigServer_src/VisionSettings.h rename to deps/tools/configServer/src/VisionSettings.h diff --git a/deps/tools/rpiConfigServer_src/VisionStatus.cpp b/deps/tools/configServer/src/VisionStatus.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/VisionStatus.cpp rename to deps/tools/configServer/src/VisionStatus.cpp diff --git a/deps/tools/rpiConfigServer_src/VisionStatus.h b/deps/tools/configServer/src/VisionStatus.h similarity index 100% rename from deps/tools/rpiConfigServer_src/VisionStatus.h rename to deps/tools/configServer/src/VisionStatus.h diff --git a/deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp b/deps/tools/configServer/src/WebSocketHandlers.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/WebSocketHandlers.cpp rename to deps/tools/configServer/src/WebSocketHandlers.cpp diff --git a/deps/tools/rpiConfigServer_src/WebSocketHandlers.h b/deps/tools/configServer/src/WebSocketHandlers.h similarity index 100% rename from deps/tools/rpiConfigServer_src/WebSocketHandlers.h rename to deps/tools/configServer/src/WebSocketHandlers.h diff --git a/deps/tools/rpiConfigServer_src/main.cpp b/deps/tools/configServer/src/main.cpp similarity index 100% rename from deps/tools/rpiConfigServer_src/main.cpp rename to deps/tools/configServer/src/main.cpp diff --git a/deps/tools/rpiConfigServer_src/resources/frcvision.css b/deps/tools/configServer/src/resources/frcvision.css similarity index 100% rename from deps/tools/rpiConfigServer_src/resources/frcvision.css rename to deps/tools/configServer/src/resources/frcvision.css diff --git a/deps/tools/rpiConfigServer_src/resources/frcvision.js b/deps/tools/configServer/src/resources/frcvision.js similarity index 100% rename from deps/tools/rpiConfigServer_src/resources/frcvision.js rename to deps/tools/configServer/src/resources/frcvision.js diff --git a/deps/tools/rpiConfigServer_src/resources/index.html b/deps/tools/configServer/src/resources/index.html similarity index 100% rename from deps/tools/rpiConfigServer_src/resources/index.html rename to deps/tools/configServer/src/resources/index.html diff --git a/deps/tools/multiCameraServer/Makefile b/deps/tools/multiCameraServer/Makefile new file mode 100644 index 0000000..e1c01ac --- /dev/null +++ b/deps/tools/multiCameraServer/Makefile @@ -0,0 +1,12 @@ +DEPS_CFLAGS?=$(shell pkg-config --cflags cameraserver ntcore wpiutil) +DEPS_LIBS?=$(shell pkg-config --libs --static cameraserver ntcore wpiutil) + +.PHONY: all clean + +all: multiCameraServer + +clean: + rm -f multiCameraServer + +multiCameraServer: src/multiCameraServer.cpp + ${CXX} -pthread -g -o $@ ${CXXFLAGS} ${DEPS_CFLAGS} $^ ${DEPS_LIBS} diff --git a/deps/tools/multiCameraServer.cpp b/deps/tools/multiCameraServer/src/multiCameraServer.cpp similarity index 100% rename from deps/tools/multiCameraServer.cpp rename to deps/tools/multiCameraServer/src/multiCameraServer.cpp diff --git a/deps/tools/setuidgids/Makefile b/deps/tools/setuidgids/Makefile new file mode 100644 index 0000000..b5f2fcc --- /dev/null +++ b/deps/tools/setuidgids/Makefile @@ -0,0 +1,9 @@ +.PHONY: all clean + +all: setuidgids + +clean: + rm -f setuidgids + +setuidgids: src/setuidgids.c + ${CC} -O -Wall -D_GNU_SOURCE -o $@ $^ diff --git a/deps/tools/setuidgids.c b/deps/tools/setuidgids/src/setuidgids.c similarity index 100% rename from deps/tools/setuidgids.c rename to deps/tools/setuidgids/src/setuidgids.c diff --git a/export-image/02-network/01-run.sh b/export-image/02-network/01-run.sh index 4150732..e1378cc 100755 --- a/export-image/02-network/01-run.sh +++ b/export-image/02-network/01-run.sh @@ -1,3 +1,11 @@ #!/bin/bash -e -install -m 644 files/resolv.conf "${ROOTFS_DIR}/etc/" +on_chroot << EOF +rm -f /etc/resolv.conf +touch /tmp/dhcpcd.resolv.conf +ln -s /tmp/dhcpcd.resolve.conf /etc/resolv.conf +sed -i -e 's/\/run\//\/var\/run\//' /etc/systemd/system/dhcpcd5.service +mv /etc/dhcpcd.conf /boot/ +chown root:root /boot/dhcpcd.conf +ln -s /boot/dhcpcd.conf /etc/dhcpcd.conf +EOF diff --git a/export-image/04-finalise/01-run.sh b/export-image/04-finalise/01-run.sh index f5a5fd8..2c3ba22 100755 --- a/export-image/04-finalise/01-run.sh +++ b/export-image/04-finalise/01-run.sh @@ -2,6 +2,10 @@ IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}.img" INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}.info" +EXAMPLE_DIR="${STAGE_WORK_DIR}/examples" + +mkdir -p "${EXAMPLE_DIR}" +cp -p "${ROOTFS_DIR}"/home/pi/zips/* "${EXAMPLE_DIR}/" on_chroot << EOF /etc/init.d/fake-hwclock stop @@ -43,7 +47,6 @@ rm -f "${ROOTFS_DIR}/etc/vnc/updateid" update_issue "$(basename "${EXPORT_DIR}")" install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/issue.txt" -install files/LICENSE.oracle "${ROOTFS_DIR}/boot/" cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE" @@ -82,3 +85,4 @@ zip "${DEPLOY_DIR}/${ZIP_FILENAME}.zip" \ popd > /dev/null cp "$INFO_FILE" "$DEPLOY_DIR" +cp -Rp "${EXAMPLE_DIR}" "${DEPLOY_DIR}" diff --git a/export-image/04-finalise/files/LICENSE.oracle b/export-image/04-finalise/files/LICENSE.oracle deleted file mode 100644 index 00898ca..0000000 --- a/export-image/04-finalise/files/LICENSE.oracle +++ /dev/null @@ -1,72 +0,0 @@ -Taken from http://www.java.com/license - -Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX - -ORACLE AMERICA, INC. ("ORACLE"), FOR AND ON BEHALF OF ITSELF AND ITS SUBSIDIARIES AND AFFILIATES UNDER COMMON CONTROL, IS WILLING TO LICENSE THE SOFTWARE TO YOU ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY CODE LICENSE AGREEMENT AND SUPPLEMENTAL LICENSE TERMS (COLLECTIVELY "AGREEMENT"). PLEASE READ THE AGREEMENT CAREFULLY. BY SELECTING THE "ACCEPT LICENSE AGREEMENT" (OR THE EQUIVALENT) BUTTON AND/OR BY USING THE SOFTWARE YOU ACKNOWLEDGE THAT YOU HAVE READ THE TERMS AND AGREE TO THEM. IF YOU ARE AGREEING TO THESE TERMS ON BEHALF OF A COMPANY OR OTHER LEGAL ENTITY, YOU REPRESENT THAT YOU HAVE THE LEGAL AUTHORITY TO BIND THE LEGAL ENTITY TO THESE TERMS. IF YOU DO NOT HAVE SUCH AUTHORITY, OR IF YOU DO NOT WISH TO BE BOUND BY THE TERMS, THEN SELECT THE "DECLINE LICENSE AGREEMENT" (OR THE EQUIVALENT) BUTTON AND YOU MUST NOT USE THE SOFTWARE ON THIS SITE OR ANY OTHER MEDIA ON WHICH THE SOFTWARE IS CONTAINED. - -1. DEFINITIONS. "Software" means the software identified above in binary form that you selected for download, install or use (in the version You selected for download, install or use) from Oracle or its authorized licensees, any other machine readable materials (including, but not limited to, libraries, source files, header files, and data files), any updates or error corrections provided by Oracle, and any user manuals, programming guides and other documentation provided to you by Oracle under this Agreement. "General Purpose Desktop Computers and Servers" means computers, including desktop and laptop computers, or servers, used for general computing functions under end user control (such as but not specifically limited to email, general purpose Internet browsing, and office suite productivity tools). The use of Software in systems and solutions that provide dedicated functionality (other than as mentioned above) or designed for use in embedded or function-specific software applications, for example but not limited to: Software embedded in or bundled with industrial control systems, wireless mobile telephones, wireless handheld devices, kiosks, TV/STB, Blu-ray Disc devices, telematics and network control switching equipment, printers and storage management systems, and other related systems are excluded from this definition and not licensed under this Agreement. "Programs" means (a) Java technology applets and applications intended to run on the Java Platform, Standard Edition platform on Java-enabled General Purpose Desktop Computers and Servers; and (b) JavaFX technology applications intended to run on the JavaFX Runtime on JavaFX-enabled General Purpose Desktop Computers and Servers. “Commercial Features” means those features identified in Table 1-1 (Commercial Features In Java SE Product Editions) of the Java SE documentation accessible at http://www.oracle.com/technetwork/java/javase/documentation/index.html. “README File” means the README file for the Software accessible at http://www.oracle.com/technetwork/java/javase/documentation/index.html. - -2. LICENSE TO USE. Subject to the terms and conditions of this Agreement including, but not limited to, the Java Technology Restrictions of the Supplemental License Terms, Oracle grants you a non-exclusive, non-transferable, limited license without license fees to reproduce and use internally the Software complete and unmodified for the sole purpose of running Programs. THE LICENSE SET FORTH IN THIS SECTION 2 DOES NOT EXTEND TO THE COMMERCIAL FEATURES. YOUR RIGHTS AND OBLIGATIONS RELATED TO THE COMMERCIAL FEATURES ARE AS SET FORTH IN THE SUPPLEMENTAL TERMS ALONG WITH ADDITIONAL LICENSES FOR DEVELOPERS AND PUBLISHERS. - -3. RESTRICTIONS. Software is copyrighted. Title to Software and all associated intellectual property rights is retained by Oracle and/or its licensors. Unless enforcement is prohibited by applicable law, you may not modify, decompile, or reverse engineer Software. You acknowledge that the Software is developed for general use in a variety of information management applications; it is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use the Software in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle disclaims any express or implied warranty of fitness for such uses. No right, title or interest in or to any trademark, service mark, logo or trade name of Oracle or its licensors is granted under this Agreement. Additional restrictions for developers and/or publishers licenses are set forth in the Supplemental License Terms. - -4. DISCLAIMER OF WARRANTY. THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. ORACLE FURTHER DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. - -5. LIMITATION OF LIABILITY. IN NO EVENT SHALL ORACLE BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, DATA OR DATA USE, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN IF ORACLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ORACLE'S ENTIRE LIABILITY FOR DAMAGES HEREUNDER SHALL IN NO EVENT EXCEED ONE THOUSAND DOLLARS (U.S. $1,000). - -6. TERMINATION. This Agreement is effective until terminated. You may terminate this Agreement at any time by destroying all copies of Software. This Agreement will terminate immediately without notice from Oracle if you fail to comply with any provision of this Agreement. Either party may terminate this Agreement immediately should any Software become, or in either party's opinion be likely to become, the subject of a claim of infringement of any intellectual property right. Upon termination, you must destroy all copies of Software. - -7. EXPORT REGULATIONS. You agree that U.S. export control laws and other applicable export and import laws govern your use of the Software, including technical data; additional information can be found on Oracle's Global Trade Compliance web site (http://www.oracle.com/products/export). You agree that neither the Software nor any direct product thereof will be exported, directly, or indirectly, in violation of these laws, or will be used for any purpose prohibited by these laws including, without limitation, nuclear, chemical, or biological weapons proliferation. - -8. TRADEMARKS AND LOGOS. You acknowledge and agree as between you -and Oracle that Oracle owns the ORACLE and JAVA trademarks and all ORACLE- and JAVA-related trademarks, service marks, logos and other brand -designations ("Oracle Marks"), and you agree to comply with the Third -Party Usage Guidelines for Oracle Trademarks currently located at -http://www.oracle.com/us/legal/third-party-trademarks/index.html . Any use you make of the Oracle Marks inures to Oracle's benefit. - -9. U.S. GOVERNMENT LICENSE RIGHTS. If Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in Software and accompanying documentation shall be only those set forth in this Agreement. - -10. GOVERNING LAW. This agreement is governed by the substantive and procedural laws of California. You and Oracle agree to submit to the exclusive jurisdiction of, and venue in, the courts of San Francisco, or Santa Clara counties in California in any dispute arising out of or relating to this agreement. - -11. SEVERABILITY. If any provision of this Agreement is held to be unenforceable, this Agreement will remain in effect with the provision omitted, unless omission would frustrate the intent of the parties, in which case this Agreement will immediately terminate. - -12. INTEGRATION. This Agreement is the entire agreement between you and Oracle relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification of this Agreement will be binding, unless in writing and signed by an authorized representative of each party. - -SUPPLEMENTAL LICENSE TERMS - -These Supplemental License Terms add to or modify the terms of the Binary Code License Agreement. Capitalized terms not defined in these Supplemental Terms shall have the same meanings ascribed to them in the Binary Code License Agreement. These Supplemental Terms shall supersede any inconsistent or conflicting terms in the Binary Code License Agreement, or in any license contained within the Software. - -A. COMMERCIAL FEATURES. You may not use the Commercial Features for running Programs, Java applets or applications in your internal business operations or for any commercial or production purpose, or for any purpose other than as set forth in Sections B, C, D and E of these Supplemental Terms. If You want to use the Commercial Features for any purpose other than as permitted in this Agreement, You must obtain a separate license from Oracle. - -B. SOFTWARE INTERNAL USE FOR DEVELOPMENT LICENSE GRANT. Subject to the terms and conditions of this Agreement and restrictions and exceptions set forth in the README File incorporated herein by reference, including, but not limited to the Java Technology Restrictions of these Supplemental Terms, Oracle grants you a non-exclusive, non-transferable, limited license without fees to reproduce internally and use internally the Software complete and unmodified for the purpose of designing, developing, and testing your Programs. - -C. LICENSE TO DISTRIBUTE SOFTWARE. Subject to the terms and conditions of this Agreement and restrictions and exceptions set forth in the README File, including, but not limited to the Java Technology Restrictions and Limitations on Redistribution of these Supplemental Terms, Oracle grants you a non-exclusive, non-transferable, limited license without fees to reproduce and distribute the Software, provided that (i) you distribute the Software complete and unmodified and only bundled as part of, and for the sole purpose of running, your Programs, (ii) the Programs add significant and primary functionality to the Software, (iii) you do not distribute additional software intended to replace any component(s) of the Software, (iv) you do not remove or alter any proprietary legends or notices contained in the Software, (v) you only distribute the Software subject to a license agreement that: (a) is a complete, unmodified reproduction of this Agreement; or (b) protects Oracle's interests consistent with the terms contained in this Agreement and that includes the notice set forth in Section H, and (vi) you agree to defend and indemnify Oracle and its licensors from and against any damages, costs, liabilities, settlement amounts and/or expenses (including attorneys' fees) incurred in connection with any claim, lawsuit or action by any third party that arises or results from the use or distribution of any and all Programs and/or Software. The license set forth in this Section C does not extend to the Software identified in Section G. - -D. LICENSE TO DISTRIBUTE REDISTRIBUTABLES. Subject to the terms and conditions of this Agreement and restrictions and exceptions set forth in the README File, including but not limited to the Java Technology Restrictions and Limitations on Redistribution of these Supplemental Terms, Oracle grants you a non-exclusive, non-transferable, limited license without fees to reproduce and distribute those files specifically identified as redistributable in the README File ("Redistributables") provided that: (i) you distribute the Redistributables complete and unmodified, and only bundled as part of Programs, (ii) the Programs add significant and primary functionality to the Redistributables, (iii) you do not distribute additional software intended to supersede any component(s) of the Redistributables (unless otherwise specified in the applicable README File), (iv) you do not remove or alter any proprietary legends or notices contained in or on the Redistributables, (v) you only distribute the Redistributables pursuant to a license agreement that: (a) is a complete, unmodified reproduction of this Agreement; or (b) protects Oracle's interests consistent with the terms contained in the Agreement and includes the notice set forth in Section H, (vi) you agree to defend and indemnify Oracle and its licensors from and against any damages, costs, liabilities, settlement amounts and/or expenses (including attorneys' fees) incurred in connection with any claim, lawsuit or action by any third party that arises or results from the use or distribution of any and all Programs and/or Software. The license set forth in this Section D does not extend to the Software identified in Section G. - -E. DISTRIBUTION BY PUBLISHERS. This section pertains to your distribution of the JavaTM SE Development Kit Software (“JDK”) with your printed book or magazine (as those terms are commonly used in the industry) relating to Java technology ("Publication"). Subject to and conditioned upon your compliance with the restrictions and obligations contained in the Agreement, Oracle hereby grants to you a non-exclusive, nontransferable limited right to reproduce complete and unmodified copies of the JDK on electronic media (the "Media") for the sole purpose of inclusion and distribution with your Publication(s), subject to the following terms: (i) You may not distribute the JDK on a stand-alone basis; it must be distributed with your Publication(s); (ii) You are responsible for downloading the JDK from the applicable Oracle web site; (iii) You must refer to the JDK as JavaTM SE Development Kit; (iv) The JDK must be reproduced in its entirety and without any modification whatsoever (including with respect to all proprietary notices) and distributed with your Publication subject to a license agreement that is a complete, unmodified reproduction of this Agreement; (v) The Media label shall include the following information: “Copyright [YEAR], Oracle America, Inc. All rights reserved. Use is subject to license terms. ORACLE and JAVA trademarks and all ORACLE- and JAVA-related trademarks, service marks, logos and other brand designations are trademarks or registered trademarks of Oracle in the U.S. and other countries.” [YEAR] is the year of Oracle's release of the Software; the year information can typically be found in the Software’s “About” box or screen. This information must be placed on the Media label in such a manner as to only apply to the JDK; (vi) You must clearly identify the JDK as Oracle's product on the Media holder or Media label, and you may not state or imply that Oracle is responsible for any third-party software contained on the Media; (vii) You may not include any third party software on the Media which is intended to be a replacement or substitute for the JDK; (viii) You agree to defend and indemnify Oracle and its licensors from and against any damages, costs, liabilities, settlement amounts and/or expenses (including attorneys' fees) incurred in connection with any claim, lawsuit or action by any third party that arises or results from the use or distribution of the JDK and/or the Publication; ; and (ix) You shall provide Oracle with a written notice for each Publication; such notice shall include the following information: (1) title of Publication, (2) author(s), (3) date of Publication, and (4) ISBN or ISSN numbers. Such notice shall be sent to Oracle America, Inc., 500 Oracle Parkway, Redwood Shores, California 94065 U.S.A , Attention: General Counsel. - -F. JAVA TECHNOLOGY RESTRICTIONS. You may not create, modify, or change the behavior of, or authorize your licensees to create, modify, or change the behavior of, classes, interfaces, or subpackages that are in any way identified as "java", "javax", "sun", “oracle” or similar convention as specified by Oracle in any naming convention designation. - -G. LIMITATIONS ON REDISTRIBUTION. You may not redistribute or otherwise transfer patches, bug fixes or updates made available by Oracle through Oracle Premier Support, including those made available under Oracle's Java SE Support program. - -H. COMMERCIAL FEATURES NOTICE. For purpose of complying with Supplemental Term Section C.(v)(b) and D.(v)(b), your license agreement shall include the following notice, where the notice is displayed in a manner that anyone using the Software will see the notice: - -Use of the Commercial Features for any commercial or production purpose requires a separate license from Oracle. “Commercial Features” means those features identified Table 1-1 (Commercial Features In Java SE Product Editions) of the Java SE documentation accessible at http://www.oracle.com/technetwork/java/javase/documentation/index.html - - - -I. SOURCE CODE. Software may contain source code that, unless expressly licensed for other purposes, is provided solely for reference purposes pursuant to the terms of this Agreement. Source code may not be redistributed unless expressly provided for in this Agreement. - -J. THIRD PARTY CODE. Additional copyright notices and license terms applicable to portions of the Software are set forth in the THIRDPARTYLICENSEREADME file accessible at http://www.oracle.com/technetwork/java/javase/documentation/index.html. In addition to any terms and conditions of any third party opensource/freeware license identified in the THIRDPARTYLICENSEREADME file, the disclaimer of warranty and limitation of liability provisions in paragraphs 4 and 5 of the Binary Code License Agreement shall apply to all Software in this distribution. - -K. TERMINATION FOR INFRINGEMENT. Either party may terminate this Agreement immediately should any Software become, or in either party's opinion be likely to become, the subject of a claim of infringement of any intellectual property right. - -L. INSTALLATION AND AUTO-UPDATE. The Software's installation and auto-update processes transmit a limited amount of data to Oracle (or its service provider) about those specific processes to help Oracle understand and optimize them. Oracle does not associate the data with personally identifiable information. You can find more information about the data Oracle collects as a result of your Software download at http://www.oracle.com/technetwork/java/javase/documentation/index.html. - -For inquiries please contact: Oracle America, Inc., 500 Oracle Parkway, - -Redwood Shores, California 94065, USA. - -Last updated 02 April 2013 - diff --git a/scripts/common b/scripts/common index bdddead..ea18cb6 100644 --- a/scripts/common +++ b/scripts/common @@ -95,7 +95,7 @@ export -f on_chroot update_issue() { local GIT_HASH GIT_HASH=$(git rev-parse HEAD) - echo -e "Raspberry Pi reference ${IMG_DATE}\nGenerated using pi-gen, https://github.com/RPi-Distro/pi-gen, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" + echo -e "FRCVision ${IMG_DATE}\nGenerated using pi-gen, https://github.com/allwpilib/FRCVision-pi-gen, ${GIT_HASH}, ${1}" > "${ROOTFS_DIR}/etc/rpi-issue" } export -f update_issue diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index cd8e425..754dbb9 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -11,25 +11,34 @@ install -m 644 files/console-setup "${ROOTFS_DIR}/etc/default/" install -m 755 files/rc.local "${ROOTFS_DIR}/etc/" -# enable pi camera -install -m 644 files/picamera.conf "${ROOTFS_DIR}/etc/modules-load.d/" +# +# Install OpenJDK +# +pushd "${STAGE_WORK_DIR}" +wget -nc -nv \ + https://github.com/wpilibsuite/raspbian-openjdk/releases/download/v2019-11.0.1-1/jdk_11.0.1-strip.tar.gz +popd -# disable wireless -install -m 644 files/raspi-blacklist.conf "${ROOTFS_DIR}/etc/modprobe.d/" - -install -m 644 files/frc.json "${ROOTFS_DIR}/boot/" - -install -m 755 extfiles/setuidgids "${ROOTFS_DIR}/usr/local/bin/" - -cat extfiles/jdk_11.0.1-strip.tar.gz | sh -c "mkdir -p ${ROOTFS_DIR}/usr/lib/jvm && cd ${ROOTFS_DIR}/usr/lib/jvm/ && tar xzf - --exclude=\*.diz --exclude=src.zip --transform=s/^jdk/jdk-11.0.1/" +mkdir -p "${ROOTFS_DIR}/usr/lib/jvm" +pushd "${ROOTFS_DIR}/usr/lib/jvm" +tar xzf "${STAGE_WORK_DIR}/jdk_11.0.1-strip.tar.gz" \ + --exclude=\*.diz \ + --exclude=src.zip \ + --transform=s/^jdk/jdk-11.0.1/ +popd cp files/jdk-11.0.1.jinfo "${ROOTFS_DIR}/usr/lib/jvm/.jdk-11.0.1.jinfo" +install -m 644 files/ld.so.conf.d/*.conf "${ROOTFS_DIR}/etc/ld.so.conf.d/" on_chroot << EOF cd /usr/lib/jvm grep /usr/lib/jvm .jdk-11.0.1.jinfo | awk '{ print "update-alternatives --install /usr/bin/" \$2 " " \$2 " " \$3 " 2"; }' | bash update-java-alternatives -s jdk-11.0.1 +ldconfig EOF +# +# Set up for read-only file system +# on_chroot << EOF rm -rf /var/lib/dhcp/ /var/run /var/spool /var/lock ln -s /tmp /var/lib/dhcp @@ -83,107 +92,4 @@ on_chroot << EOF usermod --pass='*' root EOF -install -m 644 files/ld.so.conf.d/*.conf "${ROOTFS_DIR}/etc/ld.so.conf.d/" - -install -v -d "${ROOTFS_DIR}/usr/local/frc/bin" - -install -m 755 extfiles/multiCameraServer "${ROOTFS_DIR}/usr/local/frc/bin/" -install -m 644 extfiles/multiCameraServer.debug "${ROOTFS_DIR}/usr/local/frc/bin/" - -cat extfiles/wpilib-bin.tar.gz | sh -c 'cd ${ROOTFS_DIR}/usr/local/frc/bin/ && tar xzf -' - -install -v -d "${ROOTFS_DIR}/usr/local/frc/lib" - -cat extfiles/libopencv-debug.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" -cat extfiles/libopencv.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" - -install -m 755 extfiles/cv2.*.so "${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/" - -cat extfiles/pynetworktables.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/ && tar xzf -" -cat extfiles/robotpy-cscore.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/ && tar xzf -" -install -m 755 extfiles/_cscore.*.so "${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/cscore/" - -cat extfiles/wpilib-debug.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" -cat extfiles/wpilib.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib/ && tar xzf -" - -install -v -d "${ROOTFS_DIR}/usr/local/frc/include" - -cat extfiles/wpiutil-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/cscore-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/ntcore-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/cameraserver-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/hal-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/hal-gen-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/wpilibc-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" -cat extfiles/opencv-include.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include/ && tar xzf -" - -install -v -d "${ROOTFS_DIR}/usr/local/frc/share/OpenCV" - -cat extfiles/opencv-cmake-debug.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/share/OpenCV/ && tar xzf -" -cat extfiles/opencv-cmake.tar.gz | sh -c "cd ${ROOTFS_DIR}/usr/local/frc/share/OpenCV/ && tar xzf -" - -install -v -d "${ROOTFS_DIR}/usr/local/frc/java" - -install -m 644 -o 1000 -g 1000 extfiles/*.jar "${ROOTFS_DIR}/usr/local/frc/java/" - -install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/examples/" -install -v -o 1000 -g 1000 extfiles/*-multiCameraServer.zip "${ROOTFS_DIR}/home/pi/examples/" -on_chroot << EOF -cd /home/pi/examples/ -unzip java-multiCameraServer.zip -unzip cpp-multiCameraServer.zip -unzip python-multiCameraServer.zip -mkdir ../zips -mv *.zip ../zips/ -chown -R 1000:1000 . -EOF - -# add jar dependencies to java-multiCameraServer.zip -rm -rf /tmp/java-multiCameraServer -mkdir -p /tmp/java-multiCameraServer -sh -c "cd ${ROOTFS_DIR}/usr/local/frc/java && tar cf - *.jar" | sh -c "cd /tmp/java-multiCameraServer && tar xf -" -sh -c "cd /tmp && zip -r ${ROOTFS_DIR}/home/pi/zips/java-multiCameraServer.zip java-multiCameraServer" -rm -rf /tmp/java-multiCameraServer - -# add header and library dependencies (excluding .debug files) to -# cpp-multiCameraServer.zip -# also update Makefile to use cross-compiler and point to local dependencies -rm -rf /tmp/cpp-multiCameraServer -mkdir -p /tmp/cpp-multiCameraServer -echo "CXX=arm-raspbian9-linux-gnueabihf-g++" > /tmp/cpp-multiCameraServer/Makefile -sed -e 's/\/usr\/local\/frc\///g' ${ROOTFS_DIR}/home/pi/examples/cpp-multiCameraServer/Makefile >> /tmp/cpp-multiCameraServer/Makefile -sh -c "cd ${ROOTFS_DIR}/usr/local/frc && tar cf - lib include" | sh -c "cd /tmp/cpp-multiCameraServer && tar xf -" -sh -c "cd /tmp && zip -r ${ROOTFS_DIR}/home/pi/zips/cpp-multiCameraServer.zip cpp-multiCameraServer --exclude \*.so.\*" -rm -rf /tmp/cpp-multiCameraServer - -on_chroot << EOF -chown -R 1000:1000 /home/pi/zips -ldconfig -EOF - -install -v -d "${ROOTFS_DIR}/service/configServer" - -install -m 755 files/configServer_run "${ROOTFS_DIR}/service/configServer/run" - -install -m 755 extfiles/rpiConfigServer "${ROOTFS_DIR}/usr/local/sbin/configServer" -install -m 644 extfiles/rpiConfigServer.debug "${ROOTFS_DIR}/usr/local/sbin/" - -install -v -d "${ROOTFS_DIR}/service/camera" -install -v -d "${ROOTFS_DIR}/service/camera/log" - -install -m 755 files/camera_run "${ROOTFS_DIR}/service/camera/run" -install -m 755 files/camera_log_run "${ROOTFS_DIR}/service/camera/log/run" - -on_chroot << EOF -cd /service/camera && rm -f supervise && ln -s /tmp/camera-supervise supervise -cd /service/camera/log && rm -f supervise && ln -s /tmp/camera-log-supervise supervise -cd /service/configServer && rm -f supervise && ln -s /tmp/configServer-supervise supervise -cd /etc/service && rm -f camera && ln -s /service/camera . -cd /etc/service && rm -f configServer && ln -s /service/configServer . -EOF - -install -m 755 -o 1000 -g 1000 files/runCamera "${ROOTFS_DIR}/home/pi/" -install -m 755 -o 1000 -g 1000 files/runInteractive "${ROOTFS_DIR}/home/pi/" -install -m 755 -o 1000 -g 1000 files/runService "${ROOTFS_DIR}/home/pi/" - rm -f "${ROOTFS_DIR}/etc/ssh/"ssh_host_*_key* diff --git a/stage3/01-sys-tweaks/00-packages b/stage3/01-sys-tweaks/00-packages new file mode 100644 index 0000000..9fb1800 --- /dev/null +++ b/stage3/01-sys-tweaks/00-packages @@ -0,0 +1,8 @@ +cmake +libpython3.5-minimal +libpython3.5-dev +python3.5-minimal +python3.5-dev +python3-numpy +python3-pybind11 +python3-pip diff --git a/stage3/01-sys-tweaks/00-packages-nr b/stage3/01-sys-tweaks/00-packages-nr new file mode 100644 index 0000000..08d3a2c --- /dev/null +++ b/stage3/01-sys-tweaks/00-packages-nr @@ -0,0 +1,3 @@ +libopenblas-dev liblapacke-dev +libavcodec-dev libavformat-dev libswscale-dev libavresample-dev +libgtk-3-dev diff --git a/stage3/01-sys-tweaks/01-run.sh b/stage3/01-sys-tweaks/01-run.sh new file mode 100755 index 0000000..d9f5548 --- /dev/null +++ b/stage3/01-sys-tweaks/01-run.sh @@ -0,0 +1,361 @@ +#!/bin/bash + +SUB_STAGE_DIR=${PWD} + +# +# Fixup absolute links to relative in /usr/lib and libs in /etc/alternatives +# +pushd "${ROOTFS_DIR}" +find ./usr/lib -lname '/*' | \ + while read l + do + echo ln -sf $(echo $(echo $l | sed 's|/[^/]*|/..|g')$(readlink $l) | sed 's/.....//') $l + done | sh +find ./etc/alternatives -lname '/*.so.*' | \ + while read l + do + echo ln -sf $(echo $(echo $l | sed 's|/[^/]*|/..|g')$(readlink $l) | sed 's/.....//') $l + done | sh +popd + +# +# Add symbolic link for liblapacke.h to /usr/include/openblas (required by +# OpenCV, see OpenCV#9953) +# +ln -sf ../lapacke.h "${ROOTFS_DIR}/usr/include/openblas/lapacke.h" + +# +# Download sources +# +DOWNLOAD_DIR=${STAGE_WORK_DIR}/download +mkdir -p ${DOWNLOAD_DIR} +pushd ${DOWNLOAD_DIR} + +# raspbian toolchain +wget -nc -nv \ + https://github.com/wpilibsuite/raspbian-toolchain/releases/download/v1.3.0/Raspbian9-Linux-Toolchain-6.3.0.tar.gz + +# opencv sources +wget -nc -nv \ + https://github.com/opencv/opencv/archive/3.4.4.tar.gz + +# allwpilib +wget -nc -nv -O allwpilib.tar.gz \ + https://github.com/wpilibsuite/allwpilib/archive/05d6660a6be0d37064a9fab44232b8379884ccab.tar.gz + +# pynetworktables +wget -nc -nv -O pynetworktables.tar.gz \ + https://github.com/robotpy/pynetworktables/archive/8a4288452be26e26dccad32980f46000e8d97928.tar.gz + +# robotpy-cscore +wget -nc -nv -O robotpy-cscore.tar.gz \ + https://github.com/robotpy/robotpy-cscore/archive/2590274ca4e9ef852093152be34bde4e56d027f3.tar.gz + +# pybind11 submodule of robotpy-cscore +wget -nc -nv -O pybind11.tar.gz \ + https://github.com/pybind/pybind11/archive/v2.2.tar.gz + +popd + +# +# Extract and patch sources +# +EXTRACT_DIR=${ROOTFS_DIR}/usr/src +install -v -d ${EXTRACT_DIR} +pushd ${EXTRACT_DIR} + +# opencv +tar xzf "${DOWNLOAD_DIR}/3.4.4.tar.gz" +pushd opencv-3.4.4 +sed -i -e 's/javac sourcepath/javac target="1.8" source="1.8" sourcepath/' modules/java/jar/build.xml.in +# disable extraneous data warnings; these are common with USB cameras +sed -i -e '/JWRN_EXTRANEOUS_DATA/d' 3rdparty/libjpeg/jdmarker.c +sed -i -e '/JWRN_EXTRANEOUS_DATA/d' 3rdparty/libjpeg-turbo/src/jdmarker.c +popd + +# allwpilib +tar xzf "${DOWNLOAD_DIR}/allwpilib.tar.gz" +mv allwpilib-* allwpilib + +# pynetworktables +tar xzf "${DOWNLOAD_DIR}/pynetworktables.tar.gz" +mv pynetworktables-* pynetworktables +echo "__version__ = '2019.0.1'" > pynetworktables/ntcore/version.py + +# robotpy-cscore +tar xzf "${DOWNLOAD_DIR}/robotpy-cscore.tar.gz" +mv robotpy-cscore-* robotpy-cscore +echo "__version__ = '2019.0.3'" > robotpy-cscore/cscore/version.py +pushd robotpy-cscore +rm -rf pybind11 +tar xzf "${DOWNLOAD_DIR}/pybind11.tar.gz" +mv pybind11-* pybind11 +popd + +popd + +# +# Build +# + +# extract raspbian toolchain +pushd ${WORK_DIR} +tar xzf ${DOWNLOAD_DIR}/Raspbian9-Linux-Toolchain-*.tar.gz +export PATH=${WORK_DIR}/raspbian9/bin:${PATH} +popd + +export PKG_CONFIG_DIR= +export PKG_CONFIG_LIBDIR=${ROOTFS_DIR}/usr/lib/arm-linux-gnueabihf/pkgconfig:${ROOTFS_DIR}/usr/lib/pkgconfig:${ROOTFS_DIR}/usr/share/pkgconfig +export PKG_CONFIG_SYSROOT_DIR=${ROOTFS_DIR} + +pushd ${STAGE_WORK_DIR} +# +# Build OpenCV +# +build_opencv () { + rm -rf $1 + mkdir -p $1 + pushd $1 + cmake "${EXTRACT_DIR}/opencv-3.4.4" \ + -DWITH_CUDA=OFF \ + -DWITH_IPP=OFF \ + -DWITH_ITT=OFF \ + -DWITH_OPENCL=OFF \ + -DWITH_FFMPEG=OFF \ + -DWITH_OPENEXR=OFF \ + -DWITH_GSTREAMER=OFF \ + -DWITH_LAPACK=ON \ + -DWITH_GTK=ON \ + -DWITH_1394=OFF \ + -DWITH_JASPER=OFF \ + -DWITH_TIFF=OFF \ + -DBUILD_JPEG=ON \ + -DBUILD_PNG=ON \ + -DBUILD_ZLIB=ON \ + -DBUILD_TESTS=OFF \ + -DPython_ADDITIONAL_VERSIONS=3.5 \ + -DWITH_WEBP=OFF \ + -DBUILD_JAVA=$3 \ + -DBUILD_WITH_STATIC_CRT=OFF \ + -DWITH_PROTOBUF=OFF \ + -DWITH_DIRECTX=OFF \ + -DENABLE_CXX11=ON \ + -DBUILD_SHARED_LIBS=$3 \ + -DCMAKE_BUILD_TYPE=$2 \ + -DCMAKE_DEBUG_POSTFIX=d \ + -DCMAKE_TOOLCHAIN_FILE=${SUB_STAGE_DIR}/files/arm-pi-gnueabihf.toolchain.cmake \ + -DARM_LINUX_SYSROOT=${ROOTFS_DIR} \ + -DCMAKE_MAKE_PROGRAM=make \ + -DENABLE_NEON=ON \ + -DENABLE_VFPV3=ON \ + -DBUILD_opencv_python3=$3 \ + -DPYTHON3_INCLUDE_PATH=${ROOTFS_DIR}/usr/include/python3.5m \ + -DPYTHON3_NUMPY_INCLUDE_DIRS=${ROOTFS_DIR}/usr/include/python3.5m/numpy \ + -DOPENCV_EXTRA_FLAGS_DEBUG=-Og \ + -DCMAKE_MODULE_PATH=${SUB_STAGE_DIR}/files \ + -DCMAKE_INSTALL_PREFIX=/usr/local/frc$4 \ + || exit 1 + make -j3 || exit 1 + make DESTDIR=${ROOTFS_DIR} install || exit 1 + popd +} + +build_opencv build/opencv-build-debug Debug ON "" || exit 1 +build_opencv build/opencv-build RelWithDebugInfo ON "" || exit 1 +build_opencv build/opencv-static RelWithDebugInfo OFF "-static" || exit 1 + +# fix up java install +cp -p ${ROOTFS_DIR}/usr/local/frc/share/OpenCV/java/libopencv_java344*.so "${ROOTFS_DIR}/usr/local/frc/lib/" +mkdir -p "${ROOTFS_DIR}/usr/local/frc/java" +cp -p "${ROOTFS_DIR}/usr/local/frc/share/OpenCV/java/opencv-344.jar" "${ROOTFS_DIR}/usr/local/frc/java/" + +# the opencv build names the python .so with the build platform name +# instead of the target platform, so rename it +pushd "${ROOTFS_DIR}/usr/local/frc/python/cv2/python-3.5" +mv cv2.cpython-35m-*-gnu.so cv2.cpython-35m-arm-linux-gnueabihf.so +popd + +# link python package to dist-packages +ln -sf /usr/local/frc/python/cv2 "${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/cv2" + +# +# Build wpiutil, cscore, ntcore, cameraserver +# always use the release version of opencv jar/jni +# +build_wpilib () { + rm -rf $1 + mkdir -p $1 + pushd $1 + cmake "${EXTRACT_DIR}/allwpilib" \ + -DWITHOUT_ALLWPILIB=OFF \ + -DCMAKE_BUILD_TYPE=$2 \ + -DCMAKE_TOOLCHAIN_FILE=${SUB_STAGE_DIR}/files/arm-pi-gnueabihf.toolchain.cmake \ + -DCMAKE_MODULE_PATH=${SUB_STAGE_DIR}/files \ + -DOPENCV_JAR_FILE=`ls ${ROOTFS_DIR}/usr/local/frc/java/opencv-344.jar` \ + -DOPENCV_JNI_FILE=`ls ${ROOTFS_DIR}/usr/local/frc/lib/libopencv_java344.so` \ + -DOpenCV_DIR=${ROOTFS_DIR}/usr/local/frc/share/OpenCV \ + -DTHREADS_PTHREAD_ARG=-pthread \ + -DCMAKE_INSTALL_PREFIX=/usr/local/frc \ + || exit 1 + make -j3 || exit 1 + popd +} + +build_wpilib build/allwpilib-build-debug Debug || exit 1 +build_wpilib build/allwpilib-build RelWithDebugInfo || exit 1 + +# static (for tools) +build_static_wpilib() { + rm -rf $1 + mkdir -p $1 + pushd $1 + cmake "${EXTRACT_DIR}/allwpilib" \ + -DCMAKE_BUILD_TYPE=RelWithDebugInfo \ + -DCMAKE_TOOLCHAIN_FILE=${SUB_STAGE_DIR}/files/arm-pi-gnueabihf.toolchain.cmake \ + -DCMAKE_MODULE_PATH=${SUB_STAGE_DIR}/files \ + -DOpenCV_DIR=${ROOTFS_DIR}/usr/local/frc/share/OpenCV \ + -DWITHOUT_JAVA=ON \ + -DBUILD_SHARED_LIBS=OFF \ + -DTHREADS_PTHREAD_ARG=-pthread \ + -DCMAKE_INSTALL_PREFIX=/usr/local/frc-static \ + || exit 1 + make -j3 || exit 1 + popd +} +build_static_wpilib build/allwpilib-static || exit 1 + +# manually install, since cmake install is a bit weirdly set up +# built libs and headers +sh -c 'cd build/allwpilib-build/lib && tar cf - lib*' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib && tar xf -" +sh -c 'cd build/allwpilib-build-debug/lib && tar cf - lib*' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/lib && tar xf -" +sh -c 'cd build/allwpilib-static/lib && tar cf - lib*' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc-static/lib && tar xf -" +sh -c 'cd build/allwpilib-build/hal/gen && tar cf - .' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" + +# built jars +sh -c 'cd build/allwpilib-build/jar && tar cf - *.jar' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/java && tar xf -" + +# headers +sh -c "cd ${EXTRACT_DIR}/allwpilib/wpiutil/src/main/native/include && tar cf - uv.h uv wpi" | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" +sh -c "cd ${EXTRACT_DIR}/allwpilib/cscore/src/main/native/include && tar cf - ." | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" +sh -c "cd ${EXTRACT_DIR}/allwpilib/ntcore/src/main/native/include && tar cf - ." | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" +sh -c "cd ${EXTRACT_DIR}/allwpilib/cameraserver/src/main/native/include && tar cf - cameraserver vision" | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" +sh -c "cd ${EXTRACT_DIR}/allwpilib/hal/src/main/native/include && tar cf - ." | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" +sh -c "cd ${EXTRACT_DIR}/allwpilib/wpilibc/src/main/native/include && tar cf - frc" | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/include && tar xf -" + +# executables (use static build to ensure they don't break) +sh -c 'cd build/allwpilib-static/bin && tar cf - cscore_* netconsoleTee*' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/frc/bin && tar xf -" + +# pkgconfig files +install -v -d "${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig" +install -m 644 ${SUB_STAGE_DIR}/files/pkgconfig/* "${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig" +for f in ${SUB_STAGE_DIR}/files/pkgconfig/*.pc; do + install -m 644 $f "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig" + sed -i -e 's,/usr/local/frc,/usr/local/frc-static,' "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig/`basename $f`" +done + +# clean up frc-static +rm -rf "${ROOTFS_DIR}/usr/local/frc-static/bin" +rm -rf "${ROOTFS_DIR}/usr/local/frc-static/include" +ln -sf ../frc/include "${ROOTFS_DIR}/usr/local/frc-static/include" +rm -rf "${ROOTFS_DIR}/usr/local/frc-static/python" + +# fix up frc-static opencv pkgconfig Libs.private +sed -i -e 's, -L/pi-gen[^ ]*,,g' "${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig/opencv.pc" + +popd + +# +# Install pynetworktables +# + +#sh -c "cd ${EXTRACT_DIR}/pynetworktables && tar cf - networktables ntcore" | sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/ && tar xf -" +on_chroot << EOF +pip3 install setuptools +pushd /usr/src/pynetworktables +python3 setup.py build +python3 setup.py install +python3 setup.py clean +popd +EOF + +# +# Build robotpy-cscore +# this build is pretty cpu-intensive, so we don't want to build it in a chroot, +# and setup.py doesn't support cross-builds, so build it manually +# +pushd ${EXTRACT_DIR}/robotpy-cscore + +# install Python sources +sh -c 'tar cf - cscore' | \ + sh -c "cd ${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages && tar xf -" + +# build module +arm-raspbian9-linux-gnueabihf-g++ \ + --sysroot=${ROOTFS_DIR} \ + -g -O -Wall -fvisibility=hidden -shared -fPIC \ + -o "${ROOTFS_DIR}/usr/local/lib/python3.5/dist-packages/cscore/_cscore.cpython-35m-arm-linux-gnueabihf.so" \ + -Ipybind11/include \ + `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --cflags python3 cscore wpiutil` \ + src/_cscore.cpp \ + src/ndarray_converter.cpp \ + `env PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR}:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig pkg-config --libs cscore wpiutil` \ + || exit 1 + +popd + +# +# Finish up +# + +# Split debug info + +split_debug () { + arm-raspbian9-linux-gnueabihf-objcopy --only-keep-debug $1 $1.debug + arm-raspbian9-linux-gnueabihf-strip -g $1 + arm-raspbian9-linux-gnueabihf-objcopy --add-gnu-debuglink=$1.debug $1 +} + +split_debug_so () { + pushd $1 + for lib in *.so + do + split_debug $lib + done + popd +} + +split_debug_exe () { + pushd $1 + for exe in * + do + split_debug $exe + done + popd +} + +split_debug_exe "${ROOTFS_DIR}/usr/local/frc/bin" +split_debug_so "${ROOTFS_DIR}/usr/local/frc/lib" + +# Add /usr/local/frc/lib to ldconfig + +install -m 644 files/ld.so.conf.d/*.conf "${ROOTFS_DIR}/etc/ld.so.conf.d/" + +# Add /usr/local/frc/lib/pkgconfig to pkg-config + +install -m 644 files/profile.d/*.sh "${ROOTFS_DIR}/etc/profile.d/" + +on_chroot << EOF +ldconfig +EOF diff --git a/stage3/01-sys-tweaks/files/FindJNI.cmake b/stage3/01-sys-tweaks/files/FindJNI.cmake new file mode 100644 index 0000000..998035c --- /dev/null +++ b/stage3/01-sys-tweaks/files/FindJNI.cmake @@ -0,0 +1,9 @@ +set(JNI_INCLUDE_DIRS "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include" "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include/linux") +set(JNI_LIBRARIES ) +set(JNI_FOUND YES) +set(JAVA_AWT_LIBRARY ) +set(JAVA_JVM_LIBRARY ) +set(JAVA_INCLUDE_PATH "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include") +set(JAVA_INCLUDE_PATH2 "$ENV{ROOTFS_DIR}/usr/lib/jvm/jdk-11.0.1/include/linux") +set(JAVA_AWT_INCLUDE_PATH ) + diff --git a/deps/arm-pi-gnueabihf.toolchain.cmake b/stage3/01-sys-tweaks/files/arm-pi-gnueabihf.toolchain.cmake similarity index 86% rename from deps/arm-pi-gnueabihf.toolchain.cmake rename to stage3/01-sys-tweaks/files/arm-pi-gnueabihf.toolchain.cmake index 25cc691..8639a4b 100644 --- a/deps/arm-pi-gnueabihf.toolchain.cmake +++ b/stage3/01-sys-tweaks/files/arm-pi-gnueabihf.toolchain.cmake @@ -9,8 +9,9 @@ set(FLOAT_ABI_SUFFIX "hf") set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_PROCESSOR arm) +set(CMAKE_SYSROOT "$ENV{ROOTFS_DIR}") -include("${CMAKE_CURRENT_LIST_DIR}/opencv/platforms/linux/gnu.toolchain.cmake") +include("$ENV{ROOTFS_DIR}/usr/src/opencv-3.4.4/platforms/linux/gnu.toolchain.cmake") if(NOT DEFINED CMAKE_C_COMPILER) find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) @@ -37,6 +38,8 @@ if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) endif() +set(ARM_LINKER_FLAGS "-Wl,-rpath -Wl,$ENV{ROOTFS_DIR}/opt/vc/lib") + if(NOT DEFINED CMAKE_CXX_FLAGS) set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") set(CMAKE_C_FLAGS "" CACHE INTERNAL "") @@ -44,8 +47,8 @@ if(NOT DEFINED CMAKE_CXX_FLAGS) set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-psabi") + set(CMAKE_CXX_FLAGS "-isystem $ENV{ROOTFS_DIR}/usr/include/arm-linux-gnueabihf ${CMAKE_CXX_FLAGS} -Wno-psabi") + set(CMAKE_C_FLAGS "-isystem $ENV{ROOTFS_DIR}/usr/include/arm-linux-gnueabihf ${CMAKE_C_FLAGS} -Wno-psabi") set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} -rdynamic ${CMAKE_SHARED_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} -rdynamic ${CMAKE_MODULE_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} -rdynamic ${CMAKE_EXE_LINKER_FLAGS}") diff --git a/stage2/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf b/stage3/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf similarity index 100% rename from stage2/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf rename to stage3/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf diff --git a/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc b/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc new file mode 100644 index 0000000..3a64971 --- /dev/null +++ b/stage3/01-sys-tweaks/files/pkgconfig/cameraserver.pc @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=/usr/local/frc +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: cameraserver +Description: WPILib Robotics Library CameraServer +Version: 2019.2.1 +Requires: cscore wpiutil +Requires.private: ntcore +Libs: -L${libdir} -lcameraserver +Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc b/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc new file mode 100644 index 0000000..c121d4c --- /dev/null +++ b/stage3/01-sys-tweaks/files/pkgconfig/cscore.pc @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=/usr/local/frc +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: cscore +Description: WPILib Robotics Library CameraServer Core +Version: 2019.2.1 +Requires: wpiutil opencv +Libs: -L${libdir} -lcscore +Libs.private: -lpthread +Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc b/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc new file mode 100644 index 0000000..b532ee3 --- /dev/null +++ b/stage3/01-sys-tweaks/files/pkgconfig/ntcore.pc @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=/usr/local/frc +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: ntcore +Description: WPILib Robotics Library NetworkTables +Version: 2019.2.1 +Requires: wpiutil +Libs: -L${libdir} -lntcore +Libs.private: -lpthread +Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc b/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc new file mode 100644 index 0000000..9276805 --- /dev/null +++ b/stage3/01-sys-tweaks/files/pkgconfig/wpilibc.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr/local/frc +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: wpilibc +Description: WPILib Robotics Library +Version: 2019.2.1 +Requires: cameraserver ntcore cscore wpiutil +Libs: -L${libdir} -lwpilibc -lwpiHal +Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc b/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc new file mode 100644 index 0000000..7bde92f --- /dev/null +++ b/stage3/01-sys-tweaks/files/pkgconfig/wpiutil.pc @@ -0,0 +1,13 @@ +# Package Information for pkg-config + +prefix=/usr/local/frc +exec_prefix=${prefix} +includedir=${prefix}/include +libdir=${exec_prefix}/lib + +Name: wpiutil +Description: WPILib Robotics Library utilities +Version: 2019.2.1 +Libs: -L${libdir} -lwpiutil +Libs.private: -lpthread +Cflags: -I${includedir} diff --git a/stage3/01-sys-tweaks/files/profile.d/frc_pkgconfig.sh b/stage3/01-sys-tweaks/files/profile.d/frc_pkgconfig.sh new file mode 100644 index 0000000..609d244 --- /dev/null +++ b/stage3/01-sys-tweaks/files/profile.d/frc_pkgconfig.sh @@ -0,0 +1 @@ +export PKG_CONFIG_PATH=/usr/local/frc/lib/pkgconfig diff --git a/stage3/prerun.sh b/stage3/prerun.sh new file mode 100755 index 0000000..9acd13c --- /dev/null +++ b/stage3/prerun.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +if [ ! -d "${ROOTFS_DIR}" ]; then + copy_previous +fi diff --git a/stage4/01-sys-tweaks/01-run.sh b/stage4/01-sys-tweaks/01-run.sh new file mode 100755 index 0000000..65174f4 --- /dev/null +++ b/stage4/01-sys-tweaks/01-run.sh @@ -0,0 +1,132 @@ +#!/bin/bash -e + +# enable pi camera +install -m 644 files/picamera.conf "${ROOTFS_DIR}/etc/modules-load.d/" + +install -m 644 files/frc.json "${ROOTFS_DIR}/boot/" + +# +# Install tools sources +# install to both image and work directory (to build) +# +sh -c "cd ${BASE_DIR}/deps/tools && tar cf - ." | \ + sh -c "cd ${ROOTFS_DIR}/usr/src && tar xf -" +sh -c "cd ${BASE_DIR}/deps && tar cf - tools" | \ + sh -c "cd ${STAGE_WORK_DIR} && tar xf -" + +# +# Build tools +# +export PATH=${WORK_DIR}/raspbian9/bin:${PATH} + +pushd "${STAGE_WORK_DIR}/tools" + +export CXXFLAGS="--sysroot=${ROOTFS_DIR} -Wl,-rpath -Wl,${ROOTFS_DIR}/opt/vc/lib" +export PKG_CONFIG_DIR= +export PKG_CONFIG_LIBDIR=${ROOTFS_DIR}/usr/lib/arm-linux-gnueabihf/pkgconfig:${ROOTFS_DIR}/usr/lib/pkgconfig:${ROOTFS_DIR}/usr/share/pkgconfig:${ROOTFS_DIR}/usr/local/frc-static/lib/pkgconfig +export PKG_CONFIG_SYSROOT_DIR=${ROOTFS_DIR} + +# setuidgids +pushd setuidgids +make CC=arm-raspbian9-linux-gnueabihf-gcc +install -m 755 setuidgids "${ROOTFS_DIR}/usr/local/bin/" + +popd + +# multiCameraServer +pushd multiCameraServer +make CXX=arm-raspbian9-linux-gnueabihf-g++ +install -m 755 multiCameraServer "${ROOTFS_DIR}/usr/local/frc/bin/" + +popd + +# configServer +pushd configServer +make CXX=arm-raspbian9-linux-gnueabihf-g++ +install -m 755 configServer "${ROOTFS_DIR}/usr/local/sbin/" + +popd + +popd + +# +# Examples +# install to both image and work directory (to build zips) +# +export PKG_CONFIG_LIBDIR=${ROOTFS_DIR}/usr/lib/arm-linux-gnueabihf/pkgconfig:${ROOTFS_DIR}/usr/lib/pkgconfig:${ROOTFS_DIR}/usr/share/pkgconfig:${ROOTFS_DIR}/usr/local/frc/lib/pkgconfig + +sh -c "cd ${BASE_DIR}/deps && tar cf - examples" | \ + sh -c "cd ${ROOTFS_DIR}/home/pi && tar xf -" +chown -R 1000:1000 "${ROOTFS_DIR}/home/pi/examples" + +rm -rf "${STAGE_WORK_DIR}/examples" +sh -c "cd ${BASE_DIR}/deps && tar cf - examples" | \ + sh -c "cd ${STAGE_WORK_DIR} && tar xf -" + +# build zips +pushd "${STAGE_WORK_DIR}/examples" + +# add jar dependencies to java-multiCameraServer +sh -c "cd ${ROOTFS_DIR}/usr/local/frc/java && tar cf - *.jar" | \ + sh -c "cd java-multiCameraServer && tar xf -" + +# add header and library dependencies (excluding .debug files) to +# cpp-multiCameraServer +sh -c "cd ${ROOTFS_DIR}/usr/local/frc && tar cf - include" | \ + sh -c "cd cpp-multiCameraServer && tar xf -" +mkdir -p cpp-multiCameraServer/lib +LIBS=`pkg-config --libs wpilibc | sed -e "s,-L[^ ]*,,g;s,-l\\([^ ]*\\),${ROOTFS_DIR}/usr/local/frc/lib/lib\\1.so,g"` +for lib in ${LIBS}; do + ln -sf ${lib} cpp-multiCameraServer/lib/ +done + +# update Makefile to use cross-compiler and point to local dependencies +cat > cpp-multiCameraServer/Makefile.new << EOF +CXX=arm-raspbian9-linux-gnueabihf-g++ +DEPS_CFLAGS=`pkg-config --cflags wpilibc | sed -e "s,${ROOTFS_DIR}/usr/local/frc/,,g"` +DEPS_LIBS=`pkg-config --libs wpilibc | sed -e "s,${ROOTFS_DIR}/usr/local/frc/,,g"` +EOF +sed -e '/^DEPS_/d' cpp-multiCameraServer/Makefile >> cpp-multiCameraServer/Makefile.new +mv cpp-multiCameraServer/Makefile.new cpp-multiCameraServer/Makefile + +zip -r java-multiCameraServer.zip java-multiCameraServer +zip -r cpp-multiCameraServer.zip cpp-multiCameraServer +zip -r python-multiCameraServer.zip python-multiCameraServer + +# install zips +install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/zips/" +install -v -o 1000 -g 1000 *.zip "${ROOTFS_DIR}/home/pi/zips/" + +popd + +# +# Set up services +# + +# configServer +install -v -d "${ROOTFS_DIR}/service/configServer" +install -m 755 files/configServer_run "${ROOTFS_DIR}/service/configServer/run" +on_chroot << EOF +cd /service/configServer && rm -f supervise && ln -s /tmp/configServer-supervise supervise +cd /etc/service && rm -f configServer && ln -s /service/configServer . +EOF + +# camera +install -v -d "${ROOTFS_DIR}/service/camera" +install -m 755 files/camera_run "${ROOTFS_DIR}/service/camera/run" +install -v -d "${ROOTFS_DIR}/service/camera/log" +install -m 755 files/camera_log_run "${ROOTFS_DIR}/service/camera/log/run" + +on_chroot << EOF +cd /service/camera && rm -f supervise && ln -s /tmp/camera-supervise supervise +cd /service/camera/log && rm -f supervise && ln -s /tmp/camera-log-supervise supervise +cd /etc/service && rm -f camera && ln -s /service/camera . +EOF + +# +# Set up pi user scripts +# +install -m 755 -o 1000 -g 1000 files/runCamera "${ROOTFS_DIR}/home/pi/" +install -m 755 -o 1000 -g 1000 files/runInteractive "${ROOTFS_DIR}/home/pi/" +install -m 755 -o 1000 -g 1000 files/runService "${ROOTFS_DIR}/home/pi/" + diff --git a/stage2/01-sys-tweaks/files/camera_log_run b/stage4/01-sys-tweaks/files/camera_log_run similarity index 100% rename from stage2/01-sys-tweaks/files/camera_log_run rename to stage4/01-sys-tweaks/files/camera_log_run diff --git a/stage2/01-sys-tweaks/files/camera_run b/stage4/01-sys-tweaks/files/camera_run similarity index 100% rename from stage2/01-sys-tweaks/files/camera_run rename to stage4/01-sys-tweaks/files/camera_run diff --git a/stage2/01-sys-tweaks/files/configServer_run b/stage4/01-sys-tweaks/files/configServer_run similarity index 100% rename from stage2/01-sys-tweaks/files/configServer_run rename to stage4/01-sys-tweaks/files/configServer_run diff --git a/stage2/01-sys-tweaks/files/frc.json b/stage4/01-sys-tweaks/files/frc.json similarity index 100% rename from stage2/01-sys-tweaks/files/frc.json rename to stage4/01-sys-tweaks/files/frc.json diff --git a/stage2/01-sys-tweaks/files/picamera.conf b/stage4/01-sys-tweaks/files/picamera.conf similarity index 100% rename from stage2/01-sys-tweaks/files/picamera.conf rename to stage4/01-sys-tweaks/files/picamera.conf diff --git a/stage2/01-sys-tweaks/files/runCamera b/stage4/01-sys-tweaks/files/runCamera similarity index 100% rename from stage2/01-sys-tweaks/files/runCamera rename to stage4/01-sys-tweaks/files/runCamera diff --git a/stage2/01-sys-tweaks/files/runInteractive b/stage4/01-sys-tweaks/files/runInteractive similarity index 100% rename from stage2/01-sys-tweaks/files/runInteractive rename to stage4/01-sys-tweaks/files/runInteractive diff --git a/stage2/01-sys-tweaks/files/runService b/stage4/01-sys-tweaks/files/runService similarity index 100% rename from stage2/01-sys-tweaks/files/runService rename to stage4/01-sys-tweaks/files/runService diff --git a/stage2/02-net-tweaks/00-packages b/stage4/02-net-tweaks/00-packages similarity index 100% rename from stage2/02-net-tweaks/00-packages rename to stage4/02-net-tweaks/00-packages diff --git a/stage2/02-net-tweaks/01-run.sh b/stage4/02-net-tweaks/01-run.sh similarity index 66% rename from stage2/02-net-tweaks/01-run.sh rename to stage4/02-net-tweaks/01-run.sh index 5f30565..1b61513 100755 --- a/stage2/02-net-tweaks/01-run.sh +++ b/stage4/02-net-tweaks/01-run.sh @@ -6,15 +6,8 @@ install -v -m 644 files/wait.conf "${ROOTFS_DIR}/etc/systemd/system/dhcpcd.serv install -v -d "${ROOTFS_DIR}/etc/wpa_supplicant" install -v -m 600 files/wpa_supplicant.conf "${ROOTFS_DIR}/etc/wpa_supplicant/" -on_chroot << EOF -rm -f /etc/resolv.conf -touch /tmp/dhcpcd.resolv.conf -ln -s /tmp/dhcpcd.resolve.conf /etc/resolv.conf -sed -i -e 's/\/run\//\/var\/run\//' /etc/systemd/system/dhcpcd5.service -mv /etc/dhcpcd.conf /boot/ -chown root:root /boot/dhcpcd.conf -ln -s /boot/dhcpcd.conf /etc/dhcpcd.conf -EOF +# disable wireless +install -m 644 files/raspi-blacklist.conf "${ROOTFS_DIR}/etc/modprobe.d/" if [ -v WPA_COUNTRY ] then diff --git a/stage2/01-sys-tweaks/files/raspi-blacklist.conf b/stage4/02-net-tweaks/files/raspi-blacklist.conf similarity index 100% rename from stage2/01-sys-tweaks/files/raspi-blacklist.conf rename to stage4/02-net-tweaks/files/raspi-blacklist.conf diff --git a/stage2/02-net-tweaks/files/wait.conf b/stage4/02-net-tweaks/files/wait.conf similarity index 100% rename from stage2/02-net-tweaks/files/wait.conf rename to stage4/02-net-tweaks/files/wait.conf diff --git a/stage2/02-net-tweaks/files/wpa_supplicant.conf b/stage4/02-net-tweaks/files/wpa_supplicant.conf similarity index 100% rename from stage2/02-net-tweaks/files/wpa_supplicant.conf rename to stage4/02-net-tweaks/files/wpa_supplicant.conf diff --git a/stage2/EXPORT_IMAGE b/stage4/EXPORT_IMAGE similarity index 80% rename from stage2/EXPORT_IMAGE rename to stage4/EXPORT_IMAGE index aa8f936..362c1e6 100644 --- a/stage2/EXPORT_IMAGE +++ b/stage4/EXPORT_IMAGE @@ -1,4 +1,3 @@ -IMG_SUFFIX="-lite" if [ "${USE_QEMU}" = "1" ]; then export IMG_SUFFIX="${IMG_SUFFIX}-qemu" fi diff --git a/stage4/prerun.sh b/stage4/prerun.sh new file mode 100755 index 0000000..9acd13c --- /dev/null +++ b/stage4/prerun.sh @@ -0,0 +1,5 @@ +#!/bin/bash -e + +if [ ! -d "${ROOTFS_DIR}" ]; then + copy_previous +fi