Skip to content
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
1 change: 1 addition & 0 deletions CHANGES/245.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for ``pulp deb content --type package_release_component create``, allowing an existing package to be associated with one or more release components (and thus distributions) within a repository without re-uploading.
36 changes: 34 additions & 2 deletions src/pulpcore/cli/deb/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,33 @@ def _sha256_artifact_callback(
"Repository to add the content to in the form '[[<plugin>:]<resource_type>:]<name>' or by "
"href."
),
allowed_with_contexts=(PulpDebPackageContext, PulpDebReleaseComponentContext),
allowed_with_contexts=(
PulpDebPackageContext,
PulpDebPackageReleaseComponentContext,
PulpDebReleaseComponentContext,
),
)

package_option = resource_option(
"--package",
default_plugin="deb",
default_type="package",
context_table={"deb:package": PulpDebPackageContext},
href_pattern=PulpDebPackageContext.HREF_PATTERN,
required=True,
help=_("Package to associate with a release component, by href."),
allowed_with_contexts=(PulpDebPackageReleaseComponentContext,),
)

release_component_option = resource_option(
"--release-component",
default_plugin="deb",
default_type="release_component",
context_table={"deb:release_component": PulpDebReleaseComponentContext},
href_pattern=PulpDebReleaseComponentContext.HREF_PATTERN,
required=True,
help=_("Release component the package should be associated with, by href."),
allowed_with_contexts=(PulpDebPackageReleaseComponentContext,),
)


Expand Down Expand Up @@ -285,12 +311,18 @@ def content() -> None:
help=_("The APT repo component to use"),
allowed_with_contexts=(PulpDebReleaseComponentContext,),
),
package_option,
release_component_option,
repository_option,
]
content.add_command(
create_command(
decorators=create_options,
allowed_with_contexts=(PulpDebPackageContext, PulpDebReleaseComponentContext),
allowed_with_contexts=(
PulpDebPackageContext,
PulpDebPackageReleaseComponentContext,
PulpDebReleaseComponentContext,
),
)
)

Expand Down
18 changes: 18 additions & 0 deletions tests/scripts/pulp_deb/test_deb_content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,21 @@ expect_succ pulp orphan cleanup --content-hrefs "[\"${PACKAGE_HREF}\"]" --protec
expect_succ pulp deb content --type release_component create --distribution foo --component bar
RELEASE_COMPONENT_HREF=$(echo "${OUTPUT}" | jq -r .pulp_href)
expect_succ pulp orphan cleanup --content-hrefs "[\"${RELEASE_COMPONENT_HREF}\"]" --protection-time 0 || true

# Test attaching an already-uploaded package to an additional distribution by
# creating a package_release_component for an existing release component.
expect_succ pulp deb content upload --file "${DEB_FILENAME}" --repository "${REPO1_NAME}" --distribution "extra-dist" --component "extra-comp"
EXTRA_PACKAGE_HREF=$(echo "${OUTPUT}" | jq -r .pulp_href)

expect_succ pulp deb content --type release_component create --distribution second-dist --component extra-comp --repository "${REPO1_NAME}"
SECOND_RC_HREF=$(echo "${OUTPUT}" | jq -r .pulp_href)

expect_succ pulp deb content --type package_release_component create \
--package "${EXTRA_PACKAGE_HREF}" \
--release-component "${SECOND_RC_HREF}" \
--repository "${REPO1_NAME}"

# The same package should now be referenced by PRCs in two distributions.
VERSION_HREF=$(pulp deb repository version show --repository "${REPO1_NAME}" | jq -r .pulp_href)
expect_succ pulp deb content --type package_release_component list --repository-version "${VERSION_HREF}" --package "${EXTRA_PACKAGE_HREF}"
test "$(echo "${OUTPUT}" | jq -r length)" -ge "2"