univention.updater package

Python tools for Updater and repository maintenance.

Submodules

univention.updater.commands module

Common commands to manage Debian packages.

univention.updater.commands.cmd_update = 'apt-get update'

Update package cache.

univention.updater.commands.cmd_show = 'apt-cache show'

Show package information.

univention.updater.commands.cmd_upgrade = 'apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-only=no --assume-yes --quiet=1 -u upgrade'

Upgrade only installed packages

univention.updater.commands.cmd_upgrade_sim = 'apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-only=no --assume-yes --quiet=1 -us upgrade'

Simulate upgrade only installed packages

univention.updater.commands.cmd_dist_upgrade = 'apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-only=no --assume-yes --quiet=1 -u dist-upgrade'

Upgrade system, may install new packages to satisfy dependencies

univention.updater.commands.cmd_dist_upgrade_sim = 'apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-only=no --assume-yes --quiet=1 -us dist-upgrade'

Simulate upgrade system, may install new packages to satisfy dependencies

univention.updater.commands.cmd_install = 'apt-get -o DPkg::Options::=--force-confold -o DPkg::Options::=--force-overwrite -o DPkg::Options::=--force-overwrite-dir --trivial-only=no --assume-yes --quiet=1 install'

Install packages

univention.updater.commands.cmd_remove = 'apt-get --yes remove'

Remove packages

univention.updater.commands.cmd_config = 'dpkg --configure -a'

Configure all pending packages

univention.updater.errors module

Univention Updater exceptions.

exception univention.updater.errors.UpdaterException[source]

Bases: exceptions.Exception

The root of all updater exceptions.

exception univention.updater.errors.RequiredComponentError(version, components)[source]

Bases: univention.updater.errors.UpdaterException

Signal required component not available.

Parameters:
  • version (str) – The UCS release version.
  • components (set(str)) – A list of components.
exception univention.updater.errors.PreconditionError(phase, order, component, script)[source]

Bases: univention.updater.errors.UpdaterException

Signal abort by release or component pre-/post-update script.

Parameters:
  • phase (str) – either preup or postup.
  • order (str) – either pre or main or post.
  • component (str) – The name of the component or None.
  • script (str) – The name of the failing script.
exception univention.updater.errors.DownloadError[source]

Bases: univention.updater.errors.UpdaterException

Signal temporary error in network communication.

exception univention.updater.errors.ConfigurationError[source]

Bases: univention.updater.errors.UpdaterException

Signal permanent error in configuration.

exception univention.updater.errors.VerificationError[source]

Bases: univention.updater.errors.ConfigurationError

Signal permanent error in script verification.

exception univention.updater.errors.CannotResolveComponentServerError(component, for_mirror_list)[source]

Bases: univention.updater.errors.ConfigurationError

Signal permanent error in component configuration.

Parameters:
  • component (str) – The name of the component.
  • for_mirror_list (bool) – True if the error happened while generating the list of repositories to mirror, False while generating the list of repositories for the server itself.
exception univention.updater.errors.ProxyError[source]

Bases: univention.updater.errors.ConfigurationError

Signal permanent error in proxy configuration.

exception univention.updater.errors.LockingError[source]

Bases: univention.updater.errors.UpdaterException

Signal other updater process running.

exception univention.updater.errors.UnmetDependencyError[source]

Bases: univention.updater.errors.UpdaterException

Signal unmet package dependencies

univention.updater.locking module

Univention Updater locking

class univention.updater.locking.UpdaterLock(timeout=0)[source]

Bases: object

Context wrapper for updater-lock /var/lock/univention-updater.

updater_lock_acquire()[source]

Acquire the updater-lock.

Returns:0 if it could be acquired within <timeout> seconds, >= 1 if locked by parent.
Return type:int
Raises:LockingError – otherwise.
updater_lock_release()[source]

Release the updater-lock.

Returns:True if it has been unlocked (or decremented when nested), False if it was already unlocked.
Return type:bool
_UpdaterLock__UPDATER_LOCK_FILE_NAME = '/var/lock/univention-updater'

univention.updater.mirror module

Mirror Univention repository server.

univention.updater.mirror.makedirs(dirname, mode=493)[source]

Recursively create directory hierarchy will all parent directories.

