libka.pkgedit namespace

Submodules

libka.pkgedit.ka_changelog module

This module just provides the KAChangelog class

class libka.pkgedit.ka_changelog.KAChangelog(file_path='debian/changelog')[source]

Bases: Changelog

This class is meant to represent a debian/changelog file.

add_ppa_suffix(dist, suffix_number)[source]

This method will append to the package version a suffix following this formula:

~ubuntu<dist_version>~ppa<suffix_number>

It will also set the distribution name in the top changelog block.

add_qt_ppa_suffix(dist, end_number, begin_number=0)[source]

This method will append to the package version a suffix following this formula:

~<begin_number>~ubuntu<dist_version>~ppa<end_number>

It will also set the distribution name in the top changelog block.

add_tritemio_suffix(dist, suffix_number)[source]

This method will append to the package version a suffix following this formula:

+tritemio<suffix_number>

It will also set the distribution name in the top changelog block.

convert2sru(lp_bug_number=None, force=False)[source]

This method will edit the last changelog block to be fit for a SRU.

If force is True it will perform the operation ignoring safety checks.

dump()[source]

Dump to hard disk all the changes made so far

get_last_released_version()[source]

This function returns the last released version i.e. the version from the most recent changelog block ignoring ‘UNRELEASED’ changelog blocks.

get_last_ubuntu_released_version()[source]

This function returns the last released version i.e. the version from the most recent changelog block ignoring ‘UNRELEASED’ changelog blocks.

get_ppa_suffix(dist, suffix_number)[source]

Returns a PPA suffix for the changelog.

get_qt_ppa_suffix(dist, end_number, begin_number=0)[source]

Returns a Qt PPA suffix for the changelog.

get_tritemio_suffix(dist, suffix_number)[source]

Returns a string providing a tritemio suffix for the changelog

make_ubuntu_release(dist)[source]

This method will prepare the changelog for an Ubuntu archive upload.

new_upstream_release(new_upstream_version, stability=None)[source]

This method will prepare the changelog for a new upstream release.

The stability parameter may be a string such as “beta” or “RC”, if this parameter is different than None the changelog entry will say if the new release in question is a beta version, release candidate or whatever.

parse_changelog()[source]

Parses a changelog file.

refresh_date()[source]

Executing this method will refresh the date in the last changelog block

libka.pkgedit.ka_control_file module

This module just provides the KAControlFile class

class libka.pkgedit.ka_control_file.KAControlFile(file_path='debian/control')[source]

Bases: object

Class to represent a debian/control file

add_to_relation(package_to_change, relation, package_to_add)[source]

This method adds package_to_add in the relation of package_to_change.

You may pass as package_to_change the special value “:source:” which will change the source package paragraph.

bump_version(package_to_change, relation, package_to_bump, version, operator='>=')[source]

Bump the version of package_to_bump in package_to_change to version

bump_versions_with_map(package_to_change, relation, pkg_version_map)[source]

This method bumps all the versions given by pkg_version_map in relation of package_to_change.

If relation is not found in the corresponding paragraph, calling this function will do nothing.

dump()[source]

Dumps all the changes made so far to hard disk

get_bin_packages()[source]

Returns the list of binary package names in the control file

get_standards_version()[source]

Returns the current Standards-Version as a Version object

parse_control()[source]

Parses a control file

remove_debian_broken_breaks()[source]
remove_doc_build_depends()[source]

Calling this method will remove all Build-Depends and Build-Depends-Indep labelled as <!nodoc> in the control file.

remove_from_relation(package_to_change, relation, package_to_remove, operator=None, version=None)[source]

This function removes package_to_remove from relation of package_to_change. It does nothing if we can’t find relation in package_to_change.

If you whish to alter the source package paragraph with this method, you may pass as package_to_change the special value “:source:”.

If operator or version are given, it will remove package_to_remove only if its operator and version match the values given by that parameters.

Returns True if package_to_remove was actually removed from relation.

Examples:

  • This code will remove ‘libbar5’ from the ‘libfoo5’ ‘Breaks’ relation:

    ka_control_file.remove_from_relations(‘libfoo5’, ‘Breaks’, ‘libbar5’)

  • This code will remove ‘libbar5’ from the ‘libfoo5’ ‘Breaks’ relation only if the binary package ‘libfoo5’ has a ‘Breaks’ field like this: […], libbar5 (<< 5.47), […]

    ka_control_file.remove_from_relations(‘libfoo5’, ‘Breaks’, ‘libbar5’, ‘<<’, ‘5.47’)

  • This code will remove pkg-kde-tools from ‘Build-Depends’:

    ka_control_file.remove_from_relation(package_to_change=’:source:’,

    relation=’Build-Depends’, package_to_remove=’pkg-kde-tools’)

