deepin add-apt-repository 诸多问题及其解决

2024-04-20 23:58

本文主要是介绍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 诸多问题及其解决的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/921668

相关文章

Oracle登录时忘记用户名或密码该如何解决

《Oracle登录时忘记用户名或密码该如何解决》:本文主要介绍如何在Oracle12c中忘记用户名和密码时找回或重置用户账户信息,文中通过代码介绍的非常详细,对同样遇到这个问题的同学具有一定的参... 目录一、忘记账户:二、忘记密码:三、详细情况情况 1:1.1. 登录到数据库1.2. 查看当前用户信息1.

在Dockerfile中copy和add的区别及说明

《在Dockerfile中copy和add的区别及说明》COPY和ADD都是Dockerfile中用于文件复制的命令,但COPY仅用于本地文件或目录的复制,不支持自动解压缩;而ADD除了复制本地文件或... 目录在dockerfile中,copy 和 add有什么区别?COPY 命令ADD 命令总结在Doc

springboot3.4和mybatis plus的版本问题的解决

《springboot3.4和mybatisplus的版本问题的解决》本文主要介绍了springboot3.4和mybatisplus的版本问题的解决,主要由于SpringBoot3.4与MyBat... 报错1:spring-boot-starter/3.4.0/spring-boot-starter-

在 Spring Boot 中使用异步线程时的 HttpServletRequest 复用问题记录

《在SpringBoot中使用异步线程时的HttpServletRequest复用问题记录》文章讨论了在SpringBoot中使用异步线程时,由于HttpServletRequest复用导致... 目录一、问题描述:异步线程操作导致请求复用时 Cookie 解析失败1. 场景背景2. 问题根源二、问题详细分

解读为什么@Autowired在属性上被警告,在setter方法上不被警告问题

《解读为什么@Autowired在属性上被警告,在setter方法上不被警告问题》在Spring开发中,@Autowired注解常用于实现依赖注入,它可以应用于类的属性、构造器或setter方法上,然... 目录1. 为什么 @Autowired 在属性上被警告?1.1 隐式依赖注入1.2 IDE 的警告:

解决java.lang.NullPointerException问题(空指针异常)

《解决java.lang.NullPointerException问题(空指针异常)》本文详细介绍了Java中的NullPointerException异常及其常见原因,包括对象引用为null、数组元... 目录Java.lang.NullPointerException(空指针异常)NullPointer

Android开发中gradle下载缓慢的问题级解决方法

《Android开发中gradle下载缓慢的问题级解决方法》本文介绍了解决Android开发中Gradle下载缓慢问题的几种方法,本文给大家介绍的非常详细,感兴趣的朋友跟随小编一起看看吧... 目录一、网络环境优化二、Gradle版本与配置优化三、其他优化措施针对android开发中Gradle下载缓慢的问

关于Nginx跨域问题及解决方案(CORS)

《关于Nginx跨域问题及解决方案(CORS)》文章主要介绍了跨域资源共享(CORS)机制及其在现代Web开发中的重要性,通过Nginx,可以简单地解决跨域问题,适合新手学习和应用,文章详细讲解了CO... 目录一、概述二、什么是 CORS?三、常见的跨域场景四、Nginx 如何解决 CORS 问题?五、基

python安装whl包并解决依赖关系的实现

《python安装whl包并解决依赖关系的实现》本文主要介绍了python安装whl包并解决依赖关系的实现,文中通过图文示例介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录一、什么是whl文件?二、我们为什么需要使用whl文件来安装python库?三、我们应该去哪儿下

MySQL安装时initializing database失败的问题解决

《MySQL安装时initializingdatabase失败的问题解决》本文主要介绍了MySQL安装时initializingdatabase失败的问题解决,文中通过图文介绍的非常详细,对大家的学... 目录问题页面:解决方法:问题页面:解决方法:1.勾选红框中的选项:2.将下图红框中全部改为英