Parameters:
  • dirname (str) – Name of the directory to create.
  • mode (int) – Directory permissions.
class univention.updater.mirror.UniventionMirror(check_access=True)[source]

Bases: univention.updater.tools.UniventionUpdater

Create new mirror with settings from UCR.

Parameters:check_access (bool) – Check if repository server is reachable on init.
Raises:ConfigurationError – if configured server is not available immediately.
config_repository()[source]

Retrieve configuration to access repository. Overrides univention.updater.UniventionUpdater.

release_update_available(ucs_version=None, errorsto='stderr')[source]

Check if an update is available for the ucs_version.

Parameters:
  • ucs_version (str) – The UCS release to check.
  • errorsto (str) – Select method of reporting errors; on of ‘stderr’, ‘exception’, ‘none’.
Returns:

The next UCS release or None.

Return type:

str or None

mirror_repositories()[source]

Uses apt-mirror to copy a repository.

mirror_update_scripts()[source]

Mirrors the preup.sh and postup.sh scripts.

list_local_repositories(start=None, end=None, maintained=True, unmaintained=False)[source]

This function returns a sorted list of local (un)maintained repositories.

Parameters:
  • start (UCS_Version or None) – smallest version that shall be returned.
  • end (UCS_Version or None) – largest version that shall be returned.
  • maintained (bool) – True if list shall contain maintained repositories.
  • unmaintained (bool) – True if list shall contain unmaintained repositories.
Returns:

A sorted list of repositories as (directory, UCS_Version, is_maintained) tuples.

Return type:

list[tuple(str, UCS_Version, bool)]

run()[source]

starts the mirror process.

univention.updater.repo_url module

Univention Updater: UCR Repository Server URL

class univention.updater.repo_url.UcsRepoUrl(ucr, prefix, default=None)[source]

Bases: object

UCS repository server base URL.

>>> UcsRepoUrl({'_/server': 'hostname'}, '_').path
''
>>> UcsRepoUrl({'_/server': 'hostname', '_/prefix': '/p'}, '_').path
'/p/'
>>> UcsRepoUrl({'_/server': 'hostname', '_/prefix': 'path'}, '_').path
'/path/'
>>> UcsRepoUrl({}, '', UcsRepoUrl({'_/server': 'https://hostname/'}, '_')).private()
'https://hostname/'
>>> UcsRepoUrl({'_/server': 'hostname'}, '_', UcsRepoUrl({'_/server': 'https://hostname:80/'}, '_')).private()
'http://hostname/'
DEFAULT = 'https://updates.software-univention.de/'
cred
_port
_path
public()[source]

URI without credentials.

>>> UcsRepoUrl({'_/server': 'hostname'}, '_').public()
'http://hostname/'
>>> UcsRepoUrl({'_/server': 'hostname', '_/username': 'user', '_/password': 'pass'}, '_').public()
'http://hostname/'
>>> UcsRepoUrl({'_/server': 'https://hostname'}, '_').public()
'https://hostname/'
>>> UcsRepoUrl({'_/server': 'https://user:pass@hostname'}, '_').public()
'https://hostname/'
private()[source]

URI with credentials.

>>> UcsRepoUrl({'_/server': 'hostname'}, '_').private()
'http://hostname/'
>>> UcsRepoUrl({'_/server': 'hostname', '_/username': 'user', '_/password': 'pass'}, '_').private()
'http://user:pass@hostname/'
>>> UcsRepoUrl({'_/server': 'https://hostname'}, '_').private()
'https://hostname/'
>>> UcsRepoUrl({'_/server': 'https://user:pass@hostname'}, '_').private()
'https://user:pass@hostname/'

univention.updater.repository module

Univention Updater helper functions for managing a local repository.

class univention.updater.repository.TeeFile(fds=[])[source]

Bases: object

Writes the given string to several files at once. Could by used with the print statement

Register multiple file descriptors, to which the data is written.

Parameters:fds (list(File)) – A list of opened files.
write(data)[source]

Write string to all registered files.

Parameters:data (str) – The string to write.
univention.updater.repository.gzip_file(filename)[source]

Compress file.

Parameters:filename (str) – The file name of the file to compress.
Returns:the process exit code.
Return type:int
univention.updater.repository.copy_package_files(source_dir, dest_dir)[source]

