Esempio n. 1
0
    def build_package(self):
        """Builds a debian package

        Actually does the call outs to dpkg so that we can actually build
        a package
        
        """
        source_dir = "%s" % self.package_config["working_dir"]

        # makes sure root owns the files
        run_fakeroot("chown -R root.root %s" % source_dir)
        # remove all sticky bits - a deb requirement.
        run_fakeroot("chmod -R a-s %s" % source_dir)

        self.run_hook("post_permissions")

        if not self.global_config["quiet"]:
            print "Building package %s" % self.package_config["package"]
            print "From %s" % self.package_config["path"]

        run_fakeroot(
            "dpkg -b %s %s/temp/%s"
            % (source_dir, self.global_config["build_directory"], self.package_config["package_filename"])
        )

        clean_fakeroot()

        # Cleans up assuming the no-clean flag isn't set
        if not self.global_config["no_clean"]:
            run_command("rm -rf %s" % source_dir)
Esempio n. 2
0
    def make_working_dir(self):
        """Makes a working directory under global build dir"""

        working_dir = os.path.expanduser("%s/temp/%s" % (
            self.global_config["build_directory"], 
            self.package_config["package"]
        ))

        if os.path.exists(working_dir):
            if not self.global_config['assume_yes']:
                result = get_user_input(
                    'Suitcase Warning: %s will be deleted. Are you sure?' \
                        % working_dir, ['yes','no'], 'yes',
                )
                
                if result == 'no':
                    sys.exit(1)
                    
            run_command("rm -rf %s" % working_dir)

        if DEBUG:
            print "MAKING: " + working_dir
            
        try:    
            os.makedirs(working_dir)
        except OSError, error:
            raise SuitcasePackagingError(error)
Esempio n. 3
0
                        # Remove exclusions from the walking path
                        for exclusion in path_exclusions:
                            if exclusion in dirs:
                                dirs.remove(exclusion)

                        for file_path in files:
                            config_items[os.path.join(root, file_path)] = 1

                elif os.path.isfile(config_item):
                    config_items[config_item] = 1

            config_file = open(os.path.join(self.package_config["working_dir"], "DEBIAN", "conffiles"), "w")

            for file_path in config_items.keys():
                config_items[file_path] = file_path.replace(self.package_config["working_dir"], "")
            config_file.write("\n".join(config_items.values()))
            config_file.write("\n")

        # now do copyright
        copyright_dir = "%s/usr/share/doc/%s" % (self.package_config["working_dir"], self.package_config["package"])

        try:
            os.makedirs(copyright_dir)
        except OSError, error:
            raise SuitcasePackagingError(error)

        run_command(
            "cp %s %s/copyright"
            % (os.path.join(os.path.dirname(__file__), "../templates/debian/copyright_minimum.template"), copyright_dir)
        )
Esempio n. 4
0
    """

    if exclusions is None:
        exclusions = []

    if not os.path.exists(source):
        raise SuitcaseCopyError('Source directory does not exist')

    if not os.path.isdir(destination):
        try:
            os.makedirs(destination)    
        except OSError, error:
            raise SuitcaseCopyError(error)

    excludes_str = " ".join(
        ["--exclude '%s'" % exclusion for exclusion in exclusions]
    )

    if DEBUG:
        print "SOURCE: %s" % source
        print "DEST: %s" % destination

    rsync_str = "/usr/bin/rsync -r %s '%s' '%s'" % (
        excludes_str,
        source,
        destination
    )

    return run_command(rsync_str)

Esempio n. 5
0
 def test_run_command(self):
     """testing running a typical command"""
     command = "ls"
     result = run_command(command)
     self.assert_equal(result[0], 0)