Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Dockerfile that builds a uStreamer Debian package from source #3

Closed
jdeanwallace opened this issue Apr 11, 2023 · 0 comments · Fixed by #6
Closed

Create a Dockerfile that builds a uStreamer Debian package from source #3

jdeanwallace opened this issue Apr 11, 2023 · 0 comments · Fixed by #6
Assignees
Labels

Comments

@jdeanwallace
Copy link
Contributor

jdeanwallace commented Apr 11, 2023

Related tiny-pilot/tinypilot#1353

Requirements

  • Build the Debian package in CI

    • Use Docker's --platform parameter to target both AMD64 and ARMv7 architectures
    • Save the package file as an CI artifact which we can later manually attach as a GitHub release asset
      • This will only happen for a single release until we consolidate ansible-role-ustreamer with the TinyPilot repo, in milestone 2
  • Use debhelper to automatically build the uStreamer binary via its Makefile, similar to the (official?) Debian package

  • Always build uStreamer using the WITH_JANUS make flag

    • This requires adding janus as a Debian package dependency
    • This requires adding janus-dev as a build dependency and patching Janus C header files to allow uStreamer to be built successfully
    • Remember to install the resulting uStreamer Janus plugin shared library file (i.e., libjanus_ustreamer.so)
@jdeanwallace jdeanwallace self-assigned this May 8, 2023
jdeanwallace added a commit that referenced this issue May 11, 2023
Related #3

To eventually build a uStreamer Debian package in CI, we first need
basic CI config.

