aboutsummaryrefslogtreecommitdiffstats
path: root/RepSys/rpmutil.py
diff options
context:
space:
mode:
authorBogdano Arendartchuk <bogdano@mandriva.org>2008-02-05 20:53:09 +0000
committerBogdano Arendartchuk <bogdano@mandriva.org>2008-02-05 20:53:09 +0000
commitfb388c2b7d01c98b0456ce97cf163f5394710b10 (patch)
tree168b484dbc9ec6d5f8687e7782c9a2ee37be131d /RepSys/rpmutil.py
parent49898e3e1977b32f26e8045aafb5e24afdccb167 (diff)
downloadmgarepo-fb388c2b7d01c98b0456ce97cf163f5394710b10.tar
mgarepo-fb388c2b7d01c98b0456ce97cf163f5394710b10.tar.gz
mgarepo-fb388c2b7d01c98b0456ce97cf163f5394710b10.tar.bz2
mgarepo-fb388c2b7d01c98b0456ce97cf163f5394710b10.tar.xz
mgarepo-fb388c2b7d01c98b0456ce97cf163f5394710b10.zip
Added --strict option to getsrpm + equivalent configuration option
This option makes repsys to fail if the revision provided by the user does not contain any changed path inside the package URL. This should prevent mistakes such as submitting update packages using the Cooker URL.
Diffstat (limited to 'RepSys/rpmutil.py')
-rw-r--r--RepSys/rpmutil.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py
index 45c9758..6fae669 100644
--- a/RepSys/rpmutil.py
+++ b/RepSys/rpmutil.py
@@ -33,6 +33,22 @@ def rpm_macros_defs(macros):
args = " ".join(defs)
return args
+def rev_touched_url(url, rev):
+ svn = SVN()
+ info = svn.info2(url)
+ if info is None:
+ raise Error, "can't fetch svn info about the URL: %s" % url
+ root = info["Repository Root"]
+ urlpath = url[len(root):]
+ touched = False
+ entries = svn.log(root, start=rev, limit=1)
+ entry = entries[0]
+ for change in entry.changed:
+ path = change.get("path")
+ if path and path.startswith(urlpath):
+ touched = True
+ return touched
+
def get_srpm(pkgdirurl,
mode = "current",
targetdirs = None,
@@ -46,7 +62,8 @@ def get_srpm(pkgdirurl,
submit = False,
template = None,
macros = [],
- verbose = 0):
+ verbose = 0,
+ strict = False):
svn = SVN()
tmpdir = tempfile.mktemp()
topdir = "--define '_topdir %s'" % tmpdir
@@ -66,6 +83,12 @@ def get_srpm(pkgdirurl,
geturl = os.path.join(pkgdirurl, "current")
else:
raise Error, "unsupported get_srpm mode: %s" % mode
+ strict = strict or config.getbool("submit", "strict-revision", False)
+ if strict and not rev_touched_url(geturl, revision):
+ #FIXME would be nice to have the revision number even when
+ # revision is None
+ raise Error, "the revision %s does not change anything "\
+ "inside %s" % (revision or "HEAD", geturl)
svn.export(geturl, tmpdir, rev=revision)
srpmsdir = os.path.join(tmpdir, "SRPMS")
os.mkdir(srpmsdir)