forked from ungleich-public/cdist
Compare commits
18 Commits
Author | SHA1 | Date |
---|---|---|
|
77d9a757ec | 1 month ago |
|
e5adcf451b | 1 month ago |
|
9839c2d8ec | 1 month ago |
|
1edc4d0a60 | 1 month ago |
|
3d58c9b24f | 1 month ago |
|
6c8c692a22 | 2 months ago |
|
abbc7dfc37 | 2 months ago |
|
8b915b15b5 | 3 months ago |
|
2df2578e36 | 3 months ago |
|
6f8c774cb0 | 3 months ago |
|
54a5cb17b7 | 3 months ago |
|
cb0fa0f2e4 | 3 months ago |
|
af54fe6feb | 3 months ago |
|
22039284f5 | 3 months ago |
|
bd44c023d3 | 4 months ago |
|
e0150e7796 | 4 months ago |
|
15e1ce6450 | 4 months ago |
|
08ff41efde | 4 months ago |
13 changed files with 84 additions and 86 deletions
@ -1,2 +1,3 @@
|
||||
state |
||||
package |
||||
priority |
||||
|
@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env python |
||||
# |
||||
# Remove the given apt repository. |
||||
# |
||||
# Exit with: |
||||
# 0: if it worked |
||||
# 1: if not |
||||
# 2: on other error |
||||
|
||||
import os |
||||
import sys |
||||
from aptsources import distro, sourceslist |
||||
from softwareproperties import ppa |
||||
from softwareproperties.SoftwareProperties import SoftwareProperties |
||||
|
||||
|
||||
def remove_if_empty(file_name): |
||||
with open(file_name, 'r') as f: |
||||
if f.read().strip(): |
||||
return |
||||
os.unlink(file_name) |
||||
|
||||
def remove_repository(repository): |
||||
#print 'repository:', repository |
||||
codename = distro.get_distro().codename |
||||
#print 'codename:', codename |
||||
(line, file) = ppa.expand_ppa_line(repository.strip(), codename) |
||||
#print 'line:', line |
||||
#print 'file:', file |
||||
deb_source_entry = sourceslist.SourceEntry(line, file) |
||||
src_source_entry = sourceslist.SourceEntry('deb-src{}'.format(line[3:]), file) |
||||
|
||||
try: |
||||
sp = SoftwareProperties() |
||||
sp.remove_source(deb_source_entry) |
||||
try: |
||||
# If there's a deb-src entry, remove that too |
||||
sp.remove_source(src_source_entry) |
||||
except: |
||||
pass |
||||
remove_if_empty(file) |
||||
return True |
||||
except ValueError: |
||||
print >> sys.stderr, "Error: '%s' doesn't exists in a sourcelist file" % line |
||||
return False |
||||
|
||||
if __name__ == '__main__': |
||||
if (len(sys.argv) != 2): |
||||
print >> sys.stderr, 'Error: need a repository as argument' |
||||
sys.exit(2) |
||||
repository = sys.argv[1] |
||||
if remove_repository(repository): |
||||
sys.exit(0) |
||||
else: |
||||
sys.exit(1) |
Loading…
Reference in new issue