Copy all Debian binary package files and signed updater scripts from source_dir to dest_dir.

Parameters:
  • source_dir (str) – Source directory.
  • dest_dir (str) – Destination directory.
univention.updater.repository.gen_indexes(base, version)[source]

Re-generate Debian Packages files from file:dists/ file.

Parameters:base (str) – Base directory, which contains the per architecture sub directories.
univention.updater.repository.get_repo_basedir(packages_dir)[source]

Check if a file path is a UCS package repository.

Parameters:package_dir (str) – A directory path.
Returns:The canonicalized path without the architecture sub directory.
Return type:str
univention.updater.repository.is_debmirror_installed()[source]

Check if the package univention-debmirror is installed.

Returns:a 2-tuple (status, error) where status is a boolean representing the state and error a optional error string - None otherwise.
Return type:tuple(bool, str or None)
univention.updater.repository.get_installation_version()[source]

Return UCS release version of local repository mirror.

Returns:The UCS releases which was last copied into the local repository.
Return type:str or None
univention.updater.repository.assert_local_repository(out=<open file '<stderr>', mode 'w'>)[source]

Exit with error if the local repository is not enabled.

Parameters:out (file) – Override error output. Defaults to sys.stderr.

univention.updater.tools module

Univention Update tools.

univention.updater.tools.verify_script(script, signature)[source]

Verify detached signature of script:

Parameters:
  • script (str) – The scipt text to verify.
  • signature (str) – The detached signature.
Returns:

None or the error output.

Return type:

None or str

class univention.updater.tools._UCSRepo(**kw)[source]

Bases: univention.updater.ucs_version.UCS_Version

Super class to build URLs for APT repositories.

_format(format)[source]

Format longest path for directory/file access.

class _substitution(format, values)[source]

Helper to print dynamically substituted variable.

>>> h={'major':2}
>>> h['version'] = _UCSRepo._substitution('%(major)d.%(minor)d', h)
>>> h['minor'] = 3
>>> '%(version)s' % h
'2.3'
_UCSRepo.deb(server, type='deb')[source]

Format for /etc/apt/sources.list.

Parameters:
  • server (str) – The URL of the repository server.
  • type (str) – The repository type, e.g. deb for a binary and deb-src for source package repository.
Returns:

The APT repository stanza.

Return type:

str

_UCSRepo.path(filename=None)[source]

Format pool for directory/file access.

Parameters:filename – The name of a file in the repository.
Returns:relative path.
Return type:str
_UCSRepo.clean(server)[source]

Format for /etc/apt/mirror.list

Parameters:server (str) – The URL of the repository server.
Returns:The APT repository stanza.
Return type:str
class univention.updater.tools.UCSRepoPool(**kw)[source]

Bases: univention.updater.tools._UCSRepo

Flat Debian APT repository.

deb(server, type='deb')[source]

Format for /etc/apt/sources.list.

Parameters:
  • server (str) – The URL of the repository server.
  • type (str) – The repository type, e.g. deb for a binary and deb-src for source package repository.
Returns:

The APT repository stanza.

Return type:

str

>>> r=UCSRepoPool(major=2,minor=3,patchlevel=1,part='maintained',arch='i386')
>>> r.deb('https://updates.software-univention.de/')
'deb https://updates.software-univention.de/2.3/maintained/ 2.3-1/i386/'
path(filename=None)[source]

Format pool for directory/file access.

Parameters:filename – The name of a file in the repository.
Returns:relative path.
Return type:str
>>> UCSRepoPool(major=2,minor=3).path()
'2.3/'
>>> UCSRepoPool(major=2,minor=3,part='maintained').path()
'2.3/maintained/'
>>> UCSRepoPool(major=2,minor=3,patchlevel=1,part='maintained').path()
'2.3/maintained/2.3-1/'
>>> UCSRepoPool(major=2,minor=3,patchlevel=1,part='maintained',arch='i386').path()
'2.3/maintained/2.3-1/i386/Packages.gz'
clean(server)[source]

Format for /etc/apt/mirror.list

Parameters:server (str) – The URL of the repository server.
Returns:The APT repository stanza.
Return type:str
class univention.updater.tools.UCSRepoPoolNoArch(**kw)[source]

