-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,220 additions
and
1,154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# | ||
# Generate repo file under /etc/apt/sources.list.d/ | ||
# | ||
function apt_add_repo() { | ||
local -r repo_name="$1" | ||
local -r repo_data="$3" # "http(s)://host/path/uri argument0 .. argumentN" | ||
local -r include_src="${4:-yes}" | ||
local -r kr_path="${5:-/usr/share/keyrings/${repo_name}.gpg}" | ||
local -r repo_path="${6:-/etc/apt/sources.list.d/${repo_name}.list}" | ||
|
||
echo "deb [signed-by=${kr_path}] ${repo_data}" > "${repo_path}" | ||
if [[ "${include_src}" == "yes" ]] ; then | ||
echo "deb-src [signed-by=${kr_path}] ${repo_data}" >> "${repo_path}" | ||
fi | ||
|
||
apt-get update -qq | ||
} | ||
|
||
# | ||
# Generate repo file under /etc/yum.repos.d/ | ||
# | ||
function dnf_add_repo() { | ||
local -r repo_name="$1" | ||
local -r repo_url="$3" # "http(s)://host/path/filename.repo" | ||
local -r kr_path="${5:-/etc/pki/rpm-gpg/${repo_name}.gpg}" | ||
local -r repo_path="${6:-/etc/yum.repos.d/${repo_name}.repo}" | ||
|
||
curl -s -L "${repo_url}" \ | ||
| dd of="${repo_path}" status=progress | ||
# | perl -p -e "s{^gpgkey=.*$}{gpgkey=file://${kr_path}}" \ | ||
} | ||
|
||
# | ||
# Keyrings default to | ||
# /usr/share/keyrings/${repo_name}.gpg (debian/ubuntu) or | ||
# /etc/pki/rpm-gpg/${repo_name}.gpg (rocky/RHEL) | ||
# | ||
function os_add_repo() { | ||
local -r repo_name="$1" | ||
local -r signing_key_url="$2" | ||
local -r repo_data="$3" # "http(s)://host/path/uri argument0 .. argumentN" | ||
local kr_path | ||
if is_debuntu ; then kr_path="${5:-/usr/share/keyrings/${repo_name}.gpg}" | ||
else kr_path="${5:-/etc/pki/rpm-gpg/${repo_name}.gpg}" ; fi | ||
|
||
mkdir -p "$(dirname "${kr_path}")" | ||
|
||
curl -fsS --retry-connrefused --retry 10 --retry-max-time 30 "${signing_key_url}" \ | ||
| gpg --import --no-default-keyring --keyring "${kr_path}" | ||
|
||
if is_debuntu ; then apt_add_repo "${repo_name}" "${signing_key_url}" "${repo_data}" "${4:-yes}" "${kr_path}" "${6:-}" | ||
else dnf_add_repo "${repo_name}" "${signing_key_url}" "${repo_data}" "${4:-yes}" "${kr_path}" "${6:-}" ; fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.