diff --git a/system/lib.py b/system/lib.py index d33e98e86..7be0d540f 100644 --- a/system/lib.py +++ b/system/lib.py @@ -367,6 +367,15 @@ def check_cmd_output(self, command, gold_name, match_prepare=None, expected_code else: raise + def write_file(self, path, content): + full_path = os.path.join(os.environ["HOME"], ".aptly", path) + + if not os.path.exists(os.path.dirname(full_path)): + os.makedirs(os.path.dirname(full_path), 0o755) + + with open(full_path, "w") as f: + f.write(content) + def read_file(self, path, mode=''): with open(os.path.join(os.environ["HOME"], self.aptlyDir, path), "r" + mode) as f: return f.read() diff --git a/system/t06_publish/PublishRepo34Test_gold b/system/t06_publish/PublishRepo34Test_gold new file mode 100644 index 000000000..365295fa9 --- /dev/null +++ b/system/t06_publish/PublishRepo34Test_gold @@ -0,0 +1,14 @@ +Loading packages... +Generating metadata files and linking package files... +Finalizing metadata files... +Signing file 'Release' with gpg, please enter your passphrase when prompted: +Clearsigning file 'Release' with gpg, please enter your passphrase when prompted: + +Local repo local-repo has been successfully published. +Please setup your webserver to serve directory '${HOME}/.aptly/public' with autoindexing. +Now you can add following line to apt sources: + deb http://your-server/ maverick main + deb-src http://your-server/ maverick main +Don't forget to add your GPG key to apt with apt-key. + +You can also use `aptly serve` to publish your repositories over HTTP quickly. diff --git a/system/t06_publish/repo.py b/system/t06_publish/repo.py index fd3409d68..006e70064 100644 --- a/system/t06_publish/repo.py +++ b/system/t06_publish/repo.py @@ -888,3 +888,61 @@ def check(self): self.check_exists('public/dists/maverick/main/binary-amd64/Packages') self.check_exists('public/dists/maverick/main/binary-amd64/Packages.gz') self.check_not_exists('public/dists/maverick/main/binary-amd64/Packages.bz2') + + +class PublishRepo34Test(BaseTest): + """ + publish repo: addon files + """ + fixtureCmds = [ + "aptly repo create local-repo", + "aptly repo add local-repo ${files}" + ] + runCmd = "aptly publish repo -keyring=${files}/aptly.pub -secret-keyring=${files}/aptly.sec -distribution=maverick -skip-contents local-repo" + gold_processor = BaseTest.expand_environ + + def prepare_fixture(self): + super(PublishRepo34Test, self).prepare_fixture() + + self.write_file(os.path.join('addon', 'dists', 'maverick', 'main', 'dep11', 'README'), 'README test file') + + def check(self): + super(PublishRepo34Test, self).check() + + self.check_exists('public/dists/maverick/main/dep11/README') + + self.check_exists('public/dists/maverick/Release') + + readme = self.read_file('public/dists/maverick/main/dep11/README') + if readme != 'README test file': + raise Exception("README file not copied on publish") + + release = self.read_file('public/dists/maverick/Release').split("\n") + release = [l for l in release if l.startswith(" ")] + pathsSeen = set() + for l in release: + fileHash, fileSize, path = l.split() + pathsSeen.add(path) + + fileSize = int(fileSize) + + st = os.stat(os.path.join(os.environ["HOME"], ".aptly", 'public/dists/maverick/', path)) + if fileSize != st.st_size: + raise Exception("file size doesn't match for %s: %d != %d" % (path, fileSize, st.st_size)) + + if len(fileHash) == 32: + h = hashlib.md5() + elif len(fileHash) == 40: + h = hashlib.sha1() + elif len(fileHash) == 64: + h = hashlib.sha256() + else: + h = hashlib.sha512() + + h.update(self.read_file(os.path.join('public/dists/maverick', path), mode='b')) + + if h.hexdigest() != fileHash: + raise Exception("file hash doesn't match for %s: %s != %s" % (path, fileHash, h.hexdigest())) + + if 'main/dep11/README' not in pathsSeen: + raise Exception("README file not included in release file")