Skip to content

Instantly share code, notes, and snippets.

@greyltc
Last active January 31, 2024 11:22
Show Gist options
  • Save greyltc/13111f281aeb094337e6aac22baf0e6a to your computer and use it in GitHub Desktop.
Save greyltc/13111f281aeb094337e6aac22baf0e6a to your computer and use it in GitHub Desktop.
rebuilds all the rpi5 camera stuff from git
#!/usr/bin/env bash
# curl https://gist.githubusercontent.com/greyltc/13111f281aeb094337e6aac22baf0e6a/raw | bash
set -o pipefail
set -o errexit
set -o nounset
# tested working on vanilla Raspberry Pi OS (bookworm, 64bit) on my rpi5 on 29 jan 2024
# camera software usage docs: https://www.raspberrypi.com/documentation/computers/camera_software.html
sudo sed 's,^#deb-src http://archive.raspberrypi.com,deb-src http://archive.raspberrypi.com,' -i /etc/apt/sources.list.d/raspi.list
sudo apt-get update
sudo apt-get upgrade -y
sudo rpi-update
# reboot here via `sudo reboot` to ensure any above changes are applied
cd
rm -rf {"${HOME}/git/rpicamsrc",/tmp/rpicambuild}
mkdir -p {"${HOME}/git/rpicamsrc",/tmp/rpicambuild}
pushd "${HOME}/git/rpicamsrc"
git clone https://github.com/raspberrypi/libpisp.git
apt source --download-only libpisp
sudo apt-get install -y meson pkgconf libboost-log-dev libboost-thread-dev nlohmann-json3-dev
pushd libpisp
git fetch --tags
tar -xvf ../libpisp*.debian.tar.xz
#don't build -dev
#sed '/^Package: libpisp-dev$/,/^$/d' -i debian/control
#rm debian/libpisp-dev*
echo "" >> debian/rules
echo "override_dh_missing:" >> debian/rules
echo " dh_missing --list-missing" >> debian/rules
git describe --long --tags --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' > .tarball-version
git add .
git -c user.name='A U Thor' -c user.email=author@example.com commit --message="add debian"
meson setup build
meson dist --no-tests --include-subprojects -C build
cp build/meson-dist/*.tar.xz /tmp/rpicambuild/.
cp build/meson-dist/*.tar.xz.sha256sum /tmp/rpicambuild/.
popd
build_then_install_debs
git clone https://github.com/RPi-Distro/libcamera.git libcamera-debian
git clone https://github.com/raspberrypi/libcamera.git
sudo apt-get install -y meson pkgconf cmake libgtest-dev libyaml-dev python3 python3-dev pybind11-dev python3-jinja2 python3-ply python3-yaml
#git clone https://git.libcamera.org/libcamera/libcamera.git
pushd libcamera
git fetch --tags
# git checkout next
# git checkout v0.1.0+rpt20231122
# git checkout v0.2.0
# sync pisp
rm subprojects/libpisp.wrap
cp -a "${HOME}/git/rpicamsrc/libpisp" subprojects/.
#sed 's/1.0.1/1.0.3/' -i subprojects/libpisp.wrap
cp -a "${HOME}/git/rpicamsrc/libcamera-debian/debian" .
# no test
sed 's/test=true/test=false/' -i debian/rules
#don't build -dev
#sed '/^Package: libcamera-dev$/,/^$/d' -i debian/control
#rm debian/libcamera-dev*
# don't build -doc
#sed '/^Package: libcamera-doc$/,/^$/d' -i debian/control
#rm debian/libcamera-doc*
sed '/debian\/tmp\/usr\/share\/doc/d' -i debian/rules
sed "s|\$(empty)|-D documentation=enabled -D ipas=\"['ipu3', 'rkisp1', 'rpi/pisp', 'rpi/vc4', 'vimc']\"|" -i debian/rules
echo "" >> debian/rules
echo "override_dh_missing:" >> debian/rules
echo " dh_missing --list-missing" >> debian/rules
git add .
git -c user.name='A U Thor' -c user.email=author@example.com commit --message="add debian"
meson setup build \
-D pycamera=enabled \
-D v4l2=true \
-D test=false \
-D documentation=enabled \
-D gstreamer=enabled \
-D ipas="['ipu3', 'rkisp1', 'rpi/pisp', 'rpi/vc4', 'vimc']"
meson dist --no-tests --include-subprojects -C build
cp build/meson-dist/*.tar.xz /tmp/rpicambuild/.
cp build/meson-dist/*.tar.xz.sha256sum /tmp/rpicambuild/.
popd
build_then_install_debs
git clone https://github.com/raspberrypi/rpicam-apps.git
apt source --download-only rpicam-apps
sudo apt-get install -y ninja-build pkgconf libboost-program-options-dev libexif-dev libjpeg-dev libpng-dev libtiff-dev
pushd rpicam-apps
git fetch --tags
tar -xvf ../rpicam-apps*.debian.tar.xz
# don't build lite
sed '/^Package: rpicam-apps-lite$/,/^$/d' -i debian/control
sed '/^Package: libcamera-apps-lite$/,/^$/d' -i debian/control
sed '/build_lite/d' -i debian/rules
echo "" >> debian/rules
echo "override_dh_missing:" >> debian/rules
echo " dh_missing --list-missing" >> debian/rules
git describe --long --tags --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' > .tarball-version
git add .
git -c user.name='A U Thor' -c user.email=author@example.com commit --message="add debian"
meson setup build
meson dist --no-tests --include-subprojects -C build
cp build/meson-dist/*.tar.xz /tmp/rpicambuild/.
cp build/meson-dist/*.tar.xz.sha256sum /tmp/rpicambuild/.
popd
build_then_install_debs
build_then_install_debs(){
pushd /tmp/rpicambuild
sudo apt-get install -y git build-essential devscripts fakeroot
for f in *.tar.xz
do
echo "Operating on ${f}"
tar -xvf "${f}"
pushd $(basename -s .tar.xz ${f})
yes | debchange --force-bad-version --newversion=$(cat .tarball-version) "$(cat .tarball-version) local build"
sudo DEBIAN_FRONTEND=noninteractive sudo apt build-dep -yq .
DEB_BUILD_OPTIONS="nodoc nocheck noautodbgsym" debuild --no-lintian --build-profiles=nocheck,nodoc --build=binary --root-command=fakeroot --unsigned-source --unsigned-changes
popd
echo "Operations on ${f} are done"
mv "${f}" "${f}".done
done
sudo dpkg -i *.deb
popd
}
apt source gst-rtsp-server1.0
cd gst-rtsp-server1.0-1.22.0/
sudo DEBIAN_FRONTEND=noninteractive sudo apt build-dep -yq .
DEB_BUILD_OPTIONS="nodoc nocheck noautodbgsym" debuild --no-lintian --build-profiles=nocheck,nodoc --build=binary --root-command=fakeroot --unsigned-source --unsigned-changes
find . -name 'test-launch' -exec sudo cp {} /usr/bin/gst-rtsp-server-test-launch \;
# rpicam-vid --timeout=0 --mode=2028:1520 --width=2028 --height=1520 --framerate=40 --libav-format=h264 --intra 30 --profile=high --level=4.2 --hdr --inline -o - | gst-rtsp-server-test-launch --port=8554 "( fdsrc ! h264parse ! rtph264pay name=pay0 pt=96 )"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment