|
| 1 | +# Package Policies |
| 2 | + |
| 3 | +Python repositories offer two mechanisms for controlling which packages they accept: |
| 4 | +**blocklists** to prevent specific packages from being added, and |
| 5 | +**package substitution control** to prevent silent replacement of existing packages. |
| 6 | + |
| 7 | +## Setup |
| 8 | + |
| 9 | +If you do not already have a repository, create one: |
| 10 | + |
| 11 | +```bash |
| 12 | +pulp python repository create --name foo |
| 13 | +``` |
| 14 | + |
| 15 | +## Package Blocklist |
| 16 | + |
| 17 | +A repository can have a blocklist that prevents specific packages from being added. |
| 18 | +Blocklist entries can match by package `name` (blocks all versions), package `name` with an exact `version`, or exact `filename`. |
| 19 | +Exactly one of `name` or `filename` must be provided. |
| 20 | + |
| 21 | +Package `name` is normalized using [PEP 503](https://peps.python.org/pep-0503/) before being stored, |
| 22 | +and `version` must follow [PEP 440](https://peps.python.org/pep-0440/) rules. |
| 23 | + |
| 24 | +Each entry records the PRN of the user who created it in the `added_by` field. |
| 25 | + |
| 26 | +### Add a blocklist entry |
| 27 | + |
| 28 | +=== "By name" |
| 29 | + |
| 30 | + ```bash |
| 31 | + # Block all versions of shelf-reader |
| 32 | + pulp python repository blocklist add --repository "foo" --name "shelf-reader" |
| 33 | + ``` |
| 34 | + |
| 35 | +=== "By name and version" |
| 36 | + |
| 37 | + ```bash |
| 38 | + # Block only shelf-reader 0.1 |
| 39 | + pulp python repository blocklist add --repository "foo" --name "shelf-reader" --version "0.1" |
| 40 | + ``` |
| 41 | + |
| 42 | +=== "By filename" |
| 43 | + |
| 44 | + ```bash |
| 45 | + # Block only shelf-reader-0.1.tar.gz |
| 46 | + pulp python repository blocklist add --repository "foo" --filename "shelf-reader-0.1.tar.gz" |
| 47 | + ``` |
| 48 | + |
| 49 | +### List blocklist entries |
| 50 | + |
| 51 | +```bash |
| 52 | +pulp python repository blocklist list --repository "foo" |
| 53 | +``` |
| 54 | + |
| 55 | +### Show a blocklist entry |
| 56 | + |
| 57 | +=== "By name" |
| 58 | + |
| 59 | + ```bash |
| 60 | + pulp python repository blocklist show --repository "foo" --name "shelf-reader" |
| 61 | + ``` |
| 62 | + |
| 63 | +=== "By name and version" |
| 64 | + |
| 65 | + ```bash |
| 66 | + pulp python repository blocklist show --repository "foo" --name "shelf-reader" --version "0.1" |
| 67 | + ``` |
| 68 | + |
| 69 | +=== "By filename" |
| 70 | + |
| 71 | + ```bash |
| 72 | + pulp python repository blocklist show --repository "foo" --filename "shelf-reader-0.1.tar.gz" |
| 73 | + ``` |
| 74 | + |
| 75 | +### Remove a blocklist entry |
| 76 | + |
| 77 | +=== "By name" |
| 78 | + |
| 79 | + ```bash |
| 80 | + pulp python repository blocklist remove --repository "foo" --name "shelf-reader" |
| 81 | + ``` |
| 82 | + |
| 83 | +=== "By name and version" |
| 84 | + |
| 85 | + ```bash |
| 86 | + pulp python repository blocklist remove --repository "foo" --name "shelf-reader" --version "0.1" |
| 87 | + ``` |
| 88 | + |
| 89 | +=== "By filename" |
| 90 | + |
| 91 | + ```bash |
| 92 | + pulp python repository blocklist remove --repository "foo" --filename "shelf-reader-0.1.tar.gz" |
| 93 | + ``` |
| 94 | + |
| 95 | +Once an entry is removed, packages matching it can be added to the repository again. |
| 96 | + |
| 97 | +## Package Substitution |
| 98 | + |
| 99 | +By default, Python repositories allow package substitution: uploading, syncing, or adding a package |
| 100 | +with the same filename as an existing package but a different checksum will silently replace it. |
| 101 | + |
| 102 | +This behavior is controlled by the `allow_package_substitution` field on a Python repository. |
| 103 | +When set to `False`, any operation (upload, sync, or modify) that would replace an existing package with a different checksum is rejected. |
| 104 | +Re-adding a package with the same filename *and* the same checksum is always accepted (idempotent). |
| 105 | + |
| 106 | +### Disable package substitution |
| 107 | + |
| 108 | +```bash |
| 109 | +pulp python repository update --repository "foo" --block-package-substitution |
| 110 | +``` |
| 111 | + |
| 112 | +You can also set this when creating a repository: |
| 113 | + |
| 114 | +```bash |
| 115 | +pulp python repository create --name "foo2" --block-package-substitution |
| 116 | +``` |
| 117 | + |
| 118 | +### Re-enable package substitution |
| 119 | + |
| 120 | +```bash |
| 121 | +pulp python repository update --repository "foo" --allow-package-substitution |
| 122 | +``` |
| 123 | + |
| 124 | +Once re-enabled, packages with duplicate filenames can replace existing content again. |
0 commit comments