Specfile module¶
- class rebasehelper.specfile.PackageCategory(value)[source]¶
An enumeration.
- R: Pattern[str] = re.compile('^R-')¶
- haskell: Pattern[str] = re.compile('^ghc-')¶
- nodejs: Pattern[str] = re.compile('^nodejs-')¶
- perl: Pattern[str] = re.compile('^perl-')¶
- php: Pattern[str] = re.compile('^php-')¶
- python: Pattern[str] = re.compile('^python[23]?-')¶
- ruby: Pattern[str] = re.compile('^rubygem-')¶
- rust: Pattern[str] = re.compile('^rust-')¶
- class rebasehelper.specfile.PatchObject(path, number, strip)[source]¶
Class represents set of information about patches
- class rebasehelper.specfile.SpecFile(path: str, sources_location: str = '', predefined_macros: Dict[str, str] | None = None, lookaside_cache_preset: str = 'fedpkg')[source]¶
Class representing a spec file.
- copy(new_path)[source]¶
Creates a copy of the current object and copies the SPEC file to a new location.
- Parameters:
new_path (str) – Path to copy the new SPEC file to.
- Returns:
The created SpecFile instance.
- Return type:
- extract_version_from_archive_name(archive_path: str, main_source: str) str [source]¶
Extracts version string from source archive name.
- Parameters:
archive_path – Path to the main sources archive.
main_source – Value of Source0 tag.
- Returns:
Extracted version string.
- Raises:
RebaseHelperError in case version can't be determined. –
- find_archive_target_in_prep(archive)[source]¶
Tries to find a command that is used to extract the specified archive and attempts to determine target path from it. ‘tar’ and ‘unzip’ commands are supported so far.
- Parameters:
archive – Path to archive
- Returns:
Target path relative to builddir or None if not determined
- get_applied_patches()[source]¶
Method returns list of all applied patches.
- Returns:
list of PatchObject
- classmethod get_comment_span(line: str, script_section: bool) Tuple[int, int] [source]¶
Gets span of a comment depending on the section.
- Parameters:
line – Line to find the comment in.
script_section – Whether the section the line is in is a shell script.
- Returns:
Span of the comment. If no comment is found, both tuple elements are equal to the length of the line for convenient use in a slice.
- get_main_files_section()[source]¶
Finds the exact name of the main %files section.
- Returns:
Name of the main files section.
- Return type:
str
- get_not_used_patches()[source]¶
Method returns list of all unpplied patches.
- Returns:
list of PatchObject
- get_patches()[source]¶
Method returns list of all applied and not applied patches
- Returns:
list of PatchObject
- static get_subpackage_name(files_section)[source]¶
Gets subpackage name based on the %files section.
- is_test_suite_enabled()[source]¶
Returns whether test suite is enabled during the build time
- Returns:
True if enabled or False if not
- parse_release() Tuple[bool, int, str | None] [source]¶
Parses release string.
- Returns:
Tuple of is_prerelease, release_number and extra_version.
- Raises:
RebaseHelperError in case release string is not valid. –
- process_patch_macros(comment_out: List[int] | None = None, remove: List[int] | None = None, annotate: List[int] | None = None, note: str | None = None) None [source]¶
Processes %patch macros in %prep section.
- Parameters:
comment_out – List of patch numbers to comment out.
remove – List of patch numbers to remove.
annotate – List of patch numbers to annotate.
note – Message to annotate patches with.
- set_extra_version(extra_version: str | None, version_changed: bool) None [source]¶
Updates SPEC file with the specified extra version.
- Parameters:
extra_version – Extra version string or None.
version_changed – Whether version (the value of Version tag) changed.
- static split_version_string(version_string: str, current_version: str) Tuple[str, str | None] [source]¶
Splits version string into version and extra version.
- Parameters:
version_string – Complete version string.
current_version – Current version (the value of Version tag).
- Returns:
Tuple of version and extra_version.
- Raises:
RebaseHelperError in case passed version string is not valid. –