This PR copies the following scripts from the TinyPilot Community repo
and executes them as CircleCI jobs:
*
[`dev-scripts/check-bash`](https://github.com/tiny-pilot/tinypilot/blob/d4273b9fe6f1faa7539467ba4d4054f50b99eb8f/dev-scripts/check-bash)
*
[`dev-scripts/check-trailing-newline`](https://github.com/tiny-pilot/tinypilot/blob/d4273b9fe6f1faa7539467ba4d4054f50b99eb8f/dev-scripts/check-trailing-newline)
*
[`dev-scripts/check-trailing-whitespace`](https://github.com/tiny-pilot/tinypilot/blob/d4273b9fe6f1faa7539467ba4d4054f50b99eb8f/dev-scripts/check-trailing-whitespace)

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/ustreamer-debian/5"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
jdeanwallace added a commit that referenced this issue May 17, 2023
Related #3

This PR ports overs scripts from other TinyPilot repos, with minimal
modification:
*
[`.gitignore`](44a1af0)
based on version from [TinyPilot
Community](https://github.com/tiny-pilot/tinypilot/blob/014300e0c8aade142d99b6f2bd2a20e7f231265a/.gitignore)
*
[`dev-scripts/build-debian-pkg`](3d27316)
based on version from [TinyPilot draft PR "Set up TinyPilot virtual
environment from Debian
package"](https://github.com/tiny-pilot/tinypilot/blob/e09e2dc216ed0dc3224ea619b819e9f99f0f7b02/dev-scripts/build-debian-pkg)
*
[`dev-scripts/enable-multiarch-docker`](7f0840f)
based on version from [TinyPilot draft PR "Set up TinyPilot virtual
environment from Debian
package"](https://github.com/tiny-pilot/tinypilot/blob/e09e2dc216ed0dc3224ea619b819e9f99f0f7b02/dev-scripts/enable-multiarch-docker)

These scripts will be used in subsequent PRs to help build our uStreamer
Debian package.

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/ustreamer-debian/7"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
jdeanwallace added a commit that referenced this issue May 24, 2023
Resolves #3

This PR builds a uStreamer Debian package (with Janus plugin) in CI. The
reason why we couldn't just use the [official(?) uStreamer Debian
package](https://salsa.debian.org/reedy/ustreamer/) is because it
doesn't compile the Janus plugin (which we need for WebRTC support).

Now we can avoid building uStreamer from source every time TinyPilot is
installed or updated.

You can test the uStreamer Debian package on a device via this [scratch
TinyPilot Pro build
bundle](https://app.circleci.com/pipelines/github/tiny-pilot/tinypilot-pro/2801/workflows/ba68bf47-f01c-4240-a008-6456f956dca4/jobs/20659/artifacts).

Notes:

* We compile the uStreamer Debian package for both [`armhf` and `amd64`
architectures](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R33-R38)
because the `amd64` version will be used when testing the uStreamer
Ansible role in CI (using molecule) and the `armhf` version will be used
when installing TinyPilot on a device.

* FYI, compiling for multiple architectures produces Debian packages in
the following [directory
structure](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R46-R49):
  * `/build/linux_arm_v7/*.deb`
  * `/build/linux_amd64/*.deb`
  
As opposed to just `/build/*.deb` when compiling for a single
architecture.

* Most of the [lintian
code](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R52-R80)
is copy/pasted from [TinyPilot Community
repo](https://github.com/tiny-pilot/tinypilot/blob/b984ab93a58533220ad6358831ce8e405810db8f/.circleci/continue_config.yml#L97-L122),
besides the [loop to check multiple Debian
packages](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-78a8a19706dbd2a4425dd72bdab0502ed7a2cef16365ab7030a5a0588927bf47R71-R80).

* Seeing as [uStreamer makes use of a simple `v${MAJOR}.${MINOR}`
versioning schema](https://github.com/tiny-pilot/ustreamer/tags), I used
that (without the `v` prefix) as the Debian package version with an
added a timestamp revision number to allow for the Debian package to be
updated even when the uStreamer version has stayed the same. The
resulting uStreamer Debian package versioning schema being
[`MAJOR.MINOR-YYYYMMDDhhmmss`](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557R63)

* Seeing as Docker doesn't support dynamic `WORKDIR` values based on a
command's output, I stole these
([1](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557R46-R70),
[2](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-dd2c0eb6ea5cfc6c4bd4eac30934e2d5746747af48fef6da689e85b752f39557R140-R146))
clever workarounds from Michael's
[PR](https://github.com/tiny-pilot/tinypilot/pull/1352/files#diff-d3aed37eb2a4156ced425c7bcab79741d1234d58d182d91099b780c3c3136ce4R31-R53).

* The [copyright notice I've used
here](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-eb1289be1c2cdfc905cecdba0c6810aa4d987d52e34f9dee681c1ff9cd69c34fR1-R2)
was given to me my Michael via email

* When we built uStreamer on the device, we technically [only ever ran
`make`](https://github.com/tiny-pilot/ansible-role-ustreamer/blob/b1017f8f4436071b5d8dcf812ee351fc846e1fa6/tasks/main.yml#L153-L161)
and never `make install`. This Debian package builds using `make && make
install` which results in the binary being moved to `bin/ustreamer`. I
thought running the `make install` is a good thing, so I just [added a
symlink (`/opt/ustreamer/ustreamer ->
bin/ustreamer`)](https://github.com/tiny-pilot/ustreamer-debian/pull/6/files#diff-fe915a3611d3df024aa33709affc37ff7a049adc629d69f2f0fe0dd063ad155fR1-R2)
to maintain TinyPilot's path to uStreamer.

Helpful resources on creating Debian packages:
* https://vincent.bernat.ch/en/blog/2019-pragmatic-debian-packaging
* https://github.com/vincentbernat/pragmatic-debian-packages/
* https://salsa.debian.org/reedy/ustreamer/
* https://github.com/tiny-pilot/tinypilot/pull/1352/files

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/ustreamer-debian/6"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
This was referenced May 25, 2023
jdeanwallace added a commit that referenced this issue May 25, 2023
Related #3

This PR fixes a bug in our uStreamer Debian package where the
pre-install script wasn't running because it was incorrectly named. Was
`ustreamer.preinstall` should have been `ustreamer.preinst`
([docs](https://manpages.debian.org/testing/debhelper/dh_installdeb.1.en.html)).

This means we'll need to cut another `ustreamer-debian` release 🤦‍♂️ 

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/ustreamer-debian/8"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>
jdeanwallace added a commit that referenced this issue May 25, 2023
Related #3
Dependent on #8

After installing our uStreamer Debian package, the man-pages didn't
work:
```bash
$ man ustreamer
No manual entry for ustreamer
```

This is because the uStreamer's man-pages were being copied to
`/opt/ustreamer` instead of `/usr/share/man`.

I've tested this on device.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant