Example #1
0
    def find_partconfig(self, cf):
        partconfig_id = None

        defaultprop = cf.get_file('default.prop')
        if defaultprop:
            lines = fileio.bytes_to_lines(defaultprop.content)
            for line in lines:
                if line.startswith('ro.patcher.patched'):
                    partconfig_id = line.partition('=')[1]

        mountscript = cf.get_file('init.multiboot.mounting.sh')
        if mountscript:
            lines = fileio.bytes_to_lines(mountscript.content)
            for line in lines:
                if line.startswith('TARGET_DATA='):
                    match = re.search(r'/raw-data/([^/"]+)', line)
                    if match:
                        partconfig_id = match.group(1)

        configs = partitionconfigs.get()
        for config in configs:
            if config.id == partconfig_id:
                return config

        return None
Example #2
0
    def find_partconfig(self, cf):
        partconfig_id = None

        defaultprop = cf.get_file('default.prop')
        if defaultprop:
            lines = fileio.bytes_to_lines(defaultprop.content)
            for line in lines:
                if line.startswith('ro.patcher.patched'):
                    partconfig_id = line.partition('=')[1]

        mountscript = cf.get_file('init.multiboot.mounting.sh')
        if mountscript:
            lines = fileio.bytes_to_lines(mountscript.content)
            for line in lines:
                if line.startswith('TARGET_DATA='):
                    match = re.search(r'/raw-data/([^/"]+)', line)
                    if match:
                        partconfig_id = match.group(1)

        configs = partitionconfigs.get()
        for config in configs:
            if config.id == partconfig_id:
                return config

        return None
Example #3
0
    def _is_valid_partconfig(self, partconfig_id):
        if partconfig_id == 'all':
            return True

        for partconfig in partitionconfigs.get():
            if partconfig.id == partconfig_id:
                return True

        return False
Example #4
0
    def _is_valid_partconfig(self, partconfig_id):
        if partconfig_id == 'all':
            return True

        for partconfig in partitionconfigs.get():
            if partconfig.id == partconfig_id:
                return True

        return False
Example #5
0
    def __init__(self, parent=None, filename=None):
        super().__init__(parent)
        iconpath = os.path.join(OS.rootdir, "scripts", "icon.png")
        self.setWindowIcon(QtGui.QIcon(iconpath))

        if filename:
            self.filename = os.path.abspath(filename)
            self.automode = True
        else:
            self.filename = None
            self.automode = False

        self.partconfigs = partitionconfigs.get()

        self.setWindowTitle("Dual Boot Patcher")

        # Partition configuration selector and file chooser
        self.partconfigdesc = QtWidgets.QLabel(self)
        self.partconfigcombobox = QtWidgets.QComboBox(self)
        self.filechooserbutton = QtWidgets.QPushButton(self)

        # A simple vertical layout will do
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(self.partconfigcombobox)
        layout.addWidget(self.partconfigdesc)
        layout.addStretch(1)
        layout.addWidget(self.filechooserbutton)

        self.setLayout(layout)

        # Populate partition configs
        for i in self.partconfigs:
            self.partconfigcombobox.addItem(i.name)

        self.partconfigcombobox.currentIndexChanged.connect(self.partconfigselected)
        self.partconfigselected(self.partconfigcombobox.currentIndex())

        # Choose file button
        if self.automode:
            self.filechooserbutton.setText("Continue")
        else:
            self.filechooserbutton.setText("Choose file to patch")
        self.filechooserbutton.clicked.connect(self.selectfile)

        # Progress dialog
        self.progressdialog = ProgressDialog(self)

        qtui.listener = self.progressdialog

        # Fixed size
        self.setMinimumWidth(300)
        self.setFixedHeight(self.sizeHint().height())
        self.move(300, 300)