Bases: univention.updater.tools._UCSRepo

Flat Debian APT repository without explicit architecture subdirectory.

deb(server, type='deb')[source]

Format for /etc/apt/sources.list.

Parameters:
  • server (str) – The URL of the repository server.
  • type (str) – The repository type, e.g. deb for a binary and deb-src for source package repository.
Returns:

The APT repository stanza.

Return type:

str

>>> r=UCSRepoPoolNoArch(major=2,minor=3,patch='comp',part='maintained/component',arch='all')
>>> r.deb('https://updates.software-univention.de/')
'deb https://updates.software-univention.de/2.3/maintained/component/comp/ ./'
path(filename=None)[source]

Format pool for directory/file access. Returns relative path.

Parameters:filename – The name of a file in the repository.
Returns:relative path.
Return type:str
>>> UCSRepoPoolNoArch(major=2,minor=3).path()
'2.3/'
>>> UCSRepoPoolNoArch(major=2,minor=3,part='maintained/component').path()
'2.3/maintained/component/'
>>> UCSRepoPoolNoArch(major=2,minor=3,part='maintained/component',patch='comp').path()
'2.3/maintained/component/comp/Packages.gz'
>>> UCSRepoPoolNoArch(major=2,minor=3,part='maintained/component',patch='comp',arch='all').path()
'2.3/maintained/component/comp/Packages.gz'
clean(server)[source]

Format for /etc/apt/mirror.list

Parameters:server (str) – The URL of the repository server.
Returns:The APT repository stanza.
Return type:str
class univention.updater.tools.UCSRepoDist(**kw)[source]

Bases: univention.updater.tools._UCSRepo

Debian APT repository using ‘suites’.

Attention

UCS-2.x used a different and broken layout!

deb(server, type='deb')[source]

Format for /etc/apt/sources.list.

Parameters:
  • server (str) – The URL of the repository server.
  • type (str) – The repository type, e.g. deb for a binary and deb-src for source package repository.
Returns:

The APT repository stanza.

Return type:

str

>>> r=UCSRepoDist(major=4,minor=3,patchlevel=1,part='maintained')
>>> r.deb('https://updates.software-univention.de/')
'deb https://updates.software-univention.de/4.3/maintained/4.3-1/ ucs431 main main/debian-installer'
path(filename=None)[source]

Format dist for directory/file access.

Parameters:filename – The name of a file in the repository.
Returns:relative path.
Return type:str
>>> UCSRepoDist(major=4,minor=3).path()
'4.3/'
>>> UCSRepoDist(major=4,minor=3,part='maintained').path()
'4.3/maintained/'
>>> UCSRepoDist(major=4,minor=3,patchlevel=1,part='maintained').path()
'4.3/maintained/4.3-1/dists/ucs431/main/'
>>> UCSRepoDist(major=4,minor=3,patchlevel=1,part='maintained',arch='i386').path()
'4.3/maintained/4.3-1/dists/ucs431/main/binary-i386/Packages.gz'
class univention.updater.tools._UCSServer[source]

Bases: object

Abstrace base class to access UCS compatible update server.

classmethod load_credentials(ucr)[source]

Load credentials from UCR.

Parameters:ucr (ConfigRegistry) – An UCR instance.
join(rel)[source]

Return joined URI without credential.

Parameters:rel (str) – relative URI.
Returns:The joined URI.
Return type:str
access(repo, filename=None, get=False)[source]

Access URI and optionally get data.

Parameters:
  • repo (_UCSRepo) – the URI to access as an instance of _UCSRepo.
  • filename (str) – An optional relative path.
  • get (bool) – Fetch data if True - otheriwse check only.
Returns:

a 3-tuple (code, size, content) or None on errors.

Return type:

tuple(int, int, str)

Raises:
  • DownloadError – if the server is unreachable.
  • ValueError – if the credentials use an invalid encoding.
  • ConfigurationError – if a permanent error in the configuration occurs, e.g. the credentials are invalid or the host is unresolvable.
  • ProxyError – if the HTTP proxy returned an error.
class univention.updater.tools.UCSHttpServer(baseurl, user_agent=None, timeout=None)[source]

Bases: univention.updater.tools._UCSServer

