Exemplo n.º 1
0
    def write_config(self):
        # Cleanup everything in /etc/pakfire.
        util.rm(self.chrootPath(CONFIG_DIR))

        for i in (CONFIG_DIR, CONFIG_REPOS_DIR):
            i = self.chrootPath(i)
            if not os.path.exists(i):
                os.makedirs(i)

        # Write general.conf.
        f = open(self.chrootPath(CONFIG_DIR, "general.conf"), "w")
        f.close()

        # Write builder.conf.
        f = open(self.chrootPath(CONFIG_DIR, "builder.conf"), "w")
        f.write(self.distro.get_config())
        f.close()

        # Create pakfire configuration files.
        for repo in self.pakfire.repos:
            conf = repo.get_config()

            if not conf:
                continue

            filename = self.chrootPath(CONFIG_REPOS_DIR, "%s.repo" % repo.name)
            f = open(filename, "w")
            f.write("\n".join(conf))
            f.close()
Exemplo n.º 2
0
	def handle_build(self):
		# Arch.
		if self.args.arch:
			arches = self.args.arch.split()

		(package,) = self.args.package

		self.server.create_scratch_build({})
		return

		# Temporary folter for source package.
		tmpdir = "/tmp/pakfire-%s" % util.random_string()

		try:
			os.makedirs(tmpdir)

			pakfire.dist(package, resultdir=[tmpdir,])

			for file in os.listdir(tmpdir):
				file = os.path.join(tmpdir, file)

				print file

		finally:
			if os.path.exists(tmpdir):
				util.rm(tmpdir)
Exemplo n.º 3
0
def main():

    parser = argparse.ArgumentParser()

    parser.add_argument("decline", help="value of the decline xIAC (e.g:FC0011AB00)")

    parser.add_argument("online", help="value of the online xIAC (e.g:FC0011AB00)")

    parser.add_argument("default", help="value of the decline xIAC (e.g:FC0011AB00)")

    parser.add_argument("-t", "--test", help="run the doctests", default=False, action="store_true")

    args = parser.parse_args()

    if args.test:
        import doctest

        doctest.testmod()
        return

    # xIAC
    decline = util.rm(args.decline)
    online = util.rm(args.online)
    default = util.rm(args.default)

    valid_in = validate(decline, online, default)

    if not valid_in:
        util.die("xIAC must all have the same length and be HEX values.")

    print human(decline, online, default)
    return
Exemplo n.º 4
0
    def write_config(self):
        # Cleanup everything in /etc/pakfire.
        util.rm(self.chrootPath(CONFIG_DIR))

        for i in (CONFIG_DIR, CONFIG_REPOS_DIR):
            i = self.chrootPath(i)
            if not os.path.exists(i):
                os.makedirs(i)

                # Write general.conf.
        f = open(self.chrootPath(CONFIG_DIR, "general.conf"), "w")
        f.close()

        # Write builder.conf.
        f = open(self.chrootPath(CONFIG_DIR, "builder.conf"), "w")
        f.write(self.distro.get_config())
        f.close()

        # Create pakfire configuration files.
        for repo in self.pakfire.repos:
            conf = repo.get_config()

            if not conf:
                continue

            filename = self.chrootPath(CONFIG_REPOS_DIR, "%s.repo" % repo.name)
            f = open(filename, "w")
            f.write("\n".join(conf))
            f.close()
Exemplo n.º 5
0
    def build(self, stages=None):
        # Create buildroot and remove all content if it was existant.
        util.rm(self.buildroot)
        os.makedirs(self.buildroot)

        # Build icecream toolchain if icecream is installed.
        self.create_icecream_toolchain()

        # Process stages in order.
        for stage in ("prepare", "build", "test", "install"):
            # Skip unwanted stages.
            if stages and not stage in stages:
                continue

                # Run stage.
            self.build_stage(stage)

            # Stop if install stage has not been processed.
        if stages and not "install" in stages:
            return

            # Run post-build stuff.
        self.post_compress_man_pages()
        self.post_remove_static_libs()
        self.post_extract_debuginfo()

        # Package the result.
        # Make all these little package from the build environment.
        log.info(_("Creating packages:"))
        pkgs = []
        for pkg in reversed(self.pkg.packages):
            packager = packages.packager.BinaryPackager(self.pakfire, pkg, self, self.buildroot)
            pkg = packager.run(self.resultdir)
            pkgs.append(pkg)
        log.info("")
Exemplo n.º 6
0
    def cleanup(self):
        self.log.debug("Cleaning environemnt.")

        # Remove the build directory and buildroot.
        dirs = (self.build_dir, self.chrootPath("result"))

        for d in dirs:
            if not os.path.exists(d):
                continue

            util.rm(d)
            os.makedirs(d)
Exemplo n.º 7
0
    def cleanup(self):
        self.log.debug("Cleaning environemnt.")

        # Remove the build directory and buildroot.
        dirs = (
            self.build_dir,
            self.chrootPath("result"),
        )

        for d in dirs:
            if not os.path.exists(d):
                continue

            util.rm(d)
            os.makedirs(d)
Exemplo n.º 8
0
def main():

    parser = argparse.ArgumentParser()

    parser.add_argument(
        'decline',
        help='value of the decline xIAC (e.g:FC0011AB00)',
    )

    parser.add_argument(
        'online',
        help='value of the online xIAC (e.g:FC0011AB00)',
    )

    parser.add_argument(
        'default',
        help='value of the decline xIAC (e.g:FC0011AB00)',
    )

    parser.add_argument('-t',
                        '--test',
                        help='run the doctests',
                        default=False,
                        action='store_true')

    args = parser.parse_args()

    if args.test:
        import doctest
        doctest.testmod()
        return

    # xIAC
    decline = util.rm(args.decline)
    online = util.rm(args.online)
    default = util.rm(args.default)

    valid_in = validate(decline, online, default)

    if not valid_in:
        util.die("xIAC must all have the same length and be HEX values.")

    print human(decline, online, default)
    return
Exemplo n.º 9
0
    def build(self, stages=None):
        # Create buildroot and remove all content if it was existant.
        util.rm(self.buildroot)
        os.makedirs(self.buildroot)

        # Build icecream toolchain if icecream is installed.
        self.create_icecream_toolchain()

        # Process stages in order.
        for stage in ("prepare", "build", "test", "install"):
            # Skip unwanted stages.
            if stages and not stage in stages:
                continue

            # Run stage.
            self.build_stage(stage)

        # Stop if install stage has not been processed.
        if stages and not "install" in stages:
            return

        # Run post-build stuff.
        self.post_compress_man_pages()
        self.post_remove_static_libs()
        self.post_extract_debuginfo()

        # Package the result.
        # Make all these little package from the build environment.
        log.info(_("Creating packages:"))
        pkgs = []
        for pkg in reversed(self.pkg.packages):
            packager = packages.packager.BinaryPackager(
                self.pakfire, pkg, self, self.buildroot)
            pkg = packager.run(self.resultdir)
            pkgs.append(pkg)
        log.info("")
Exemplo n.º 10
0
    def destroy(self):
        self.log.debug("Destroying environment %s" % self.path)

        if os.path.exists(self.path):
            util.rm(self.path)
Exemplo n.º 11
0
 def cleanup(self):
     if os.path.exists(self.buildroot):
         util.rm(self.buildroot)
Exemplo n.º 12
0
def manage(conf, args):
  '''
  Move a file to the base directory and leave a link pointing to its new
  location in its place.
  '''
  # bail if the file is already a link
  if os.path.islink(args.path):
    raise ValueError('Unable to manage ' + color.cyan(args.path) +
        " since it's already a link!")

  # make sure the path is a descendant of the destination directory
  if not util.is_descendant(args.path, conf['destination']):
    raise ValueError("Unable to manage files that aren't descendants of " +
        'the destination directory (' + color.cyan(conf['destination']) + ')')

  # mark files that aren't direct descendants of the root as such
  unrooted = os.path.dirname(args.path) != conf['destination']

  # get the path of the file if it will be copied into the repo directory
  dest_path = os.path.join(constants.REPO_DIR, os.path.basename(args.path))

  # rename the file as appropriate to to its original name
  dest_path, config_file_path = config.configify_file_name(dest_path)

  # give unrooted files a config file path so they'll go to the correct place
  if unrooted and config_file_path is None:
    config_file_path = util.toggle_hidden(dest_path, True)

  # bail if the file is already managed and we're not overwriting
  dest_exists = os.path.exists(dest_path)
  config_exists = (config_file_path is not None and
      os.path.exists(config_file_path))
  if (dest_exists or config_exists) and not args.force:
    raise ValueError("Can't manage " + color.cyan(args.path) +
        " since it already appears to be managed (use --force to override)")

  # create a file config if necessary
  # replace any existing dest file with a copy of the new one
  util.rm(dest_path, force=True)
  util.cp(args.path, dest_path, recursive=True)

  # replace any existing config file with our new one
  if config_file_path is not None:
    util.rm(config_file_path, force=True)

    # build a config for this file
    file_config = config.normalize_file_config({
      'paths': [args.path],
    }, conf['destination'])

    # create a config file from our config dict
    with open(config_file_path, 'w') as f:
      json.dump(file_config, f, indent=2)

  # create a link to the new location, overwriting the old file
  util.symlink(args.path, dest_path, overwrite=True)

  print(color.cyan(args.path), 'copied and linked')

  # add and commit the file to the repo if --save is specified
  if args.save:
    files = [color.cyan(os.path.basename(dest_path))]
    if config_file_path:
      files.append(color.cyan(os.path.basename(config_file_path)))
    files = files.join(' and ')

    print('Adding', files, 'to the repository...')

    # move us to the current repo directory so all git commands start there
    os.chdir(constants.REPO_DIR)

    # alert the user if we have uncommitted changes (git exits non-0 in this case)
    if git.diff(exit_code=True, quiet=True, _ok_code=(0, 1)).exit_code != 0:
      raise ValueError('The repository has uncommitted changes - the '
        'newly-managed file will have to be added to the repo manually.')

    # add the new files to the staging area
    git.add(dest_path)
    if config_file_path is not None:
      git.add(config_file_path)

    print('Successfully added', files, 'to the repository')
    print('Committing changes...')

    # commit the file to the repository
    commit_message = 'Manage %s' % os.path.basename(args.path)
    git.commit(m=commit_message, quiet=True)

    print('Commit successful!')
    print('Pushing committed changes...')

    # pull any changes down from upstream, then push our new addition
    git.pull(rebase=True, quiet=True)
    git.push(quiet=True)

    print('Push successful!')
Exemplo n.º 13
0
    def destroy(self):
        self.log.debug("Destroying environment %s" % self.path)

        if os.path.exists(self.path):
            util.rm(self.path)
Exemplo n.º 14
0
 def cleanup(self):
     if os.path.exists(self.buildroot):
         util.rm(self.buildroot)