def parse_attribute(attribute, lines, i, path):
    """
    Parse one attribute from the APKBUILD.

    It may be written across multiple lines, use a quoting sign and/or have
    a comment at the end. Some examples:

    pkgrel=3
    options="!check" # ignore this comment
    arch='all !armhf'
    depends="
        first-pkg
        second-pkg"

    :param attribute: from the APKBUILD, i.e. "pkgname"
    :param lines: 
-terminated list of lines from the APKBUILD
    :param i: index of the line we are currently looking at
    :param path: full path to the APKBUILD (for error message)
    :returns: (found, value, i)
              found: True if the attribute was found in line i, False otherwise
              value: that was parsed from the line
              i: line that was parsed last
    """
    if not lines[i].startswith(attribute + '='):
        return False, None, i
    value = lines[i][len(attribute + '='):-1]
    end_char = None
    for char in ["'", '"']:
        if value.startswith(char):
            end_char = char
            value = value[1:]
            break
    if not end_char:
        return True, value, i
    if end_char in value:
        value = value.split(end_char, 1)[0]
        return True, value, i
    i += 1
    while i < len(lines):
        line = lines[i]
        value += ' '
        if end_char in line:
            value += line.split(end_char, 1)[0].strip()
            return True, value.strip(), i
        value += line.strip()
        i += 1
    raise RuntimeError("Can't find closing quote sign (" + end_char +
        ") for attribute '" + attribute + "' in: " + path)