Access to UCS compatible remote update server.

Setup URL handler for accessing a UCS repository server.

Parameters:
  • baseurl (UcsRepoUrl) – the base URL.
  • user_agent (str) – optional user agent string.
  • timeout (int) – optional timeout for network access.
class HTTPHeadHandler[source]

Bases: urllib2.BaseHandler

Handle fallback from HEAD to GET if unimplemented.

http_error_501(req, fp, code, msg, headers)[source]
UCSHttpServer.log = <celery.utils.log.ProcessAwareLogger object>
UCSHttpServer.http_method = 'HEAD'
UCSHttpServer.head_handler = <univention.updater.tools.HTTPHeadHandler instance>
UCSHttpServer.password_manager = <urllib2.HTTPPasswordMgrWithDefaultRealm instance>
UCSHttpServer.auth_handler = <urllib2.HTTPBasicAuthHandler instance>
UCSHttpServer.proxy_handler = <urllib2.ProxyHandler instance>
UCSHttpServer.opener = <urllib2.OpenerDirector instance>
UCSHttpServer.failed_hosts = set([])
UCSHttpServer.prefix
classmethod UCSHttpServer.reinit()[source]

Reload proxy settings and reset failed hosts.

classmethod UCSHttpServer.load_credentials(ucr)[source]

Load credentials from UCR.

Parameters:ucr (ConfigRegistry) – An UCR instance.
UCSHttpServer.join(rel)[source]

Return joined URI without credential.

Parameters:rel (str) – relative URI.
Returns:The joined URI.
Return type:str
UCSHttpServer.access(repo, filename=None, get=False)[source]

Access URI and optionally get data.

Parameters:
  • repo (_UCSRepo) – the URI to access as an instance of _UCSRepo.
  • filename (str) – An optional relative path.
  • get (bool) – Fetch data if True - otheriwse check only.
Returns:

a 3-tuple (code, size, content)

Return type:

tuple(int, int, str)

Raises:
  • DownloadError – if the server is unreachable.
  • ValueError – if the credentials use an invalid encoding.
  • ConfigurationError – if a permanent error in the configuration occurs, e.g. the credentials are invalid or the host is unresolvable.
  • ProxyError – if the HTTP proxy returned an error.
class univention.updater.tools.UCSLocalServer(prefix)[source]

Bases: univention.updater.tools._UCSServer

Access to UCS compatible local update server.

Setup URL handler for accessing a UCS repository server.

Parameters:prefix (str) – The local path of the repository.
join(rel)[source]

Return joined URI without credential.

Parameters:rel (str) – relative URI.
Returns:The joined URI.
Return type:str
access(repo, filename=None, get=False)[source]

Access URI and optionally get data.

Parameters:
  • repo (_UCSRepo) – the URI to access as an instance of _UCSRepo.
  • filename (str) – An optional relative path.
  • get (bool) – Fetch data if True - otherwise check only.
Returns:

a 3-tuple (code, size, content)

Return type:

tuple(int, int, str)

Raises:
  • DownloadError – if the server is unreachable.
  • ValueError – if the credentials use an invalid encoding.
  • ConfigurationError – if a permanent error in the configuration occurs, e.g. the credentials are invalid or the host is unresolvable.
  • ProxyError – if the HTTP proxy returned an error.
class univention.updater.tools.UniventionUpdater(check_access=True)[source]

Handle UCS package repositories.

Create new updater with settings from UCR.

Parameters:check_access (bool) – Check if repository server is reachable on init.
Raises:ConfigurationError – if configured server is not available immediately.
COMPONENT_AVAILABLE = 'available'
COMPONENT_NOT_FOUND = 'not_found'
COMPONENT_DISABLED = 'disabled'
COMPONENT_UNKNOWN = 'unknown'
COMPONENT_PERMISSION_DENIED = 'permission_denied'
FN_UPDATER_APTSOURCES_COMPONENT = '/etc/apt/sources.list.d/20_ucs-online-component.list'
config_repository()[source]

Retrieve configuration to access repository. Overridden by univention.updater.UniventionMirror.

ucr_reinit()[source]

Re-initialize settings.

get_next_version(version, components=[], errorsto='stderr')[source]

