def apply_patch (self, patch, strip_components=1): name, parameters = misc.dissect_url (patch) strip = str (strip_components) strip = parameters.get ('strip', [strip])[0] strip = parameters.get ('strip_components', [strip])[0] self.system (''' cd %(srcdir)s && patch -p%(strip)s < %(patchdir)s/%(name)s ''', locals ())
def apply_patch(self, patch, strip_components=1): name, parameters = misc.dissect_url(patch) strip = str(strip_components) strip = parameters.get('strip', [strip])[0] strip = parameters.get('strip_components', [strip])[0] self.system( ''' cd %(srcdir)s && patch -p%(strip)s < %(patchdir)s/%(name)s ''', locals())
def get_repository(dir, url, branch="", module="", revision=""): parameters = dict() if url: url, parameters = misc.dissect_url(url) branch = parameters.get("branch", [branch])[0] revision = parameters.get("revision", [revision])[0] # FIXME/TODO: pass these nicely to create () # possibly do dir,url,branch,revision also as dict or kwargs? name = parameters.get("name", [""])[0] module = parameters.get("module", [module])[0] for proxy in RepositoryProxy.repositories: if proxy.check_url(proxy, url): # FIXME: drop branch, module, revision and pass as parameters return proxy.create(proxy, dir, url, branch, module, revision, parameters) if url and url.startswith("file://"): u = misc.Url(url) proto = u.protocol host = u.host url_dir = u.dir for proxy in RepositoryProxy.repositories: if proxy.check_dir(proxy, url_dir): return proxy.create(proxy, dir, url, branch, module, revision, parameters) for proxy in RepositoryProxy.repositories: if proxy.check_dir(proxy, dir): return proxy.create(proxy, dir, url, branch, module, revision, parameters) for proxy in RepositoryProxy.repositories: if proxy.check_suffix(proxy, url): return proxy.create(proxy, dir, url, branch, module, revision, parameters) for proxy in RepositoryProxy.repositories: if os.path.isdir(os.path.join(dir, ".gub" + proxy.vc_system)): d = misc.find_dirs(dir, "^" + proxy.vc_system) if d and proxy.check_dir(proxy, os.path.dirname(d[0])): return proxy.create(proxy, dir, url, branch, module, revision, parameters) for proxy in RepositoryProxy.repositories: # FIXME: this is currently used to determine flavour of # downloads/lilypond.git. But is is ugly and fragile; # what if I do brz branch foo foo.git? if proxy.check_suffix(proxy, dir): return proxy.create(proxy, dir, url, branch, module, revision, parameters) raise UnknownVcSystem("Cannot determine source: url=%(url)s, dir=%(dir)s" % locals())
def name_to_dependencies_via_gub(url): platform, url = split_platform(url) if ':' in url: base, unused_parameters = misc.dissect_url(url) name = (os.path.basename(base).replace('.git', '')) key = url else: name = get_base_package_name(url) url = None key = name key = with_platform(key, platform) if key in specs: spec = specs[key] else: if platform not in sets: sets[platform] = gub.settings.Settings(platform) spec = dependency.Dependency(sets[platform], name, url).build() specs[key] = spec return list( map(get_base_package_name, spec.get_platform_build_dependencies()))
def name_to_dependencies_via_gub (url): platform, url = split_platform (url) if ':' in url: base, unused_parameters = misc.dissect_url (url) name = (os.path.basename (base) .replace ('.git', '')) key = url else: name = get_base_package_name (url) url = None key = name key = with_platform (key, platform) if key in specs: spec = specs[key] else: if platform not in sets: sets[platform] = gub.settings.Settings (platform) spec = dependency.Dependency (sets[platform], name, url).build () specs[key] = spec return list (map (get_base_package_name, spec.get_platform_build_dependencies ()))
def url (self): if not self._url: self._url = self.build_class ().source if not self._url: logging.warning ('no source specified in class: ' + self.build_class ().__name__ + '\n') if not self._url: self._url = self.settings.dependency_url (self.name ()) if not self._url: raise Exception ('No URL for: ' + misc.with_platform (self._name, self.settings.platform)) if type (self._url) == str: try: self._url = self._url % self.settings.__dict__ except: printf ('URL:', self._url) raise x, parameters = misc.dissect_url (self._url) if parameters.get ('patch'): self._cls.patches = parameters['patch'] if parameters.get ('dependency'): self._cls.build_dependencies = parameters['dependency'] return self._url