Debian 增加 add-apt-repository 命令用来添加 PPA 源
更新:
使用software-properties-common
代替脚本
sudo apt install -y apt-transport-https ca-certificates gnupg2 software-properties-common
==============================================================================
#!/bin/bash
if [ "$#" -ge "1" ]; then
ppa_name=`echo "$1" | awk -F ':' '{print $2}'`
app_name=`echo "$ppa_name" | cut -d '/' -f2-`
if [ -z "$ppa_name" ]; then
echo "PPA name not found"
echo "Utility to add PPA repositories in your debian machine"
echo "$0 ppa:user/ppa-name"
else
echo "$ppa_name" " $app_name"
if [ "$2" != "" ]; then
version=$2
else
version="xenial"
fi
echo "deb http://ppa.launchpad.net/$ppa_name/ubuntu $version main" > /etc/apt/sources.list.d/$app_name.list
apt-get update > /dev/null 2> /tmp/apt_add_key.txt
key=`cat /tmp/apt_add_key.txt | awk -F ":" '{print $6}' | awk '{print $2}'`
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv $key
rm -rf /tmp/apt_add_key.txt
fi
else
echo "Utility to add PPA repositories in your debian machine"
echo "$0 ppa:user/ppa-name"
fi
保存这个脚本到/usr/bin目录下,名称为add-apt-repository,然后执行下列命令即可:
sudo chmod +x /usr/bin/add-apt-repository
sudo chown root:root /usr/bin/add-apt-repository
添加PPA源
sudo add-apt-repository ppa:ppa_name
删除PPA源
sudo rm /etc/apt/sources.list.d/app_name.list
删除key
sudo apt-key del key
debian 9.4 测试通过