Check if a new patchlevel, minor or major release is available for the given version. Components must be available for the same major.minor version.

Parameters:
  • version (UCS_Version) – A UCS release version.
  • components (list[str]) – A list of component names, which must be available for the next release.
  • errorsto (str) – Select method of reporting errors; on of ‘stderr’, ‘exception’, ‘none’.
Returns:

The next UCS release or None.

Return type:

str or None

Raises:

RequiredComponentError – if a required component is missing

get_all_available_release_updates(ucs_version=None)[source]

Returns a list of all available release updates - the function takes required components into account and stops if a required component is missing

Parameters:ucs_version (UCS_Version or None) – starts travelling through available version from version.
Returns:a list of 2-tuple (versions, blocking_component), where versions is a list of UCS release and blocking_component is the first missing component blocking the update.
Return type:tuple(list[str], str or None)
release_update_available(ucs_version=None, errorsto='stderr')[source]

Check if an update is available for the ucs_version.

Parameters:
  • ucs_version (str) – The UCS release to check.
  • errorsto (str) – Select method of reporting errors; on of ‘stderr’, ‘exception’, ‘none’.
Returns:

The next UCS release or None.

Return type:

str or None

release_update_temporary_sources_list(version, components=None)[source]

Return list of Debian repository statements for the release update including all enabled components.

Parameters:
  • version (str) – The UCS release.
  • components (list or None) – A list of required component names or None.
Returns:

A list of Debian APT sources.list lines.

Return type:

list[str]

current_version

Return current (major.minor-patchlevel) version.

Returns:The current UCS release.
Return type:UCS_Version
get_ucs_version()[source]

Return current (major.minor-patchlevel) version as string.

Returns:The current UCS release.
Return type:str
get_components(only_localmirror_enabled=False)[source]

Retrieve all enabled components from registry as set(). By default, only “enabled” components will be returned (repository/online/component/%s=$TRUE).

Parameters:only_localmirror_enabled (bool) – Only the components enabled for local mirroring. If only_`localmirror`_enabled is True, then all components with repository/online/component/%s/localmirror=$TRUE will be returned. If repository/online/component/%s/localmirror is not set, then the value of repository/online/component/%s is used for backward compatibility.
Returns:The set of enabled components.
Return type:set(str)
get_current_components()[source]

Return set() of all components marked as current.

Returns:Set of component names marked as current.
Return type:set(str)
get_all_components()[source]

Retrieve all configured components from registry as set().

Returns:Set of component names.
Return type:set(str)
get_component(name)[source]

Retrieve named component from registry as hash.

Parameters:name (str) – The name of the component.
Returns:A dictionary containsing the component specific settions.
Return type:dict(str, str)
get_current_component_status(name)[source]

Returns the current status of specified component based on /etc/apt/sources.list.d/20_ucs-online-component.list

Parameters:name (str) – The name of the component.
Returns:One of the strings:
COMPONENT_DISABLED
component has been disabled via UCR
COMPONENT_AVAILABLE
component is enabled and at least one valid repo string has been found in .list file
COMPONENT_NOT_FOUND
component is enabled but no valid repo string has been found in .list file
COMPONENT_PERMISSION_DENIED
component is enabled but authentication failed
COMPONENT_UNKNOWN
component’s status is unknown
Return type:str
get_component_defaultpackage(componentname)[source]

Returns a set of (meta) package names to be installed for this component.

Parameters:componentname (str) – The name of the component.
Returns:a set of package names.
Return type:set(str)
is_component_defaultpackage_installed(componentname, ignore_invalid_package_names=True)[source]

Returns installation status of component’s default packages

Parameters:
  • componentname (str) – The name of the component.
  • ignore_invalid_package_names (bool) – Ignore invalid package names.
Returns:

On of the values:

None

no default packages are defined

True

all default packages are installed

False

at least one package is not installed

Return type:

None or bool

Raises:

ValueError – if UCR variable contains invalid package names if ignore_invalid_package_names=False

component_update_available()[source]

Check if any component has new or upgradeable packages available.

Returns:True if updates are pending, False otherwise.
Return type:bool
component_update_get_packages()[source]

Return tuple with list of (new, upgradeable, removed) packages.

Returns:A 3-tuple (new, upgraded, removed).
Return type:tuple(list[str], list[str], list[str])
run_dist_upgrade()[source]

