Skip to content

Commit

Permalink
v2.99.6.0: Package classes done [git-only release]
Browse files Browse the repository at this point in the history
TODO: issue #22

Signed-off-by: Kwpolska <[email protected]>
  • Loading branch information
Kwpolska committed Mar 31, 2013
1 parent 10fbe58 commit db46d88
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 35 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ PKGBUILDer uses the following versioning schemes:
Generation 3
============

:2.99.5.0: Exceptions 2.0 fully implemented. [testing git-only version]
:2.99.4.0: First four stages done. [testing git-only version]
Testing git-only releases
-------------------------

:2.99.6.0: Package classes done.
:2.99.5.0: Exceptions 2.0 fully implemented.
:2.99.4.0: First four stages done.

Generation 2
============
Expand Down
42 changes: 21 additions & 21 deletions pkgbuilder/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,19 @@ def fetch_runner(pkgnames):
raise pkgbuilder.exceptions.NetworkError(
_('Failed to retieve {0} (from ABS/rsync).').format(
pkg.name), pkg=pkg, retcode=rc)
print(_(':: Retrieving packages from aur...'))
UI.pcount = len(aurpkgs)
for pkg in aurpkgs:
UI.pmsg(_('retrieving {0}').format(pkg.name), True)
filename = pkg.name + '.tar.gz'
download(pkg.urlpath, filename)

print(':: ' + _('Extracting AUR packages...'))
for pkg in aurpkgs:
filename = pkg.name + '.tar.gz'
extract(filename)

if aurpkgs:
print(_(':: Retrieving packages from aur...'))
UI.pcount = len(aurpkgs)
for pkg in aurpkgs:
UI.pmsg(_('retrieving {0}').format(pkg.name), True)
filename = pkg.name + '.tar.gz'
download(pkg.urlpath, filename)

print(':: ' + _('Extracting AUR packages...'))
for pkg in aurpkgs:
filename = pkg.name + '.tar.gz'
extract(filename)

