Skip to content

Commit

Permalink
Merge pull request #382 from freedomofpress/reorg
Browse files Browse the repository at this point in the history
Reorganize how wheels are stored, stop special-casing bootstrap
  • Loading branch information
gonzalo-bulnes authored Oct 4, 2022
2 parents 5136507 + bf55e6e commit 4f4ce9c
Show file tree
Hide file tree
Showing 166 changed files with 287 additions and 464 deletions.
19 changes: 8 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
DEFAULT_GOAL: help
SHELL := /bin/bash

.PHONY: securedrop-proxy
securedrop-proxy: ## Builds Debian package for securedrop-proxy code
WHEELS_DIR="$(PWD)/localwheels/" PKG_NAME="securedrop-proxy" ./scripts/build-debianpackage
PKG_NAME="securedrop-proxy" ./scripts/build-debianpackage

.PHONY: securedrop-client
securedrop-client: ## Builds Debian package for securedrop-client code
WHEELS_DIR="$(PWD)/localwheels/" PKG_NAME="securedrop-client" ./scripts/build-debianpackage
PKG_NAME="securedrop-client" ./scripts/build-debianpackage

.PHONY: securedrop-workstation-config
securedrop-workstation-config: ## Builds Debian metapackage for Qubes Workstation base dependencies
Expand All @@ -22,11 +23,11 @@ securedrop-workstation-viewer: ## Builds Debian metapackage for Disposable VM de

.PHONY: securedrop-export
securedrop-export: ## Builds Debian package for Qubes Workstation export scripts
WHEELS_DIR="$(PWD)/localwheels/" PKG_NAME="securedrop-export" ./scripts/build-debianpackage
PKG_NAME="securedrop-export" ./scripts/build-debianpackage

.PHONY: securedrop-log
securedrop-log: ## Builds Debian package for Qubes Workstation securedrop-log scripts
WHEELS_DIR="$(PWD)/localwheels/" PKG_NAME="securedrop-log" ./scripts/build-debianpackage
PKG_NAME="securedrop-log" ./scripts/build-debianpackage

.PHONY: securedrop-keyring
securedrop-keyring: ## Builds Debian package containing the release key
Expand All @@ -46,9 +47,9 @@ requirements: ## Creates requirements files for the Python projects

.PHONY: build-wheels
build-wheels: ## Builds the wheels and adds them to the localwheels directory
./scripts/verify-sha256sum-signature
./scripts/build-sync-wheels -p ${PKG_DIR}
./scripts/sync-sha256sums
./scripts/verify-sha256sum-signature $$(basename ${PKG_DIR})
./scripts/build-sync-wheels
./scripts/sync-sha256sums $$(basename ${PKG_DIR})
@printf "Done! Now please follow the instructions in\n"
@printf "https://github.com/freedomofpress/securedrop-debian-packaging-guide/"
@printf "to push these changes to the FPF PyPI index\n"
Expand All @@ -57,10 +58,6 @@ build-wheels: ## Builds the wheels and adds them to the localwheels directory
test: ## Run simple test suite (skips reproducibility checks)
pytest -v tests/test_update_requirements.py

