Exemple #1
0
def main():
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    """ Main

    Args: None.  (Use sys.argv[] to get args)

    Returns: N/A

    Raises: None

    """
    # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    # Initialize.
    err = None
    ret = 0
    debug = are_keys = force_req_print = False

    # Parse commandline into options and args.
    try:
        (opt_pairs, other_args) = getopt.getopt(sys.argv[1:], "dhkr?")
    except getopt.GetoptError as err:
        print("ManifestRead: " + str(err), file=sys.stderr)
    except IndexError as err:
        print("ManifestRead: Insufficient arguments", file=sys.stderr)
    if (err is not None):
        usage(sys.stderr)
        sys.exit(errno.EINVAL)

    # Set option flags.
    for (opt, optarg) in opt_pairs:
        del optarg
        if (opt == "-d"):
            debug = True
        elif ((opt == "-h") or (opt == "-?")):
            usage(sys.stdout)
            sys.exit(0)
        elif (opt == "-k"):
            are_keys = True
        elif (opt == "-r"):
            force_req_print = True

    # Must have at least socket specified as first arg.
    if (not other_args):
        usage(sys.stderr)
        sys.exit(errno.EINVAL)

    # Do the work.
    try:
        mrobj = ManifestRead(other_args[0])
        mrobj.set_debug(debug)
        print_values(mrobj, other_args[1:], are_keys, force_req_print)
    except (SystemExit, KeyboardInterrupt):
        pass
    except Exception as err:
        print("Error running Manifest Reader", file=sys.stderr)
    if (err):
        ret = err.args[0]
    sys.exit(ret)
Exemple #2
0
"""
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if (len(sys.argv) != 7):  # Don't forget sys.argv[0] is the script itself.
    raise Exception, (
        sys.argv[0] + ": Requires 6 args:\n" +
        "    Reader socket, pkg_image area, temp dir,\n" +
        "    boot archive build area, media area, grub setup type.")

# collect input arguments from what this script sees as a commandline.
MFEST_SOCKET = sys.argv[1]  # Manifest reader socket
PKG_IMG_PATH = sys.argv[2]  # package image area mountpoint
GRUB_SETUP_TYPE = sys.argv[6]  # Grub setup type

# get the manifest reader object from the socket
MANIFEST_READER_OBJ = ManifestRead(MFEST_SOCKET)

# if a string is specified in the manifest to be used as the title of the grub
# menu entries, that string will be used.  Otherwise, use the first
# line of /etc/release as the title

# Get grub title from manifest, if any
RELEASE = get_manifest_value(MANIFEST_READER_OBJ, GRUB_TITLE)
if RELEASE is not None:
    # User specified a special grub menu, record that in .image_info
    IMG_INFO_FD = None
    try:
        IMG_INFO_PATH = PKG_IMG_PATH + "/" + IMAGE_INFO_FILE
        try:
            IMG_INFO_FD = open(IMG_INFO_PATH, "a+")
            IMG_INFO_FD.write(IMAGE_INFO_GRUB_TITLE_KEYWORD + RELEASE + "\n")
Exemple #3
0
"""

if __name__ == "__main__":

    if (len(sys.argv) != 6):  # Don't forget sys.argv[0] is the script itself.
        raise Exception, (sys.argv[0] + ": Requires 5 args:\n" +
                          "    Reader socket, pkg_image area, temp dir,\n" +
                          "    boot archive build area, media area.")

    # collect input arguments from what this script sees as a commandline.
    mfest_socket = sys.argv[1]  # Manifest reader socket
    pkg_img_path = sys.argv[2]  # package image area mountpoint

    # get the manifest reader object from the socket
    manifest_reader_obj = ManifestRead(mfest_socket)

    # Get the password for the root user from the manifest
    root_passwd_text = get_manifest_value(manifest_reader_obj, ROOT_PASSWD)
    is_plaintext = get_manifest_boolean(manifest_reader_obj,
                                        ROOT_PASSWD_PLAINTEXT)

    print "root_passwd_text = " + root_passwd_text
    print "is_plaintext = " + str(is_plaintext)

    if is_plaintext:
        encrypted_root_passwd = encrypt_password(root_passwd_text,
                                                 alt_root=pkg_img_path)
    else:
        encrypted_root_passwd = root_passwd_text
Exemple #4
0
    if (len(sys.argv) != 6):  # sys.argv[0] is the script itself.
        raise Exception(sys.argv[0] + ": Requires 5 args:\n" +
                        "    Reader socket, pkg_image area, tmp dir,\n" +
                        "    bootroot build area, media area")

    # Collect input arguments from what
    # this script sees as a commandline.
    MFEST_SOCKET = sys.argv[1]  # Manifest reader socket
    PKG_IMG_MNT_PT = sys.argv[2]  # package image area mountpoint
    TMP_DIR = sys.argv[3]  # temp directory to contain boot archive

    UNSET_AUTH_LIST = []
    UNSET_MIRROR_LIST = []

    MANIFEST_SERVER_OBJ = ManifestRead(MFEST_SOCKET)

    PKG_URL = dcu.get_manifest_value(MANIFEST_SERVER_OBJ, DEFAULT_MAIN_URL)
    PKG_AUTH = dcu.get_manifest_value(MANIFEST_SERVER_OBJ,
                                      DEFAULT_MAIN_AUTHNAME)

    if PKG_AUTH is None:
        raise Exception(sys.argv[0] +
                        ": pkg publisher is missing from manifest")
    if PKG_URL is None:
        raise Exception(sys.argv[0] + ": pkg url is missing from manifest")

    QUIT_ON_PKG_FAILURE = dcu.get_manifest_value(MANIFEST_SERVER_OBJ,
                                                 STOP_ON_ERR).lower()

    # Initialize log instance
Exemple #5
0
        elif ((opt == "-h") or (opt == "-?")):
            usage(sys.stdout)
            sys.exit(0)
        elif (opt == "-k"):
            are_keys = True
        elif (opt == "-r"):
            force_req_print = True

    # Must have at least socket specified as first arg.
    if (not other_args):
        usage(sys.stderr)
        sys.exit(errno.EINVAL)

    # Do the work.
    try:
        mrobj = ManifestRead(other_args[0])
        mrobj.set_debug(debug)
        print_values(mrobj, other_args[1:], are_keys, force_req_print)
    except (SystemExit, KeyboardInterrupt):
        pass
    except Exception, err:
        print >> sys.stderr, "Error running Manifest Reader"
    if (err):
        ret = err.args[0]
    sys.exit(ret)


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Main
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if __name__ == "__main__":