示例#1
0
	def from_pkgbuild(path, ignore_deps=False, force=False):
		''' Makes a package from a pkgbuild '''
		path = abspath(path)

		if basename(path) != Package.PKGBUILD:
			path = join(path, Package.PKGBUILD)

		if not isfile(path):
			raise BuildError(_('Could not find PKGBUILD: {0}').format(path))

		path, info = Package._process_pkgbuild(path)

		if not ignore_deps:
			unresolved = Pacman.check_deps(info['depends'] + info['makedepends'])

			if unresolved:
				raise DependencyError(path, unresolved)

		try:
			Pacman.make_package(path, force=force)
		except PacmanError as e:
			raise e
		finally:
			pkgfile = Package._process_build_output(info['name'], path)

		if pkgfile:
			return Package.from_file(join(path, pkgfile))

		raise BuildError(_('Could not find any package: {0}').format(path))
示例#2
0
	def test_install(self):
		Pacman.install(['pkg1', 'pkg2'], as_deps=True)

		cmds = ['/usr/bin/sudo /usr/bin/pacman -Sy pkg1 pkg2 --asdeps',
		        '/bin/su -c \'/usr/bin/pacman -Sy pkg1 pkg2 --asdeps\'']

		self.assertIn(PacmanTest.cmd, cmds)
示例#3
0
    def _install_deps(names):
        ''' Installs missing dependencies '''
        aurs, officials = [], names
        Msg.info(_('Need following packages as dependencies:'))
        if Config.get('check-deps-from-aur', True):
            aur_checks = Pacman.check_from_aur(names)
            aurs = list(filter(lambda k: aur_checks[k], aur_checks))
            officials = list(filter(lambda k: not aur_checks[k], aur_checks))
            for i in [("AUR", aurs), ("Official", officials)]:
                if i[1]:
                    Msg.info(
                        _('{0} repository: [{1}]'.format(
                            i[0], ', '.join(i[1]))))
        else:
            Msg.info(_('[{0}]'.format(', '.join(names))))

        if not Msg.ask(_('Install?')):
            if Msg.ask(_('Try without installing dependencies?')):
                return False

            Msg.info(_('Bye'))
            LocalRepo.shutdown(1)

        try:
            if aurs:
                LocalRepo.aur_add(aurs)
            Pacman.install(officials, as_deps=True)
            return True
        except LocalRepoError as e:
            LocalRepo.error(e)
示例#4
0
    def from_pkgbuild(path, ignore_deps=False, force=False):
        ''' Makes a package from a pkgbuild '''
        path = abspath(path)

        if basename(path) != Package.PKGBUILD:
            path = join(path, Package.PKGBUILD)

        if not isfile(path):
            raise BuildError(_('Could not find PKGBUILD: {0}').format(path))

        path, info = Package._process_pkgbuild(path)

        if not ignore_deps:
            unresolved = Pacman.check_deps(info['depends'] +
                                           info['makedepends'])

            if unresolved:
                raise DependencyError(path, unresolved)

        try:
            Pacman.make_package(path, force=force)
        except PacmanError as e:
            raise e
        finally:
            pkgfile = Package._process_build_output(info['name'], path)

        if pkgfile:
            return Package.from_file(join(path, pkgfile))

        raise BuildError(_('Could not find any package: {0}').format(path))
示例#5
0
	def test_repo_remove(self):
		Config.init('mytestrepo')
		Config.set('signdb', False)
		Pacman.repo_remove('my.db.tar.gz', ['pkg1', 'pkg2'])
		self.assertEqual('/usr/bin/repo-remove my.db.tar.gz pkg1 pkg2', PacmanTest.cmd)
		Config.set('signdb', True)
		Pacman.repo_remove('db', ['pkg1'])
		self.assertEqual('/usr/bin/repo-remove db pkg1 --verify --sign', PacmanTest.cmd)
示例#6
0
	def _uninstall_deps(names):
		''' Uninstalls previoulsy installed dependencies '''
		Msg.info(_('Installed following packages as dependencies:\n[{0}]').format(', '.join(names)))

		if Msg.ask(_('Uninstall?')):
			try:
				Pacman.uninstall(names)
			except LocalRepoError as e:
				LocalRepo.error(e)
示例#7
0
    def test_install(self):
        Pacman.install(['pkg1', 'pkg2'], as_deps=True)

        cmds = [
            '/usr/bin/sudo /usr/bin/pacman -Sy pkg1 pkg2 --asdeps',
            '/bin/su -c \'/usr/bin/pacman -Sy pkg1 pkg2 --asdeps\''
        ]

        self.assertIn(PacmanTest.cmd, cmds)
示例#8
0
 def test_repo_remove(self):
     Config.init('mytestrepo')
     Config.set('signdb', False)
     Pacman.repo_remove('my.db.tar.gz', ['pkg1', 'pkg2'])
     self.assertEqual('/usr/bin/repo-remove my.db.tar.gz pkg1 pkg2',
                      PacmanTest.cmd)
     Config.set('signdb', True)
     Pacman.repo_remove('db', ['pkg1'])
     self.assertEqual('/usr/bin/repo-remove db pkg1 --verify --sign',
                      PacmanTest.cmd)
示例#9
0
    def _uninstall_deps(names):
        ''' Uninstalls previoulsy installed dependencies '''
        Msg.info(
            _('Installed following packages as dependencies:\n[{0}]').format(
                ', '.join(names)))

        if Msg.ask(_('Uninstall?')):
            try:
                Pacman.uninstall(names)
            except LocalRepoError as e:
                LocalRepo.error(e)
