aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MgaRepo/binrepo.py17
-rw-r--r--MgaRepo/commands/sync.py6
-rw-r--r--MgaRepo/rpmutil.py14
3 files changed, 35 insertions, 2 deletions
diff --git a/MgaRepo/binrepo.py b/MgaRepo/binrepo.py
index 89679b0..874a091 100644
--- a/MgaRepo/binrepo.py
+++ b/MgaRepo/binrepo.py
@@ -170,3 +170,20 @@ def update_sources(topdir, added=[], removed=[]):
f.write("%s %s\n" % (entries[name], name))
f.close()
+def check_sources(topdir):
+ """Verify hashes against binrepo files
+
+ Returns a list of files that differ. Files have do not exist locally are
+ ignored.
+ """
+ changed = []
+ path = sources_path(topdir)
+ if os.path.isfile(path):
+ entries = parse_sources(path)
+ for filename in entries:
+ filepath = os.path.join(topdir, 'SOURCES', filename)
+ if os.path.exists(filepath):
+ name = os.path.basename(filepath)
+ if entries[name] != file_hash(filepath):
+ changed.append(name)
+ return changed
diff --git a/MgaRepo/commands/sync.py b/MgaRepo/commands/sync.py
index 54f5635..9f318e1 100644
--- a/MgaRepo/commands/sync.py
+++ b/MgaRepo/commands/sync.py
@@ -8,12 +8,14 @@ Usage: mgarepo sync
Will add or remove from the working copy those files added or removed
in the spec file.
-It will not commit the changes.
+It will not commit the changes, but it will upload or download binrepo files
+when -u or -d are given.
Options:
--dry-run Print results without changing the working copy
--download -d
Try to download the source files not found
+ --upload -u Upload changed source files and update sha1.lst
-h Show this message
Examples:
@@ -30,6 +32,8 @@ def parse_options():
action="store_true")
parser.add_option("-d", "--download", dest="download", default=False,
action="store_true")
+ parser.add_option("-u", "--upload", dest="up", default=False,
+ action="store_true")
opts, args = parser.parse_args()
# TODO:
# Completely remove -c switch from code
diff --git a/MgaRepo/rpmutil.py b/MgaRepo/rpmutil.py
index 66343b5..b71afb0 100644
--- a/MgaRepo/rpmutil.py
+++ b/MgaRepo/rpmutil.py
@@ -514,7 +514,7 @@ def ispkgtopdir(path=None):
names = os.listdir(path)
return (".svn" in names and "SPECS" in names and "SOURCES" in names)
-def sync(dryrun=False, commit=False, download=False):
+def sync(dryrun=False, commit=False, download=False, up=False):
svn = SVN()
topdir = getpkgtopdir()
spath = binrepo.sources_path(topdir)
@@ -596,6 +596,18 @@ def sync(dryrun=False, commit=False, download=False):
print("A\t%s" % path)
if not dryrun:
upload([path], commit=commit)
+ # check binrepo files
+ changed = binrepo.check_sources(topdir)
+ if changed:
+ changed_paths = []
+ for filename in changed:
+ filepath = os.path.join(topdir, 'SOURCES', filename)
+ changed_paths.append(filepath)
+ print('M\t%s' % filepath)
+ if not dryrun and up:
+ binrepo.upload_binary(topdir, filename)
+ if not dryrun and up:
+ binrepo.update_sources(topdir, added=changed_paths)
def commit(target=".", message=None, logfile=None):
svn = SVN()