sanitize()[source]

Sanitizes a debian/control file so it won’t trigger bugs from python-debian or wrap-and-sort, see, for instance:

https://git.launchpad.net/~kubuntu-packagers/kubuntu-packaging/+git/cantor/commit/?id=7422c21f

https://git.launchpad.net/~kubuntu-packagers/kubuntu-packaging/+git/cantor/commit/?id=a90b3e90

set_kubuntu_maintainer_fields()[source]

Sets the maintainer fields for Kubuntu.

Returns True if the file was actually changed.

set_kubuntu_vcs_fields(release_type, repo_name)[source]

Sets the vcs fields for Kubuntu.

Returns True if the file was actually changed.

set_standards_version(new_value)[source]

Sets the current Standards-Version

wrap_and_sort_field(package, field, short_indent=False, trailing_comma=True)[source]

Change field from package so it would look like if we ran [ka-]wrap-and-sort.

The package parameter is either the name of a binary package or the special value “:source:” which would change the source package paragraph.

libka.pkgedit.ka_git_repo module

This module just provides the KAGitRepo class

class libka.pkgedit.ka_git_repo.KAGitRepo(path: str | ~os.PathLike[str] | None = None, odbt: ~typing.Type[~gitdb.db.loose.LooseObjectDB] = <class 'git.db.GitCmdObjectDB'>, search_parent_directories: bool = False, expand_vars: bool = True)[source]

Bases: Repo

This class is meant to represent a git repository, it’s just a subclass of git.Repo with some extra methods

branch_out_of_sync()[source]

Returns True if the current branch doesn’t point to the same commit than the branch it is suposed to track.

If we are in ‘detached mode’ this function returns True.

If the current branch isn’t tracking any remote branch, this function returns True.

check_valid_kubuntu_branch()[source]

Returns True if the current branch is a valid kubuntu branch

commit_all_debian_changes(noci, message)[source]

Commits all the files under the debian/ directory, including untracked files

get_max_version_tag(prefix='debian/')[source]

Get the maximum version tag so far with the given prefix

revert_first_matching_commit(commit_message_regexp, starting_commit=None)[source]

Reverts the first commit found whose message matches commit_message_regexp.

If starting_commit is None it will pick the latest from the current branch.

Returns True if the commit was found and reverted, otherwise returns False.

libka.pkgedit.ka_src_pkg module

This module just provides the KASrcPkg class

class libka.pkgedit.ka_src_pkg.KASrcPkg[source]

Bases: object

This class is meant to represent a Debian source package, extract information about the package and change it.

add_gitattributes_file()[source]
add_ppa_suffix(dist, suffix_number)[source]

Adds a PPA suffix to the changelog.

add_qt_ppa_suffix(dist, end_number, begin_number=0)[source]

Adds a Qt PPA suffix to the changelog.

add_tritemio_suffix(dist, suffix_number, suffix_offset=0)[source]

Add a tritemio suffix to the changelog.

bump_build_depends(dist, release_type=None, bump_autopkgtest=False)[source]

Bumps all build depends using ka-metadata.

You may use the release_type parameter to force the “release type” (i.e “frameworks”, “plasma”, “applications” …). If it’s None it will be automatically calculated.

If bump_autopkgtest is True, it will bump the autopkgtest Depends in ‘debian/tests/control’.

download_tarball_from_kde_sftp()[source]

Downloads the orig source tarball from KDE’s sftp.

download_tarball_with_uscan(repack=False)[source]

Downloads the orig source tarball with uscan.

fix_rules_perms()[source]

Calling this function will set debian/rules permissions to 0755. Returns False if the permissions are already 0755, otherwise returns True.

get_bin_packages()[source]

Returns the list of binary package names produced by this source package.

get_kci_tarball()[source]

Prepares a tarball which could be used to do a kci build.

get_last_released_version()[source]

This function returns the last released version i.e. the version from the most recent changelog block ignoring ‘UNRELEASED’ changelog blocks.

get_last_ubuntu_released_version()[source]

This function returns the last released version i.e. the version from the most recent changelog block ignoring ‘UNRELEASED’ and Debian changelog blocks.

get_orig_tarball()[source]

Downloads and creates as symlink for the orig tarball.

