Index: scripts/univention-rename-app =================================================================== --- scripts/univention-rename-app (Revision 0) +++ scripts/univention-rename-app (Revision 0) @@ -0,0 +1,91 @@ +#!/usr/bin/python2.6 +# -*- coding: utf-8 -*- +# +# Univention App Center +# univention-rename-app +# +# Copyright 2014 Univention GmbH +# +# http://www.univention.de/ +# +# All rights reserved. +# +# The source code of this program is made available +# under the terms of the GNU Affero General Public License version 3 +# (GNU AGPL V3) as published by the Free Software Foundation. +# +# Binary versions of this program provided by Univention to you as +# well as other copyrighted, protected or trademarked materials like +# Logos, graphics, fonts, specific documentations and configurations, +# cryptographic keys etc. are subject to a license agreement between +# you and Univention and not subject to the GNU AGPL V3. +# +# In the case you use this program under the terms of the GNU AGPL V3, +# the program is provided 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License with the Debian GNU/Linux or Univention distribution in file +# /usr/share/common-licenses/AGPL-3; if not, see +# . +# + +import sys +from optparse import OptionParser + +from univention.lib.package_manager import PackageManager +from univention.updater import UniventionUpdater +from univention.config_registry import ConfigRegistry +from univention.management.console.modules.appcenter.util import ComponentManager, install_opener +from univention.management.console.modules.appcenter.app_center import Application + +ucr = ConfigRegistry() +ucr.load() + +def rename(old_id, new_id): + install_opener(ucr) + app = Application.find(old_id) + if not app: + app = Application.find(new_id) + if not app: + sys.stderr.write('Found neither OLD_ID nor NEW_ID.\n') + raise ValueError() + uu = UniventionUpdater(False) + component_manager = ComponentManager(ucr, uu) + package_manager = PackageManager(lock=False) + + if not app.is_installed(package_manager, strict=False): + sys.stdout.write('%s is not installed. Fine, nothing to do.\n' % app.name) + return + + app.set_id(old_id) + app.unregister_all_and_register(None, component_manager, package_manager) + app.tell_ldap(ucr, package_manager, inform_about_error=False) + + app.set_id(new_id) + app.register(component_manager, package_manager) + app.tell_ldap(ucr, package_manager, inform_about_error=False) + +if __name__ == '__main__': + usage = '%prog OLD_ID NEW_ID' + description = '%prog changes the internal ID of an application. This means:' \ + '(1) unregister OLD_ID, remove from LDAP' \ + '(2) register NEW_ID, add to LDAP' + parser = OptionParser(usage=usage, description=description) + options, args = parser.parse_args() + try: + old_id, new_id = args + except ValueError: + parser.print_usage() + sys.exit(1) + try: + rename(old_id, new_id) + except Exception as exc: + sys.stderr.write('univention-rename-app did not succeed.\n') + sys.exit(1) + else: + sys.stdout.write('Rename done.\n') + sys.exit(0) + Index: debian/univention-management-console-module-appcenter.install =================================================================== --- debian/univention-management-console-module-appcenter.install (Revision 47811) +++ debian/univention-management-console-module-appcenter.install (Arbeitskopie) @@ -2,3 +2,4 @@ ldap/*.schema usr/share/univention-management-console-module-appcenter ldap/*.acl usr/share/univention-management-console-module-appcenter scripts/univention-register-apps usr/sbin/ +scripts/univention-rename-app usr/sbin/ Index: debian/univention-management-console-module-appcenter.postinst =================================================================== --- debian/univention-management-console-module-appcenter.postinst (Revision 47751) +++ debian/univention-management-console-module-appcenter.postinst (Arbeitskopie) @@ -70,5 +70,9 @@ " fi +if dpkg --compare-versions "$2" lt-nl 3.0.51-3; then + /usr/sbin/univention-rename-app tine20org tine20 +fi + exit 0 Index: umc/python/appcenter/app_center.py =================================================================== --- umc/python/appcenter/app_center.py (Revision 48083) +++ umc/python/appcenter/app_center.py (Arbeitskopie) @@ -341,12 +341,14 @@ if self.get(ikey): self._options[ikey] = urljoin('%s/' % self.get_metainf_url(), self.get(ikey)) + # versions will be set to something meaningful by Application.all() + self.versions = [self] + # save important meta data - self.id = self._options['id'] = self._options['id'].lower() + self.id = self.ldap_id = self.ldap_container = None + self.set_id(self._options['id']) self.name = self._options['name'] self.version = self._options['version'] - self.ldap_container = 'cn=%s,cn=apps,cn=univention,%s' % (self.id, ucr.get('ldap/base')) - self.ldap_id = '%s_%s' % (self.id, self.version) # get the name of the component m = self._reg_component_id.match(url) @@ -368,6 +370,18 @@ # is set by all() self.candidate = None + def set_id(self, app_id, recursive=True): + if recursive: + for iapp in self.versions: + # will call also for self! + iapp.set_id(app_id, recursive=False) + else: + app_id = app_id.lower() + self.id = app_id + self._options['id'] = app_id + self.ldap_id = '%s_%s' % (self.id, self.get('version')) + self.ldap_container = 'cn=%s,cn=apps,cn=univention,%s' % (self.id, ucr.get('ldap/base')) + def get(self, key): '''Helper function to access configuration elements of the application's .ini file. If element is not given, returns (for string elements) an empty string. Index: umc/js/de.po =================================================================== --- umc/js/de.po (Revision 48029) +++ umc/js/de.po (Arbeitskopie) @@ -1019,9 +1019,6 @@ #~ "aus, nachdem Sie die Applikation auf diesem System installiert " #~ "haben." -#~ msgid "Buy" -#~ msgstr "Kaufen" - #~ msgid "Categories" #~ msgstr "Kategorien"