Commit 8b008e1c authored by Vitaly Lipatov's avatar Vitaly Lipatov

epm: repo addkey support (add gpg key for a repo)

parent 67995600
...@@ -263,7 +263,7 @@ check_command() ...@@ -263,7 +263,7 @@ check_command()
epm_cmd=update epm_cmd=update
direct_args=1 direct_args=1
;; ;;
addrepo|ar) # HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list addrepo|ar|--add-repo) # HELPCMD: add package repo (etersoft, autoimports, archive 2017/12/31); run with param to get list
epm_cmd=addrepo epm_cmd=addrepo
direct_args=1 direct_args=1
;; ;;
......
...@@ -139,21 +139,70 @@ __epm_addrepo_altlinux() ...@@ -139,21 +139,70 @@ __epm_addrepo_altlinux()
} }
# TODO: add repo addkey command __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() __epm_addkey_deb()
{ {
local url="$1" local url="$1"
local fingerprint="$2" local fingerprint="$2"
local comment="$3"
local name="$(basename $url .gpg)"
[ -s /etc/apt/trusted.gpg.d/$name.gpg ] && return
if [ -z "$fingerprint" ] ; then if [ -z "$fingerprint" ] ; then
assure_exists curl
set_sudo set_sudo
showcmd "curl -fsSL '$url' | $SUDO apt-key add -" eget -q -O- "$url" | sudorun apt-key add -
a= curl -fsSL "$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 return
fi fi
sudocmd apt-key adv --keyserver "$url" --recv "$fingerprint" sudocmd apt-key adv --keyserver "$url" --recv "$fingerprint"
} }
epm_addkey()
{
case $DISTRNAME in
ALTLinux|ALTServer)
__epm_addkey_altlinux "$@"
return
;;
esac
case $PMTYPE in
apt-dpkg)
__epm_addkey_deb "$@"
;;
esac
}
__epm_addrepo_deb() __epm_addrepo_deb()
{ {
assure_exists apt-add-repository software-properties-common assure_exists apt-add-repository software-properties-common
......
...@@ -79,6 +79,10 @@ EOF ...@@ -79,6 +79,10 @@ EOF
epm_addrepo "$@" epm_addrepo "$@"
epm update epm update
;; ;;
addkey) # HELPCMD: add repository gpg key
load_helper epm-addrepo
epm_addkey "$@"
;;
rm|remove) # HELPCMD: remove repository from the sources lists (epm repo remove all for all) rm|remove) # HELPCMD: remove repository from the sources lists (epm repo remove all for all)
load_helper epm-removerepo load_helper epm-removerepo
epm_removerepo "$@" epm_removerepo "$@"
......
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