.PHONY: clean
clean: ## Removes all non-version controlled packaging artifacts
rm -rf localwheels/*

.PHONY: reprotest
reprotest: ## Runs only reproducibility tests, for .deb and .whl files
pytest -vvs tests/test_reproducible_*.py
Expand Down
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,21 @@ If we have to update the tool, use the following steps
rm -rf .venv && python3 -m venv .venv
source .venv/bin/activate
# Then install pip-tools, from pinned dependencies
python3 -m pip install -r requirements.txt
python3 -m pip install -r workstation-bootstrap/requirements.txt
# Then update the requirements.in file as required
pip-compile --allow-unsafe --generate-hashes --output-file=requirements.txt requirements.in
pip-compile --allow-unsafe --generate-hashes \
--output-file=workstation-bootstrap/requirements.txt workstation-bootstrap/requirements.in
# Now we are ready for bootstrapping
./scripts/build-sync-wheels --cache ./bootstrap -p $PWD
./scripts/build-sync-wheels --project workstation-bootstrap --pkg-dir ./workstation-bootstrap --requirements .
# Here we have the new wheels ready
# Now let us recreate our new sha256sums for bootstrapping
BOOTSTRAP=true ./scripts/sync-sha256sums
./scripts/sync-sha256sums ./workstation-bootstrap
# now let us sign the list of sha256sums
gpg --armor --output bootstrap-sha256sums.txt.asc --detach-sig bootstrap-sha256sums.txt
gpg --armor --output workstation-bootstrap/sha256sums.txt.asc --detach-sig workstation-bootstrap/sha256sums.txt
# We can even verify if we want
BOOTSTRAP=true ./scripts/verify-sha256sum-signature
./scripts/verify-sha256sum-signature ./workstation-bootstrap/
# Update the build-requirements.txt file
PKG_DIR=$PWD BOOTSTRAP=true ./scripts/update-requirements
./scripts/update-requirements --pkg-dir ./workstation-bootstrap/ --project workstation-bootstrap --requirements .
```

Make sure that your GPG public key is stored in `pubkeys/`, so CI can verify the signatures.
Expand All @@ -73,9 +74,8 @@ to do the following (we are taking `securedrop-client` project as example):
You can create a fresh virtualenv and install the build tools from our bootstrapped wheels.

```
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --require-hashes --no-index --no-deps --no-cache-dir -r build-requirements.txt --find-links ./bootstrap/
rm -rf .venv
make install-deps
```

Remember that the following steps needs to be done from the same virtual environment.
Expand Down Expand Up @@ -104,9 +104,8 @@ Also update the index HTML files accordingly commit your changes.
After these steps, please rerun the command again.
```

The next step is to build the wheels. To do this step, you will need an owner
of the SecureDrop release key to build the wheel and sign the updated sha256sums file
with the release key. If you're not sure who to ask, ping @redshiftzero for a pointer.
The next step is to build the wheels. To do this step, you will need a maintainer
to build the wheels and sign the updated sha256sums file with your individual key.

### 2. Build wheels

Expand All @@ -120,12 +119,6 @@ This above command will let you know about any new wheels + sources. It will
build/download sources from PyPI (by verifying it against the sha256sums from
the `requirements.txt` of the project).

Then navigate back to the project's code directory and run the following command.

```bash
python3 setup.py sdist
```

### 3. Commit changes to the localwheels directory (if only any update of wheels)

Now add these built artifacts to version control:
Expand Down
3 changes: 0 additions & 3 deletions localwheels/MarkupSafe-1.0-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/MarkupSafe-1.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/MarkupSafe-1.1.1-cp37-cp37m-linux_x86_64.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/MarkupSafe-1.1.1-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/MarkupSafe-1.1.1.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/PyYAML-5.1-cp37-cp37m-linux_x86_64.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/PyYAML-5.1.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/PyYAML-5.3.1.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/Werkzeug-0.16.0-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/Werkzeug-0.16.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/certifi-2018.10.15-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/certifi-2018.10.15.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/chardet-3.0.4-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/chardet-3.0.4.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/idna-2.7-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/idna-2.7.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/idna-2.8-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/idna-2.8.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/requests-2.20.0-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/requests-2.20.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/requests-2.22.0-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/requests-2.22.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.0.12.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.0.13.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.1.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.1.1.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.2.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.3.0.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.3.1.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop-sdk-0.3.2.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.0.12-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.0.13-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.1.0-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.1.1-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.2.0-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.3.0-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.3.1-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/securedrop_sdk-0.3.2-py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/urllib3-1.24.3-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/urllib3-1.24.3.tar.gz

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/urllib3-1.25.10-py2.py3-none-any.whl

This file was deleted.

3 changes: 0 additions & 3 deletions localwheels/urllib3-1.25.10.tar.gz

This file was deleted.

31 changes: 19 additions & 12 deletions scripts/build-debianpackage
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ set -e
set -u
set -o pipefail


# Validate required args.
if [[ -z "${PKG_NAME:-}" ]]; then
echo "Set PKG_NAME of the build";
exit 1
fi

# Store root of repo, since we'll change dirs several times.
CUR_DIR="$(git rev-parse --show-toplevel)"
VERSION_CODENAME=$("${CUR_DIR}/scripts/codename")

# Verify sha256sums.txt in the git repo
"${CUR_DIR}/scripts/verify-sha256sum-signature"

# Disable use of pip cache during debhelper build actions.
export DH_PIP_EXTRA_ARGS="--no-cache-dir --require-hashes"
# Point dh-virtualenv/pip to our prebuilt wheels
export WHEELS_DIR="${CUR_DIR}/${PKG_NAME}/wheels"

if [[ -d "${WHEELS_DIR}" ]]; then
# Verify sha256sums.txt in the git repo if we have dependencies
"${CUR_DIR}/scripts/verify-sha256sum-signature" "${PKG_NAME}"
fi

# Declare general packaging building workspace; subdirs will
# be created within, to build specific packages.
Expand All @@ -29,12 +40,6 @@ mkdir -p "$TOP_BUILDDIR"
rm -rf "${TOP_BUILDDIR:?}/${PKG_NAME}"
mkdir -p "${TOP_BUILDDIR}/${PKG_NAME}"

# Validate required args.
if [[ -z "${PKG_NAME:-}" ]]; then
echo "Set PKG_NAME of the build";
exit 1
fi


# Look up most recent release from GitHub repo
function find_latest_version() {
Expand Down Expand Up @@ -115,8 +120,10 @@ if [[ "${PKG_NAME}" =~ ^(securedrop-client|securedrop-proxy|securedrop-export|se

# Hop into the package build dir, to run dpkg-buildpackage
cd "$TOP_BUILDDIR/$PKG_NAME/"
# Verify all the hashes from the verified sha256sums.txt
"${CUR_DIR}/scripts/verify-hashes" "${CUR_DIR}/sha256sums.txt"
if [[ -d "${WHEELS_DIR}" ]]; then
# Verify all the hashes from the verified sha256sums.txt if we have dependencies
"${CUR_DIR}/scripts/verify-hashes" "${CUR_DIR}/${PKG_NAME}/sha256sums.txt"
fi

echo "All hashes verified."
else
Expand Down Expand Up @@ -158,7 +165,7 @@ export SOURCE_DATE_EPOCH
# Build the package
dpkg-buildpackage -us -uc

# Tell the user the path of the files buillt
# Tell the user the path of the files built
pkg_path="$(find "$TOP_BUILDDIR" -type f -iname "${PKG_NAME}_${PKG_VERSION}*.deb" | head -n1)"
if [[ -f "$pkg_path" ]]; then
echo "Package location: $pkg_path"
Expand Down
Loading

0 comments on commit 4f4ce9c

Please sign in to comment.