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

Using reproducible wheels into our securedrop-app-code Debian package on Focal #5901

Open
5 tasks
kushaldas opened this issue Apr 15, 2021 · 9 comments
Open
5 tasks
Assignees

Comments

@kushaldas
Copy link
Contributor

Description

Currently we are using Python dependencies installed from source during the Debian package build. As we are
retiring the Xenial builds, we should move to using our own reproducible wheels in Focal packaging
using the scripts from the securedrop-debian-packaing repository.

Works need to done

  • Xenial package builds should be removed.
  • Create a requirements.txt file for the app code (should be copy of securedrop/requirements/python3/securedrop-app-code-requirements.txt in the same directory
  • Add all bootstapping wheels for Focal that is Python 3.8 in the securedrop-debian-packaging repository.
  • Build all the wheels for securedrop-app-code and add them to securedrop-debian-packaging repository.
  • Update the ansible role and the rules file to use our wheels to build the Debian package.

Note: For Focal we can use the dh-virtualenv package from https://launchpad.net/~jyrki-pulliainen/+archive/ubuntu/dh-virtualenv directly.

@eloquence
Copy link
Member

During this sprint, @kushaldas will investigate this build workflow locally, to begin scoping work for the next sprint.

@kushaldas
Copy link
Contributor Author

kushaldas commented Jun 23, 2021

Few open questions/points:

  • If we keep all the wheels in the securedrop-debian-packaging repository, we have to clone it during the package build process. This may slow down the whole package building effort. If we mount it on the build container from the local host system, then things will be much faster and the human will be in charge to keep the repo updated from git. Or else the package build will fail.
  • If we put all the wheels for the securedrop-app-code in the same localwheels directory, then our CI will break as a few wheels are dependent on the Python version/ OS. Should we use a separate directory for Focal wheels?
  • Should we add a separate job in CI for Focal based wheel building? I think yes.

Update:

We should mark the wheels are all related files (sha256sums and signatures) properly for each distro. For example, bootstrap-focal, bootstrap-buster and so on. Otherwise the code updates to continue supporting the current names (without distro specific directories and filenames) create too much extra maintenance burden. I can not understand my own updates after I almost managed to support the scenarios.

This will also enable us in future to add a new distro very easily. For example when Debian Bullseye comes out in Qubes.

@kushaldas
Copy link
Contributor Author

kushaldas commented Jun 24, 2021

One good point of having all wheel from a particular OS into separate directory is that we can also separate out the tests in CI machines running the same OS can handle only the wheels from that particular directory. I will update with my findings more later in the evening.

Also the bootstrapping requirements will be different for various OS/projects. For all the workstation projects, it is one set, and for the securedrop-app-code it is a slightly different set.

@kushaldas
Copy link
Contributor Author

This branch https://github.com/freedomofpress/securedrop-debian-packaging/tree/wheels_on_focal needs to be rebased to latest securedrop-debian-packaging repo. And then rebuild the dependencies for app-code.

@eloquence
Copy link
Member

^ That is the extent of our commitment for the current sprint; we're aiming to continue work on this leading up to the SecureDrop 2.1.0 release.

@legoktm
Copy link
Member

legoktm commented Sep 15, 2022

This is the remaining issue preventing reproducibility of securedrop-app-code. The issue is really subtle, the only thing that varies is the "build ID". pip ends up building each wheel in a randomly named temporary directory, which is captured into the build ID and then becomes non-reproducible. In theory https://reproducible-builds.org/docs/build-path/ would help here, but that needs to be injected by setuptools or whatever is building the C extension, and I don't think we know the new path, so it's messy and doesn't work. Oh and pip deprecated and removed the setting that allowed using a fixed build path!

Of course, this is a solved problem by SDW. We use build to build the wheel in a fixed directory (see here). I would suggest we do the same for SD server, which Kushal already started working on.

FWIW, I played with a middle ground of using build to build the wheels on the fly and then install them: 6a491d7. It technically worked after some fixes I didn't push, but none of the bootstrapping was pinned, which kind of defeats the point. No point re-inventing the wheel either, when we've already invented reproducible wheels!

@legoktm
Copy link
Member

legoktm commented Sep 15, 2022

Also, during package builds we're currently building all of the Python dependencies twice. Using pre-built wheels will cut that down to zero times.

@legoktm
Copy link
Member

legoktm commented Sep 15, 2022

I filed #6546 to clean up how our requirements.txt files are organized before we embark down this.

legoktm added a commit to freedomofpress/securedrop-builder that referenced this issue Sep 26, 2022
Each project, whether it's securedrop-client or the
workstation-bootstrap, will now store wheels and associated metadata in
the exact same way. Moving files around will happen in follow-up
commits.

securedrop-client/
  debian/
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The workstation-bootstrap is similar, except it also contains its
requirements files.

workstation-bootstrap/
  build-requirements.txt
  requirements.in
  requirements.txt
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The main goal of this refactor is to make room for the new
securedrop-app-code bootstrap and wheels. The main scripts now take a
`--project` parameter, which is the path in this repository, and
`--pkg-dir`, which is the path to the Git checkout of it (previously a
PKG_DIR environment variable). In nearly all cases backwards-compat code
has been added so it should do the right thing based on old
documentation.

Makefile:
* Updates for how scripts are now invoked.
* Drop misleading "clean" target, people can use git-clean(1) directly.

scripts/build-debianpackage:
* Validate $PKG_NAME before we use it.
* Set $WHEELS_DIR to that package's wheel directory.
* Only verify sha256sums.txt if it exists (securedrop-export and
  metapackages have no Python dependencies).

scripts/build-sync-wheels:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Drop "cache" terminology since this is persistent storage.
* Remove dead commented-out code.

scripts/install-deps:
* Debian 11 is our baseline now, fix typo.
* Look for and install wheels from workstation-bootstrap now.

scripts/sync-sha256sums:
* Require a directory instead of looking for a BOOTSTRAP variable.

scripts/update-requirements:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Use pathlib internally

scripts/verify-sha256sum-signature:
* Require a directory instead of looking for a BOOTSTRAP variable.

Refs <freedomofpress/securedrop#5901>.
legoktm added a commit to freedomofpress/securedrop-builder that referenced this issue Sep 27, 2022
Each project, whether it's securedrop-client or the
workstation-bootstrap, will now store wheels and associated metadata in
the exact same way. Moving files around will happen in follow-up
commits.

securedrop-client/
  debian/
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The workstation-bootstrap is similar, except it also contains its
requirements files.

workstation-bootstrap/
  build-requirements.txt
  requirements.in
  requirements.txt
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The main goal of this refactor is to make room for the new
securedrop-app-code bootstrap and wheels. The main scripts now take a
`--project` parameter, which is the path in this repository, and
`--pkg-dir`, which is the path to the Git checkout of it (previously a
PKG_DIR environment variable). In nearly all cases backwards-compat code
has been added so it should do the right thing based on old
documentation.

Makefile:
* Updates for how scripts are now invoked.
* Drop misleading "clean" target, people can use git-clean(1) directly.

scripts/build-debianpackage:
* Validate $PKG_NAME before we use it.
* Set $WHEELS_DIR to that package's wheel directory.
* Only verify sha256sums.txt if it exists (securedrop-export and
  metapackages have no Python dependencies).

scripts/build-sync-wheels:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Drop "cache" terminology since this is persistent storage.
* Remove dead commented-out code.

scripts/install-deps:
* Debian 11 is our baseline now, fix typo.
* Look for and install wheels from workstation-bootstrap now.

scripts/sync-sha256sums:
* Require a directory instead of looking for a BOOTSTRAP variable.

scripts/update-requirements:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Use pathlib internally

scripts/verify-sha256sum-signature:
* Require a directory instead of looking for a BOOTSTRAP variable.

Refs <freedomofpress/securedrop#5901>.
legoktm added a commit to freedomofpress/securedrop-builder that referenced this issue Sep 27, 2022
Each project, whether it's securedrop-client or the
workstation-bootstrap, will now store wheels and associated metadata in
the exact same way. Moving files around will happen in follow-up
commits.

securedrop-client/
  debian/
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The workstation-bootstrap is similar, except it also contains its
requirements files.

workstation-bootstrap/
  build-requirements.txt
  requirements.in
  requirements.txt
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The main goal of this refactor is to make room for the new
securedrop-app-code bootstrap and wheels. The main scripts now take a
`--project` parameter, which is the path in this repository, and
`--pkg-dir`, which is the path to the Git checkout of it (previously a
PKG_DIR environment variable). In nearly all cases backwards-compat code
has been added so it should do the right thing based on old
documentation.

Makefile:
* Updates for how scripts are now invoked.
* Drop misleading "clean" target, people can use git-clean(1) directly.

scripts/build-debianpackage:
* Validate $PKG_NAME before we use it.
* Set $WHEELS_DIR to that package's wheel directory.
* Only verify sha256sums.txt if it exists (securedrop-export and
  metapackages have no Python dependencies).

scripts/build-sync-wheels:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Drop "cache" terminology since this is persistent storage.
* Remove dead commented-out code.

scripts/install-deps:
* Debian 11 is our baseline now, fix typo.
* Look for and install wheels from workstation-bootstrap now.

scripts/sync-sha256sums:
* Require a directory instead of looking for a BOOTSTRAP variable.

scripts/update-requirements:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Use pathlib internally

scripts/verify-sha256sum-signature:
* Require a directory instead of looking for a BOOTSTRAP variable.

Refs <freedomofpress/securedrop#5901>.
@legoktm legoktm self-assigned this Sep 27, 2022
legoktm added a commit to freedomofpress/securedrop-builder that referenced this issue Sep 30, 2022
Each project, whether it's securedrop-client or the
workstation-bootstrap, will now store wheels and associated metadata in
the exact same way. Moving files around will happen in follow-up
commits.

securedrop-client/
  debian/
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The workstation-bootstrap is similar, except it also contains its
requirements files.

workstation-bootstrap/
  build-requirements.txt
  requirements.in
  requirements.txt
  sha256sums.txt
  sha256sums.txt.asc
  wheels/

The main goal of this refactor is to make room for the new
securedrop-app-code bootstrap and wheels. The main scripts now take a
`--project` parameter, which is the path in this repository, and
`--pkg-dir`, which is the path to the Git checkout of it (previously a
PKG_DIR environment variable). In nearly all cases backwards-compat code
has been added so it should do the right thing based on old
documentation.

Makefile:
* Updates for how scripts are now invoked.
* Drop misleading "clean" target, people can use git-clean(1) directly.

scripts/build-debianpackage:
* Validate $PKG_NAME before we use it.
* Set $WHEELS_DIR to that package's wheel directory.
* Only verify sha256sums.txt if it exists (securedrop-export and
  metapackages have no Python dependencies).

scripts/build-sync-wheels:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Drop "cache" terminology since this is persistent storage.
* Remove dead commented-out code.

scripts/install-deps:
* Debian 11 is our baseline now, fix typo.
* Look for and install wheels from workstation-bootstrap now.

scripts/sync-sha256sums:
* Require a directory instead of looking for a BOOTSTRAP variable.

scripts/update-requirements:
* Switch to --pkg-dir/--project args, with backwards-compat.
* Allow specifying where requirements.txt lives.
* Use pathlib internally

scripts/verify-sha256sum-signature:
* Require a directory instead of looking for a BOOTSTRAP variable.

Refs <freedomofpress/securedrop#5901>.
@legoktm
Copy link
Member

legoktm commented Sep 30, 2022

Current work in flight:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Cycle Backlog
Development

No branches or pull requests

3 participants