示例#10
0
文件: repo.py 项目: feuri/local-repo
    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()
示例#11
0
	def _install_deps(names):
		''' Installs missing dependencies '''
		Msg.info(_('Need following packages as dependencies:\n[{0}]').format(', '.join(names)))

		if not Msg.ask(_('Install?')):
			if Msg.ask(_('Try without installing dependencies?')):
				return

			Msg.info(_('Bye'))
			LocalRepo.shutdown(1)

		try:
			Pacman.install(names, as_deps=True)
		except LocalRepoError as e:
			LocalRepo.error(e)
示例#12
0
文件: repo.py 项目: feuri/local-repo
    def remove(self, names):
        """ Removes one or more packages from the repo """
        if type(names) is not list:
            names = [names]

        for name in names:
            self.package(name).remove()
            del (self._packages[name])

        try:
            Pacman.repo_remove(self._db, names)
        except PacmanError as e:
            self.clear_cache()
            raise DbError(_("Could not remove packages from the db: {0}").format(e.message))

        self.update_cache()
示例#13
0
    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)
示例#14
0
    def remove(self, names):
        ''' Removes one or more packages from the repo '''
        if type(names) is not list:
            names = [names]

        for name in (n for n in names if n in self):
            self[name].remove()
            del (self._packages[name])

        try:
            Pacman.repo_remove(self._db, names)
        except PacmanError as e:
            self.clear_cache()
            raise DbError(
                _('Could not remove packages from the db: {0}').format(
                    e.message))

        self.update_cache()
示例#15
0
文件: repo.py 项目: feuri/local-repo
    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()
示例#16
0
    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()
示例#17
0
	def from_pkgbuild(path, ignore_deps=False):
		''' Makes a package from a pkgbuild '''
		path = abspath(path)

		if basename(path) != Package.PKGBUILD:
			path = join(path, Package.PKGBUILD)

		if not isfile(path):
			raise BuildError(_('Could not find PKGBUILD: {0}').format(path))

		info = PkgbuildParser(path).parse()

		if not ignore_deps:
			unresolved = Pacman.check_deps(info['depends'] + info['makedepends'])

			if unresolved:
				raise DependencyError(path, unresolved)

		path = dirname(path)
		log = bool(Config.get('buildlog', False))

		if Config.get('pkgbuild', False):
			path = Package._load_pkgbuild(info['name'], path)

		try:
			Pacman.make_package(path, log=log)
		except PacmanError as e:
			raise e
		finally:
			pkgfile = None

			for f in (f for f in listdir(path) if f.startswith(info['name'])):
				if log and f.endswith(Package.LOGEXT):
					BuildLog.store(info['name'], join(path, f))
				elif f.endswith(Package.EXT):
					pkgfile = f

		if pkgfile:
			return Package.from_file(join(path, pkgfile))

		raise BuildError(_('Could not find any package'))
示例#18
0
    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)
示例#19
0
 def test_make_package(self):
     Config.init('mytestrepo')
     Config.set('sign', False)
     Config.set('buildlog', '')
     Pacman.make_package('/tmp')
     self.assertEqual('/usr/bin/makepkg -d --nosign', PacmanTest.cmd)
     Pacman.make_package('/tmp', force=True)
     self.assertEqual('/usr/bin/makepkg -d -f --nosign', PacmanTest.cmd)
     Config.set('buildlog', '/some/path')
     Pacman.make_package('/tmp')
     self.assertEqual('/usr/bin/makepkg -d -L -m --nosign', PacmanTest.cmd)
     Config.set('sign', True)
     Pacman.make_package('/tmp')
     self.assertEqual('/usr/bin/makepkg -d -L -m --sign', PacmanTest.cmd)
示例#20
0
	def test_make_package(self):
		Config.init('mytestrepo')
		Config.set('sign', False)
		Config.set('buildlog', '')
		Pacman.make_package('/tmp')
		self.assertEqual('/usr/bin/makepkg -d --nosign', PacmanTest.cmd)
		Pacman.make_package('/tmp', force=True)
		self.assertEqual('/usr/bin/makepkg -d -f --nosign', PacmanTest.cmd)
		Config.set('buildlog', '/some/path')
		Pacman.make_package('/tmp')
		self.assertEqual('/usr/bin/makepkg -d -L -m --nosign', PacmanTest.cmd)
		Config.set('sign', True)
		Pacman.make_package('/tmp')
		self.assertEqual('/usr/bin/makepkg -d -L -m --sign', PacmanTest.cmd)
示例#21
0
	def test_check_deps(self):
		self.assertEqual(['pkg1', 'pkg2'], Pacman.check_deps(['pkg1', 'pkg2', 'pacman']))
		self.assertEqual([], Pacman.check_deps(['pacman']))
		self.assertEqual([], Pacman.check_deps([]))
示例#22
0
 def test_check_deps(self):
     self.assertEqual(['pkg1', 'pkg2'],
                      Pacman.check_deps(['pkg1', 'pkg2', 'pacman']))
     self.assertEqual([], Pacman.check_deps(['pacman']))
     self.assertEqual([], Pacman.check_deps([]))
示例#23
0
	def elephant():
		''' The elephant never forgets '''
		try:
			Pacman.repo_elephant()
		except LocalRepoError as e:
			LocalRepo.error(e)
示例#24
0
 def elephant():
     ''' The elephant never forgets '''
     try:
         Pacman.repo_elephant()
     except LocalRepoError as e:
         LocalRepo.error(e)