Commit cd600cda authored by Rafael Monnerat's avatar Rafael Monnerat

slapos.package.distribute: Check existence before take action

parent 79561a0d
...@@ -146,6 +146,7 @@ class AptGet: ...@@ -146,6 +146,7 @@ class AptGet:
def purgeRepository(self, caller): def purgeRepository(self, caller):
""" Remove all repositories """ """ Remove all repositories """
# Aggressive removal # Aggressive removal
if os.path.exists(self.source_list_path):
os.remove(self.source_list_path) os.remove(self.source_list_path)
open(self.source_list_path, "w+").write("# Removed all") open(self.source_list_path, "w+").write("# Removed all")
for file_path in glob.glob("%s/*" % self.source_list_d_path): for file_path in glob.glob("%s/*" % self.source_list_d_path):
...@@ -153,6 +154,8 @@ class AptGet: ...@@ -153,6 +154,8 @@ class AptGet:
def addRepository(self, caller, url, alias): def addRepository(self, caller, url, alias):
""" Add a repository """ """ Add a repository """
if not os.path.exists(self.source_list_d_path):
os.mkdir(self.source_list_d_path)
repos_file = open("%s/%s.list" % (self.source_list_d_path, alias), "w") repos_file = open("%s/%s.list" % (self.source_list_d_path, alias), "w")
prefix = "deb " prefix = "deb "
if alias.endswith("-src"): if alias.endswith("-src"):
...@@ -209,7 +212,7 @@ class Zypper: ...@@ -209,7 +212,7 @@ class Zypper:
if alias.endswith("unsafe"): if alias.endswith("unsafe"):
base_command.append('--no-gpgcheck') base_command.append('--no-gpgcheck')
base_command.extend([url, alias]) base_command.extend([url, alias])
output, err = caller(base_command, stdout=None) caller(base_command, stdout=None)
def addKey(self, caller, url, alias): def addKey(self, caller, url, alias):
""" Add gpg or key """ """ Add gpg or key """
......
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