Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,11 @@ python_build_opts: ''
python_force_build: False
setuptools_force_build: False

# List of patches to download and apply, should be maps with:
# - url
# - basename - base name of the patch (filename to download to)
# - sha1sum - sha1sum check string
# - pargs - patch args (default -p1)
python_patches: []

# vi:ts=2:sw=2:et:ft=yaml
11 changes: 11 additions & 0 deletions tasks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
src="{{python_src_prefix}}/{{python_src_pkg}}"
dest="{{python_src_prefix}}"

- name: Patch code

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably change a few things here, to improve a bit on idempotency.

  1. use the get_url module, and iterate along the patches urls. Register successful downloads
  2. Use:
args:
  chdir: "{{python_src_prefix}}"

instead of cd ...
3. Using the register var from get_url apply the patche.
4. Not sure about removing the patches. IMO it is a good idea to actually know what has been applied, and also, that would break get_url idempotency.

@klaussfreire klaussfreire Jan 3, 2017

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sha1 checksum checking for get_url is only there for ansible 2.0 and above. Prior versions support only the sha256sum argument, which is deprecated on 2.0, so maintaining cross compatibility becomes very cumbersome.

Idempotence is already broken since get_url in the previous step is currently unconditional (when is commented), unarchive is unconditional as well, and the build is currently conditional only on python not being installed (so it won't pick up changes in source code even if all the above tasks actually report changed or not correctly).

You can never fully ascertain which patches were applied also, there's no way to know whether a binary was built with or without a patch. So even if the patches were left on the source path, that still doesn't guarantee they were built into the binary. So preserving idempotence in the presence of patches seems like a tall order.

The other changes don't seem like a big deal

shell: >
#!/bin/bash
set -e
wget -q -O "{{item.basename}}" "{{item.url}}"
echo "{{item.sha1sum}}" | sha1sum
patch {{item.pargs|default('-p1')}} -i "{{item.basename}}"
args:
chdir: "{{python_src_prefix}}"
with_items: "{{python_patches}}"

- name: Check Custom Python binary
command: >
{{python_bin}} --version
Expand Down