print(_('Successfully fetched: ') + ' '.join(pkgnames))
except pkgbuilder.exceptions.PBException as e:
Expand All @@ -333,17 +335,15 @@ def build_runner(pkgname, performdepcheck=True,
try:
pkg = pkgbuilder.utils.info([pkgname])[0]
except IndexError:
try:
DS.log.info('{0} not found in the AUR, checking in ABS'.format(
pkgname))
syncpkgs = []
for j in [i.pkgcache for i in DS.pyc.get_syncdbs()]:
syncpkgs.append(j)
syncpkgs = functools.reduce(lambda x, y: x + y, syncpkgs)
abspkg = pyalpm.find_satisfier(syncpkgs, pkgname)
DS.log.info('{0} not found in the AUR, checking in ABS'.format(
pkgname))
syncpkgs = []
for j in [i.pkgcache for i in DS.pyc.get_syncdbs()]:
syncpkgs.append(j)
syncpkgs = functools.reduce(lambda x, y: x + y, syncpkgs)
abspkg = pyalpm.find_satisfier(syncpkgs, pkgname)
if abspkg: # abspkg can be None or a pyalpm.Package object.
pkg = pkgbuilder.package.ABSPackage.from_pyalpm(abspkg)
except AttributeError:
pass

if not pkg:
raise pkgbuilder.exceptions.PackageNotFoundError(pkgname, 'build')
Expand Down
8 changes: 3 additions & 5 deletions pkgbuilder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"""

from . import DS, _, __version__
import pkgbuilder.exceptions
from pkgbuilder.exceptions import NetworkError, PBException
import pkgbuilder.build
import pkgbuilder.utils
import pkgbuilder.upgrade
Expand Down Expand Up @@ -213,21 +213,19 @@ def main(source='AUTO', quit=True):
if out:
toinstall += out[1][0]
sigs += out[1][1]
if out[2]:
tovalidate = tovalidate - set([pkgname])

if toinstall:
pkgbuilder.build.install(toinstall, sigs)

if args.validate and tovalidate:
pkgbuilder.build.validate(tovalidate)
except pkgbuilder.exceptions.NetworkError as e:
except NetworkError as e:
DS.fancy_error(str(e))
# TRANSLATORS: do not translate the word 'requests'.
DS.fancy_error(_('PKGBUILDer (or the requests library) had '
'problems with fulfilling an HTTP request.'))
exit(1)
except Exception as e:
except PBException as e:
DS.fancy_error(str(e))
exit(1)

Expand Down
2 changes: 1 addition & 1 deletion pkgbuilder/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def from_pyalpm(cls, abspkg):
utc = UTC()

p.repo = abspkg.db.name
p.desc = abspkg.description
p.description = abspkg.desc
p.human = abspkg.packager
p.builddate = datetime.datetime.utcfromtimestamp(
abspkg.builddate).replace(tzinfo=utc)
Expand Down
16 changes: 15 additions & 1 deletion pkgbuilder/pbds.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"""

from . import _, __version__
import pkgbuilder.ui
import sys
import os
import logging
import subprocess
import pycman
import time

__all__ = ['PBDS']

Expand Down Expand Up @@ -53,6 +55,7 @@ class PBDS():
debug = False
console = None
_pyc = None
_ui = None

if os.getenv('PACMAN') is None:
paccommand = 'pacman'
Expand Down Expand Up @@ -95,11 +98,22 @@ class PBDS():
log = logging.getLogger('pkgbuilder')
log.info('*** PKGBUILDer v' + __version__)

@property
def ui(self):
"""Return an UI object, initializing one if necessary."""
if not self._ui:
self._ui = pkgbuilder.ui.UI()

return self._ui

@property
def pyc(self):
"""Return a pycman handle, initializing one if necessary."""
if not self._pyc:
self._pyc = pycman.config.init_with_config('/etc/pacman.conf')
msg = _('Initializing pacman access...')
with self.ui.throbber(msg, printback=False):
self._pyc = pycman.config.init_with_config('/etc/pacman.conf')
sys.stdout.write('\r' + ((len(msg) + 4) * ' '))

return self._pyc

Expand Down
8 changes: 8 additions & 0 deletions pkgbuilder/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import sys
import time
import threading
from contextlib import contextmanager

__all__ = ['UI']

Expand Down Expand Up @@ -58,11 +59,18 @@ def _throbber(self, msg, finalthrob='*', printback=True):
time.sleep(0.1)
print()

@contextmanager
def throbber(self, msg, finalthrob='*', printback=True):
"""Run the throbber in a thread."""
self._tt = threading.Thread(target=self._throbber, args=(
msg, finalthrob, printback))
self._tt.start()
try:
yield
finally:
self.throb = False
while self.throbber_alive:
time.sleep(0.1)

@property
def throbber_alive(self):
Expand Down
17 changes: 12 additions & 5 deletions pkgbuilder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ def print_package_search(pkg, use_categories=True, cachemode=False, prefix='',
installed = _(' [installed: {0}]').format(lpkg.version)
else:
installed = _(' [installed]')
if pkg.is_outdated:
installed = (installed + ' ' + DS.colors['red'] + _(
'[out of date]') + DS.colors['all_off'])
try:
if pkg.is_outdated:
installed = (installed + ' ' + DS.colors['red'] + _(
'[out of date]') + DS.colors['all_off'])
except AttributeError:
pass # for ABS packages

if use_categories or pkg.is_abs:
category = pkg.repo
Expand Down Expand Up @@ -130,8 +133,13 @@ def print_package_info(pkgs, cachemode=False):
of ``pacman -Si``.
"""
if pkgs == []:
raise SanityError('Didn’t pass any packages.')
raise SanityError(_('Didn’t pass any packages.'))
else:
for i in pkgs:
if not isinstance(i, AURPackage):
raise SanityError(_('Trying to use utils.print_package_info '
'with an ABS package'),
source='utils.print_package_info')
loct = os.getenv('LC_TIME')
loc = os.getenv('LC_ALL')

Expand Down Expand Up @@ -172,7 +180,6 @@ def print_package_info(pkgs, cachemode=False):
ood = DS.colors['red'] + _('yes') + DS.colors['all_off']
else:
ood = _('no')

to.append(t.format(cat=pkg.repo,
nme=pkg.name, url=pkg.url,
ver=pkg.version, lic=pkg.licenses,
Expand Down

0 comments on commit db46d88

Please sign in to comment.