#parser.add_option("-l", "--list-datatypes", action="store_true",
# help="List datatypes for which delta is supported.")
parser.add_argument("-o", "--outputdir", action="store", metavar="DIR",
- help="Output directory.", default="./")
+ help="Output directory.", default=None)
parser.add_argument("-d", "--database", action="store_true",
help="Force database generation")
parser.add_argument("--ignore-missing", action="store_true",
# Final move
if os.path.exists(self.final_path):
- self._warning("Destination dir already exists! Removing %s" % \
+ self._debug("Destination dir already exists! Removing %s" % \
self.final_path)
shutil.rmtree(self.final_path)
self._debug("Moving %s -> %s" % (self.new_repodata_path, self.final_path))
import os
import pprint
import os.path
+import time
import librepo
import tempfile
import createrepo_c as cr
def apply_resolved_path(self, resolved_path):
# TODO: Make it look better (progressbar, etc.)
- counter = 0
+ counter = 1
tmpdir = tempfile.mkdtemp(prefix="deltarepos-", dir="/tmp")
- targetrepo = tempfile.mkdtemp(prefix="targetrepo", dir=tmpdir)
- self._debug("Using temporary dir for downloading: {0}".format(tmpdir))
+ tmprepo = tempfile.mkdtemp(prefix="targetrepo", dir=tmpdir)
+ prevrepo = self.localrepo.path
+
+ self._debug("Using temporary directory: {0}".format(tmpdir))
for link in resolved_path:
# Download repo
- print("Downloading delta repo {0}".format(link.deltarepourl))
+ self._info("{0:2}/{1:<2} Downloading delta repo {2}".format(
+ counter, len(resolved_path), link.deltarepourl))
dirname = "deltarepo_{0:02}".format(counter)
destdir = os.path.join(tmpdir, dirname)
os.mkdir(destdir)
repo = Updater.DownloadedRepo(link.deltarepourl)
repo.download(destdir)
- counter += 1
# Apply repo
- da = DeltaRepoApplicator(self.localrepo.path,
+ self._info("{0:2}/{1:<2} Applying delta repo".format(
+ counter, len(resolved_path)))
+ da = DeltaRepoApplicator(prevrepo,
destdir,
- out_path=targetrepo,
+ out_path=tmprepo,
logger=self.logger,
ignore_missing=True)
da.apply()
- # def update(self, target_contenthash, target_contenthash_type="sha256"):
- # """Transform the localrepo to the version specified
- # by the target_contenthash"""
- #
- # if not self.localrepo.contenthash or not self.localrepo.contenthash_type:
- # raise DeltaRepoError("content hash is not specified in localrepo")
- #
- # if self.localrepo.contenthash_type != target_contenthash_type:
- # raise DeltaRepoError("Contenthash type mishmash - LocalRepo {0}, "
- # "Target: {1}".format(self.localrepo.contenthash_type,
- # target_contenthash_type))
- #
- # resolved_path = self.updatesolver.resolve_path(self.localrepo.contenthash,
- # target_contenthash,
- # target_contenthash_type)
- #
- # if not resolved_path:
- # raise DeltaRepoError("Path \'{0}\'->\'{1}\' ({2}) cannot "
- # "be resolved".format(self.localrepo.contenthash,
- # target_contenthash,
- # target_contenthash_type))
- #
- # self.apply_resolved_path(resolved_path)
-
- #def update_to_current(self, originrepo):
- # target_contenthash_type = self.localrepo.contenthash_type
- # _, target_contenthash = self.find_repo_contenthash(originrepo,
- # target_contenthash_type)
- # if not target_contenthash:
- # raise DeltaRepoError("Cannot determine contenthash ({0}) "
- # "of originrepo".format(target_contenthash_type))
- #
- # self.update(target_contenthash,
- # target_contenthash_type=target_contenthash_type)
- #
+ counter += 1
+ prevrepo = tmprepo
+
+ # Move updated repo to the final destination
+ dirname = os.path.dirname(self.localrepo.path)
+ basename = ".deltarepo-repodata-{0}-{1}".format(time.time(), os.getpid())
+ targettmprepodata = os.path.join(dirname, basename)
+ originaltmprepodata = targettmprepodata+"-original"
+ tmprepodata = os.path.join(tmprepo, "repodata")
+ originalrepodatapath = os.path.join(self.localrepo.path, "repodata")
+
+ self._debug("Final move to {0}".format(self.localrepo.path))
+
+ self._debug("Copying {0} -> {1}".format(tmprepodata, targettmprepodata))
+ shutil.copytree(tmprepodata, targettmprepodata)
+ self._debug("Moving {0} -> {1}".format(originalrepodatapath, originaltmprepodata))
+ shutil.move(originalrepodatapath, originaltmprepodata)
+ self._debug("Moving {0} -> {1}".format(targettmprepodata, originalrepodatapath))
+ shutil.move(targettmprepodata, originalrepodatapath)
+ self._debug("Removing {0}".format(originaltmprepodata))
+ shutil.rmtree(originaltmprepodata)
+ self._debug("Removing {0}".format(tmpdir))
+ shutil.rmtree(tmpdir)
cp -r repos/repo1 test/
cp -r repos/repo3 test/
-../repoupdater.py test/repo1/ --verbose --repo file://`pwd`/test/repo3/ --drmirror file://`pwd`/deltarepos/
+../repoupdater.py test/repo1/ $@ --repo file://`pwd`/test/repo3/ --drmirror file://`pwd`/deltarepos/
+++ /dev/null
-a content
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-MY_DIR=`dirname $0`
-
-if [[ -z "$CREATEREPO" ]]
-then
- CREATEREPO="createrepo_c"
-fi
-
-if [[ -z "$MODIFYREPO" ]]
-then
- MODIFYREPO="modifyrepo_c"
-fi
-
-pushd "$MY_DIR"
-$CREATEREPO $EXTRAARGS --pkglist pkglist --groupfile group.xml --revision "1st repo" --content "A content tag" .
-$MODIFYREPO --mdtype="foobar" foobar-1 repodata/
-popd
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
-<comps>
-<!-- -->
-</comps>
+++ /dev/null
-../packages/Archer-3.4.5-6.x86_64.rpm
-../packages/fake_bash-1.1.1-1.x86_64.rpm
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
-<comps>
-<!-- -->
-</comps>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
- <revision>1st repo</revision>
- <tags>
- <content>A content tag</content>
- </tags>
- <data type="primary">
- <checksum type="sha256">4b4a98a3883ca24ecda5cb105f9c162dfdfc6d074379e7c9e8311f9fde249407</checksum>
- <open-checksum type="sha256">9276f812675ba0193df682253ece4b14faa8a1dda77a14217aa95a4a53f96caf</open-checksum>
- <location href="repodata/4b4a98a3883ca24ecda5cb105f9c162dfdfc6d074379e7c9e8311f9fde249407-primary.xml.gz"/>
- <timestamp>1392910623</timestamp>
- <size>1060</size>
- <open-size>3916</open-size>
- </data>
- <data type="filelists">
- <checksum type="sha256">fac6a651423edc252a488b74995641ec4514e6bca12864032c019dcce9614d81</checksum>
- <open-checksum type="sha256">50c5f1c5645a8e52c16845c321d6b0fcf3bd6ea2227d5d49b1d8f0b585da31ed</open-checksum>
- <location href="repodata/fac6a651423edc252a488b74995641ec4514e6bca12864032c019dcce9614d81-filelists.xml.gz"/>
- <timestamp>1392910623</timestamp>
- <size>370</size>
- <open-size>630</open-size>
- </data>
- <data type="other">
- <checksum type="sha256">a5ad5ae1f43eae9e8e1b3fb6ee93e2cf8950708e0b3db8af3ee68f31dd0a38c2</checksum>
- <open-checksum type="sha256">db841078c111c4ae9c59ee996f6234d2dd4bf4f61a01892565bdaf6fb1c0879e</open-checksum>
- <location href="repodata/a5ad5ae1f43eae9e8e1b3fb6ee93e2cf8950708e0b3db8af3ee68f31dd0a38c2-other.xml.gz"/>
- <timestamp>1392910623</timestamp>
- <size>438</size>
- <open-size>939</open-size>
- </data>
- <data type="primary_db">
- <checksum type="sha256">a81604899900f2f58ead1e4a1d903700efe7acf64f684d6e16c9ae5be16094a7</checksum>
- <open-checksum type="sha256">84d58ab2442be220c192439c5f528eb11997cd0d5bbd075e634ecb912870d3e8</open-checksum>
- <location href="repodata/a81604899900f2f58ead1e4a1d903700efe7acf64f684d6e16c9ae5be16094a7-primary.sqlite.bz2"/>
- <timestamp>1392910623</timestamp>
- <size>2376</size>
- <open-size>21504</open-size>
- <database_version>10</database_version>
- </data>
- <data type="filelists_db">
- <checksum type="sha256">64e015b633e6cac5193a0a44403162cf90c39bb29cd8cb1df8e5ca0f2ec56436</checksum>
- <open-checksum type="sha256">4d0dfa0564f4e57953ea58f1d5c28c4bd94b18e2ebf26c640c7c4a3051ec838a</open-checksum>
- <location href="repodata/64e015b633e6cac5193a0a44403162cf90c39bb29cd8cb1df8e5ca0f2ec56436-filelists.sqlite.bz2"/>
- <timestamp>1392910623</timestamp>
- <size>927</size>
- <open-size>7168</open-size>
- <database_version>10</database_version>
- </data>
- <data type="other_db">
- <checksum type="sha256">0e43813b2bf4a47abcafa39072c0bc3279b8ec65ab34b929a6cd234f5b0e3e4f</checksum>
- <open-checksum type="sha256">54719f2eeae2623c331373f79fe6ed61c9ef81ad861446f566ff31ab7eeff71f</open-checksum>
- <location href="repodata/0e43813b2bf4a47abcafa39072c0bc3279b8ec65ab34b929a6cd234f5b0e3e4f-other.sqlite.bz2"/>
- <timestamp>1392910623</timestamp>
- <size>933</size>
- <open-size>6144</open-size>
- <database_version>10</database_version>
- </data>
- <data type="foobar">
- <checksum type="sha256">06d8204d74de57ed4050a72280d25d2e73dabf8298f94e415d12d3b847682752</checksum>
- <open-checksum type="sha256">d2d2acf640179223bf9e1eb43c5fbf854c4e50ffb6733bc3a9279d3ff7de9be1</open-checksum>
- <location href="repodata/06d8204d74de57ed4050a72280d25d2e73dabf8298f94e415d12d3b847682752-foobar-1.gz"/>
- <timestamp>1392910623</timestamp>
- <size>29</size>
- <open-size>9</open-size>
- </data>
- <data type="group">
- <checksum type="sha256">a5e176f8963047438fee997c4cad6a5388ef85d0b22d72a48712cc91bf2821c5</checksum>
- <location href="repodata/a5e176f8963047438fee997c4cad6a5388ef85d0b22d72a48712cc91bf2821c5-group.xml"/>
- <timestamp>1392910623</timestamp>
- <size>140</size>
- </data>
- <data type="group_gz">
- <checksum type="sha256">46b296e6f4193dcf5cdc11f10be8472a7085c6d45f05a09da5ef4e4c80c8828b</checksum>
- <open-checksum type="sha256">a5e176f8963047438fee997c4cad6a5388ef85d0b22d72a48712cc91bf2821c5</open-checksum>
- <location href="repodata/46b296e6f4193dcf5cdc11f10be8472a7085c6d45f05a09da5ef4e4c80c8828b-group.xml.gz"/>
- <timestamp>1392910623</timestamp>
- <size>141</size>
- <open-size>140</open-size>
- </data>
-</repomd>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
-<comps>
-<!-- -->
-</comps>
+++ /dev/null
-a content
\ No newline at end of file
+++ /dev/null
-#!/bin/bash
-
-MY_DIR=`dirname $0`
-
-if [[ -z "$CREATEREPO" ]]
-then
- CREATEREPO="createrepo_c"
-fi
-
-if [[ -z "$MODIFYREPO" ]]
-then
- MODIFYREPO="modifyrepo_c"
-fi
-
-pushd "$MY_DIR"
-$CREATEREPO $EXTRAARGS --pkglist pkglist --groupfile comps.xml --revision "3th repo" --content "Content tag 123456" .
-$MODIFYREPO foobar repodata/
-popd
+++ /dev/null
-../packages/Archer-3.4.5-6.x86_64.rpm
-../packages/balicek-utf8-1.1.1-1.x86_64.rpm
-../packages/empty-0-0.x86_64.rpm
-../packages/fake_bash-1.1.1-1.x86_64.rpm
-../packages/super_kernel-6.0.1-2.x86_64.rpm
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE comps PUBLIC "-//Red Hat, Inc.//DTD Comps info//EN" "comps.dtd">
-<comps>
-<!-- -->
-</comps>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<repomd xmlns="http://linux.duke.edu/metadata/repo" xmlns:rpm="http://linux.duke.edu/metadata/rpm">
- <revision>3th repo</revision>
- <tags>
- <content>Content tag 123456</content>
- </tags>
- <data type="primary">
- <checksum type="sha256">f209787b500f81fc59f7babcfaa122db99cbe3c0817edd7336febc96b95ece33</checksum>
- <open-checksum type="sha256">a09ebfe06c2ab1200ef8f05bb380f9540f1d06e6a1407f16c7f325eb20a86109</open-checksum>
- <location href="repodata/f209787b500f81fc59f7babcfaa122db99cbe3c0817edd7336febc96b95ece33-primary.xml.gz"/>
- <timestamp>1392910626</timestamp>
- <size>1740</size>
- <open-size>8069</open-size>
- </data>
- <data type="filelists">
- <checksum type="sha256">e6c1900810fb1155e7a29c59df839e9d20a369b5fb2cad87d880f664fa815e3f</checksum>
- <open-checksum type="sha256">fb32b1e587f0a2499ea15fb2224d0dec9ce615f2661ba4757b3ea18ce56ccc76</open-checksum>
- <location href="repodata/e6c1900810fb1155e7a29c59df839e9d20a369b5fb2cad87d880f664fa815e3f-filelists.xml.gz"/>
- <timestamp>1392910626</timestamp>
- <size>560</size>
- <open-size>1217</open-size>
- </data>
- <data type="other">
- <checksum type="sha256">07125d910a68f01ac92f37921aa7fb4edd20a05e493c7b9123fd4cd43ed27b45</checksum>
- <open-checksum type="sha256">cb344434c4f54eca225b3db0202163bd61f7524e3f18df4812f82c9377b0350e</open-checksum>
- <location href="repodata/07125d910a68f01ac92f37921aa7fb4edd20a05e493c7b9123fd4cd43ed27b45-other.xml.gz"/>
- <timestamp>1392910626</timestamp>
- <size>743</size>
- <open-size>1863</open-size>
- </data>
- <data type="primary_db">
- <checksum type="sha256">5b18db33715f9cbdd50e72b14af24476bad7b065bfe0cf56f45bbebd6dd92b08</checksum>
- <open-checksum type="sha256">711c7cd2ab9c93a5a7349c8a1b225a6794fc87fa66232329f33273ce7e117a0c</open-checksum>
- <location href="repodata/5b18db33715f9cbdd50e72b14af24476bad7b065bfe0cf56f45bbebd6dd92b08-primary.sqlite.bz2"/>
- <timestamp>1392910626</timestamp>
- <size>3439</size>
- <open-size>23552</open-size>
- <database_version>10</database_version>
- </data>
- <data type="filelists_db">
- <checksum type="sha256">7946a0f6e1676a33f763e12eddf0ce805c15a81d5de9d93ca81537eda34ccef4</checksum>
- <open-checksum type="sha256">ba39a46626a7b413d775ce685d52a81e536d748fa56af0558ecc8d109f48b55c</open-checksum>
- <location href="repodata/7946a0f6e1676a33f763e12eddf0ce805c15a81d5de9d93ca81537eda34ccef4-filelists.sqlite.bz2"/>
- <timestamp>1392910626</timestamp>
- <size>1217</size>
- <open-size>7168</open-size>
- <database_version>10</database_version>
- </data>
- <data type="other_db">
- <checksum type="sha256">609eca035393772a53575fa2792c238277034760e616e11fbaaf0517e1ea877f</checksum>
- <open-checksum type="sha256">d30994831b79ac3cb8a819c4f17cac0b9ae95f093539ffc216845f9f9216cd42</open-checksum>
- <location href="repodata/609eca035393772a53575fa2792c238277034760e616e11fbaaf0517e1ea877f-other.sqlite.bz2"/>
- <timestamp>1392910626</timestamp>
- <size>1322</size>
- <open-size>6144</open-size>
- <database_version>10</database_version>
- </data>
- <data type="foobar">
- <checksum type="sha256">06d8204d74de57ed4050a72280d25d2e73dabf8298f94e415d12d3b847682752</checksum>
- <open-checksum type="sha256">d2d2acf640179223bf9e1eb43c5fbf854c4e50ffb6733bc3a9279d3ff7de9be1</open-checksum>
- <location href="repodata/06d8204d74de57ed4050a72280d25d2e73dabf8298f94e415d12d3b847682752-foobar.gz"/>
- <timestamp>1392910626</timestamp>
- <size>29</size>
- <open-size>9</open-size>
- </data>
- <data type="group">
- <checksum type="sha256">a5e176f8963047438fee997c4cad6a5388ef85d0b22d72a48712cc91bf2821c5</checksum>
- <location href="repodata/a5e176f8963047438fee997c4cad6a5388ef85d0b22d72a48712cc91bf2821c5-comps.xml"/>
- <timestamp>1392910626</timestamp>
- <size>140</size>
- </data>
- <data type="group_gz">
- <checksum type="sha256">46b296e6f4193dcf5cdc11f10be8472a7085c6d45f05a09da5ef4e4c80c8828b</checksum>
- <open-checksum type="sha256">a5e176f8963047438fee997c4cad6a5388ef85d0b22d72a48712cc91bf2821c5</open-checksum>
- <location href="repodata/46b296e6f4193dcf5cdc11f10be8472a7085c6d45f05a09da5ef4e4c80c8828b-comps.xml.gz"/>
- <timestamp>1392910626</timestamp>
- <size>141</size>
- <open-size>140</open-size>
- </data>
-</repomd>
def print_contenthashes(args, logger):
# Print content hash from the repomd.xml
- localrepo = LocalRepo.from_path(args.path, calculate_contenthash=False)
+ localrepo = LocalRepo.from_path(args.path, calc_contenthash=False)
if localrepo.repomd_contenthash and localrepo.repomd_contenthash_type:
print("R {0} {1}".format(localrepo.repomd_contenthash_type, localrepo.repomd_contenthash))
def check(args, logger):
# Get type and value of content hash in repomd
- localrepo = LocalRepo.from_path(args.path, calculate_contenthash=False)
+ localrepo = LocalRepo.from_path(args.path, calc_contenthash=False)
if not localrepo.repomd_contenthash or not localrepo.repomd_contenthash_type:
if args.missing_contenthash_in_repomd_is_ok:
return True
# Resolve path
resolved_path = updatesolver.resolve_path(source_contenthash, target_contenthash)
- print(resolved_path)
# TODO check cost, if bigger then cost of downloading
# origin repo then download origin repo