本文主要是介绍deepin add-apt-repository 诸多问题及其解决,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
deepin不会自带这个命令的,需要安装
apt-get install python-software-properties
sudo apt-get install software-properties-common
知乎上的解决方法:
https://www.zhihu.com/question/30361833/answer/84878458
测试命令:
sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php
但是使用起来会报错:
Traceback (most recent call last):File "/usr/bin/add-apt-repository", line 160, in <module>sp = SoftwareProperties(options=options)File "/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py", line 96, in __init__self.reload_sourceslist()File "/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py", line 584, in reload_sourceslistself.distro.get_sources(self.sourceslist) File "/usr/lib/python2.7/dist-packages/aptsources/distro.py", line 93, in get_sources(self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Deepin/stable
我们看到/usr/share/python-apt/templates/Deepin.info
Suite: unstable
RepositoryType: deb
BaseURI: http://packages.deepin.com/deepin/
MatchURI: \.deepin\.com
MirrorsFile: Deepin.mirrors
Description: Deepin 'unstable'
Component: main
CompDescription: Officially supported
Component: contrib
CompDescription: DFSG-compatible Software with Non-Free Dependencies
Component: non-free
CompDescription: Non-DFSG-compatible Software
(没什么卵用)
修改/etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=wily
DISTRIB-DESCRIPTION="Ubuntu wily"
最后需要修改一下/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py
文件
# software-properties backend
#
# Copyright (c) 2004-2007 Canonical Ltd.
# 2004-2005 Michiel Sikkes
#
# Author: Michiel Sikkes <michiel@eyesopened.nl>
# Michael Vogt <mvo@debian.org>
# Sebastian Heinlein <glatzor@ubuntu.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USAfrom __future__ import absolute_import, print_functionimport apt_pkg
import copy
from hashlib import md5
import re
import os
import glob
import shutil
import threading
import atexit
import tempfile
try:from string import maketrans
except ImportError:maketrans = str.maketrans
import statfrom tempfile import NamedTemporaryFile
from xml.sax.saxutils import escape
try:from configparser import ConfigParser
except ImportError:from ConfigParser import ConfigParser
from gettext import gettext as _import aptsources
import aptsources.distro
import softwarepropertiesfrom .AptAuth import AptAuth
from aptsources.sourceslist import SourcesList, SourceEntry
from . import shortcuts
from . import ppa
from . import cloudarchive_SHORTCUT_FACTORIES = [ppa.shortcut_handler,cloudarchive.shortcut_handler,shortcuts.shortcut_handler,
]class SoftwareProperties(object):# known (whitelisted) channelsCHANNEL_PATH="/usr/share/app-install/channels/"# release upgrades policyRELEASE_UPGRADES_CONF = "/etc/update-manager/release-upgrades"#RELEASE_UPGRADES_CONF = "/tmp/release-upgrades"(RELEASE_UPGRADES_NORMAL,RELEASE_UPGRADES_LTS,RELEASE_UPGRADES_NEVER) = list(range(3))release_upgrades_policy_map = {RELEASE_UPGRADES_NORMAL : 'normal',RELEASE_UPGRADES_LTS : 'lts',RELEASE_UPGRADES_NEVER : 'never',}def __init__(self, datadir=None, options=None, rootdir="/"):""" Provides the core functionality to configure the used software repositories, the corresponding authentication keys and update automation """self.popconfile = rootdir+"/etc/popularity-contest.conf"self.rootdir = rootdirif rootdir != "/":apt_pkg.config.set("Dir", rootdir)# FIXME: some saner way is needed hereif datadir == None:datadir = "/usr/share/software-properties/"self.options = optionsself.datadir = datadirself.sourceslist = SourcesList()self.distro = aptsources.distro.get_distro()self.seen_server = []self.modified_sourceslist = Falseself.reload_sourceslist()self.backup_sourceslist()self.backup_apt_conf()# FIXME: we need to store this value in a config option#self.custom_mirrors = ["http://adasdwww.de/ubuntu"]self.custom_mirrors= []# apt-key stuffself.apt_key = AptAuth(rootdir=rootdir)atexit.register(self.wait_for_threads)def wait_for_threads(self):" wait for all running threads (PPA key fetchers) to exit "for t in threading.enumerate():if t.ident != threading.current_thread().ident:t.join()def backup_apt_conf(self):"""Backup all apt configuration options"""self.apt_conf_backup = {}for option in softwareproperties.CONF_MAP.keys():value = apt_pkg.config.find_i(softwareproperties.CONF_MAP[option])self.apt_conf_backup[option] = valuedef restore_apt_conf(self):"""Restore the stored apt configuration"""for option in self.apt_conf_backup.keys():apt_pkg.config.set(softwareproperties.CONF_MAP[option],str(self.apt_conf_backup[option]))self.write_config()def get_update_automation_level(self):""" Parse the apt cron configuration. Try to fit a predefined use case and return it. Special case: if the user made a custom configurtation, that we cannot represent it will return None """if apt_pkg.config.find_i(softwareproperties.CONF_MAP["autoupdate"]) > 0:# Autodownloadif apt_pkg.config.find_i(softwareproperties.CONF_MAP["unattended"]) == 1\and os.path.exists("/usr/bin/unattended-upgrade"):return softwareproperties.UPDATE_INST_SECelif apt_pkg.config.find_i(softwareproperties.CONF_MAP["autodownload"]) == 1 and \apt_pkg.config.find_i(softwareproperties.CONF_MAP["unattended"]) == 0:return softwareproperties.UPDATE_DOWNLOADelif apt_pkg.config.find_i(softwareproperties.CONF_MAP["unattended"]) == 0 and \apt_pkg.config.find_i(softwareproperties.CONF_MAP["autodownload"]) == 0:return softwareproperties.UPDATE_NOTIFYelse:return Noneelif apt_pkg.config.find_i(softwareproperties.CONF_MAP["unattended"]) == 0 and \apt_pkg.config.find_i(softwareproperties.CONF_MAP["autodownload"]) == 0:return softwareproperties.UPDATE_MANUALelse:return Nonedef set_update_automation_level(self, state):""" Set the apt periodic configurtation to the selected update automation level. To synchronize the cache update and the actual upgrading function, the upgrade function, e.g. unattended, will run every day, if enabled. """if state == softwareproperties.UPDATE_INST_SEC:apt_pkg.config.set(softwareproperties.CONF_MAP["unattended"], str(1))apt_pkg.config.set(softwareproperties.CONF_MAP["autodownload"], str(1))elif state == softwareproperties.UPDATE_DOWNLOAD:apt_pkg.config.set(softwareproperties.CONF_MAP["autodownload"], str(1))apt_pkg.config.set(softwareproperties.CONF_MAP["unattended"], str(0))elif s
这篇关于deepin add-apt-repository 诸多问题及其解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!