feat(rpm-ostree): Add support for installing local repos & RPMs
I also made installing packages more efficient, as rpm-ostree can install from URL, local RPM & classic RPM package at the same time, so there is no need to keep packages installing separately from URLs as it is now. I also made logs more informative for install section, so classic RPMs, local RPMs & URL RPMs are printed separately.
This commit is contained in:
parent
32bbddc245
commit
d9d7d0968e
3 changed files with 62 additions and 15 deletions
|
|
@ -4,12 +4,24 @@ The [`rpm-ostree`](https://coreos.github.io/rpm-ostree/) module offers pseudo-de
|
||||||
|
|
||||||
The module first downloads the repository files from repositories declared under `repos:` into `/etc/yum.repos.d/`. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version), which can be used, for example, for pulling correct versions of repositories from [Fedora's Copr](https://copr.fedorainfracloud.org/).
|
The module first downloads the repository files from repositories declared under `repos:` into `/etc/yum.repos.d/`. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version), which can be used, for example, for pulling correct versions of repositories from [Fedora's Copr](https://copr.fedorainfracloud.org/).
|
||||||
|
|
||||||
|
You can also have local repos inserted in this file location (make the directory if it doesn't exist):
|
||||||
|
```
|
||||||
|
files/rpm-ostree/my-repository.repo
|
||||||
|
files/rpm-ostree/my-image/my-2nd-repository.repo
|
||||||
|
```
|
||||||
|
|
||||||
If you use a repo that requires adding custom keys (eg. Brave Browser), you can import the keys by declaring the key URLs under `keys:`. The magic string acts the same as it does in `repos`.
|
If you use a repo that requires adding custom keys (eg. Brave Browser), you can import the keys by declaring the key URLs under `keys:`. The magic string acts the same as it does in `repos`.
|
||||||
|
|
||||||
Then the module installs the packages declared under `install:` using `rpm-ostree install`, it removes the packages declared under `remove:` using `rpm-ostree override remove`. If there are packages declared under both `install:` and `remove:` a hybrid command `rpm-ostree remove <packages> --install <packages>` is used, which should allow you to switch required packages for other ones.
|
Then the module installs the packages declared under `install:` using `rpm-ostree install`, it removes the packages declared under `remove:` using `rpm-ostree override remove`. If there are packages declared under both `install:` and `remove:` a hybrid command `rpm-ostree remove <packages> --install <packages>` is used, which should allow you to switch required packages for other ones.
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
Installing local RPM packages from the file location is supported. You can insert those RPMs in this file location (make the directory if it doesn't exist):
|
||||||
|
```
|
||||||
|
files/rpm-ostree/my-package.rpm
|
||||||
|
files/rpm-ostree/my-image/somepackage.rpm
|
||||||
|
```
|
||||||
|
|
||||||
The module can also replace base RPM packages with packages from COPR repo. Under `replace:`, the module finds every pair of keys `- from-repo:` and `packages:`. (Multiple pairs are supported.) The module downloads the COPR 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 COPR repository file is then deleted. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version) as already said above. At the moment, only COPR repo is supported.
|
The module can also replace base RPM packages with packages from COPR repo. Under `replace:`, the module finds every pair of keys `- from-repo:` and `packages:`. (Multiple pairs are supported.) The module downloads the COPR 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 COPR repository file is then deleted. The magic string `%OS_VERSION%` is substituted with the current VERSION_ID (major Fedora version) as already said above. At the moment, only COPR repo is supported.
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ example: |
|
||||||
repos:
|
repos:
|
||||||
- https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo # when including COPR repos, use the %OS_VERSION% magic string
|
- https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo # when including COPR repos, use the %OS_VERSION% magic string
|
||||||
- https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
|
- https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
|
||||||
|
- my-local-repository.repo # local repo located in `files/rpm-ostree/my-local-repository.repo`
|
||||||
keys:
|
keys:
|
||||||
- https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
|
- https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
|
||||||
optfix:
|
optfix:
|
||||||
|
|
@ -16,9 +17,11 @@ example: |
|
||||||
remove:
|
remove:
|
||||||
- firefox
|
- firefox
|
||||||
- firefox-langpacks
|
- firefox-langpacks
|
||||||
|
- my-local-package.rpm # local package located in `files/rpm-ostree/my-local-package.rpm`
|
||||||
|
- some-folder/my-local-package-2.rpm # local package located in `files/rpm-ostree/some-folder/my-local-package-2.rpm`
|
||||||
replace:
|
replace:
|
||||||
- from-repo: https://copr.fedorainfracloud.org/coprs/trixieua/mutter-patched/repo/fedora-%OS_VERSION%/trixieua-mutter-patched-fedora-%OS_VERSION%.repo
|
- from-repo: https://copr.fedorainfracloud.org/coprs/trixieua/mutter-patched/repo/fedora-%OS_VERSION%/trixieua-mutter-patched-fedora-%OS_VERSION%.repo
|
||||||
packages:
|
packages:
|
||||||
- mutter
|
- mutter
|
||||||
- mutter-common
|
- mutter-common
|
||||||
- gdm
|
- gdm
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,12 @@ get_yaml_array REPOS '.repos[]' "$1"
|
||||||
if [[ ${#REPOS[@]} -gt 0 ]]; then
|
if [[ ${#REPOS[@]} -gt 0 ]]; then
|
||||||
echo "Adding repositories"
|
echo "Adding repositories"
|
||||||
for REPO in "${REPOS[@]}"; do
|
for REPO in "${REPOS[@]}"; do
|
||||||
REPO="${REPO//%OS_VERSION%/${OS_VERSION}}"
|
REPO="${REPO//%OS_VERSION%/${OS_VERSION}}"
|
||||||
curl --output-dir "/etc/yum.repos.d/" -O "${REPO//[$'\t\r\n ']}"
|
if [[ "${REPO}" =~ ^https?:\/\/.* ]]; then
|
||||||
|
curl --output-dir "/etc/yum.repos.d/" -O "${REPO//[$'\t\r\n ']}"
|
||||||
|
elif [[ ! "${REPO}" =~ ^https?:\/\/.* ]] && [[ "${REPO}" == *".repo" ]] && [[ -f "${CONFIG_DIRECTORY}/rpm-ostree/${REPO}" ]]; then
|
||||||
|
cp "${CONFIG_DIRECTORY}/rpm-ostree/${REPO}" "/etc/yum.repos.d/${REPO}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -43,16 +47,22 @@ fi
|
||||||
get_yaml_array INSTALL '.install[]' "$1"
|
get_yaml_array INSTALL '.install[]' "$1"
|
||||||
get_yaml_array REMOVE '.remove[]' "$1"
|
get_yaml_array REMOVE '.remove[]' "$1"
|
||||||
|
|
||||||
|
# Install and remove RPM packages
|
||||||
|
# Sort classic, URL & local packages
|
||||||
if [[ ${#INSTALL[@]} -gt 0 ]]; then
|
if [[ ${#INSTALL[@]} -gt 0 ]]; then
|
||||||
for PKG in "${INSTALL[@]}"; do
|
for PKG in "${INSTALL[@]}"; do
|
||||||
if [[ "$PKG" =~ ^https?:\/\/.* ]]; then
|
if [[ "$PKG" =~ ^https?:\/\/.* ]]; then
|
||||||
REPLACED_PKG="${PKG//%OS_VERSION%/${OS_VERSION}}"
|
VERSION_SUBSTITUTED_PKG="${PKG//%OS_VERSION%/${OS_VERSION}}"
|
||||||
echo "Installing directly from URL: ${REPLACED_PKG}"
|
HTTPS_INSTALL=true
|
||||||
rpm-ostree install "$REPLACED_PKG"
|
HTTPS_PKG+=("${VERSION_SUBSTITUTED_PKG}")
|
||||||
INSTALL=( "${INSTALL[@]/$PKG}" ) # delete URL from install array
|
elif [[ ! "$PKG" =~ ^https?:\/\/.* ]] && [[ -f "${CONFIG_DIRECTORY}/rpm-ostree/${PKG}" ]]; then
|
||||||
fi
|
LOCAL_INSTALL=true
|
||||||
done
|
LOCAL_PKG+=("${PKG}")
|
||||||
fi
|
else
|
||||||
|
CLASSIC_INSTALL=true
|
||||||
|
CLASSIC_PKG+=("${PKG}")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# The installation is done with some wordsplitting hacks
|
# The installation is done with some wordsplitting hacks
|
||||||
# because of errors when doing array destructuring at the installation step.
|
# because of errors when doing array destructuring at the installation step.
|
||||||
|
|
@ -60,16 +70,38 @@ fi
|
||||||
INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n')
|
INSTALL_STR=$(echo "${INSTALL[*]}" | tr -d '\n')
|
||||||
REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n')
|
REMOVE_STR=$(echo "${REMOVE[*]}" | tr -d '\n')
|
||||||
|
|
||||||
# Install and remove RPM packages
|
echo_rpm_install() {
|
||||||
|
if ${CLASSIC_INSTALL} && ! ${HTTPS_INSTALL} && ! ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing: ${CLASSIC_PKG[*]}"
|
||||||
|
elif ! ${CLASSIC_INSTALL} && ${HTTPS_INSTALL} && ! ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing package(s) directly from URL: ${HTTPS_PKG[*]}"
|
||||||
|
elif ! ${CLASSIC_INSTALL} && ! ${HTTPS_INSTALL} && ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing local package(s): ${LOCAL_PKG[*]}"
|
||||||
|
elif ${CLASSIC_INSTALL} && ${HTTPS_INSTALL} && ! ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing: ${CLASSIC_PKG[*]}"
|
||||||
|
echo "Installing package(s) directly from URL: ${HTTPS_PKG[*]}"
|
||||||
|
elif ${CLASSIC_INSTALL} && ! ${HTTPS_INSTALL} && ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing: ${CLASSIC_PKG[*]}"
|
||||||
|
echo "Installing local package(s): ${LOCAL_PKG[*]}"
|
||||||
|
elif ! ${CLASSIC_INSTALL} && ${HTTPS_INSTALL} && ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing package(s) directly from URL: ${HTTPS_PKG[*]}"
|
||||||
|
echo "Installing local package(s): ${LOCAL_PKG[*]}"
|
||||||
|
elif ${CLASSIC_INSTALL} && ${HTTPS_INSTALL} && ${LOCAL_INSTALL}; then
|
||||||
|
echo "Installing: ${CLASSIC_PKG[*]}"
|
||||||
|
echo "Installing package(s) directly from URL: ${HTTPS_PKG[*]}"
|
||||||
|
echo "Installing local package(s): ${LOCAL_PKG[*]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then
|
if [[ ${#INSTALL[@]} -gt 0 && ${#REMOVE[@]} -gt 0 ]]; then
|
||||||
echo "Installing & Removing RPMs"
|
echo "Installing & Removing RPMs"
|
||||||
echo "Installing: ${INSTALL_STR[*]}"
|
echo_rpm_install
|
||||||
echo "Removing: ${REMOVE_STR[*]}"
|
echo "Removing: ${REMOVE_STR[*]}"
|
||||||
# Doing both actions in one command allows for replacing required packages with alternatives
|
# Doing both actions in one command allows for replacing required packages with alternatives
|
||||||
rpm-ostree override remove $REMOVE_STR $(printf -- "--install=%s " $INSTALL_STR)
|
rpm-ostree override remove $REMOVE_STR $(printf -- "--install=%s " $INSTALL_STR)
|
||||||
elif [[ ${#INSTALL[@]} -gt 0 ]]; then
|
elif [[ ${#INSTALL[@]} -gt 0 ]]; then
|
||||||
echo "Installing RPMs"
|
echo "Installing RPMs"
|
||||||
echo "Installing: ${INSTALL_STR[*]}"
|
echo_rpm_install
|
||||||
rpm-ostree install $INSTALL_STR
|
rpm-ostree install $INSTALL_STR
|
||||||
elif [[ ${#REMOVE[@]} -gt 0 ]]; then
|
elif [[ ${#REMOVE[@]} -gt 0 ]]; then
|
||||||
echo "Removing RPMs"
|
echo "Removing RPMs"
|
||||||
|
|
@ -108,7 +140,7 @@ if [[ ${#REPLACE[@]} -gt 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Replacing packages from repository: '${REPO_NAME}' owned by '${MAINTAINER}'"
|
echo "Replacing packages from COPR repository: '${REPO_NAME}' owned by '${MAINTAINER}'"
|
||||||
echo "Replacing: ${REPLACE_STR}"
|
echo "Replacing: ${REPLACE_STR}"
|
||||||
|
|
||||||
curl --output-dir "/etc/yum.repos.d/" -O "${REPO//[$'\t\r\n ']}"
|
curl --output-dir "/etc/yum.repos.d/" -O "${REPO//[$'\t\r\n ']}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue