예제 #1
0
def convert_archive(dest_dir, spkg_file):
    working_dir = tempfile.mkdtemp()
    try:
        expand_tarball(os.path.abspath(spkg_file), cwd=working_dir)
    except:
            print(spkg_file)
            print("....Bad archive! Skipping file!")
            print("....removing tmp: " + working_dir)
            shutil.rmtree(working_dir)
            return

    dir = os.listdir(working_dir)
    working_dir_project = os.path.join(os.path.normpath(working_dir), dir[0])

    f_spkg_install = None

    # look in package root
    for file in os.listdir(working_dir_project):
        if file == "spkg-install":
            f_spkg_install = os.path.join(working_dir_project, "spkg-install")

    if f_spkg_install != None:
        rewrite_file(f_spkg_install)
        make_tarball(os.path.basename(spkg_file), os.path.basename(working_dir_project), cwd=working_dir)
        process_command(["cp", os.path.basename(spkg_file), dest_dir], cwd=working_dir)
        print("Processed: " + f_spkg_install)
    else:
        print("....No spkg-install found! Skipping this package!")

    print("....removing tmp: " + working_dir)
    shutil.rmtree(working_dir)
예제 #2
0
def convert_archive(dest_dir, spkg_file):
    working_dir = tempfile.mkdtemp()
    try:
        expand_tarball(os.path.abspath(spkg_file), cwd=working_dir)
    except:
        print(spkg_file)
        print("....Bad archive! Skipping file!")
        print("....removing tmp: " + working_dir)
        shutil.rmtree(working_dir)
        return

    dir = os.listdir(working_dir)
    working_dir_project = os.path.join(os.path.normpath(working_dir), dir[0])

    f_spkg_install = None

    # look in package root
    for file in os.listdir(working_dir_project):
        if file == "spkg-install":
            f_spkg_install = os.path.join(working_dir_project, "spkg-install")

    if f_spkg_install != None:
        rewrite_file(f_spkg_install)
        make_tarball(os.path.basename(spkg_file),
                     os.path.basename(working_dir_project),
                     cwd=working_dir)
        process_command(["cp", os.path.basename(spkg_file), dest_dir],
                        cwd=working_dir)
        print("Processed: " + f_spkg_install)
    else:
        print("....No spkg-install found! Skipping this package!")

    print("....removing tmp: " + working_dir)
    shutil.rmtree(working_dir)
