aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RepSys/binrepo.py45
-rw-r--r--RepSys/rpmutil.py48
2 files changed, 52 insertions, 41 deletions
diff --git a/RepSys/binrepo.py b/RepSys/binrepo.py
index 2f80b82..12e394a 100644
--- a/RepSys/binrepo.py
+++ b/RepSys/binrepo.py
@@ -118,11 +118,10 @@ def svn_root(target):
return info["Repository Root"]
def enabled(url):
+ #TODO use information from url to find out whether we have a binrepo
+ # available for this url
use = config.getbool("global", "use-binaries-repository", False)
- default_parent = config.get("global", "default_parent", None)
- if url and use and default_parent and same_base(url, default_parent):
- return True
- return False
+ return use
def target_url(path=None):
from RepSys.rpmutil import get_submit_info
@@ -391,35 +390,43 @@ def markrelease(srcurl, desturl, version, release, revision):
finally:
shutil.rmtree(tmpdir)
-def download(target, url=None, check=True):
+def download(target, url=None, files=None, check=True):
+ """Tries to download files from binrepo, based on a svn directory
+
+ @target: directory where downloaded files will be placed.
+ @url: the url of the destination directory (in case it is not available
+ from target, as in a svn export'ed directory).
+ @files: names of files to be downloaded (in case the 'sources' file is
+ not available)
+ @check: check the integrity of the files against the hashes in the
+ 'sources' file
+ """
targeturl = target_url(url or target)
spath = sources_path(target)
- if not os.path.exists(spath):
- # we don't have external sources
+ if not os.path.exists(spath) and not files:
+ # we don't have anything to download
return
entries = parse_sources(spath)
+ for file in files:
+ # setdefault because the 'sources' file has precedence over the
+ # 'files' list, as we have hashes
+ entries.setdefault(file, None)
try:
host, path = targeturl.split(":", 1)
except ValueError:
host = None
path = targeturl
- if os.path.isdir(target):
- paths = [os.path.join(path, name) for name, sum in entries.iteritems()]
- targetdir = target
- else:
- paths = [os.path.join(path, os.path.basename(target))]
- name = os.path.basename(target)
- targetdir = os.path.dirname(target)
- if name not in entries:
- raise Error, "file not uploaded yet (not found in "\
- "sources file): %s" % target
- copy(sources=paths, sourcehost=host, dest=targetdir)
+ paths = [os.path.join(path, name) for name, sum in entries.iteritems()]
+ copy(sources=paths, sourcehost=host, dest=target)
if check:
yield "Checking files"
for path in paths:
name = os.path.basename(path)
- bpath = os.path.join(targetdir, name)
+ bpath = os.path.join(target, name)
sum = entries[name]
+ if sum is None:
+ # should we warn the user about it?
+ continue
check_hash(bpath, sum)
yield "Done"
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py
index 0eeee03..c53661e 100644
--- a/RepSys/rpmutil.py
+++ b/RepSys/rpmutil.py
@@ -596,51 +596,55 @@ def commit(target=".", message=None, logfile=None):
print "use \"repsys switch\" in order to switch back to mirror "\
"later"
+def spec_sources(topdir):
+ specs = glob.glob(os.path.join(topdir, "SPECS/*.spec"))
+ spec_path = specs[0] # FIXME use svn info to ensure which one
+ ts = rpm.ts()
+ spec = ts.parseSpec(spec_path)
+ sources = [name for name, x, y in spec.sources()]
+ return sources
+
def download_binaries(target, pkgdirurl=None, check=True):
refurl = pkgdirurl
if refurl is None:
refurl = binrepo.svn_root(target)
if binrepo.enabled(refurl):
+ download = []
sourcesdir = "SOURCES"
+ sources = spec_sources(target)
+ for source in sources:
+ path = os.path.join(target, sourcesdir, source)
+ if not os.path.exists(path):
+ # try to download those files that are referred in the spec
+ # but were not found in the svn working copy
+ download.append(source)
url = None
bintarget = os.path.join(target, sourcesdir)
if pkgdirurl:
url = os.path.join(pkgdirurl, sourcesdir)
- for status in binrepo.download(bintarget, url, check):
+ for status in binrepo.download(bintarget, url, download, check):
print status
def update(target=None):
svn = SVN()
+ info = None
svn_target = None
br_target = None
if target:
- info = svn.info2(target)
- spath = binrepo.sources_path(target)
- if info is None:
- # probably something kept in the binary repository
- if os.path.exists(spath):
- entries = binrepo.parse_sources(spath)
- name = os.path.basename(target)
- if name in entries:
- br_target = target
- svn_target = spath
- else:
- svn_target = target
- if info["Node Kind"] == "directory":
- if os.path.exists(spath):
- br_target = target
+ svn_target = target
else:
top = getpkgtopdir()
svn_target = top
- br_target = os.path.join(top, "SOURCES")
- if not br_target and not svn_target:
- raise Error, "target not in SVN nor in binaries "\
- "repository: %s" % target
+ br_target = top
if svn_target:
svn.update(svn_target, show=True)
if br_target:
- for status in binrepo.download(br_target):
- print status
+ info = svn.info2(svn_target)
+ if not br_target and not svn_target:
+ raise Error, "target not in SVN nor in binaries "\
+ "repository: %s" % target
+ url = info["URL"]
+ download_binaries(br_target, url)
def _sources_log(added, deleted):
lines = ["SILENT: changed sources list:\n"]