diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 559a5dc..c6c6c67 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -1,13 +1,15 @@ name: Build Image -on: [push, pull_request] +on: [push, pull_request, workflow_dispatch] jobs: build: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Install Dependencies - run: sudo apt-get update && sudo apt install coreutils p7zip-full qemu-user-static + run: | + sudo apt-get update + sudo apt-get install coreutils p7zip-full qemu-user-static - name: Checkout CustomPiOS uses: actions/checkout@v2 @@ -28,22 +30,40 @@ jobs: node-version: 12.x - name: Build React frontend - run: pushd repository/naturewatch_camera_server/static/client && npm i -y && npm run build && popd + run: | + pushd repository/naturewatch_camera_server/static/client + npm i -y + npm run build + popd - name: Download Raspbian Image - run: cd repository/os/image && wget -q -c --trust-server-names 'https://downloads.raspberrypi.org/raspbian_lite_latest' + run: | + cd repository/os/image + wget -q -c --trust-server-names 'https://downloads.raspberrypi.org/raspios_lite_armhf_latest' - name: Update CustomPiOS Paths - run: cd repository/os && ../../CustomPiOS/src/update-custompios-paths + run: | + cd repository/os + ../../CustomPiOS/src/update-custompios-paths - name: Copy NaturewatchCameraServer to CustomPiOS directory - run: cp -r repository /tmp/NaturewatchCameraServer && rm -rf /tmp/NaturewatchCameraServer/os && rm -rf /tmp/NaturewatchCameraServer/naturewatch_camera_server/static/client/node_modules && mv /tmp/NaturewatchCameraServer repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer && ls repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer + run: | + cp -r repository /tmp/NaturewatchCameraServer + rm -rf /tmp/NaturewatchCameraServer/os + rm -rf /tmp/NaturewatchCameraServer/naturewatch_camera_server/static/client/node_modules + mv /tmp/NaturewatchCameraServer repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer + ls repository/os/modules/naturewatchcamera/filesystem/home/pi/NaturewatchCameraServer - name: Build Image - run: export BASE_IMAGE_ENLARGEROOT=2000 && export AUTO_HOTSPOT_NAME=MyNaturewatch && export AUTO_HOTSPOT_PASSWORD=badgersandfoxes && sudo modprobe loop && cd repository/os && sudo bash -x ./build_dist + run: | + export BASE_IMAGE_ENLARGEROOT=2000 + export AUTO_HOTSPOT_NAME=MyNaturewatch + export AUTO_HOTSPOT_PASSWORD=badgersandfoxes + sudo modprobe loop && cd repository/os + sudo bash -x ./build_dist - name: Copy Output - run: cp ${{ github.workspace }}/repository/os/workspace/*-raspbian-buster-lite.img mynaturewatch-camera.img + run: cp ${{ github.workspace }}/repository/os/workspace/*lite.img mynaturewatch-camera.img - name: Zip Output run: gzip mynaturewatch-camera.img diff --git a/naturewatch_camera_server/__main__.py b/naturewatch_camera_server/__main__.py index 8a0accc..85818d5 100755 --- a/naturewatch_camera_server/__main__.py +++ b/naturewatch_camera_server/__main__.py @@ -13,7 +13,7 @@ class CameraNotFoundException(Exception): def is_camera_enabled(): # inspired by https://stackoverflow.com/questions/58250817/raspberry-pi-camera-module-check-if-connected#comment102874971_58250817 - vcgencmd_result = subprocess.run(['/opt/vc/bin/vcgencmd', 'get_camera'], stdout=subprocess.PIPE) + vcgencmd_result = subprocess.run(['vcgencmd', 'get_camera'], stdout=subprocess.PIPE) result_text = vcgencmd_result.stdout.decode('utf-8').strip() properties = dict(pair.split('=') for pair in result_text.split(' ')) return properties['supported'] == '1' diff --git a/os/modules/naturewatchcamera/start_chroot_script b/os/modules/naturewatchcamera/start_chroot_script index 6983749..8f46513 100644 --- a/os/modules/naturewatchcamera/start_chroot_script +++ b/os/modules/naturewatchcamera/start_chroot_script @@ -35,17 +35,16 @@ echo "$NATUREWATCHCAMERA_VAR" libxvidcore-dev libx264-dev libgtk2.0-dev libgtk-3-dev \ libatlas-base-dev libblas-dev libeigen{2,3}-dev liblapack-dev \ gfortran \ - python2.7-dev python3-dev python-pip python3-pip python python3 - apt-get install -y libilmbase23 - apt-get install -y libopenexr-dev - apt-get install -y libgstreamer1.0-dev - apt install -y gpac - pip2 install -U pip - pip3 install -U pip - pip2 install numpy - pip3 install numpy + python3-dev python3-pip python python3 + apt-get install -y libilmbase25 libopenexr-dev libgstreamer1.0-dev + apt-get install -y gpac + +echo "Enabling legacy camera support for Pi Zero W 2" +raspi-config nonint do_camera 1 +echo "start_x=1" >> /boot/config.txt + echo "Installing OpenCV" -pip3 install opencv-python-headless +pip3 install -U pip numpy opencv-python-headless pushd /home/pi pushd NaturewatchCameraServer