get_orig_tarball_path(tarball_extension)[source]

Returns the path where the orig tarball should be available for package building.

For example: ../build-area/foo_5.1.orig.tar.xz

get_patches_list()[source]

Returns de patches series list

get_ppa_suffix(dist, suffix_number)[source]

Returns a PPA suffix for the current package.

get_qt_ppa_suffix(dist, end_number, begin_number=0)[source]

Returns a Qt PPA suffix for the current package.

get_release_type(use_overrides=True)[source]

Find out the release type for a given package.

Returns the release type string: “frameworks”, “plasma”, “applications”, “qt” or “other”.

get_source_format()[source]

Returns the source package format

get_stability(version)[source]

Returns a string naming the type of release (“beta”, RC”, …) for the given version.

get_standards_version()[source]

Returns the current Standards-Version as a Version object

get_tritemio_suffix(dist, suffix_number, suffix_offset=0)[source]

Returns a tritemio suffix for the current package.

get_version()[source]

Returns the package version from changelog.

has_autopkgtests_disabled()[source]

Returns True if this package has autopktests there, but disabled.

is_native_package()[source]

Returns True if the package is native

is_part_of_qt_bootstrap_set(dist)[source]

This method return True if the package is part of the Qt bootstrap set configured in ka-metadata/qt-bootstrap/<dist>

ka_wrap_and_sort()[source]
load_changelog()[source]

This function opens the debian/changelog file and parses it so its data can be used in other parts of the KASrcPkg class

load_control_file()[source]

This function opens the debian/control file and parses it so its data can be used in other parts of the KaSrcPkg class

load_tests_control_file()[source]

This function opens the debian/tests/control file and parses it so its data can be used in other parts of the KaSrcPkg class

load_watch_file()[source]

This function opens the debian/watch file and parses it so its data can be used in other parts of the KASrcPkg class.

new_upstream_release(dist, new_upstream_version=None, bump_autopkgtest=False)[source]

Makes all the needed changes in the packaging to provide a new upstream release.

If the new upstream release was already done, returns False and does nothing, otherwise returns the new upstream version.

If bump_autopkgtest is True, it will bump the autopkgtest Depends in ‘debian/tests/control’.

prepare_qt_stage1(dist)[source]

This method prepares the packaging for the first stage of Qt bootstraping.

It checks if the package is part of the bootstrap set checking the ka-metadata/qt-bootstrap/<dist> file; if the package is part to that set, this method will apply the needed changes and it will return True; if it’s not part of the bootstrap set it will do nothing and return False.

reload()[source]

This function loads all files again.

This is useful if the files changed or if you are using this class against a git repository and you checkout another branch and you need to refresh the data.

remove_broken_debian_breaks()[source]
replace_build_depend(old_bd, new_bd, control_field='Build-Depends')[source]

Replaces the package given in old_bd with new_bd in the Build-Depends field or in the field given in control_field.

If old_bd is not found, this method will return False, otherwise it will return True.

restore_autopkgtests()[source]

Tries to restore autopkgtests if they are available but disabled.

Returns True if they were indeed re-enabled.

sanitize_control_file(file_name='debian/control')[source]

Sanitizes a debian/control file so it won’t trigger bugs from python-debian or wrap-and-sort.

set_kubuntu_maintainer_fields()[source]

Sets the maintainer fields for Kubuntu.

Returns True if the file was actually changed.

set_kubuntu_vcs_fields()[source]

Sets the vcs fields for Kubuntu.

Returns True if the file was actually changed.

set_standards_version(new_value)[source]

Sets the current Standards-Version

source_package_name()[source]

Returns the name of the current source package.

sync_with_archive(dist, dist_version)[source]