Run apt-get dist-upgrade command.

Returns:a 3-tuple (return_code, stdout, stderr)
Return type:tuple(int, str, str)
_iterate_release(ver, start, end)[source]

Iterate through all versions of repositories between start and end.

Parameters:
  • ver (UCSRepo) – An instance of UCS_Version used for iteration.
  • start (UCS_Version) – The UCS release to start from.
  • end (UCS_Version) – The UCS release where to stop.
_iterate_versions(ver, start, end, parts, archs, server)[source]

Iterate through all versions of repositories between start and end.

Parameters:
  • ver (UCSRepo) – An instance of UCS_Version used for iteration.
  • start (UCS_Version) – The UCS release to start from.
  • end (UCS_Version) – The UCS release where to stop.
  • parts (list[str]) – List of maintained and/or unmaintained.
  • archs (list[str]) – List of architectures.
  • server (UCSHttpServer) – The UCS repository server to use.
Returns:

A iterator throug all UCS releases between start and end returning ver.

Raises:

ProxyError – if the repository server is blocked by the proxy.

_iterate_version_repositories(start, end, parts, archs, dists=False)[source]

Iterate over all UCS releases and return (server, version).

Parameters:
  • start (UCS_Version) – The UCS release to start from.
  • end (UCS_Version) – The UCS release where to stop.
  • parts (list[str]) – List of maintained and/or unmaintained.
  • archs (list[str]) – List of architectures without all.
  • dists (bool) – Also return UCSRepoDist repositories before UCSRepoPool
Returns:

A iterator returning 2-tuples (server, ver).

_iterate_component_repositories(components, start, end, archs, for_mirror_list=False)[source]

Iterate over all components and return (server, version).

Para components:
 

List of component names.

Parameters:
  • start (UCS_Version) – The UCS release to start from.
  • end (UCS_Version) – The UCS release where to stop.
  • archs (list[str]) – List of architectures without all.
  • for_mirror_list (bool) – Use the settings for mirroring.
Returns:

A iterator returning 2-tuples (server, ver).

print_version_repositories(clean=False, dists=False, start=None, end=None)[source]

Return a string of Debian repository statements for all UCS versions between start and end.

Parameters:
  • clean (bool) – Add additional clean statements for apt-mirror.
  • dists (bool) – Also return UCSRepoDist repositories before UCSRepoPool
  • start (UCS_Version) – Start UCS release. Defaults to (major, 0, 0).
  • end (UCS_Version) – End UCS release. Defaults to (major, minor, patchlevel).
Returns:

A string with APT statement lines.

Return type:

str

_get_component_baseurl(component, for_mirror_list=False)[source]

Calculate the base URL for a component.

Parameters:
  • component (str) – Name of the component.
  • for_mirror_list (bool) – Use external or local repository.
CS (component server)
value of repository/online/component/%s/server
MS (mirror server)
value of repository/mirror/server
RS (repository server)
value of repository/online/server
-
value is unset or no entry
/blank/
value is irrelevant
UCR configuration Result  
isRepoServer enabled localmirror server sources.list mirror.list
False False False - - - no local repository mirror
True   - RS -
True   CS CS -
True False False   - - local repository mirror
False True - - MS
False True CS - CS
True False - MS -
True False CS CS -
True True - RS MS
True True CS RS CS
False - - - - backward compabibility [1]
True - RS MS
True CS RS CS
[1]if repository/online/component/%s/localmirror is unset, then the value of repository/online/component/%s will be used to achieve backward compatibility.
_get_component_server(component, for_mirror_list=False)[source]

Return UCSHttpServer for component as configures via UCR.

Parameters:
  • component (str) – Name of the component.
  • for_mirror_list (bool) – component entries for mirror.list will be returned, otherwise component entries for local sources.list.
Returns:

The repository server for the component.

Return type:

UCSHttpServer

Raises:

ConfigurationError – if the configured server is not useable.

_get_component_versions(component, start, end)[source]

Return configured versions for component.

Parameters:
  • component (str) – Name of the component.
  • start (UCS_Version) – smallest version that shall be returned.
  • end (UCS_Version) – largest version that shall be returned.
Returns:

