backend/satellite_tools/spacewalk-remove-channel | 74 ++++++++++++------
backend/satellite_tools/spacewalk-remove-channel.sgml | 12 ++
backend/spacewalk-backend.spec | 7 +
rel-eng/packages/spacewalk-backend | 2
4 files changed, 69 insertions(+), 26 deletions(-)
New commits:
commit bf393594abbb14cc56e1af8f278f6b165462014e
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Jan 29 14:55:03 2014 +0100
Automatic commit of package [spacewalk-backend] release [2.1.46-1].
diff --git a/backend/spacewalk-backend.spec b/backend/spacewalk-backend.spec
index 3a936ae..3ada77f 100644
--- a/backend/spacewalk-backend.spec
+++ b/backend/spacewalk-backend.spec
@@ -11,7 +11,7 @@ Name: spacewalk-backend
Summary: Common programs needed to be installed on the Spacewalk servers/proxies
Group: Applications/Internet
License: GPLv2
-Version: 2.1.45
+Version: 2.1.46
Release: 1%{?dist}
URL:
https://fedorahosted.org/spacewalk
Source0:
https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -628,6 +628,11 @@ rm -f %{rhnconf}/rhnSecret.py*
%{pythonrhnroot}/satellite_tools/exporter/xmlWriter.py*
%changelog
+* Wed Jan 29 2014 Michael Mraka <michael.mraka(a)redhat.com> 2.1.46-1
+- fixed man page for spacewalk-remove-channel
+- added option to skip kickstart trees removal
+- 1058431 - sw-remove-channel does not rm ks trees.
+
* Fri Jan 24 2014 Stephen Herr <sherr(a)redhat.com> 2.1.45-1
- 1051658 - Fixing InvalidPackageError when importing from channel dump
diff --git a/rel-eng/packages/spacewalk-backend b/rel-eng/packages/spacewalk-backend
index 1cf6e81..2c4c8c1 100644
--- a/rel-eng/packages/spacewalk-backend
+++ b/rel-eng/packages/spacewalk-backend
@@ -1 +1 @@
-2.1.45-1 backend/
+2.1.46-1 backend/
commit 603d6cb64063e781b431c170316c07772f104639
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Jan 29 14:47:03 2014 +0100
fixed man page for spacewalk-remove-channel
diff --git a/backend/satellite_tools/spacewalk-remove-channel.sgml
b/backend/satellite_tools/spacewalk-remove-channel.sgml
index c8b6716..30376cc 100644
--- a/backend/satellite_tools/spacewalk-remove-channel.sgml
+++ b/backend/satellite_tools/spacewalk-remove-channel.sgml
@@ -98,6 +98,18 @@ Removes a channel from an Red Hat Satellite or Spacewalk server.
<para>Do not remove the package metadata or the files from the
filesystem.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>--skip-kickstart-trees</term>
+ <listitem>
+ <para>Do not remove kickstart trees from the filesystem.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>--skip-channels</term>
+ <listitem>
+ <para>Remove only packages from channel not the channel
itself.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</RefSect1>
commit 67ea5b347b76294b9d12f6cc9566666168a74b79
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Jan 29 14:46:18 2014 +0100
added option to skip kickstart trees removal
diff --git a/backend/satellite_tools/spacewalk-remove-channel
b/backend/satellite_tools/spacewalk-remove-channel
index 1b9216c..13e005a 100755
--- a/backend/satellite_tools/spacewalk-remove-channel
+++ b/backend/satellite_tools/spacewalk-remove-channel
@@ -49,6 +49,8 @@ options_table = [
help="Remove the channel packages from any other channels too (Not
Recommended)"),
Option("-p", "--skip-packages", action="store_true",
help="Do not remove package metadata or packages from the filesystem (Not
Recommended)"),
+ Option( "--skip-kickstart-trees", action="store_true",
+ help="Do not remove kickstart trees from the filesystem (Not
Recommended)."),
Option( "--skip-channels", action="store_true",
help="Remove only packages from channel not the channel itself."),
]
@@ -297,7 +299,8 @@ def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0,
skip_chan
_delete_srpms(srpms_ids)
_delete_rpms(rpms_ids)
- _delete_ks_files(channelLabels)
+ if not skip_kickstart_trees:
+ _delete_ks_files(channelLabels)
if not justdb and not skip_packages:
_delete_files(rpms_paths + srpms_paths)
commit 82d723ab7e3168c8cfb04c009eff170746a901ff
Author: Dimitar Yordanov <dyordano(a)redhat.com>
Date: Mon Jan 27 20:09:53 2014 +0100
1058431 - sw-remove-channel does not rm ks trees.
diff --git a/backend/satellite_tools/spacewalk-remove-channel
b/backend/satellite_tools/spacewalk-remove-channel
index 3ce75be..1b9216c 100755
--- a/backend/satellite_tools/spacewalk-remove-channel
+++ b/backend/satellite_tools/spacewalk-remove-channel
@@ -297,9 +297,12 @@ def delete_channels(channelLabels, force=0, justdb=0,
skip_packages=0, skip_chan
_delete_srpms(srpms_ids)
_delete_rpms(rpms_ids)
+ _delete_ks_files(channelLabels)
+
if not justdb and not skip_packages:
_delete_files(rpms_paths + srpms_paths)
+
# Get the channel ids
h = rhnSQL.prepare("""
select id, parent_channel
@@ -540,6 +543,26 @@ def _get_package_paths(package_ids, sources=0):
return pdict.keys()
+def _delete_ks_files(channel_lables):
+ sql = """
+ select kt.base_path
+ from rhnChannel c
+ left join rhnKickstartableTree kt on c.id = kt.channel_id
+ where c.label in (%s);
+ """
+
+ params, bind_params = _bind_many(channel_lables)
+ bind_params = string.join(bind_params, ', ')
+ h = rhnSQL.prepare(sql % (bind_params))
+ h.execute(**params)
+ list = h.fetchall_dict()
+
+ for map in list:
+ path = os.path.join(CFG.MOUNT_POINT, str(map['base_path']))
+ if not os.path.exists(path):
+ log_debug(1, "Not removing %s: no such file" % path)
+ continue
+ shutil.rmtree(path)
def releaseLOCK():
commit 6d41f5c545a1eae3be8b950638cba3c573f046ae
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Jan 29 14:39:17 2014 +0100
removed trailing spaces
diff --git a/backend/satellite_tools/spacewalk-remove-channel
b/backend/satellite_tools/spacewalk-remove-channel
index f3b5d2e..3ce75be 100755
--- a/backend/satellite_tools/spacewalk-remove-channel
+++ b/backend/satellite_tools/spacewalk-remove-channel
@@ -11,10 +11,10 @@
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
#
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
+#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
+# in this software or its documentation.
#
import sys
@@ -35,11 +35,11 @@ from spacewalk.server import rhnSQL
from spacewalk.server.rhnPackage import unlink_package_file
options_table = [
- Option("-v", "--verbose", action="count",
+ Option("-v", "--verbose", action="count",
help="Increase verbosity"),
Option("-l", "--list", action="store_true",
help="List defined channels and exit"),
- Option("-c", "--channel", action="append",
+ Option("-c", "--channel", action="append",
help="Delete this channel (can be present multiple times)"),
Option("-u", "--unsubscribe", action="store_true",
help="Unsubscribe systems registered to the specified channels"),
@@ -157,7 +157,7 @@ def main():
def __serverCheck(labels, unsubscribe):
sql = """
select distinct S.org_id, S.id, S.name
- from rhnChannel c inner join
+ from rhnChannel c inner join
rhnServerChannel sc on c.id = sc.channel_id inner join
rhnServer s on s.id = sc.server_id
where c.label in (%s)
@@ -187,13 +187,13 @@ def __serverCheck(labels, unsubscribe):
print str(map['id']).ljust(14),
print(map['name'])
- return len(list)
+ return len(list)
def __unsubscribeServers(labels):
sql = """
select distinct sc.server_id as server_id, C.id as channel_id, c.parent_channel,
c.label
- from rhnChannel c inner join
+ from rhnChannel c inner join
rhnServerChannel sc on c.id = sc.channel_id
where c.label in (%s) order by C.parent_channel
"""
@@ -231,7 +231,7 @@ def __unsubscribeServers(labels):
def __kickstartCheck(labels):
sql = """
select K.org_id, K.label
- from rhnKSData K inner join
+ from rhnKSData K inner join
rhnKickstartDefaults KD on KD.kickstart_id = K.id inner join
rhnKickstartableTree KT on KT.id = KD.kstree_id inner join
rhnChannel c on c.id = KT.channel_id
@@ -250,7 +250,7 @@ def __kickstartCheck(labels):
"Please remove these or change their associated base channel.\n")
print('org_id'.ljust(8)),
print('label')
- print("-"*20)
+ print("-"*20)
for map in list:
print str(map['org_id']).ljust(8),
print(map['label'])
@@ -260,7 +260,7 @@ def __kickstartCheck(labels):
def __listChannels():
sql = """
- select c1.label, c2.label parent_channel
+ select c1.label, c2.label parent_channel
from rhnChannel c1 left outer join rhnChannel c2 on c1.parent_channel = c2.id
order by c2.label desc, c1.label asc
"""
@@ -286,7 +286,7 @@ def __listChannels():
def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0, skip_channels=0):
# Get the package ids
if not channelLabels:
- return
+ return
rpms_ids = list_packages(channelLabels, force=force, sources=0)
rpms_paths = _get_package_paths(rpms_ids, sources=0)
@@ -302,9 +302,9 @@ def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0,
skip_chan
# Get the channel ids
h = rhnSQL.prepare("""
- select id, parent_channel
- from rhnChannel
- where label = :label
+ select id, parent_channel
+ from rhnChannel
+ where label = :label
order by parent_channel""")
channel_ids = []
for label in channelLabels:
@@ -327,7 +327,7 @@ def delete_channels(channelLabels, force=0, justdb=0, skip_packages=0,
skip_chan
]
query = """
delete from %(table_2)s where %(link_field)s in (
- select id
+ select id
from %(table_1)s
where %(channel_field)s = :channel_id
)
@@ -459,7 +459,7 @@ def _delete_srpms(srcPackageIds):
def _delete_rpms(packageIds):
if not packageIds:
return
- group = 300
+ group = 300
toDel = packageIds[:]
print "Deleting package metadata (" + str(len(toDel)) + "):"
pb = ProgressBar(prompt='Removing: ', endTag=' - complete',
@@ -476,14 +476,14 @@ def _delete_rpms(packageIds):
def _delete_rpm_group(packageIds):
references = [
- 'rhnChannelPackage',
- 'rhnErrataPackage',
- 'rhnErrataPackageTMP',
- 'rhnPackageChangelogRec',
- 'rhnPackageConflicts',
- 'rhnPackageFile',
- 'rhnPackageObsoletes',
- 'rhnPackageProvides',
+ 'rhnChannelPackage',
+ 'rhnErrataPackage',
+ 'rhnErrataPackageTMP',
+ 'rhnPackageChangelogRec',
+ 'rhnPackageConflicts',
+ 'rhnPackageFile',
+ 'rhnPackageObsoletes',
+ 'rhnPackageProvides',
'rhnPackageRequires',
'rhnPackageRecommends',
'rhnPackageSuggests',