Executing this function will dowload the latest package from the Ubuntu/Debian archive and it will copy its debian/* files to the current directory. The ‘dist’ parameter must be either ‘ubuntu’ or ‘debian’

unpack_upstream_source()[source]

Unpacks the upstream source code in the source package directory.

upstream_git_name()[source]

Returns the upstream (KDE) git name.

upstream_tarball_name()[source]

Returns the upstream tarball name reading it from debian/watch

upstream_tarball_paths()[source]

Returns the path where the upstream tarball should be available to be symlinked for package building.

For example:

[ "/home/user/kde-ftp/frameworks/5.81/extra-cmake-modules-5.81.0.tar.xz",
  "/home/user/kde-ftp/frameworks/5.81/extra-cmake-modules-5.81.0.tar.gz",
  ...
]

This is going to be the target of the symlink in the ‘build-area’ directory.

upstream_tarball_repack_suffix()[source]

Returns the upstream tarball repack suffix (e.g. +dfsg)

upstream_tarball_repacked()[source]

Returns True if the upstream tarball is being repacked

upstream_tarball_version()[source]

Returns the upstream tarball version

libka.pkgedit.ka_src_pkg.get_release_type(upstream_tarball_name, use_overrides=True)[source]

This function returns the release type (qt, frameworks, plasma, applications, other) for the package given by upstream_tarball_name

libka.pkgedit.ka_src_pkg_git_repo module

This module just provides the KASrcPkgGitRepo class

class libka.pkgedit.ka_src_pkg_git_repo.KASrcPkgGitRepo[source]

Bases: KAGitRepo, KASrcPkg

This class is meant to represent git repositories where our source packages are mainatained and allow the programmer to extract information about the package, make changes in that source package and perform git operations

fix_rules_perms()[source]

Calling this function will set debian/rules permissions to 0755, and, if no_commit is True, it will commit the changes to git (if any). Returns False if the permissions are already 0755, otherwise returns True.

get_pkg_modified_files()[source]

Returns a list of modified packaging files in the current clone.

get_pkg_untracked_files()[source]

Returns a list of packaging untracked files. I.e. untracked files under the debian/ directory.

get_unmerged_files()[source]

Returns a list of unmerged files in the current clone.

get_upstream_untracked_files()[source]

Returns a list of upstream source code untracked files.

new_upstream_release(dist, new_upstream_version=None, bump_autopkgtest=False)[source]

Makes all the needed changes in the packaging to provide a new upstream release.

If the new upstream release was already done, returns False and does nothing, otherwise returns the new upstream version.

sanitize_control_file(file_name='debian/control')[source]

Sanitizes a debian/control file so it won’t trigger bugs from python-debian or wrap-and-sort.

set_auto_commit(auto_commit, noci, commit_message=None)[source]

If auto_commit is True it will commit the changes to git if that’s appropiate.

If noci is True it will include the ‘NOCI’ in the commit message to avoid triggering a KCI rebuild with the change.

If commit_message is None it will use a pre-defined commit message.

set_kubuntu_maintainer_fields()[source]

This method updates the Maintainer and XSBC-Original-Maintainer fields for Kubuntu if needed.

set_kubuntu_vcs_fields()[source]

This method updates the Vcs-Browser and Vcs-Git fields for Kubuntu if needed.

unpack_upstream_source(force=False)[source]

Unpacks the upstream source code in the source package directory.

If force is False it will raise an exception if the upstream source code was already unpacked.

libka.pkgedit.ka_watch_file module

This module just provides the KAWatchFile class

class libka.pkgedit.ka_watch_file.KAWatchFile(file_path='debian/watch')[source]

Bases: object

Class to represent a debian/watch file

opts()[source]

Returns a list of dictionaries of ‘opts’, each dictionary is indexed by option name, the whole list of dictionaries is indexed by ‘real line’ number.

parse_watch()[source]

Parses a watch file

raw_lines()[source]

Returns a list with the raw lines of the watch file

raw_tarball_patterns()[source]

Returns a list of raw tarball patterns i.e. without replacing @PACKAGE@, @ANY_VERSION@ or @ARCHIVE_EXT@

real_lines()[source]

Returns a list with the real lines of the watch file, taking into account those ending with \ and the comments starting with #

tarball_name(src_pkg_name)[source]

Returns the tarball name.

tarball_patterns(src_pkg_name, src_pkg_uversion)[source]

Returns a list of tarball patterns after expanding uscan variables @PACKAGE, @ANY_VERSION@ and @ARCHIVE_EXT@

tarball_repack_suffix()[source]

Returns the tarball repack suffix or None if the tarball is not repacked or we couldn’t find the suffix.

tarball_repacked()[source]

Returns True if the tarball is repacked.

uscan_supported_extensions()[source]

Returns a list of the uscan supported extensions

libka.pkgedit.wrap_control module

This code was copied from wrap-and-sort, it’s helpful when converting a package relation from the structured deb822.PkgRelation to string, because deb822.PkgRelation.str(relation_structured) returns a string in a single line so it’s nice to get it in the wrap-and-sort-like format again

libka.pkgedit.wrap_control.sort_list(unsorted_list)[source]
libka.pkgedit.wrap_control.wrap_field(control, entry, wrap_always, short_indent, trailing_comma=True, sort=True)[source]