Skip to content

Commit

Permalink
chore: Add separate copr array
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftydinar authored Dec 25, 2024
1 parent e66b176 commit 4920cc4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion modules/dnf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- my-repository.repo # copies in .repo file from files/dnf/my-repository.repo to /etc/yum.repos.d/
```
Specific COPR repositories can also be specified in `COPR user/project` format & is prefered over using direct COPR URL.
Specific COPR repositories can also be specified in `user/project` format in `copr:` array.

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`.

Expand Down
26 changes: 16 additions & 10 deletions modules/dnf/dnf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,30 @@ if [[ ${#REPOS[@]} -gt 0 ]]; then
repo="${REPOS[$i]}"
repo="${repo//%OS_VERSION%/${OS_VERSION}}"
REPOS[$i]="${repo//[$'\t\r\n ']}"
# Remove spaces/newlines for all repos other than COPR
if [[ "${repo}" != "COPR "* ]]; then
REPOS[$i]="${repo//[$'\t\r\n ']}"
else
REPOS[$i]="${repo}"
fi
done
# dnf config-manager & dnf copr don't support adding multiple repositories at once, hence why for/done loop is used
# dnf config-manager doesn't support adding multiple repositories at once, hence why for/done loop is used
for repo in "${REPOS[@]}"; do
if [[ "${repo}" =~ ^https?:\/\/.* ]]; then
echo "Adding repository URL: '${repo}'"
dnf -y config-manager addrepo --from-repofile="${repo}"
elif [[ "${repo}" == *".repo" ]] && [[ -f "${CONFIG_DIRECTORY}/dnf/${repo}" ]]; then
echo "Adding repository file: '${repo##*/}'"
dnf -y config-manager addrepo --from-repofile="${CONFIG_DIRECTORY}/dnf/${repo}"
elif [[ "${repo}" == "COPR "* ]]; then
echo "Adding COPR repository: '${repo#COPR }'"
dnf -y copr enable "${repo#COPR }"
fi
done
fi

# Pull in COPR repos
get_json_array COPR_REPOS 'try .["copr"][]' "${1}"
if [[ ${#COPR_REPOS[@]} -gt 0 ]]; then
echo "Adding COPR repositories"
for repo in "${COPR_REPOS[@]}"; do
if [[ "${repo}" == *"/"* ]]; then
echo "Adding COPR repository: '${repo}'"
dnf copr enable "${repo}"
else
echo "ERROR: You didn't provide COPR repository in proper format, it should be in 'user/project' format."
exit 1
fi
done
fi
Expand Down
3 changes: 3 additions & 0 deletions modules/dnf/dnf.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ model DnfModule {
/** List of links to .repo files to download into /etc/yum.repos.d/. */
repos?: Array<string>;

/** List of COPR project repos to download into /etc/yum.repos.d/. */
copr?: Array<string>;

/** List of links to key files to import for installing from custom repositories. */
keys?: Array<string>;

Expand Down
5 changes: 3 additions & 2 deletions modules/dnf/module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ shortdesc: The dnf module offers pseudo-declarative package and repository manag
example: |
type: dnf
repos:
- COPR atim/starship
- COPR trixieua/mutter-patched
- https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
copr:
- atim/starship
- trixieua/mutter-patched
keys:
- https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
optfix:
Expand Down

0 comments on commit 4920cc4

Please sign in to comment.