* [gentoo-commits] proj/portage:master commit in: bin/, lib/portage/dbapi/
@ 2019-11-18 1:46 Zac Medico
0 siblings, 0 replies; only message in thread
From: Zac Medico @ 2019-11-18 1:46 UTC (permalink / raw
To: gentoo-commits
commit: b24a484ab190af9c9b96b9ef01837aded845fb54
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 18 01:32:38 2019 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Nov 18 01:41:27 2019 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=b24a484a
dblink: add quickpkg method
Bug: https://bugs.gentoo.org/699986
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
bin/quickpkg | 34 ++++--------------------------
lib/portage/dbapi/vartree.py | 50 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+), 30 deletions(-)
diff --git a/bin/quickpkg b/bin/quickpkg
index c28a3e382..df8c1a8e8 100755
--- a/bin/quickpkg
+++ b/bin/quickpkg
@@ -10,7 +10,6 @@ import math
import signal
import subprocess
import sys
-import tarfile
from os import path as osp
if osp.isfile(osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), ".portage_not_installed")):
@@ -23,10 +22,8 @@ from portage.dbapi.dep_expand import dep_expand
from portage.dep import Atom, use_reduce
from portage.exception import (AmbiguousPackageName, InvalidAtom, InvalidData,
InvalidDependString, PackageSetNotFound, PermissionDenied)
-from portage.util import ConfigProtect, ensure_dirs, shlex_split, varexpand, _xattr
+from portage.util import ensure_dirs, shlex_split, varexpand, _xattr
xattr = _xattr.xattr
-from portage.dbapi.vartree import dblink, tar_contents
-from portage.checksum import perform_md5
from portage._sets import load_default_config, SETPREFIX
from portage.process import find_binary
from portage.util.compression_probe import _compressors
@@ -35,13 +32,11 @@ from portage.util._eventloop.global_event_loop import global_event_loop
def quickpkg_atom(options, infos, arg, eout):
settings = portage.settings
- root = portage.settings['ROOT']
eroot = portage.settings['EROOT']
trees = portage.db[eroot]
vartree = trees["vartree"]
vardb = vartree.dbapi
bintree = trees["bintree"]
- xattrs = 'xattr' in settings.features
include_config = options.include_config == "y"
include_unmodified_config = options.include_unmodified_config == "y"
@@ -104,26 +99,6 @@ def quickpkg_atom(options, infos, arg, eout):
eout.ewarn("%s: it might not be legal to redistribute this." % cpv)
eout.ebegin("Building package for %s" % cpv)
pkgs_for_arg += 1
- contents = dblnk.getcontents()
- protect = None
- if not include_config:
- confprot = ConfigProtect(eroot,
- shlex_split(settings.get("CONFIG_PROTECT", "")),
- shlex_split(settings.get("CONFIG_PROTECT_MASK", "")),
- case_insensitive=("case-insensitive-fs"
- in settings.features))
- def protect(filename):
- if not confprot.isprotected(filename):
- return False
- if include_unmodified_config:
- file_data = contents[filename]
- if file_data[0] == "obj":
- orig_md5 = file_data[2].lower()
- cur_md5 = perform_md5(filename, calc_prelink=1)
- if orig_md5 == cur_md5:
- return False
- excluded_config_files.append(filename)
- return True
existing_metadata = dict(zip(fix_metadata_keys,
vardb.aux_get(cpv, fix_metadata_keys)))
category, pf = portage.catsplit(cpv)
@@ -167,10 +142,9 @@ def quickpkg_atom(options, infos, arg, eout):
cmd = [x for x in cmd if x != ""]
with open(binpkg_tmpfile, "wb") as fobj:
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=fobj)
- # The tarfile module will write pax headers holding the
- # xattrs only if PAX_FORMAT is specified here.
- with tarfile.open(mode="w|",format=tarfile.PAX_FORMAT if xattrs else tarfile.DEFAULT_FORMAT, fileobj=proc.stdin) as tar:
- tar_contents(contents, root, tar, protect=protect, xattrs=xattrs)
+ excluded_config_files = dblnk.quickpkg(proc.stdin,
+ include_config=include_config,
+ include_unmodified_config=include_unmodified_config)
proc.stdin.close()
if proc.wait() != os.EX_OK:
eout.eend(1)
diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py
index fa1e1523c..603d58015 100644
--- a/lib/portage/dbapi/vartree.py
+++ b/lib/portage/dbapi/vartree.py
@@ -1883,6 +1883,56 @@ class dblink(object):
self.contentscache = pkgfiles
return pkgfiles
+ def quickpkg(self, output_file, include_config=False, include_unmodified_config=False):
+ """
+ Create a tar file appropriate for use by quickpkg.
+
+ @param output_file: Write binary tar stream to file.
+ @type output_file: file
+ @param include_config: Include all files protected by CONFIG_PROTECT
+ (as a security precaution, default is False).
+ @type include_config: bool
+ @param include_config: Include files protected by CONFIG_PROTECT that
+ have not been modified since installation (as a security precaution,
+ default is False).
+ @type include_config: bool
+ @rtype: list
+ @return: Paths of protected configuration files which have been omitted.
+ """
+ settings = self.settings
+ cpv = self.mycpv
+ xattrs = 'xattr' in settings.features
+ contents = self.getcontents()
+ excluded_config_files = []
+ protect = None
+
+ if not include_config:
+ confprot = ConfigProtect(settings['EROOT'],
+ portage.util.shlex_split(settings.get('CONFIG_PROTECT', '')),
+ portage.util.shlex_split(settings.get('CONFIG_PROTECT_MASK', '')),
+ case_insensitive=('case-insensitive-fs' in settings.features))
+
+ def protect(filename):
+ if not confprot.isprotected(filename):
+ return False
+ if include_unmodified_config:
+ file_data = contents[filename]
+ if file_data[0] == 'obj':
+ orig_md5 = file_data[2].lower()
+ cur_md5 = perform_md5(filename, calc_prelink=1)
+ if orig_md5 == cur_md5:
+ return False
+ excluded_config_files.append(filename)
+ return True
+
+ # The tarfile module will write pax headers holding the
+ # xattrs only if PAX_FORMAT is specified here.
+ with tarfile.open(fileobj=output_file, mode='w|',
+ format=tarfile.PAX_FORMAT if xattrs else tarfile.DEFAULT_FORMAT) as tar:
+ tar_contents(contents, settings['ROOT'], tar, protect=protect, xattrs=xattrs)
+
+ return excluded_config_files
+
def _prune_plib_registry(self, unmerge=False,
needed=None, preserve_paths=None):
# remove preserved libraries that don't have any consumers left
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-11-18 1:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-18 1:46 [gentoo-commits] proj/portage:master commit in: bin/, lib/portage/dbapi/ Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox