def test_repo_add(self): Config.init('mytestrepo') Config.set('signdb', False) Pacman.repo_add('my.db.tar.gz', ['pkg1', 'pkg2']) self.assertEqual('/usr/bin/repo-add my.db.tar.gz pkg1 pkg2', PacmanTest.cmd) Config.set('signdb', True) Pacman.repo_add('db', ['pkg1']) self.assertEqual('/usr/bin/repo-add db pkg1 --verify --sign', PacmanTest.cmd)
def restore_db(self): """ Deletes the database and creates a new one by adding all packages """ if isfile(self._db): remove(self._db) pkgs = [join(self._path, f) for f in listdir(self._path) if f.endswith(Package.EXT)] if pkgs: Pacman.repo_add(self._db, pkgs) self.clear_cache()
def restore_db(self): """ Deletes the database and creates a new one by adding all packages """ try: pkgs = [join(self._path, f) for f in listdir(self._path) if f.endswith(Package.EXT)] except OSError: raise DbError(_("Could not list directory: {0}").format(self._path)) self.clear_cache() try: if isfile(self._db): remove(self._db) except: raise DbError(_("Could not remove database: {0}").format(self._db)) if pkgs: Pacman.repo_add(self._db, pkgs)
def add(self, pkg, force=False): """ Adds a new package to the repo """ if self.has(pkg.name): if not force or self._packages[pkg.name].path == pkg.path: raise RepoError(_("Package is already in the repo: {0}").format(pkg.name)) self._packages[pkg.name].remove() pkg.move(self._path, force) self._packages[pkg.name] = pkg try: Pacman.repo_add(self._db, [pkg.path]) except PacmanError as e: self.clear_cache() raise DbError(_("Could not add packages to the db: {0}").format(e.message)) self.update_cache()
def add(self, pkg, force=False): ''' Adds a new package to the repo ''' if pkg.name in self: if not force or self._packages[pkg.name] == pkg: raise RepoError( _('Package is already in the repo: {0}').format(pkg.name)) self._packages[pkg.name].remove() pkg.move(self._path, force) self._packages[pkg.name] = pkg try: Pacman.repo_add(self._db, [pkg.path]) except PacmanError as e: self.clear_cache() raise DbError( _('Could not add packages to the db: {0}').format(e.message)) self.update_cache()
def restore_db(self): ''' Deletes the database and creates a new one by adding all packages ''' try: pkgs = [ join(self._path, f) for f in listdir(self._path) if f.endswith(Package.EXT) ] except OSError: raise DbError( _('Could not list directory: {0}').format(self._path)) self.clear_cache() try: if isfile(self._db): remove(self._db) except: raise DbError(_('Could not remove database: {0}').format(self._db)) if pkgs: Pacman.repo_add(self._db, pkgs)