feat(rpm-ostree): Add support for replacing base packages with 'rpm-o… (#269)
This commit is contained in:
commit
4634ac7330
3 changed files with 53 additions and 0 deletions
|
|
@ -10,6 +10,8 @@ Then the module installs the packages declared under `install:` using `rpm-ostre
|
|||
|
||||
Installing RPM packages directly from a `http(s)` url that points to the RPM file is also supported, you can just put the URLs under `install:` and they'll be installed along with the other packages. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version) like with the `repos:` property.
|
||||
|
||||
The module can also replace base RPM packages. Under `replace:`, the module finds every pair of keys `- from-repo:` and `packages:`. (Multiple pairs are supported.) The module downloads the repository file declared by `- from-repo:` into `/etc/yum.repos.d/` and from that repository replaces packages declared under `packages:` using the command `rpm-ostree override replace`. The repository file is then deleted. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version) as already said above.
|
||||
|
||||
:::note
|
||||
[Removed packages are still present in the underlying ostree repository](https://coreos.github.io/rpm-ostree/administrator-handbook/#removing-a-base-package), what `remove` does is kind of like hiding them from the system, it doesn't free up storage space.
|
||||
:::
|
||||
|
|
|
|||
|
|
@ -15,3 +15,13 @@ example: |
|
|||
remove:
|
||||
- firefox
|
||||
- firefox-langpacks
|
||||
replace:
|
||||
- from-repo: https://copr.fedorainfracloud.org/coprs/trixieua/mutter-patched/repo/fedora-%OS_VERSION%/trixieua-mutter-patched-fedora-%OS_VERSION%.repo
|
||||
packages:
|
||||
- mutter
|
||||
- mutter-common
|
||||
- gdm
|
||||
- from-repo: https://copr.fedorainfracloud.org/coprs/owner/repository2/repo/fedora-%OS_VERSION%/owner-repository2-fedora-%OS_VERSION%.repo
|
||||
packages:
|
||||
- package4
|
||||
- package5
|
||||
|
|
|
|||
|
|
@ -76,3 +76,44 @@ elif [[ ${#REMOVE[@]} -gt 0 ]]; then
|
|||
echo "Removing: ${REMOVE_STR[*]}"
|
||||
rpm-ostree override remove $REMOVE_STR
|
||||
fi
|
||||
|
||||
get_yaml_array REPLACE '.replace[]' "$1"
|
||||
|
||||
# Override-replace RPM packages
|
||||
if [[ ${#REPLACE[@]} -gt 0 ]]; then
|
||||
for REPLACEMENT in "${REPLACE[@]}"; do
|
||||
|
||||
# Get repository
|
||||
REPO=$(echo "${REPLACEMENT}" | yq -I=0 ".from-repo")
|
||||
REPO="${REPO//%OS_VERSION%/${OS_VERSION}}"
|
||||
|
||||
# Ensure repository is provided
|
||||
if [[ "${REPO}" == "null" ]]; then
|
||||
echo "Error: Key 'from-repo' was declared, but repository URL was not provided."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get info from repository URL
|
||||
MAINTAINER=$(awk -F'/' '{print $5}' <<< "${REPO}")
|
||||
REPO_NAME=$(awk -F'/' '{print $6}' <<< "${REPO}")
|
||||
FILE_NAME=$(awk -F'/' '{print $9}' <<< "${REPO}")
|
||||
|
||||
# Get packages to replace
|
||||
get_yaml_array PACKAGES '.packages[]' "${REPLACEMENT}"
|
||||
REPLACE_STR="$(echo "${PACKAGES[*]}" | tr -d '\n')"
|
||||
|
||||
# Ensure packages are provided
|
||||
if [[ ${#PACKAGES[@]} == 0 ]]; then
|
||||
echo "Error: No packages were provided for repository '${REPO_NAME}'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Replacing packages from repository: '${REPO_NAME}' owned by '${MAINTAINER}'"
|
||||
echo "Replacing: ${REPLACE_STR}"
|
||||
|
||||
curl --output-dir "/etc/yum.repos.d/" -O "${REPO//[$'\t\r\n ']}"
|
||||
rpm-ostree override replace --experimental --from repo=copr:copr.fedorainfracloud.org:${MAINTAINER}:${REPO_NAME} ${REPLACE_STR}
|
||||
rm "/etc/yum.repos.d/${FILE_NAME}"
|
||||
|
||||
done
|
||||
fi
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue