diff --git a/copyextfiles.sh b/copyextfiles.sh new file mode 100755 index 0000000..5b22772 --- /dev/null +++ b/copyextfiles.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +mkdir -p stage2/01-sys-tweaks/extfiles + +# +# openjdk +# +cp ../raspbian-openjdk/jdk_11.0.1-strip.tar.gz stage2/01-sys-tweaks/extfiles/ + +# +# thirdparty-opencv +# + +sh -c 'cd ../thirdparty-opencv/buildShared/linux-raspbian/lib && tar czf - libopencv*' > stage2/01-sys-tweaks/extfiles/libopencv.tar.gz + +# the opencv build names the python .so with the build platform name instead +# of the target platform, so rename it +cp ../thirdparty-opencv/buildShared/linux-raspbian/lib/python3/cv2.*.so stage2/01-sys-tweaks/extfiles/cv2.cpython-35m-arm-linux-gnueabihf.so + +# +# allwpilib +# + +cp \ + ../allwpilib/wpiutil/build/libs/wpiutil/shared/raspbian/release/libwpiutil.so* \ + ../allwpilib/wpiutil/build/libs/wpiutil/shared/raspbian/debug/libwpiutild.so* \ + ../allwpilib/wpiutil/build/libs/wpiutil.jar \ + ../allwpilib/cscore/build/libs/cscore/shared/raspbian/release/libcscore.so* \ + ../allwpilib/cscore/build/libs/cscore/shared/raspbian/debug/libcscored.so* \ + ../allwpilib/cscore/build/libs/cscoreJNIShared/shared/raspbian/release/libcscorejni.so* \ + ../allwpilib/cscore/build/libs/cscore.jar \ + ../allwpilib/ntcore/build/libs/ntcore/shared/raspbian/release/libntcore.so* \ + ../allwpilib/ntcore/build/libs/ntcore/shared/raspbian/debug/libntcored.so* \ + ../allwpilib/ntcore/build/libs/ntcoreJNIShared/shared/raspbian/release/libntcorejni.so* \ + ../allwpilib/ntcore/build/libs/ntcore.jar \ + ../allwpilib/cameraserver/build/libs/cameraserver/shared/raspbian/release/libcameraserver.so* \ + ../allwpilib/cameraserver/build/libs/cameraserver/shared/raspbian/debug/libcameraserverd.so* \ + ../allwpilib/cameraserver/build/libs/cameraserver.jar \ + stage2/01-sys-tweaks/extfiles/ + +sh -c 'cd ../allwpilib/wpiutil/src/main/native/include && tar czf - uv.h uv wpi' > stage2/01-sys-tweaks/extfiles/wpiutil-include.tar.gz +sh -c 'cd ../allwpilib/cscore/src/main/native/include && tar czf - .' > stage2/01-sys-tweaks/extfiles/cscore-include.tar.gz +sh -c 'cd ../allwpilib/ntcore/src/main/native/include && tar czf - .' > stage2/01-sys-tweaks/extfiles/ntcore-include.tar.gz +sh -c 'cd ../allwpilib/cameraserver/src/main/native/include && tar czf - cameraserver vision' > stage2/01-sys-tweaks/extfiles/cameraserver-include.tar.gz + +cp \ + ../allwpilib/cameraserver/build/exe/multiCameraServer/raspbian/multiCameraServer \ + ../allwpilib/wpiutil/build/exe/netconsoleServer/raspbian/netconsoleServer \ + ../allwpilib/wpiutil/build/exe/rpiConfigServer/raspbian/rpiConfigServer \ + stage2/01-sys-tweaks/extfiles/ diff --git a/stage2/01-sys-tweaks/00-packages b/stage2/01-sys-tweaks/00-packages index be29212..0a82ab6 100644 --- a/stage2/01-sys-tweaks/00-packages +++ b/stage2/01-sys-tweaks/00-packages @@ -1,11 +1,13 @@ java-common ntp daemontools daemontools-run +build-essential busybox-syslogd ssh less fbset sudo psmisc strace ed ncdu crda console-setup keyboard-configuration debconf-utils parted unzip -python gdbserver pkg-config -python-rpi.gpio v4l-utils +python python3 gdbserver pkg-config +python3-numpy +python-rpi.gpio python3-rpi.gpio v4l-utils avahi-daemon lua5.1 luajit diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index 1c56345..201d397 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -16,9 +16,9 @@ install -m 644 files/raspi-blacklist.conf "${ROOTFS_DIR}/etc/modprobe.d/" install -m 644 files/frc.json "${ROOTFS_DIR}/boot/" -install -m 755 -o 1000 -g 1000 files/multiCameraServer "${ROOTFS_DIR}/home/pi/" +install -m 755 -o 1000 -g 1000 extfiles/multiCameraServer "${ROOTFS_DIR}/home/pi/" -cat files/jdk_11.0.1-strip.tar.gz | sh -c "mkdir -p ${ROOTFS_DIR}/usr/lib/jvm && cd ${ROOTFS_DIR}/usr/lib/jvm/ && tar xzf - --transform=s/^jdk/jdk-11.0.1/" +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/" cp files/jdk-11.0.1.jinfo "${ROOTFS_DIR}/usr/lib/jvm/.jdk-11.0.1.jinfo" on_chroot << EOF @@ -33,7 +33,7 @@ ln -s /tmp /var/lib/dhcp ln -s /run /var/run ln -s /tmp /var/spool ln -s /tmp /var/lock -sed -i -e 's/d \/var\/spool/#d \/var\/spool/' /usr/lib/tmpfiles/var.conf +sed -i -e 's/d \/var\/spool/#d \/var\/spool/' /usr/lib/tmpfiles.d/var.conf sed -i -e 's/\/var\/lib\/ntp/\/var\/tmp/' /etc/ntp.conf EOF @@ -42,8 +42,6 @@ cat files/bash.bashrc >> "${ROOTFS_DIR}/etc/bash.bashrc" cat files/bash.logout >> "${ROOTFS_DIR}/etc/bash.bash_logout" on_chroot << EOF -systemctl disable hwclock.sh -systemctl disable rpcbind systemctl enable ssh systemctl enable regenerate_ssh_host_keys EOF @@ -78,6 +76,41 @@ 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/lib" + +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/" + +install -m 755 extfiles/libwpiutil*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" +install -m 755 extfiles/libcscore*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" +install -m 755 extfiles/libntcore*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" +install -m 755 extfiles/libcameraserver*.so* "${ROOTFS_DIR}/usr/local/frc/lib/" + +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 -" + +install -v -o 1000 -g 1000 -d "${ROOTFS_DIR}/home/pi/java-example/" +install -m 644 -o 1000 -g 1000 extfiles/*.jar "${ROOTFS_DIR}/home/pi/java-example/" + +on_chroot << EOF +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 755 extfiles/netconsoleServer "${ROOTFS_DIR}/usr/local/bin/" + install -v -d "${ROOTFS_DIR}/service/camera" install -m 755 files/camera_run "${ROOTFS_DIR}/service/camera/run" @@ -85,6 +118,7 @@ install -m 755 files/camera_run "${ROOTFS_DIR}/service/camera/run" on_chroot << EOF cd /service/camera && rm -f supervise && ln -s /tmp/camera-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/" diff --git a/stage2/01-sys-tweaks/files/camera_run b/stage2/01-sys-tweaks/files/camera_run index fdebe3d..555640d 100755 --- a/stage2/01-sys-tweaks/files/camera_run +++ b/stage2/01-sys-tweaks/files/camera_run @@ -1,4 +1,4 @@ #!/bin/sh sleep 1 cd /home/pi -exec ./runCamera +exec pgrphack setuidgid pi /usr/local/bin/netconsoleServer -u ./runCamera diff --git a/stage2/01-sys-tweaks/files/configServer_run b/stage2/01-sys-tweaks/files/configServer_run new file mode 100755 index 0000000..d3c65b1 --- /dev/null +++ b/stage2/01-sys-tweaks/files/configServer_run @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/local/sbin/configServer diff --git a/stage2/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf b/stage2/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf new file mode 100644 index 0000000..3d6f5a6 --- /dev/null +++ b/stage2/01-sys-tweaks/files/ld.so.conf.d/frc_libs.conf @@ -0,0 +1,2 @@ +/usr/local/frc/lib +/usr/local/frc/third-party/lib diff --git a/stage2/01-sys-tweaks/files/ld.so.conf.d/java_libs.conf b/stage2/01-sys-tweaks/files/ld.so.conf.d/java_libs.conf new file mode 100644 index 0000000..5486d10 --- /dev/null +++ b/stage2/01-sys-tweaks/files/ld.so.conf.d/java_libs.conf @@ -0,0 +1,3 @@ +/usr/lib/jvm/jdk-11.0.1/lib/jli +/usr/lib/jvm/jdk-11.0.1/lib/minimal +/usr/lib/jvm/jdk-11.0.1/lib diff --git a/stage2/01-sys-tweaks/files/runCamera b/stage2/01-sys-tweaks/files/runCamera index bf6d308..236e79d 100755 --- a/stage2/01-sys-tweaks/files/runCamera +++ b/stage2/01-sys-tweaks/files/runCamera @@ -1,3 +1,4 @@ #!/bin/sh +echo "Waiting 5 seconds..." sleep 5 -./multiCameraServer +exec ./multiCameraServer diff --git a/stage2/01-sys-tweaks/files/runInteractive b/stage2/01-sys-tweaks/files/runInteractive index 561a412..e9e335f 100755 --- a/stage2/01-sys-tweaks/files/runInteractive +++ b/stage2/01-sys-tweaks/files/runInteractive @@ -1,10 +1,4 @@ #!/bin/bash -SVCPID=`ps ax | grep runCamera | grep -v grep | cut -c -6 | sed -e 's/ *//g'` sudo svc -d /service/camera -if [[ ! -z $SVCPID ]]; then - sudo kill $SVCPID - sleep 1 - sudo kill -9 $SVCPID - sleep 1 -fi +sleep 1 exec ./runCamera diff --git a/stage2/02-net-tweaks/01-run.sh b/stage2/02-net-tweaks/01-run.sh index 8952c67..480f85a 100755 --- a/stage2/02-net-tweaks/01-run.sh +++ b/stage2/02-net-tweaks/01-run.sh @@ -10,7 +10,7 @@ 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.control +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