-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite doins by python (bug 624526). #190
Conversation
bin/ebuild-helpers/doins
Outdated
rm -rf "$TMP" | ||
[[ $failed -ne 0 || $success -eq 0 ]] && { __helpers_die "${helper} failed"; exit 1; } || exit 0 | ||
"${PORTAGE_PYTHON:-/usr/bin/python}" \ | ||
"${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/doins.py \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is /usr/lib/portage/bin a safe fallback? Shouldn't we check for it being unset instead?
bin/ebuild-helpers/doins
Outdated
mkdir -p "$TMP"/{1,2} | ||
# Use safe cwd, avoiding unsafe import for bug #469338. | ||
export __PORTAGE_HELPER_CWD=${PWD} | ||
cd "${PORTAGE_PYM_PATH:-/usr/lib/portage/pym}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this path a safe fallback?
bin/doins.py
Outdated
"""Installs a file at |source| into |dest_dir| in process.""" | ||
dest = os.path.join(dest_dir, os.path.basename(source)) | ||
try: | ||
# TODO: Consider to use portage.util.file_copy.copyfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible to get this TODO done before merging?
bin/doins.py
Outdated
def run(self, dest): | ||
"""Installs a dir into |dest| by 'install' command.""" | ||
command = ['install', '-d'] + self._split_options + [dest] | ||
subprocess.call(command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could need some exception handling, if subprocess.call fails
bin/doins.py
Outdated
# supported. | ||
# In Python 3, the prefix of octal int must be '0o' rather than '0'. | ||
# So, set base explicitly in that case. | ||
return int(mode, 8 if re.search(r'^0[0-7]*$', mode) else 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split up into multiple lines for readability and consider compiling the regex
6f23b87
to
414e807
Compare
94491c3
to
e7e89ce
Compare
Updated with the version merged in chromiumos/third_party/portage_tool, and added a commit to optimize with copyfile from portage.util.file_copy. |
doins is written in bash. However, specifically in case that too many files are installed, it is very slow. This CL rewrites the script in python for performance. BUG=chromium:712659 TEST=time (./setup_board --forace && \ ./build_package --withdev && \ ./build_image --noenable_rootfs_verification test) ===Before=== real 21m35.445s user 93m40.588s sys 21m31.224s ===After=== real 17m30.106s user 94m1.812s sys 20m13.468s Change-Id: Ib10f623961ba316753d58397cff5e72fbc343339 Reviewed-on: https://chromium-review.googlesource.com/559225 X-Chromium-Bug: 712659 X-Chromium-Bug-url: https://bugs.chromium.org/p/chromium/issues/detail?id=712659 Reviewed-by: Manuel Rüger <mrueg@gentoo.org> Bug: https://bugs.gentoo.org/624526
doins is written in bash. However, specifically in case that
too many files are installed, it is very slow.
This CL rewrites the script in python for performance.
BUG=chromium:712659
TEST=time (./setup_board --forace &&
./build_package --withdev &&
./build_image --noenable_rootfs_verification test)
===Before===
real 21m35.445s
user 93m40.588s
sys 21m31.224s
===After===
real 17m30.106s
user 94m1.812s
sys 20m13.468s
Change-Id: Ib10f623961ba316753d58397cff5e72fbc343339
Reviewed-on: https://chromium-review.googlesource.com/559225
X-Chromium-Bug: 712659
X-Chromium-Bug-url: https://bugs.chromium.org/p/chromium/issues/detail?id=712659
X-Gentoo-Bug: 624526
X-Gentoo-Bug-url: https://bugs.gentoo.org/624526