Skip to content
This repository has been archived by the owner on Oct 10, 2020. It is now read-only.

Commit

Permalink
syscontainers: support uninstall of rpm installed containers
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>

Closes: #767
Approved by: rhatdan
  • Loading branch information
giuseppe authored and rh-atomic-bot committed Mar 22, 2017
1 parent 13f0493 commit 7006675
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Atomic/syscontainers.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@ def _install_rpm(self, rpm_file):
else:
util.check_call(["yum", "install", "-y", rpm_file])

def _uninstall_rpm(self, rpm):
if os.path.exists("/run/ostree-booted"):
raise ValueError("This doesn't work on Atomic Host yet")
elif os.path.exists("/usr/bin/dnf"):
util.check_call(["dnf", "remove", "-y", rpm])
else:
util.check_call(["yum", "remove", "-y", rpm])

def install(self, image, name):
repo = self._get_ostree_repo()
if not repo:
Expand Down Expand Up @@ -1163,7 +1171,8 @@ def _is_preinstalled_container(self, name):

def uninstall(self, name):
if self._is_preinstalled_container(name):
raise ValueError("Cannot uninstall a preinstalled container")
self._uninstall_rpm("%s-%s" % (RPM_NAME_PREFIX, name))
return

with open(os.path.join(self._get_system_checkout_path(), name, "info"), "r") as info_file:
info = json.loads(info_file.read())
Expand Down

0 comments on commit 7006675

Please sign in to comment.