예제 #3
0
def convert_file(file):
    global PACKAGE_NAME, VERSION
    print("Processing " + file)
    PACKAGE_NAME = os.path.basename(file.replace('.spkg', ''))
    PACKAGE_NAME = PACKAGE_NAME.split('-')

    if len(PACKAGE_NAME) == 2 and PACKAGE_NAME[1][0].isdigit():
        VERSION = PACKAGE_NAME[1]
    else:
        print("....filename does not contain version?")
        VERSION = s.get_version()
        print("....using default version from settings.xml: " + VERSION)

    PACKAGE_NAME = PACKAGE_NAME[0]
    working_dir = tempfile.mkdtemp()
    try:
        expand_tarball(os.path.abspath(file), cwd=working_dir)
    except:
            print("....Bad archive! Skipping file!")
            print("....removing tmp: " + working_dir)
            shutil.rmtree(working_dir)
            return

    dir = os.listdir(working_dir)
    working_dir_project = os.path.join(os.path.normpath(working_dir), dir[0])

    src_path = working_dir_project
    if os.path.exists(os.path.join(working_dir_project, "src")):
        src_path = os.path.join(working_dir_project, "src")
        # uncomment those 3 lines, if you want to disable dpkg dir name warnings
        #new_src = working_dir_project + os.sep + PACKAGE_NAME + "-" + VERSION
        #os.rename(src_path, new_src)
        #src_path = os.path.join(working_dir_project, new_src)

    f_spkg_install = None
    f_setup_py = None
    f_makefile = None
    f_configure = None
    f_config = None

    # look in package root
    for file in os.listdir(working_dir_project):
        if file == "spkg-install":
            f_spkg_install = os.path.join(working_dir_project, "spkg-install")
        elif file == "setup.py":
            f_setup_py = os.path.join(working_dir_project, "setup.py")
        elif file == "Makefile":
            f_makefile = os.path.join(working_dir_project, "Makefile")
        elif file == "configure":
            f_configure = os.path.join(working_dir_project, "configure")
        elif file == "config":
            f_config = os.path.join(working_dir_project, "config")

    # look in src_path in case it wasn't found in the root
    if f_setup_py == None and src_path != working_dir_project:
        "setup.py is not in package's root, but can be in src subdirectory!"
        f_setup_py = fix_src_path(src_path, "setup.py")
    if f_makefile == None and src_path != working_dir_project:
        f_makefile = fix_src_path(src_path, "Makefile")
    if f_configure == None and src_path != working_dir_project:
        f_configure = fix_src_path(src_path, "configure")
    if f_config == None and src_path != working_dir_project:
        f_config = fix_src_path(src_path, "config")

    if f_spkg_install != None:
        print("....Found spkg-install! Building deb package.")

        # ./configure or ./config is the first option
        # setup.py is the second option
        # custom Makefile is the last option as it will mostly fail
        if f_configure != None:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            try:
                if BUILD_BINARY == True:
                    print("....Found configure script.")
                    process_command_quiet(["./configure"], cwd=src_path)
                build_deb(working_dir, working_dir_project,
                                    src_path, f_setup_py)
            except:
                print("....Error in configure script! Skipping this package!")
        elif f_config != None:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            try:
                if BUILD_BINARY == True:
                    print("....Found config script.")
                    process_command_quiet(["./config"], cwd=src_path)
                build_deb(working_dir, working_dir_project,
                                    src_path, f_setup_py)
            except:
                print("....Error in configure script! Skipping this package!")

        elif f_setup_py != None:
            install_deps("python-" + PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            print("....Found setup.py => building deb control file.")
            generate_deb_from_python(working_dir, working_dir_project,
                                    src_path, f_setup_py)
        elif f_makefile != None:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            print("....Found custom Makefile script.")
            build_deb(working_dir, working_dir_project,
                                    src_path, f_setup_py)
        else:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            print("....No Makefile or setup.py found => build source .deb")
            generate_src_deb_from_source(working_dir, working_dir_project,
                                    src_path, f_setup_py)

    else:
        print("....No spkg-install found! Skipping this package!")

    print("....removing tmp: " + working_dir)
    shutil.rmtree(working_dir)
예제 #4
0
def convert_file(file):
    global PACKAGE_NAME, VERSION
    print("Processing " + file)
    PACKAGE_NAME = os.path.basename(file.replace('.spkg', ''))
    PACKAGE_NAME = PACKAGE_NAME.split('-')

    if len(PACKAGE_NAME) == 2 and PACKAGE_NAME[1][0].isdigit():
        VERSION = PACKAGE_NAME[1]
    else:
        print("....filename does not contain version?")
        VERSION = s.get_version()
        print("....using default version from settings.xml: " + VERSION)

    PACKAGE_NAME = PACKAGE_NAME[0]
    working_dir = tempfile.mkdtemp()
    try:
        expand_tarball(os.path.abspath(file), cwd=working_dir)
    except:
        print("....Bad archive! Skipping file!")
        print("....removing tmp: " + working_dir)
        shutil.rmtree(working_dir)
        return

    dir = os.listdir(working_dir)
    working_dir_project = os.path.join(os.path.normpath(working_dir), dir[0])

    src_path = working_dir_project
    if os.path.exists(os.path.join(working_dir_project, "src")):
        src_path = os.path.join(working_dir_project, "src")
        # uncomment those 3 lines, if you want to disable dpkg dir name warnings
        #new_src = working_dir_project + os.sep + PACKAGE_NAME + "-" + VERSION
        #os.rename(src_path, new_src)
        #src_path = os.path.join(working_dir_project, new_src)

    f_spkg_install = None
    f_setup_py = None
    f_makefile = None
    f_configure = None
    f_config = None

    # look in package root
    for file in os.listdir(working_dir_project):
        if file == "spkg-install":
            f_spkg_install = os.path.join(working_dir_project, "spkg-install")
        elif file == "setup.py":
            f_setup_py = os.path.join(working_dir_project, "setup.py")
        elif file == "Makefile":
            f_makefile = os.path.join(working_dir_project, "Makefile")
        elif file == "configure":
            f_configure = os.path.join(working_dir_project, "configure")
        elif file == "config":
            f_config = os.path.join(working_dir_project, "config")

    # look in src_path in case it wasn't found in the root
    if f_setup_py == None and src_path != working_dir_project:
        "setup.py is not in package's root, but can be in src subdirectory!"
        f_setup_py = fix_src_path(src_path, "setup.py")
    if f_makefile == None and src_path != working_dir_project:
        f_makefile = fix_src_path(src_path, "Makefile")
    if f_configure == None and src_path != working_dir_project:
        f_configure = fix_src_path(src_path, "configure")
    if f_config == None and src_path != working_dir_project:
        f_config = fix_src_path(src_path, "config")

    if f_spkg_install != None:
        print("....Found spkg-install! Building deb package.")

        # ./configure or ./config is the first option
        # setup.py is the second option
        # custom Makefile is the last option as it will mostly fail
        if f_configure != None:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            try:
                if BUILD_BINARY == True:
                    print("....Found configure script.")
                    process_command_quiet(["./configure"], cwd=src_path)
                build_deb(working_dir, working_dir_project, src_path,
                          f_setup_py)
            except:
                print("....Error in configure script! Skipping this package!")
        elif f_config != None:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            try:
                if BUILD_BINARY == True:
                    print("....Found config script.")
                    process_command_quiet(["./config"], cwd=src_path)
                build_deb(working_dir, working_dir_project, src_path,
                          f_setup_py)
            except:
                print("....Error in configure script! Skipping this package!")

        elif f_setup_py != None:
            install_deps("python-" + PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            print("....Found setup.py => building deb control file.")
            generate_deb_from_python(working_dir, working_dir_project,
                                     src_path, f_setup_py)
        elif f_makefile != None:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            print("....Found custom Makefile script.")
            build_deb(working_dir, working_dir_project, src_path, f_setup_py)
        else:
            install_deps(PACKAGE_NAME)
            PACKAGE_NAME = source_debianize_name(PACKAGE_NAME)
            VERSION = debianize_version(VERSION)
            print("....No Makefile or setup.py found => build source .deb")
            generate_src_deb_from_source(working_dir, working_dir_project,
                                         src_path, f_setup_py)

    else:
        print("....No spkg-install found! Skipping this package!")

    print("....removing tmp: " + working_dir)
    shutil.rmtree(working_dir)