Commit 60b48241 authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm-addrepo: move addkey code to epm-repo-addkey module

parent 4bcd29f6
......@@ -290,69 +290,6 @@ __epm_addrepo_altlinux()
}
__epm_addkey_altlinux()
{
local url="$1"
local fingerprint="$2"
local comment="$3"
local name="$(basename "$url" .gpg)"
[ -s /etc/apt/vendors.list.d/$name.list ] && return
# TODO: get this info from the gpg key
cat << EOF | sudorun tee /etc/apt/vendors.list.d/$name.list
simple-key "$name" {
FingerPrint "$fingerprint";
Name "$comment";
}
EOF
eget -q -O /tmp/$name.gpg $url || fatal
sudorun gpg --no-default-keyring --keyring /usr/lib/alt-gpgkeys/pubring.gpg --import /tmp/$name.gpg
rm -f /tmp/$name.gpg
}
__epm_addkey_deb()
{
local url="$1"
local fingerprint="$2"
local comment="$3"
local name="$(basename $url .gpg)"
[ -s /etc/apt/trusted.gpg.d/$name.gpg ] && return
if [ -z "$fingerprint" ] ; then
set_sudo
eget -q -O- "$url" | sudorun apt-key add -
#
# if [ ! -f /etc/apt/trusted.gpg.d/$name.gpg ]; then
# epm tool eget -q -O /etc/apt/trusted.gpg.d/$name.gpg https://example.com/$name.gpg > /dev/null
# chmod 0644 /etc/apt/trusted.gpg.d/$name.gpg
# fi
return
fi
sudocmd apt-key adv --keyserver "$url" --recv "$fingerprint"
}
epm_addkey()
{
case $BASEDISTRNAME in
"alt")
__epm_addkey_altlinux "$@"
return
;;
esac
case $PMTYPE in
apt-dpkg)
__epm_addkey_deb "$@"
;;
esac
}
__epm_addrepo_astra()
{
......
......@@ -68,8 +68,8 @@ epm_repo()
load_helper epm-repodisable
epm_repodisable "$@"
;;
addkey) # HELPCMD: add repository gpg key
load_helper epm-addrepo
addkey) # HELPCMD: add repository gpg key (by URL or file)
load_helper epm-repo-addkey
epm_addkey "$@"
;;
clean) # HELPCMD: remove temp. repos (tasks and CD-ROMs)
......
#!/bin/sh
#
# Copyright (C) 2023 Etersoft
# Copyright (C) 2023 Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
load_helper epm-sh-altlinux
__epm_addkey_altlinux()
{
local url="$1"
local fingerprint="$2"
local comment="$3"
local name="$(basename "$url" .gpg)"
[ -s /etc/apt/vendors.list.d/$name.list ] && return
# TODO: get this info from the gpg key
cat << EOF | sudorun tee /etc/apt/vendors.list.d/$name.list
simple-key "$name" {
FingerPrint "$fingerprint";
Name "$comment";
}
EOF
eget -q -O /tmp/$name.gpg $url || fatal
sudorun gpg --no-default-keyring --keyring /usr/lib/alt-gpgkeys/pubring.gpg --import /tmp/$name.gpg
rm -f /tmp/$name.gpg
}
__epm_addkey_deb()
{
local url="$1"
local fingerprint="$2"
local comment="$3"
local name="$(basename $url .gpg)"
[ -s /etc/apt/trusted.gpg.d/$name.gpg ] && return
if [ -z "$fingerprint" ] ; then
set_sudo
eget -q -O- "$url" | sudorun apt-key add -
#
# if [ ! -f /etc/apt/trusted.gpg.d/$name.gpg ]; then
# epm tool eget -q -O /etc/apt/trusted.gpg.d/$name.gpg https://example.com/$name.gpg > /dev/null
# chmod 0644 /etc/apt/trusted.gpg.d/$name.gpg
# fi
return
fi
sudocmd apt-key adv --keyserver "$url" --recv "$fingerprint"
}
epm_addkey()
{
case $BASEDISTRNAME in
"alt")
__epm_addkey_altlinux "$@"
return
;;
esac
case $PMTYPE in
apt-dpkg)
__epm_addkey_deb "$@"
;;
esac
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment