Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print(':: ' + _('Fetching package information...'))
for u in args.userfetch:
try:
tofetch += pkgbuilder.utils.msearch(u)
except pkgbuilder.exceptions.AURError as e:
print(_('Error while processing {0}: {1}').format(u, e))
pkgbuilder.build.fetch_runner(tofetch, preprocessed=True)
if quit:
exit(0)
# If we didn't quit, we should build the packages.
if pkgnames:
DS.root_crash()
DS.log.info('Starting build...')
toinstall = []
sigs = []
tovalidate = set(pkgnames)
for pkgname in pkgnames:
try:
DS.log.info('Building {0}'.format(pkgname))
out = pkgbuilder.build.auto_build(pkgname, args.depcheck,
args.pkginst, pkgnames)
if out:
toinstall += out[1][0]
sigs += out[1][1]
except PBException as e:
DS.fancy_error(str(e))
if e.exit:
exit(1)
user_chdir = DS.config.get('extras', 'chdir').strip()
if user_chdir:
DS.log.debug('Changing directory to %s (via config)', user_chdir)
os.makedirs(user_chdir, exist_ok=True)
os.chdir(user_chdir)
elif DS.pacman:
DS.log.debug('-S passed, building in /tmp/.')
path = '/tmp/pkgbuilder-{0}'.format(str(DS.uid))
if not os.path.exists(path):
os.mkdir(path)
os.chdir(path)
if args.upgrade:
DS.root_crash()
DS.log.info('Starting upgrade...')
dodowngrade = args.upgrade > 1
ignorelist = []
for i in (args.ignorelist or []):
# `pacman -Syu --ignore a,b --ignore c` → ignores a, b, c
ignorelist.extend(i.split(','))
upnames = pkgbuilder.upgrade.auto_upgrade(
dodowngrade, DS.vcsupgrade, DS.fetch, ignorelist)
pkgnames = upnames + pkgnames
if DS.fetch and pkgnames:
pkgbuilder.build.fetch_runner(pkgnames)
if quit:
exit(0)
if args.userfetch:
tofetch = []
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.'))
if e.exit:
exit(1)
except PBException as e:
DS.fancy_error(str(e))
if e.exit:
exit(1)
except KeyboardInterrupt:
pkgbuilder.DS.fancy_error(pkgbuilder.DS.inttext)
exit(130)
DS.log.info('Quitting peacefully.')
if args.finst:
pkgbuilder.build.install(pkgnames, [], False)
if quit:
exit(0)
if args.pac:
DS.log.debug('-S passed, building in /tmp/.')
path = '/tmp/pkgbuilder-{0}'.format(str(DS.uid))
if not os.path.exists(path):
os.mkdir(path)
os.chdir(path)
if args.upgrade > 0:
DS.root_crash()
DS.log.info('Starting upgrade...')
dodowngrade = args.upgrade > 1
upnames = pkgbuilder.upgrade.auto_upgrade(dodowngrade, args.vcsup)
pkgnames = upnames + pkgnames
if args.fetch:
pkgbuilder.build.fetch_runner(pkgnames)
if quit:
exit(0)
if args.userfetch:
tofetch = []
print(':: ' + _('Fetching package information...'))
for u in args.userfetch:
try:
tofetch += pkgbuilder.utils.msearch(u)
except pkgbuilder.exceptions.AURError as e:
else:
args = parser.parse_args()
DS.pacman = args.pac
DS.cleanup = args.cleanup
pkgnames = args.pkgnames
if args.aur4:
pkgbuilder.aur.AUR.base = 'https://aur4.archlinux.org'
if args.debug:
DS.debugmode(nochange=True)
DS.log.info('*** PKGBUILDer v{0}'.format(__version__))
DS.log.debug('*** debug output on.')
DS.log.info('Arguments parsed. {0}'.format(args.__dict__))
if 'VIRTUAL_ENV' in os.environ:
DS.log.error("virtualenv detected, exiting.")
DS.fancy_error(_("PKGBUILDer cannot work in a virtualenv, "
"exiting."))
exit(83)
if not args.color:
DS.colorsoff()
DS.log.debug('Colors turned off.')
if args.info:
DS.log.debug('Showing info...')
pkgs = pkgbuilder.utils.info(pkgnames)
foundnames = [i.name for i in pkgs]
print(':: ' + _('Fetching package information...'))
for u in args.userfetch:
try:
tofetch += pkgbuilder.utils.msearch(u)
except pkgbuilder.exceptions.AURError as e:
print(_('Error while processing {0}: {1}').format(u, e))
pkgbuilder.build.fetch_runner(tofetch, preprocessed=True)
if quit:
exit(0)
# If we didn't quit, we should build the packages.
if pkgnames:
DS.root_crash()
DS.log.info('Starting build...')
toinstall = []
sigs = []
tovalidate = set(pkgnames)
for pkgname in pkgnames:
try:
DS.log.info('Building {0}'.format(pkgname))
out = pkgbuilder.build.auto_build(pkgname, DS.depcheck,
DS.pkginst, pkgnames,
DS.edit_pkgbuild)
if out:
toinstall += out[1][0]
sigs += out[1][1]
except PBException as e:
DS.fancy_error(str(e))
if e.exit:
def save(self, filename=None):
"""Save a transaction file."""
if filename is not None:
self.filename = filename
if self.filename:
with open(self.filename, 'w+') as fh:
fh.write(self.tojson())
DS.log.info("Transaction saved: {0}".format(self.filename))
def build_runner(pkgname, performdepcheck=True,
pkginstall=True, pkgbuild_edit=False):
"""A build function, which actually links to others.
DO NOT use it unless you re-implement auto_build!
"""
pkg = None
try:
pkg = pkgbuilder.utils.info([pkgname])[0]
except IndexError:
DS.log.info('{0} not found in the AUR, checking in repositories'.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)
subpackages = [pkg.name] # no way to get it
if not pkg:
raise pkgbuilder.exceptions.PackageNotFoundError(pkgname, 'build')
DS.fancy_msg(_('Building {0}...').format(pkg.name))
pkgbuilder.utils.print_package_search(pkg,
prefix=DS.colors['blue'] +
' ->' + DS.colors['all_off'] +