View | Details | Raw Unified | Return to bug 33728 | Differences between
and this patch

Collapse All | Expand All

(-)scripts/univention-rename-app (+91 lines)
Line 0    Link Here 
1
#!/usr/bin/python2.6
2
# -*- coding: utf-8 -*-
3
#
4
# Univention App Center
5
#  univention-rename-app
6
#
7
# Copyright 2014 Univention GmbH
8
#
9
# http://www.univention.de/
10
#
11
# All rights reserved.
12
#
13
# The source code of this program is made available
14
# under the terms of the GNU Affero General Public License version 3
15
# (GNU AGPL V3) as published by the Free Software Foundation.
16
#
17
# Binary versions of this program provided by Univention to you as
18
# well as other copyrighted, protected or trademarked materials like
19
# Logos, graphics, fonts, specific documentations and configurations,
20
# cryptographic keys etc. are subject to a license agreement between
21
# you and Univention and not subject to the GNU AGPL V3.
22
#
23
# In the case you use this program under the terms of the GNU AGPL V3,
24
# the program is provided in the hope that it will be useful,
25
# but WITHOUT ANY WARRANTY; without even the implied warranty of
26
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
# GNU Affero General Public License for more details.
28
#
29
# You should have received a copy of the GNU Affero General Public
30
# License with the Debian GNU/Linux or Univention distribution in file
31
# /usr/share/common-licenses/AGPL-3; if not, see
32
# <http://www.gnu.org/licenses/>.
33
#
34
35
import sys
36
from optparse import OptionParser
37
38
from univention.lib.package_manager import PackageManager
39
from univention.updater import UniventionUpdater
40
from univention.config_registry import ConfigRegistry
41
from univention.management.console.modules.appcenter.util import ComponentManager, install_opener
42
from univention.management.console.modules.appcenter.app_center import Application
43
44
ucr = ConfigRegistry()
45
ucr.load()
46
47
def rename(old_id, new_id):
48
	install_opener(ucr)
49
	app = Application.find(old_id)
50
	if not app:
51
		app = Application.find(new_id)
52
	if not app:
53
		sys.stderr.write('Found neither OLD_ID nor NEW_ID.\n')
54
		raise ValueError()
55
	uu = UniventionUpdater(False)
56
	component_manager = ComponentManager(ucr, uu)
57
	package_manager = PackageManager(lock=False)
58
59
	if not app.is_installed(package_manager, strict=False):
60
		sys.stdout.write('%s is not installed. Fine, nothing to do.\n' % app.name)
61
		return
62
63
	app.set_id(old_id)
64
	app.unregister_all_and_register(None, component_manager, package_manager)
65
	app.tell_ldap(ucr, package_manager, inform_about_error=False)
66
67
	app.set_id(new_id)
68
	app.register(component_manager, package_manager)
69
	app.tell_ldap(ucr, package_manager, inform_about_error=False)
70
71
if __name__ == '__main__':
72
	usage = '%prog OLD_ID NEW_ID'
73
	description = '%prog changes the internal ID of an application. This means:' \
74
		'(1) unregister OLD_ID, remove from LDAP' \
75
		'(2) register NEW_ID, add to LDAP'
76
	parser = OptionParser(usage=usage, description=description)
77
	options, args = parser.parse_args()
78
	try:
79
		old_id, new_id = args
80
	except ValueError:
81
		parser.print_usage()
82
		sys.exit(1)
83
	try:
84
		rename(old_id, new_id)
85
	except Exception as exc:
86
		sys.stderr.write('univention-rename-app did not succeed.\n')
87
		sys.exit(1)
88
	else:
89
		sys.stdout.write('Rename done.\n')
90
		sys.exit(0)
91
(-)debian/univention-management-console-module-appcenter.install (+1 lines)
 Lines 2-4    Link Here 
2
ldap/*.schema usr/share/univention-management-console-module-appcenter
2
ldap/*.schema usr/share/univention-management-console-module-appcenter
3
ldap/*.acl usr/share/univention-management-console-module-appcenter
3
ldap/*.acl usr/share/univention-management-console-module-appcenter
4
scripts/univention-register-apps usr/sbin/
4
scripts/univention-register-apps usr/sbin/
5
scripts/univention-rename-app usr/sbin/
(-)debian/univention-management-console-module-appcenter.postinst (+4 lines)
 Lines 70-74    Link Here 
70
"
70
"
71
fi
71
fi
72
72
73
if dpkg --compare-versions "$2" lt-nl 3.0.51-3; then
74
	/usr/sbin/univention-rename-app tine20org tine20
75
fi
76
73
exit 0
77
exit 0
74
78
(-)umc/python/appcenter/app_center.py (-3 / +17 lines)
 Lines 341-352    Link Here 
341
			if self.get(ikey):
341
			if self.get(ikey):
342
				self._options[ikey] = urljoin('%s/' % self.get_metainf_url(), self.get(ikey))
342
				self._options[ikey] = urljoin('%s/' % self.get_metainf_url(), self.get(ikey))
343
343
344
		# versions will be set to something meaningful by Application.all()
345
		self.versions = [self]
346
344
		# save important meta data
347
		# save important meta data
345
		self.id = self._options['id'] = self._options['id'].lower()
348
		self.id = self.ldap_id = self.ldap_container = None
349
		self.set_id(self._options['id'])
346
		self.name = self._options['name']
350
		self.name = self._options['name']
347
		self.version = self._options['version']
351
		self.version = self._options['version']
348
		self.ldap_container = 'cn=%s,cn=apps,cn=univention,%s' % (self.id, ucr.get('ldap/base'))
349
		self.ldap_id = '%s_%s' % (self.id, self.version)
350
352
351
		# get the name of the component
353
		# get the name of the component
352
		m = self._reg_component_id.match(url)
354
		m = self._reg_component_id.match(url)
 Lines 368-373    Link Here 
368
		# is set by all()
370
		# is set by all()
369
		self.candidate = None
371
		self.candidate = None
370
372
373
	def set_id(self, app_id, recursive=True):
374
		if recursive:
375
			for iapp in self.versions:
376
				# will call also for self!
377
				iapp.set_id(app_id, recursive=False)
378
		else:
379
			app_id = app_id.lower()
380
			self.id = app_id
381
			self._options['id'] = app_id
382
			self.ldap_id = '%s_%s' % (self.id, self.get('version'))
383
			self.ldap_container = 'cn=%s,cn=apps,cn=univention,%s' % (self.id, ucr.get('ldap/base'))
384
371
	def get(self, key):
385
	def get(self, key):
372
		'''Helper function to access configuration elements of the application's .ini
386
		'''Helper function to access configuration elements of the application's .ini
373
		file. If element is not given, returns (for string elements) an empty string.
387
		file. If element is not given, returns (for string elements) an empty string.
(-)umc/js/de.po (-3 lines)
 Lines 1019-1027    Link Here 
1019
#~ "aus, <em>nachdem</em> Sie die Applikation auf diesem System installiert "
1019
#~ "aus, <em>nachdem</em> Sie die Applikation auf diesem System installiert "
1020
#~ "haben."
1020
#~ "haben."
1021
1021
1022
#~ msgid "Buy"
1023
#~ msgstr "Kaufen"
1024
1025
#~ msgid "Categories"
1022
#~ msgid "Categories"
1026
#~ msgstr "Kategorien"
1023
#~ msgstr "Kategorien"
1027
1024

Return to bug 33728