2 commits - modifyrepo.py
[email protected] Mon, 30 Sep 2013 14:27:38 +0000 (UTC)
| Newsgroups | gmane.linux.rpm.metadata |
|---|---|
| Message-ID | <[email protected]> |
modifyrepo.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) New commits: commit de6c0b5e53ab1628355443b2c1d60574654a89be Author: Zdenek Pavlas <[email protected]> Date: Mon Sep 30 15:57:47 2013 +0200 modifyrepo --remove: fix multiple bugs. BZ 1013626 - Fix mdtype autodetection from filename. Now we should correctly derive mdtype even if the file argument used full path, and/or --unique-md-filenames was on. - Remove metadata file using path relative to repodir. See the BZ, unlink should work from any $cwd. - Honor --mdtype option When --mdtype is specified, it overrides mdtype autodetection. This should work for --remove, too. diff --git a/modifyrepo.py b/modifyrepo.py index 13b14a5..f9d346c 100755 --- a/modifyrepo.py +++ b/modifyrepo.py @@ -60,6 +60,9 @@ class RepoMetadata: """ Get mdtype from existing mdtype or from a mdname. """ if mdtype: return mdtype + mdname = os.path.basename(mdname) + if re.match(r'[0-9a-f]{32,}-', mdname): + mdname = mdname.split('-', 1)[1] return mdname.split('.')[0] def _print_repodata(self, repodata): @@ -82,7 +85,8 @@ class RepoMetadata: def _remove_repodata_file(self, repodata): """ Remove a file specified in repodata location """ try: - os.remove(repodata.location[1]) + fname = os.path.basename(repodata.location[1]) + os.remove(os.path.join(self.repodir, fname)) except OSError, ex: if ex.errno != 2: # continue on a missing file @@ -243,7 +247,7 @@ def main(args): # remove if opts.remove: try: - repomd.remove(metadata) + repomd.remove(metadata, mdtype=opts.mdtype) except MDError, ex: print "Could not remove metadata: %s" % (metadata, str(ex)) return 1 commit 66b4c0557b33e797a1a8c47d8575e70b179b1785 Author: Tomas Mlcoch <[email protected]> Date: Mon Sep 30 14:20:34 2013 +0200 Add support for <open-size> element + show size and open-size on output diff --git a/modifyrepo.py b/modifyrepo.py index 804a243..13b14a5 100755 --- a/modifyrepo.py +++ b/modifyrepo.py @@ -69,6 +69,8 @@ class RepoMetadata: print " checksum =", repodata.checksum[1] print " timestamp =", repodata.timestamp print " open-checksum =", repodata.openchecksum[1] + print " size =", repodata.size + print " open-size =", repodata.opensize def _write_repomd(self): """ Write the updated repomd.xml. """ @@ -142,8 +144,10 @@ class RepoMetadata: new_rd.type = mdtype new_rd.location = (None, 'repodata/' + base_destmd) new_rd.checksum = (self.checksum_type, csum) - new_rd.openchecksum = (self.checksum_type, open_csum) new_rd.size = str(os.stat(destmd).st_size) + if do_compress: + new_rd.openchecksum = (self.checksum_type, open_csum) + new_rd.opensize = str(os.stat(metadata).st_size) new_rd.timestamp = str(int(os.stat(destmd).st_mtime)) self.repoobj.repoData[new_rd.type] = new_rd self._print_repodata(new_rd)