Exemplo n.º 1
0
 def _create_package(self):
     files = self._gather_files()
     params = {
         "files": files,
         "requires": self._requirements(),
         "obsoletes": self._obsoletes(),
         "conflicts": self._conflicts(),
         "defines": self._defines(),
         "undefines": self._undefines(),
         "build": self._build_details(),
         "who": sh.getuser(),
         "date": utils.iso8601(),
         "patches": self._patches(),
         "details": self.details,
     }
     (_fn, content) = utils.load_template("packaging", "spec.tmpl")
     spec_base = self._make_fn("spec")
     spec_fn = sh.joinpths(self.build_paths["specs"], spec_base)
     LOG.debug("Creating spec file %s with params:", spec_fn)
     files["sources"].append("%s.tar.gz" % (spec_base))
     utils.log_object(params, logger=LOG, level=logging.DEBUG)
     sh.write_file(spec_fn, utils.expand_template(content, params))
     tar_it(
         sh.joinpths(self.build_paths["sources"], "%s.tar.gz" % (spec_base)),
         spec_base,
         wkdir=self.build_paths["specs"],
     )
Exemplo n.º 2
0
 def _create_package(self):
     files = self._gather_files()
     params = {
         'files': files,
         'requires': self._requirements(),
         'obsoletes': self._obsoletes(),
         'conflicts': self._conflicts(),
         'defines': self._defines(),
         'undefines': self._undefines(),
         'build': self._build_details(),
         'who': sh.getuser(),
         'date': utils.iso8601(),
         'details': self.details,
     }
     (_fn, content) = utils.load_template('packaging', 'spec.tmpl')
     spec_base = self._make_fn("spec")
     spec_fn = sh.joinpths(self.build_paths['specs'], spec_base)
     LOG.debug("Creating spec file %s with params:", spec_fn)
     files['sources'].append("%s.tar.gz" % (spec_base))
     utils.log_object(params, logger=LOG, level=logging.DEBUG)
     sh.write_file(spec_fn, utils.expand_template(content, params))
     tar_it(sh.joinpths(self.build_paths['sources'],
                        "%s.tar.gz" % (spec_base)),
            spec_base,
            wkdir=self.build_paths['specs'])
Exemplo n.º 3
0
 def details(self):
     if self._details is not None:
         return self._details
     self._details = {
         'name': self.name,
         'version': 0,
         'release': self.get_int_option('release', default_value=1),
         'packager': "%s <%s@%s>" % (sh.getuser(), sh.getuser(), sh.hostname()),
         'changelog': '',
         'license': 'Apache License, Version 2.0',
         'automatic_dependencies': True,
         'vendor': None,
         'url': '',
         'description': '',
         'summary': 'Package build of %s on %s' % (self.name, utils.iso8601()),
     }
     return self._details
Exemplo n.º 4
0
 def _process_special(self, who, key):
     if key == 'ip' and who == 'auto':
         return utils.get_host_ip()
     if key == 'user' and who == 'auto':
         return sh.getuser()
     if who == 'auto':
         raise KeyError("Unknown auto key type %s" % (key))
     return None
Exemplo n.º 5
0
 def _process_special(self, who, key):
     if key == 'ip' and who == 'auto':
         return utils.get_host_ip()
     if key == 'user' and who == 'auto':
         return sh.getuser()
     if who == 'auto':
         raise KeyError("Unknown auto key type %s" % (key))
     return None
Exemplo n.º 6
0
 def details(self):
     if self._details is not None:
         return self._details
     self._details = {
         'name': self.name,
         'version': 0,
         'release': self.get_int_option('release', default_value=1),
         'packager':
         "%s <%s@%s>" % (sh.getuser(), sh.getuser(), sh.hostname()),
         'changelog': '',
         'license': 'Apache License, Version 2.0',
         'automatic_dependencies': True,
         'vendor': None,
         'url': '',
         'description': '',
         'summary':
         'Package build of %s on %s' % (self.name, utils.iso8601()),
     }
     return self._details
Exemplo n.º 7
0
def add_header(fn, contents):
    lines = list()
    if not fn:
        fn = "???"
    lines.append("# Adjusted source file %s" % (fn.strip()))
    lines.append("# On %s" % (date.rcf8222date()))
    lines.append("# By user %s, group %s" % (sh.getuser(), sh.getgroupname()))
    lines.append("")
    if contents:
        lines.append(contents)
    return joinlinesep(*lines)
Exemplo n.º 8
0
 def _generate_root_wrap(self):
     if not self.cfg.getboolean("nova", "do_root_wrap"):
         return False
     else:
         lines = list()
         lines.append("%s ALL=(root) NOPASSWD: %s" % (sh.getuser(), self.root_wrap_bin))
         fc = utils.joinlinesep(*lines)
         root_wrap_fn = sh.joinpths(self.distro.get_command_config("sudoers_dir"), "nova-rootwrap")
         self.tracewriter.file_touched(root_wrap_fn)
         with sh.Rooted(True):
             sh.write_file(root_wrap_fn, fc)
             sh.chmod(root_wrap_fn, 0440)
             sh.chown(root_wrap_fn, sh.getuid(sh.ROOT_USER), sh.getgid(sh.ROOT_GROUP))
         return True
Exemplo n.º 9
0
def add_header(fn, contents, adjusted=True):
    lines = []
    if not fn:
        fn = "???"
    if adjusted:
        lines.append('# Adjusted source file %s' % (fn.strip()))
    else:
        lines.append('# Created source file %s' % (fn.strip()))
    lines.append("# On %s" % (iso8601()))
    lines.append("# By user %s, group %s" % (sh.getuser(), sh.getgroupname()))
    lines.append("")
    if contents:
        lines.append(contents)
    return joinlinesep(*lines)
Exemplo n.º 10
0
def add_header(fn, contents, adjusted=True):
    lines = []
    if not fn:
        fn = "???"
    if adjusted:
        lines.append('# Adjusted source file %s' % (fn.strip()))
    else:
        lines.append('# Created source file %s' % (fn.strip()))
    lines.append("# On %s" % (iso8601()))
    lines.append("# By user %s, group %s" % (sh.getuser(), sh.getgroupname()))
    lines.append("")
    if contents:
        lines.append(contents)
    return joinlinesep(*lines)
Exemplo n.º 11
0
 def _get_param_map(self, config_fn):
     data_dir = sh.joinpths(self.get_option("app_dir"), self.cfg.getdefaulted("swift", "data_location", "data"))
     cfg_dir = self.get_option("cfg_dir")
     log_dir = sh.joinpths(data_dir, LOG_DIR)
     return {
         "USER": self.cfg.getdefaulted("swift", "swift_user", sh.getuser()),
         "GROUP": self.cfg.getdefaulted("swift", "swift_group", sh.getgroupname()),
         "SWIFT_DATA_LOCATION": data_dir,
         "SWIFT_CONFIG_LOCATION": cfg_dir,
         "SERVICE_TOKEN": self.cfg.get("passwords", "service_token"),
         "AUTH_SERVER": AUTH_SERVICE,
         "SWIFT_HASH": self.cfg.get("passwords", "swift_hash"),
         "SWIFT_LOGDIR": log_dir,
         "SWIFT_PARTITION_POWER_SIZE": self.cfg.getdefaulted("swift", "partition_power_size", "9"),
         # Note: leave these alone, will be adjusted later
         "NODE_PATH": "%NODE_PATH%",
         "BIND_PORT": "%BIND_PORT%",
         "LOG_FACILITY": "%LOG_FACILITY%",
     }
Exemplo n.º 12
0
 def _create_package(self):
     files = self._gather_files()
     params = {
         'files': files,
         'requires': self._requirements(),
         'obsoletes': self._obsoletes(),
         'conflicts': self._conflicts(),
         'defines': self._defines(),
         'undefines': self._undefines(),
         'build': self._build_details(),
         'who': sh.getuser(),
         'date': utils.iso8601(),
         'details': self.details,
     }
     (_fn, content) = utils.load_template('packaging', 'spec.tmpl')
     spec_base = self._make_fn("spec")
     spec_fn = sh.joinpths(self.build_paths['specs'], spec_base)
     LOG.debug("Creating spec file %s with params:", spec_fn)
     files['sources'].append("%s.tar.gz" % (spec_base))
     utils.log_object(params, logger=LOG, level=logging.DEBUG)
     sh.write_file(spec_fn, utils.expand_template(content, params))
     tar_it(sh.joinpths(self.build_paths['sources'], "%s.tar.gz" % (spec_base)),
            spec_base, wkdir=self.build_paths['specs'])
Exemplo n.º 13
0
 def _get_policy_users(self):
     ident_users = set()
     ident_users.add(DEF_IDENT)
     ident_users.add('unix-user:%s' % (sh.getuser()))
     return ident_users
Exemplo n.º 14
0
 def _get_apache_user_group(self):
     user = self.cfg.getdefaulted('horizon', 'apache_user', sh.getuser())
     group = self.cfg.getdefaulted('horizon', 'apache_group', sh.getgroupname())
     return (user, group)
Exemplo n.º 15
0
 def _get_packager(self):
     return "%s <%s@%s>" % (sh.getuser(), sh.getuser(), sh.hostname())
Exemplo n.º 16
0
 def _get_packager(self):
     return "%s <%s@%s>" % (sh.getuser(), sh.getuser(), sh.hostname())
Exemplo n.º 17
0
 def _get_policy_users(self):
     ident_users = [
         DEF_IDENT,
         'unix-user:%s' % (sh.getuser()),
     ]
     return ident_users