class FetcherTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self, database = False) self.spec = SpecFile() self.spec.read("tests/helloworld/pspec.xml") self.url = uri.URI(self.spec.source.archiveUri) self.destpath = ctx.config.archives_dir() self.fetch = fetcher.Fetcher(self.url, self.destpath) def testFetch(self): self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archiveSHA1) os.remove(fetchedFile) def testResume(self): resume_test_file = "tests/helloworld/hello-1.3.tar.gz.part" shutil.copy(resume_test_file, ctx.config.archives_dir()) self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archiveSHA1) os.remove(fetchedFile)
class FetcherTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self, database = False) self.spec = SpecFile() self.spec.read("tests/helloworld/pspec.xml") self.url = uri.URI(self.spec.source.archive.uri) self.destpath = ctx.config.archives_dir() self.fetch = fetcher.Fetcher(self.url, self.destpath) def testFetch(self): self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archive.sha1sum) os.remove(fetchedFile) def testResume(self): resume_test_file = "tests/helloworld/helloworld-2.0.tar.bz2.part" shutil.copy(resume_test_file, ctx.config.archives_dir()) self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archive.sha1sum) os.remove(fetchedFile)
def set_spec_file(self, specuri): if not specuri.is_remote_file(): specuri = URI(os.path.realpath(specuri.get_uri())) # FIXME: doesn't work for file:// self.specuri = specuri spec = SpecFile() spec.read(specuri, ctx.config.tmp_dir()) self.spec = spec
def set_spec_file(self, specuri): if not specuri.is_remote_file(): specuri = URI(os.path.realpath( specuri.get_uri())) # FIXME: doesn't work for file:// self.specuri = specuri spec = SpecFile() spec.read(specuri, ctx.config.tmp_dir()) self.spec = spec
def set_spec_file(self, pspecfile): self.pspecfile = pspecfile spec = SpecFile() spec.read(pspecfile) # FIXME: following checks the integrity but does nothing when it is wrong # -gurer #spec.verify() # check pspec integrity self.spec = spec
def main(): pisi_init() spec = SpecFile() try: spec.read(sys.argv[1], ctx.config.tmp_dir()) except: print "'%s' geçerli bir pspec.xml dosyası değil.." % (sys.argv[1]) return package_dir = pkg_dir(spec) install_dir = util.join_path(package_dir + ctx.const.install_dir_suffix) if not os.path.isdir(install_dir): print "'%s' dizini yok. Paket build edilmemiş olabilir.." % (install_dir) return unowned_files = [] all_paths_in_packages = [] files_already_in_any_package = [] for package in spec.packages: for path in package.files: all_paths_in_packages.append(util.join_path(install_dir + path.path)) for root, dirs, files in os.walk(install_dir): for file_ in files: already_in_package = False fpath = util.join_path(root, file_) for path in all_paths_in_packages: if not fpath.find(path): already_in_package = True if not already_in_package: unowned_files.append(fpath) if unowned_files: print print "Install dizininde oluşmuş fakat pspec.xml içerisindeki hiç bir pakete dahil edilmemiş dosyalar:" print "===============================================================================================" print for p in unowned_files: print p print else: print "Install dizininde oluşmuş fakat pspec.xml içerisindeki hiç bir pakete dahil edilmemiş dosya yok" pisi_finalize()
class SourceDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.sourcedb = pisi.sourcedb.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml')) ) def testAddRemove(self): self.sourcedb.add_spec(self.spec, 'test') self.assert_(self.sourcedb.has_spec("popt")) self.sourcedb.remove_spec("popt", 'test') self.assert_(not self.sourcedb.has_spec("popt"))
class FetcherTestCase(unittest.TestCase): def setUp(self): pisi.api.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") self.url = uri.URI(self.spec.source.archiveUri) self.destpath = ctx.config.archives_dir() self.fetch = fetcher.Fetcher(self.url, self.destpath) def testFetch(self): self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archiveSHA1)
class SourceDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.sourcedb = pisi.sourcedb.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml'))) def testAddRemove(self): self.sourcedb.add_spec(self.spec, 'test') self.assert_(self.sourcedb.has_spec("popt")) self.sourcedb.remove_spec("popt", 'test') self.assert_(not self.sourcedb.has_spec("popt"))
class SourceDBTestCase(unittest.TestCase): def setUp(self): pisi.api.init() self.sourcedb = pisi.sourcedb.init() self.spec = SpecFile() self.spec.read("tests/popt/pspec.xml") def testAdd(self): self.sourcedb.add_source(self.spec.source) self.assert_(self.sourcedb.has_source("popt")) def testRemove(self): self.testAdd() self.sourcedb.remove_source("popt") self.assert_(not self.sourcedb.has_source("popt"))
class PackageDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.spec.check() def testAdd(self): if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml'))) ctx.packagedb.add_package(self.spec.packages[1], 'test') self.assert_(ctx.packagedb.has_package('popt-libs')) # close the database and remove lock #self.pdb.close() def testRemove(self): ctx.packagedb.remove_package('popt-libs', 'test') self.assert_(not ctx.packagedb.has_package('popt-libs', 'test'))
class PackageDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.spec.check() def testAdd(self): if not ctx.repodb.has_repo('test'): ctx.repodb.add_repo('test', pisi.repodb.Repo(pisi.uri.URI('fakerepo.xml')) ) ctx.packagedb.add_package(self.spec.packages[1], 'test') self.assert_(ctx.packagedb.has_package('popt-libs')) # close the database and remove lock #self.pdb.close() def testRemove(self): ctx.packagedb.remove_package('popt-libs', 'test') self.assert_(not ctx.packagedb.has_package('popt-libs', 'test'))
class PackageDBTestCase(testcase.TestCase): def setUp(self): testcase.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.pdb = PackageDB('testdb') def testAdd(self): self.pdb.add_package(self.spec.packages[0]) self.assert_(self.pdb.has_package('popt-libs')) # close the database and remove lock self.pdb.close() def testRemove(self): self.pdb.remove_package('popt-libs') self.assert_(not self.pdb.has_package('popt-libs')) self.pdb.close()
class PackageDBTestCase(unittest.TestCase): def setUp(self): # setUp will be called for each test individually pisi.api.init() self.spec = SpecFile() self.spec.read('tests/popt/pspec.xml') self.pdb = PackageDB('testdb') def testAdd(self): self.pdb.add_package(self.spec.packages[0]) self.assert_(self.pdb.has_package('popt-libs')) # close the database and remove lock del self.pdb def testRemove(self): self.pdb.remove_package('popt-libs') self.assert_(not self.pdb.has_package('popt-libs')) del self.pdb
class FetchTestCase(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml') self.url = uri.URI(self.spec.source.archive[0].uri) self.url.set_auth_info(("user", "pass")) self.destpath = ctx.config.archives_dir() self.fetch = Fetcher(self.url, self.destpath) def testFetch(self): self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile),self.spec.source.archive[0].sha1sum) os.remove(fetchedFile) def testFetcherFunctions(self): enc = base64.encodestring('%s:%s' % self.url.auth_info()) self.assertEqual(self.fetch._get_http_headers(),(('Authorization', 'Basic %s' % enc),)) assert not self.fetch._get_ftp_headers()
class FetchTestCase(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) self.spec = SpecFile() self.spec.read('repos/pardus-2007/system/base/curl/pspec.xml') self.url = uri.URI(self.spec.source.archive.uri) self.url.set_auth_info(("user", "pass")) self.destpath = ctx.config.archives_dir() self.fetch = Fetcher(self.url, self.destpath) def testFetch(self): self.fetch.fetch() fetchedFile = os.path.join(self.destpath, self.url.filename()) if os.access(fetchedFile, os.R_OK): self.assertEqual(util.sha1_file(fetchedFile), self.spec.source.archive.sha1sum) os.remove(fetchedFile) def testFetcherFunctions(self): enc = base64.encodestring('%s:%s' % self.url.auth_info()) self.assertEqual(self.fetch._get_http_headers(), (('Authorization', 'Basic %s' % enc), )) assert not self.fetch._get_ftp_headers()
def read(filepath): spec = SpecFile() spec.read(filepath) tmp = Pspec(spec.source.name, filepath) tmp.pspec.source.packager = spec.source.packager tmp.pspec.source.homepage = spec.source.homepage tmp.pspec.source.archive = spec.source.archive tmp.pspec.source.name = spec.source.name tmp.pspec.source.license = spec.source.license tmp.pspec.source.partOf = spec.source.partOf tmp.pspec.source.summary = spec.source.summary tmp.pspec.source.description = spec.source.description for pkg in spec.packages: p = Package() p.name = pkg.name p.files = pkg.files p.conflicts = pkg.conflicts p.packageDependencies = pkg.packageDependencies tmp.pspec.packages.append(p) tmp.pspec.history = spec.history return tmp
class SourceFetcher(object): def __init__(self, url, authInfo=None): self.url = url if authInfo: self.url.set_auth_info(authInfo) self.location = dirname(self.url.uri) pkgname = basename(dirname(self.url.path())) self.dest = join(ctx.config.tmp_dir(), pkgname) def fetch_all(self): # fetch pspec file self.fetch() pspec = join(self.dest, self.url.filename()) self.spec = SpecFile() self.spec.read(pspec) self.fetch_actionsfile() self.fetch_patches() self.fetch_comarfiles() self.fetch_additionalFiles() return pspec def fetch_actionsfile(self): actionsuri = join(self.location, ctx.const.actions_file) self.url.uri = actionsuri self.fetch() def fetch_patches(self): spec = self.spec for patch in spec.source.patches: patchuri = join(self.location, ctx.const.files_dir, patch.filename) self.url.uri = patchuri self.fetch(ctx.const.files_dir) def fetch_comarfiles(self): spec = self.spec for package in spec.packages: for pcomar in package.providesComar: comaruri = join(self.location, ctx.const.comar_dir, pcomar.script) self.url.uri = comaruri self.fetch(ctx.const.comar_dir) def fetch_additionalFiles(self): spec = self.spec for pkg in spec.packages: for afile in pkg.additionalFiles: afileuri = join(self.location, ctx.const.files_dir, afile.filename) self.url.uri = afileuri self.fetch(ctx.const.files_dir) def fetch(self, appendDest=""): from fetcher import fetch_url ctx.ui.info(_("Fetching %s") % self.url.uri) dest = join(self.dest, appendDest) fetch_url(self.url, dest)
def set_spec_file(self, pspecfile): self.pspecfile = pspecfile spec = SpecFile() spec.read(pspecfile) self.spec = spec