Source code for libka.remove_broken_debian_breaks

#!/usr/bin/python3
# kate: space-indent on; indent-width 4; replace-tabs on; indent-mode python; remove-trailing-space modified;
# vim: expandtab ts=4

############################################################################
#   Copyright © 2016 José Manuel Santamaría Lema <panfaust@gmail.com>      #
#                                                                          #
#   This program is free software; you can redistribute it and/or modify   #
#   it under the terms of the GNU General Public License as published by   #
#   the Free Software Foundation; either version 2 of the License, or      #
#   (at your option) any later version.                                    #
############################################################################

# script to remove some bad debian breaks on reverse dependencies

#Handle Crtl+C
import signal
from libka.ka_print import *
[docs] def signal_handler(signal, frame): ka_print_plain('Aborted by user request') sys.exit(130) #http://www.tldp.org/LDP/abs/html/exitcodes.html
signal.signal(signal.SIGINT, signal_handler) import subprocess import warnings import os from libka.control_edit import * from libka.ka_data_utils import *
[docs] def read_bin_pkg_name_list(): cwd = os.path.dirname(os.path.realpath(__file__)) packageFile = os.path.join( getDataFilesPath(), "debian-bin-package-names-lists/frameworks" ) f = open(packageFile) lines = f.readlines() result = [] version = None for line in lines: line = line.strip("\r\n\t ") if line.startswith("#Version: "): version = line.split("#Version: ")[1] continue if not line.startswith("#"): result.append(line) f.close() return result, version
[docs] def strip_broken_debian_breaks(src_pkg, bin_pkg_list, bin_pkg_map): warnings.simplefilter('ignore', UserWarning) #Ignore the warnings from python-debian warnings.simplefilter('ignore', FutureWarning) #Ignore the warnings from python-debian packages_blacklist, version = read_bin_pkg_name_list() for bin_pkg_name in bin_pkg_list: bin_pkg_to_change = bin_pkg_map[bin_pkg_name] if 'Breaks' in bin_pkg_to_change: for p in packages_blacklist: remove_from_relations(bin_pkg_to_change,'Breaks',p,True,'<<',version) warnings.simplefilter('default', FutureWarning) #Reset the future warnings warnings.simplefilter('default', UserWarning) #Reset the user warnings return src_pkg, bin_pkg_list, bin_pkg_map
[docs] def remove_broken_debian_breaks(): #Sanitize the control file sanitize_control_file('./debian/control') #Open the control file src_pkg, bin_pkg_list, bin_pkg_map = parse_control('./debian/control'); #Remove the undesired breaks src_pkg, bin_pkg_list, bin_pkg_map = strip_broken_debian_breaks(src_pkg, bin_pkg_list, bin_pkg_map) #Dump the contents of the control file dump_control('./debian/control',src_pkg, bin_pkg_list, bin_pkg_map)
if __name__ == "__main__": remove_broken_debian_breaks()