Example #6
0
def ask_partconfig(file_info):
    unsupported_configs = []
    partition_configs = []
    partition_configs_raw = partitionconfigs.get()

    for i in partition_configs_raw:
        if (i.id in file_info.configs or 'all' in file_info.configs) \
                and '!' + i.id not in file_info.configs:
            partition_configs.append(i)
        else:
            unsupported_configs.append(i)

    if not partition_configs:
        raise Exception("No usable partition configurations found")

    print("Choose a partition configuration to use:")
    print("")

    counter = 0
    for i in partition_configs:
        print("%i: %s" % (counter + 1, i.name))
        print("\t- %s" % i.description)
        counter += 1

    for i in unsupported_configs:
        print("*: %s (UNSUPPORTED)" % i.name)
        print("\t- %s" % i.description)

    print("")
    choice = input("Choice: ")

    try:
        choice = int(choice)
        choice -= 1
        if choice < 0 or choice >= counter:
            raise Exception("Invalid choice")

        return (partition_configs, choice)
    except ValueError:
        raise Exception("Invalid choice")
Example #7
0
ui = OS.ui


if __name__ == "__main__":
    if len(sys.argv) < 2:
        ui.info("Usage: %s [zip file or boot.img] [multiboot type]"
                % sys.argv[0])
        sys.exit(1)

    filename = sys.argv[1]
    if len(sys.argv) == 2:
        config_name = 'dualboot'
    else:
        config_name = sys.argv[2]

    partition_configs = partitionconfigs.get()
    partition_config = None
    for i in partition_configs:
        if i.id == config_name:
            partition_config = i

    if not partition_config:
        ui.info("Multiboot config %s does not exist!" % config_name)
        sys.exit(1)

    if not os.path.exists(filename):
        ui.info("%s does not exist!" % filename)
        sys.exit(1)

    filename = os.path.abspath(filename)
Example #8
0
partconfig = None
noquestions = False

# For unsupported files
f_preset_name = None
f_hasbootimage = None
f_bootimage = None
f_ramdisk = None
f_autopatcher_name = None
f_patch = None
f_init = None
f_devicecheck = None

# Lists
devices = config.list_devices()
partition_configs = partitionconfigs.get()
presets = None
autopatchers = None
inits = None
ramdisks = None


class SimpleListDialog:
    def __init__(self):
        self.desc = None
        self.choicemsg = None
        self.names = list()
        self.values = list()
        self.invalidnames = list()
        self.invalidvalues = list()
        self.hasvalues = True
Example #9
0
    def __init__(self, parent=None, filename=None):
        super().__init__(parent)
        iconpath = os.path.join(OS.rootdir, 'scripts', 'icon.png')
        self.setWindowIcon(QtGui.QIcon(iconpath))

        if filename:
            self.filename = os.path.abspath(filename)
            self.automode = True
        else:
            self.filename = None
            self.automode = False

        self.primaryupgrade = False

        self.partconfigs = partitionconfigs.get()
        self.devices = config.list_devices()

        self.setWindowTitle('Dual Boot Patcher')

        # Partition configuration selector and file chooser
        self.partconfigdesc = QtWidgets.QLabel(self)
        self.partconfigcombobox = QtWidgets.QComboBox(self)
        self.devicecombobox = QtWidgets.QComboBox(self)
        self.filechooserbutton = QtWidgets.QPushButton(self)

        # A simple vertical layout will do
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(self.devicecombobox)
        layout.addWidget(self.partconfigcombobox)
        layout.addWidget(self.partconfigdesc)
        layout.addStretch(1)
        layout.addWidget(self.filechooserbutton)

        self.setLayout(layout)

        # Populate devices
        for d in self.devices:
            name = config.config['devices'][d]['name']
            self.devicecombobox.addItem('%s (%s)' % (d, name))

        self.devicecombobox.currentIndexChanged.connect(self.deviceselected)
        self.deviceselected(self.devicecombobox.currentIndex())

        # Populate partition configs
        for i in self.partconfigs:
            self.partconfigcombobox.addItem(i.name)

        self.partconfigcombobox.currentIndexChanged.connect(
            self.partconfigselected)
        self.partconfigselected(self.partconfigcombobox.currentIndex())

        # Choose file button
        if self.automode:
            self.filechooserbutton.setText("Continue")
        else:
            self.filechooserbutton.setText("Choose file to patch")
        self.filechooserbutton.clicked.connect(self.selectfile)

        # Progress dialog
        self.progressdialog = ProgressDialog(self)

        qtui.listener = self.progressdialog

        # Fixed size
        self.setMinimumWidth(420)
        self.setFixedHeight(self.sizeHint().height())
        self.move(300, 300)