1- # Package Blocklist
1+ # Package Policies
22
3- A repository can have a blocklist that prevents specific packages from being added.
4- Blocklist entries can match by package ` name ` (all versions), package ` name ` with an exact ` version ` , or exact ` filename ` .
5- Exactly one of ` name ` or ` filename ` must be provided.
6-
7- Each entry records the PRN of the user who created it in the ` added_by ` field.
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.
86
97## Setup
108
@@ -21,7 +19,15 @@ PULP_API="http://localhost:5001"
2119REPO_HREF=$( pulp python repository show --name foo | jq -r " .pulp_href" )
2220```
2321
24- ## Add a blocklist entry
22+ ## Package Blocklist
23+
24+ A repository can have a blocklist that prevents specific packages from being added.
25+ Blocklist entries can match by package ` name ` (all versions), package ` name ` with an exact ` version ` , or exact ` filename ` .
26+ Exactly one of ` name ` or ` filename ` must be provided.
27+
28+ Each entry records the PRN of the user who created it in the ` added_by ` field.
29+
30+ ### Add a blocklist entry
2531
2632=== "By name (all versions)"
2733
@@ -50,7 +56,7 @@ Set the UUID of a created entry for use in the subsequent commands:
5056ENTRY_UUID=$( http GET " ${PULP_API}${REPO_HREF} blocklist_entries/" | jq -r ' .results[0].prn | split(":") | .[-1]' )
5157```
5258
53- ## List blocklist entries
59+ ### List blocklist entries
5460
5561List all entries for a repository:
5662
@@ -64,10 +70,39 @@ Show a single entry:
6470http GET " ${PULP_API}${REPO_HREF} blocklist_entries/${ENTRY_UUID} /"
6571```
6672
67- ## Remove a blocklist entry
73+ ### Remove a blocklist entry
6874
6975``` bash
7076http DELETE " ${PULP_API}${REPO_HREF} blocklist_entries/${ENTRY_UUID} /"
7177```
7278
7379Once an entry is removed, packages matching it can be added to the repository again.
80+
81+ ## Package Substitution
82+
83+ By default, Python repositories allow package substitution: uploading, syncing, or adding a package
84+ with the same filename as an existing package but a different checksum will silently replace it.
85+
86+ This behavior is controlled by the ` allow_package_substitution ` field on a Python repository.
87+ When set to ` False ` , any operation (upload, sync, or modify) that would replace an existing package with a different checksum is rejected.
88+ Re-adding a package with the same filename * and* the same checksum is always accepted (idempotent).
89+
90+ ### Disable package substitution
91+
92+ ``` bash
93+ http PATCH " ${PULP_API}${REPO_HREF} " allow_package_substitution=false
94+ ```
95+
96+ You can also set this when creating a repository:
97+
98+ ``` bash
99+ http POST " ${PULP_API} /pulp/api/v3/repositories/python/python/" name=" bar" allow_package_substitution=false
100+ ```
101+
102+ ### Re-enable package substitution
103+
104+ ``` bash
105+ http PATCH " ${PULP_API}${REPO_HREF} " allow_package_substitution=true
106+ ```
107+
108+ Once re-enabled, packages with duplicate filenames can replace existing content again.
0 commit comments