A set of UCR release versions for which the component is enabled.

Return type:

set(UCS_Version)

For each component the UCR variable repository/online/component/%s/version is evaluated, which can be a space/comma separated combination of the following values:

current
required component; must exist for requested version.
/empty/
optional component; used when exists for requested version.
/major.minor/
use exactly this version.
get_component_repositories(component, versions, clean=False, debug=True, for_mirror_list=False)[source]

Return list of Debian repository statements for requested component.

Parameters:
  • component (str) – The name of the component.
  • versions (list[str] or list[UCS_Version].) – A list of UCS releases.
  • clean (bool) – Add additional clean statements for apt-mirror.
  • debug (bool) – UNUSED.
  • for_mirror_list (bool) – component entries for mirror.list will be returned, otherwise component entries for local sources.list.
Returns:

A list of strings with APT statements.

Return type:

list(str)

_releases_in_range(start=None, end=None)[source]

Find all $major.$minor releases between start [$major.0] and end [$major.$minor] including.

Parameters:
Returns:

A list of available UCS releases between start and end.

Return type:

list[UCS_Version]

print_component_repositories(clean=False, start=None, end=None, for_mirror_list=False)[source]

Return a string of Debian repository statements for all enabled components.

Parameters:
  • clean (bool) – Add additional clean statements for apt-mirror if enabled by UCRV repository/online/component/%s/clean.
  • start (UCS_Version) – optional smallest UCS release to return.
  • end (UCS_Version) – optional largest UCS release to return.
  • for_mirror_list (bool) – component entries for mirror.list will be returned, otherwise component entries for local sources.list.
Returns:

A string with APT statement lines.

Return type:

str

_get_user_agent_string()[source]

Return the HTTP user agent string encoding the enabled components.

Returns:A HTTP user agent string.
Return type:str
static call_sh_files(scripts, logname, *args)[source]

Get pre- and postup.sh files and call them in the right order:

u = UniventionUpdater()
ver = u.current_version
struct = u._iterate_version_repositories(ver, ver, u.parts, u.architectures)
struct = u._iterate_component_repositories(['ucd'], ver, ver, u.architectures)
scripts = u.get_sh_files(struct)
next_ver = u.get_next_version(u.current_version)
for phase, order in u.call_sh_files(scripts, '/var/log/univention/updater.log', next_ver):
  if (phase, order) == ('update', 'main'):
    pass
Parameters:
  • scripts – A generator returing the script to call, e.g. get_sh_files()
  • logname (str) – The file name of the log file.
  • args – Additional arguments to pass through to the scripts.
Returns:

A generator returning 2-tuples (phase, part)

static get_sh_files(repositories, verify=False)[source]

Return all preup- and postup-scripts of repositories.

Parameters:
  • repositories – iteratable (server, struct)s
  • verify (bool) – Verify the PGP signature of the downloaded scripts.
Returns:

iteratable (server, struct, phase, path, script)

Raises:

VerificationError – if the PGP signature is invalid.

See call_sh_files() for an example.

class univention.updater.tools.LocalUpdater[source]

Bases: univention.updater.tools.UniventionUpdater

Direct file access to local repository.

univention.updater.ucs_version module

Univention Updater: UCS Release version

class univention.updater.ucs_version.UCS_Version(version)[source]

Bases: object

Version object consisting of major-, minor-number and patch-level

Parameters:version (list(int) or tuple(int) or str or UCS_Version) – must a str matching the pattern X.Y-Z or a triple with major, minor and patchlevel.
Raises:TypeError – if the version cannot be parsed.
>>> v = UCS_Version((2,3,1))
>>> UCS_Version([2,3,1]) == v
True
>>> UCS_Version("2.3-1") == v
True
>>> UCS_Version(u"2.3-1") == v
True
>>> UCS_Version(v) == v
True
FORMAT = '%(major)d.%(minor)d'
FULLFORMAT = '%(major)d.%(minor)d-%(patchlevel)d'
_regexp = <_sre.SRE_Pattern object>
mm

2-tuple (major, minor) version

mmp

3-tuple (major, minor, patch-level) version

set(version)[source]

Parse string and set version.

Parameters:verion (str) – A UCS release version string.
Raises:ValueError – if the string is not a valid UCS release version string.