From 6563293d18daed502ccdb663f3c72b4bae5fe23a Mon Sep 17 00:00:00 2001 From: Alexander Bersenev Date: Mon, 17 Feb 2014 17:57:05 +0600 Subject: updated portage to 2.2.8-r1 --- .gitignore | 1 + integration_with_portage.patch | 441 ++-- portage_with_autodep/bin/archive-conf | 54 +- portage_with_autodep/bin/banned-helper | 6 - portage_with_autodep/bin/bashrc-functions.sh | 63 +- portage_with_autodep/bin/binhost-snapshot | 27 +- portage_with_autodep/bin/chpathtool.py | 76 +- portage_with_autodep/bin/clean_locks | 16 +- portage_with_autodep/bin/dispatch-conf | 34 +- portage_with_autodep/bin/dohtml.py | 99 +- portage_with_autodep/bin/ebuild | 112 +- portage_with_autodep/bin/ebuild-helpers/4/dodoc | 1 - portage_with_autodep/bin/ebuild-helpers/4/dohard | 1 - portage_with_autodep/bin/ebuild-helpers/4/dosed | 1 - .../bin/ebuild-helpers/4/prepalldocs | 1 - portage_with_autodep/bin/ebuild-helpers/dobin | 13 +- portage_with_autodep/bin/ebuild-helpers/doconfd | 2 +- portage_with_autodep/bin/ebuild-helpers/dodir | 9 +- portage_with_autodep/bin/ebuild-helpers/dodoc | 20 +- portage_with_autodep/bin/ebuild-helpers/doenvd | 2 +- portage_with_autodep/bin/ebuild-helpers/doexe | 16 +- portage_with_autodep/bin/ebuild-helpers/dohard | 14 +- portage_with_autodep/bin/ebuild-helpers/dohtml | 11 +- portage_with_autodep/bin/ebuild-helpers/doinfo | 15 +- portage_with_autodep/bin/ebuild-helpers/doinitd | 2 +- portage_with_autodep/bin/ebuild-helpers/doins | 47 +- portage_with_autodep/bin/ebuild-helpers/dolib | 13 +- portage_with_autodep/bin/ebuild-helpers/doman | 13 +- portage_with_autodep/bin/ebuild-helpers/domo | 11 +- portage_with_autodep/bin/ebuild-helpers/dosbin | 13 +- portage_with_autodep/bin/ebuild-helpers/dosed | 14 +- portage_with_autodep/bin/ebuild-helpers/dosym | 9 +- portage_with_autodep/bin/ebuild-helpers/ecompress | 14 +- .../bin/ebuild-helpers/ecompressdir | 101 +- portage_with_autodep/bin/ebuild-helpers/emake | 2 +- portage_with_autodep/bin/ebuild-helpers/fowners | 12 +- portage_with_autodep/bin/ebuild-helpers/fperms | 9 +- portage_with_autodep/bin/ebuild-helpers/newbin | 23 +- portage_with_autodep/bin/ebuild-helpers/newconfd | 23 +- portage_with_autodep/bin/ebuild-helpers/newdoc | 23 +- portage_with_autodep/bin/ebuild-helpers/newenvd | 23 +- portage_with_autodep/bin/ebuild-helpers/newexe | 23 +- portage_with_autodep/bin/ebuild-helpers/newinitd | 23 +- portage_with_autodep/bin/ebuild-helpers/newins | 67 +- portage_with_autodep/bin/ebuild-helpers/newlib.a | 23 +- portage_with_autodep/bin/ebuild-helpers/newlib.so | 23 +- portage_with_autodep/bin/ebuild-helpers/newman | 23 +- portage_with_autodep/bin/ebuild-helpers/newsbin | 23 +- portage_with_autodep/bin/ebuild-helpers/portageq | 6 +- portage_with_autodep/bin/ebuild-helpers/prepall | 7 +- .../bin/ebuild-helpers/prepalldocs | 14 +- .../bin/ebuild-helpers/prepallinfo | 7 +- portage_with_autodep/bin/ebuild-helpers/prepallman | 14 +- .../bin/ebuild-helpers/prepallstrip | 9 +- portage_with_autodep/bin/ebuild-helpers/prepinfo | 11 +- portage_with_autodep/bin/ebuild-helpers/preplib | 31 - portage_with_autodep/bin/ebuild-helpers/prepman | 16 +- portage_with_autodep/bin/ebuild-helpers/prepstrip | 206 +- portage_with_autodep/bin/ebuild-ipc | 6 +- portage_with_autodep/bin/ebuild-ipc.py | 184 +- portage_with_autodep/bin/ebuild.sh | 185 +- portage_with_autodep/bin/egencache | 491 ++-- portage_with_autodep/bin/emaint | 672 +----- portage_with_autodep/bin/emerge | 99 +- portage_with_autodep/bin/emerge-webrsync | 178 +- portage_with_autodep/bin/env-update | 14 +- portage_with_autodep/bin/etc-update | 26 +- .../bin/filter-bash-environment.py | 18 +- portage_with_autodep/bin/fixpackages | 22 +- portage_with_autodep/bin/glsa-check | 196 +- portage_with_autodep/bin/helper-functions.sh | 67 +- portage_with_autodep/bin/isolated-functions.sh | 168 +- portage_with_autodep/bin/lock-helper.py | 3 +- portage_with_autodep/bin/misc-functions.sh | 363 +-- portage_with_autodep/bin/phase-functions.sh | 412 ++-- portage_with_autodep/bin/phase-helpers.sh | 610 +++-- portage_with_autodep/bin/portageq | 675 +++++- portage_with_autodep/bin/quickpkg | 61 +- portage_with_autodep/bin/regenworld | 14 +- portage_with_autodep/bin/repoman | 1698 +++++++------ portage_with_autodep/bin/save-ebuild-env.sh | 73 +- portage_with_autodep/bin/xpak-helper.py | 9 +- .../integration_with_portage.patch | 920 -------- .../pym/_emerge/AbstractDepPriority.py | 5 +- .../pym/_emerge/AbstractDepPriority.pyo | Bin 1757 -> 1793 bytes .../pym/_emerge/AbstractEbuildProcess.py | 58 +- .../pym/_emerge/AbstractEbuildProcess.pyo | Bin 10082 -> 11181 bytes .../pym/_emerge/AbstractPollTask.py | 2 +- .../pym/_emerge/AbstractPollTask.pyo | Bin 4918 -> 4895 bytes .../pym/_emerge/AsynchronousLock.py | 66 +- .../pym/_emerge/AsynchronousLock.pyo | Bin 10536 -> 10023 bytes .../pym/_emerge/AsynchronousTask.py | 14 + .../pym/_emerge/AsynchronousTask.pyo | Bin 5610 -> 6276 bytes portage_with_autodep/pym/_emerge/AtomArg.py | 5 +- portage_with_autodep/pym/_emerge/AtomArg.pyo | Bin 771 -> 820 bytes portage_with_autodep/pym/_emerge/Binpkg.py | 7 +- portage_with_autodep/pym/_emerge/Binpkg.pyo | Bin 13229 -> 13289 bytes .../pym/_emerge/BinpkgEnvExtractor.pyo | Bin 3084 -> 3066 bytes .../pym/_emerge/BinpkgExtractorAsync.py | 15 +- .../pym/_emerge/BinpkgExtractorAsync.pyo | Bin 1337 -> 1664 bytes portage_with_autodep/pym/_emerge/BinpkgFetcher.py | 18 +- portage_with_autodep/pym/_emerge/BinpkgFetcher.pyo | Bin 5698 -> 5818 bytes .../pym/_emerge/BinpkgPrefetcher.pyo | Bin 1932 -> 1922 bytes portage_with_autodep/pym/_emerge/BinpkgVerifier.py | 143 +- .../pym/_emerge/BinpkgVerifier.pyo | Bin 2515 -> 4166 bytes portage_with_autodep/pym/_emerge/Blocker.pyo | Bin 853 -> 847 bytes portage_with_autodep/pym/_emerge/BlockerCache.py | 10 +- portage_with_autodep/pym/_emerge/BlockerCache.pyo | Bin 6840 -> 6831 bytes portage_with_autodep/pym/_emerge/BlockerDB.py | 12 +- portage_with_autodep/pym/_emerge/BlockerDB.pyo | Bin 4286 -> 4276 bytes .../pym/_emerge/BlockerDepPriority.pyo | Bin 797 -> 789 bytes portage_with_autodep/pym/_emerge/CompositeTask.py | 4 + portage_with_autodep/pym/_emerge/CompositeTask.pyo | Bin 5111 -> 5151 bytes portage_with_autodep/pym/_emerge/DepPriority.py | 29 +- portage_with_autodep/pym/_emerge/DepPriority.pyo | Bin 1653 -> 1802 bytes .../pym/_emerge/DepPriorityNormalRange.pyo | Bin 1866 -> 1856 bytes .../pym/_emerge/DepPrioritySatisfiedRange.py | 24 +- .../pym/_emerge/DepPrioritySatisfiedRange.pyo | Bin 2980 -> 3350 bytes portage_with_autodep/pym/_emerge/Dependency.py | 2 +- portage_with_autodep/pym/_emerge/Dependency.pyo | Bin 1092 -> 1107 bytes portage_with_autodep/pym/_emerge/DependencyArg.py | 23 +- portage_with_autodep/pym/_emerge/DependencyArg.pyo | Bin 1612 -> 2058 bytes portage_with_autodep/pym/_emerge/EbuildBinpkg.pyo | Bin 2007 -> 1999 bytes portage_with_autodep/pym/_emerge/EbuildBuild.py | 48 +- portage_with_autodep/pym/_emerge/EbuildBuild.pyo | Bin 11947 -> 12547 bytes portage_with_autodep/pym/_emerge/EbuildBuildDir.py | 11 +- .../pym/_emerge/EbuildBuildDir.pyo | Bin 3933 -> 3786 bytes portage_with_autodep/pym/_emerge/EbuildExecuter.py | 13 +- .../pym/_emerge/EbuildExecuter.pyo | Bin 3424 -> 3293 bytes portage_with_autodep/pym/_emerge/EbuildFetcher.py | 68 +- portage_with_autodep/pym/_emerge/EbuildFetcher.pyo | Bin 9374 -> 8910 bytes .../pym/_emerge/EbuildFetchonly.pyo | Bin 1552 -> 1546 bytes .../pym/_emerge/EbuildIpcDaemon.pyo | Bin 3227 -> 3219 bytes portage_with_autodep/pym/_emerge/EbuildMerge.pyo | Bin 2558 -> 2550 bytes .../pym/_emerge/EbuildMetadataPhase.py | 66 +- .../pym/_emerge/EbuildMetadataPhase.pyo | Bin 5787 -> 6407 bytes portage_with_autodep/pym/_emerge/EbuildPhase.py | 82 +- .../pym/_emerge/EbuildPhase.py.rej | 12 - portage_with_autodep/pym/_emerge/EbuildPhase.pyo | Bin 11191 -> 11978 bytes portage_with_autodep/pym/_emerge/EbuildProcess.py | 12 +- portage_with_autodep/pym/_emerge/EbuildProcess.pyo | Bin 967 -> 1095 bytes .../pym/_emerge/EbuildSpawnProcess.py | 10 +- .../pym/_emerge/EbuildSpawnProcess.pyo | Bin 897 -> 1001 bytes portage_with_autodep/pym/_emerge/EventsAnalyser.py | 153 +- portage_with_autodep/pym/_emerge/EventsLogger.py | 52 +- portage_with_autodep/pym/_emerge/FakeVartree.py | 114 +- portage_with_autodep/pym/_emerge/FakeVartree.pyo | Bin 9274 -> 11428 bytes portage_with_autodep/pym/_emerge/FifoIpcDaemon.py | 43 +- portage_with_autodep/pym/_emerge/FifoIpcDaemon.pyo | Bin 2902 -> 3419 bytes .../pym/_emerge/JobStatusDisplay.py | 44 +- .../pym/_emerge/JobStatusDisplay.pyo | Bin 9115 -> 9232 bytes portage_with_autodep/pym/_emerge/MergeListItem.py | 8 +- portage_with_autodep/pym/_emerge/MergeListItem.pyo | Bin 3960 -> 4015 bytes portage_with_autodep/pym/_emerge/MetadataRegen.py | 93 +- portage_with_autodep/pym/_emerge/MetadataRegen.pyo | Bin 5760 -> 4868 bytes .../pym/_emerge/MiscFunctionsProcess.py | 7 +- .../pym/_emerge/MiscFunctionsProcess.pyo | Bin 1701 -> 1805 bytes portage_with_autodep/pym/_emerge/Package.py | 389 ++- portage_with_autodep/pym/_emerge/Package.pyo | Bin 21535 -> 26683 bytes portage_with_autodep/pym/_emerge/PackageArg.pyo | Bin 1110 -> 1104 bytes portage_with_autodep/pym/_emerge/PackageMerge.py | 7 +- portage_with_autodep/pym/_emerge/PackageMerge.pyo | Bin 1509 -> 1604 bytes .../pym/_emerge/PackageUninstall.py | 6 +- .../pym/_emerge/PackageUninstall.pyo | Bin 4110 -> 4109 bytes .../pym/_emerge/PackageVirtualDbapi.py | 4 +- .../pym/_emerge/PackageVirtualDbapi.pyo | Bin 6099 -> 6068 bytes portage_with_autodep/pym/_emerge/PipeReader.py | 37 +- portage_with_autodep/pym/_emerge/PipeReader.pyo | Bin 3672 -> 3854 bytes portage_with_autodep/pym/_emerge/PollScheduler.py | 122 +- portage_with_autodep/pym/_emerge/PollScheduler.pyo | Bin 8151 -> 5939 bytes .../pym/_emerge/ProgressHandler.pyo | Bin 1115 -> 1105 bytes portage_with_autodep/pym/_emerge/QueueScheduler.py | 105 - .../pym/_emerge/QueueScheduler.pyo | Bin 3658 -> 0 bytes portage_with_autodep/pym/_emerge/RootConfig.py | 13 +- portage_with_autodep/pym/_emerge/RootConfig.pyo | Bin 1404 -> 1517 bytes portage_with_autodep/pym/_emerge/Scheduler.py | 234 +- portage_with_autodep/pym/_emerge/Scheduler.pyo | Bin 55155 -> 57688 bytes .../pym/_emerge/SequentialTaskQueue.pyo | Bin 3343 -> 3321 bytes portage_with_autodep/pym/_emerge/SetArg.py | 5 +- portage_with_autodep/pym/_emerge/SetArg.pyo | Bin 719 -> 768 bytes portage_with_autodep/pym/_emerge/SpawnProcess.py | 269 +-- portage_with_autodep/pym/_emerge/SpawnProcess.pyo | Bin 6006 -> 5914 bytes portage_with_autodep/pym/_emerge/SubProcess.py | 30 +- portage_with_autodep/pym/_emerge/SubProcess.pyo | Bin 4178 -> 4547 bytes portage_with_autodep/pym/_emerge/Task.py | 9 +- portage_with_autodep/pym/_emerge/Task.pyo | Bin 2148 -> 2563 bytes portage_with_autodep/pym/_emerge/TaskScheduler.py | 26 - portage_with_autodep/pym/_emerge/TaskScheduler.pyo | Bin 1309 -> 0 bytes portage_with_autodep/pym/_emerge/TaskSequence.pyo | Bin 2147 -> 2131 bytes .../pym/_emerge/UninstallFailure.pyo | Bin 785 -> 779 bytes .../pym/_emerge/UnmergeDepPriority.py | 27 +- .../pym/_emerge/UnmergeDepPriority.pyo | Bin 1345 -> 1416 bytes portage_with_autodep/pym/_emerge/UseFlagDisplay.py | 10 +- .../pym/_emerge/UseFlagDisplay.pyo | Bin 4148 -> 4169 bytes portage_with_autodep/pym/_emerge/__init__.pyo | Bin 129 -> 127 bytes .../pym/_emerge/_find_deep_system_runtime_deps.pyo | Bin 1299 -> 1293 bytes .../pym/_emerge/_flush_elog_mod_echo.pyo | Bin 606 -> 602 bytes portage_with_autodep/pym/_emerge/actions.py | 1784 ++++++++++---- portage_with_autodep/pym/_emerge/actions.pyo | Bin 80730 -> 106907 bytes portage_with_autodep/pym/_emerge/clear_caches.py | 4 +- portage_with_autodep/pym/_emerge/clear_caches.pyo | Bin 719 -> 632 bytes portage_with_autodep/pym/_emerge/countdown.py | 18 +- portage_with_autodep/pym/_emerge/countdown.pyo | Bin 917 -> 840 bytes .../pym/_emerge/create_depgraph_params.py | 19 + .../pym/_emerge/create_depgraph_params.pyo | Bin 1954 -> 2283 bytes .../pym/_emerge/create_world_atom.py | 25 +- .../pym/_emerge/create_world_atom.pyo | Bin 2648 -> 2813 bytes portage_with_autodep/pym/_emerge/depgraph.py | 2491 ++++++++++++++------ portage_with_autodep/pym/_emerge/depgraph.pyo | Bin 162245 -> 194570 bytes portage_with_autodep/pym/_emerge/emergelog.py | 12 +- portage_with_autodep/pym/_emerge/emergelog.pyo | Bin 1927 -> 1902 bytes portage_with_autodep/pym/_emerge/getloadavg.py | 5 +- portage_with_autodep/pym/_emerge/getloadavg.pyo | Bin 931 -> 951 bytes portage_with_autodep/pym/_emerge/help.py | 8 +- portage_with_autodep/pym/_emerge/help.pyo | Bin 2546 -> 2505 bytes .../pym/_emerge/is_valid_package_atom.py | 7 +- .../pym/_emerge/is_valid_package_atom.pyo | Bin 910 -> 960 bytes portage_with_autodep/pym/_emerge/main.py | 1302 ++-------- portage_with_autodep/pym/_emerge/main.pyo | Bin 52644 -> 23273 bytes .../pym/_emerge/resolver/__init__.pyo | Bin 138 -> 136 bytes .../pym/_emerge/resolver/backtracking.py | 56 +- .../pym/_emerge/resolver/backtracking.pyo | Bin 7838 -> 8962 bytes .../pym/_emerge/resolver/circular_dependency.py | 24 +- .../pym/_emerge/resolver/circular_dependency.pyo | Bin 7555 -> 7873 bytes .../pym/_emerge/resolver/output.py | 453 ++-- .../pym/_emerge/resolver/output.pyo | Bin 28079 -> 27400 bytes .../pym/_emerge/resolver/output_helpers.py | 88 +- .../pym/_emerge/resolver/output_helpers.pyo | Bin 18016 -> 20242 bytes .../pym/_emerge/resolver/slot_collision.py | 136 +- .../pym/_emerge/resolver/slot_collision.pyo | Bin 23644 -> 24965 bytes portage_with_autodep/pym/_emerge/search.py | 4 +- portage_with_autodep/pym/_emerge/search.pyo | Bin 11825 -> 11809 bytes .../pym/_emerge/show_invalid_depstring_notice.pyo | Bin 2001 -> 1995 bytes portage_with_autodep/pym/_emerge/stdout_spinner.py | 13 +- .../pym/_emerge/stdout_spinner.pyo | Bin 3440 -> 3450 bytes portage_with_autodep/pym/_emerge/sync/__init__.pyo | Bin 134 -> 132 bytes .../pym/_emerge/sync/getaddrinfo_validate.pyo | Bin 847 -> 843 bytes .../pym/_emerge/sync/old_tree_timestamp.pyo | Bin 2746 -> 2738 bytes portage_with_autodep/pym/_emerge/unmerge.pyo | Bin 14236 -> 14226 bytes portage_with_autodep/pym/_emerge/userquery.pyo | Bin 2254 -> 2250 bytes portage_with_autodep/pym/portage/__init__.py | 208 +- portage_with_autodep/pym/portage/__init__.pyo | Bin 22647 -> 25156 bytes .../pym/portage/_global_updates.py | 28 +- .../pym/portage/_global_updates.pyo | Bin 7542 -> 7765 bytes .../pym/portage/_legacy_globals.py | 3 +- .../pym/portage/_legacy_globals.pyo | Bin 1922 -> 1962 bytes portage_with_autodep/pym/portage/_selinux.py | 83 +- portage_with_autodep/pym/portage/_selinux.pyo | Bin 4706 -> 5663 bytes portage_with_autodep/pym/portage/_sets/__init__.py | 42 +- .../pym/portage/_sets/__init__.pyo | Bin 9216 -> 10350 bytes portage_with_autodep/pym/portage/_sets/base.py | 4 +- portage_with_autodep/pym/portage/_sets/base.pyo | Bin 10383 -> 10316 bytes portage_with_autodep/pym/portage/_sets/dbapi.py | 111 +- portage_with_autodep/pym/portage/_sets/dbapi.pyo | Bin 15064 -> 17711 bytes portage_with_autodep/pym/portage/_sets/files.py | 21 +- portage_with_autodep/pym/portage/_sets/files.pyo | Bin 13042 -> 13023 bytes portage_with_autodep/pym/portage/_sets/libs.py | 17 +- portage_with_autodep/pym/portage/_sets/libs.pyo | Bin 4053 -> 4091 bytes .../pym/portage/_sets/profiles.pyo | Bin 2296 -> 2286 bytes portage_with_autodep/pym/portage/_sets/security.py | 4 +- .../pym/portage/_sets/security.pyo | Bin 4426 -> 4405 bytes portage_with_autodep/pym/portage/_sets/shell.pyo | Bin 2072 -> 2062 bytes .../pym/portage/cache/__init__.pyo | Bin 135 -> 133 bytes portage_with_autodep/pym/portage/cache/anydbm.pyo | Bin 3755 -> 3735 bytes .../pym/portage/cache/cache_errors.pyo | Bin 4629 -> 4587 bytes .../pym/portage/cache/ebuild_xattr.py | 2 +- .../pym/portage/cache/ebuild_xattr.pyo | Bin 6260 -> 6228 bytes .../pym/portage/cache/flat_hash.py | 31 +- .../pym/portage/cache/flat_hash.pyo | Bin 5468 -> 5542 bytes .../pym/portage/cache/flat_list.py | 134 -- .../pym/portage/cache/flat_list.pyo | Bin 4939 -> 0 bytes .../pym/portage/cache/fs_template.py | 25 +- .../pym/portage/cache/fs_template.pyo | Bin 3580 -> 3846 bytes portage_with_autodep/pym/portage/cache/mappings.py | 6 +- .../pym/portage/cache/mappings.pyo | Bin 18081 -> 17936 bytes portage_with_autodep/pym/portage/cache/metadata.py | 3 +- .../pym/portage/cache/metadata.pyo | Bin 5048 -> 5055 bytes .../pym/portage/cache/sql_template.pyo | Bin 10542 -> 10508 bytes portage_with_autodep/pym/portage/cache/sqlite.py | 80 +- portage_with_autodep/pym/portage/cache/sqlite.pyo | Bin 9109 -> 10457 bytes portage_with_autodep/pym/portage/cache/template.py | 13 +- .../pym/portage/cache/template.pyo | Bin 11332 -> 11444 bytes .../pym/portage/cache/volatile.pyo | Bin 1633 -> 1619 bytes portage_with_autodep/pym/portage/checksum.py | 112 +- portage_with_autodep/pym/portage/checksum.pyo | Bin 10716 -> 13772 bytes portage_with_autodep/pym/portage/const.py | 215 +- portage_with_autodep/pym/portage/const.py.rej | 12 - portage_with_autodep/pym/portage/const.pyo | Bin 4887 -> 6100 bytes portage_with_autodep/pym/portage/cvstree.pyo | Bin 9826 -> 9800 bytes portage_with_autodep/pym/portage/data.py | 63 +- portage_with_autodep/pym/portage/data.pyo | Bin 5965 -> 6741 bytes .../pym/portage/dbapi/_MergeProcess.py | 214 +- .../pym/portage/dbapi/_MergeProcess.pyo | Bin 6813 -> 7418 bytes portage_with_autodep/pym/portage/dbapi/__init__.py | 185 +- .../pym/portage/dbapi/__init__.pyo | Bin 11096 -> 15582 bytes .../pym/portage/dbapi/_expand_new_virt.py | 12 +- .../pym/portage/dbapi/_expand_new_virt.pyo | Bin 1943 -> 2184 bytes portage_with_autodep/pym/portage/dbapi/bintree.py | 357 +-- portage_with_autodep/pym/portage/dbapi/bintree.pyo | Bin 39953 -> 42052 bytes .../pym/portage/dbapi/cpv_expand.py | 4 +- .../pym/portage/dbapi/cpv_expand.pyo | Bin 2373 -> 2467 bytes .../pym/portage/dbapi/dep_expand.py | 6 +- .../pym/portage/dbapi/dep_expand.pyo | Bin 1500 -> 1606 bytes portage_with_autodep/pym/portage/dbapi/porttree.py | 152 +- .../pym/portage/dbapi/porttree.pyo | Bin 33775 -> 35582 bytes portage_with_autodep/pym/portage/dbapi/vartree.py | 754 ++++-- portage_with_autodep/pym/portage/dbapi/vartree.pyo | Bin 120778 -> 129927 bytes portage_with_autodep/pym/portage/dbapi/virtual.py | 56 +- portage_with_autodep/pym/portage/dbapi/virtual.pyo | Bin 5813 -> 6046 bytes portage_with_autodep/pym/portage/debug.pyo | Bin 4434 -> 4408 bytes portage_with_autodep/pym/portage/dep/__init__.py | 740 ++++-- portage_with_autodep/pym/portage/dep/__init__.pyo | Bin 67806 -> 75365 bytes portage_with_autodep/pym/portage/dep/dep_check.py | 126 +- portage_with_autodep/pym/portage/dep/dep_check.pyo | Bin 13211 -> 14218 bytes portage_with_autodep/pym/portage/dispatch_conf.py | 18 +- portage_with_autodep/pym/portage/dispatch_conf.pyo | Bin 7195 -> 7383 bytes portage_with_autodep/pym/portage/eapi.py | 90 +- portage_with_autodep/pym/portage/eapi.pyo | Bin 4007 -> 8429 bytes portage_with_autodep/pym/portage/eclass_cache.py | 14 +- portage_with_autodep/pym/portage/eclass_cache.pyo | Bin 5716 -> 6331 bytes portage_with_autodep/pym/portage/elog/__init__.pyo | Bin 5346 -> 5330 bytes .../pym/portage/elog/filtering.pyo | Bin 574 -> 570 bytes portage_with_autodep/pym/portage/elog/messages.pyo | Bin 4935 -> 4919 bytes .../pym/portage/elog/mod_custom.pyo | Bin 988 -> 984 bytes portage_with_autodep/pym/portage/elog/mod_echo.pyo | Bin 1933 -> 1925 bytes portage_with_autodep/pym/portage/elog/mod_mail.pyo | Bin 1464 -> 1460 bytes .../pym/portage/elog/mod_mail_summary.pyo | Bin 3107 -> 3099 bytes portage_with_autodep/pym/portage/elog/mod_save.py | 24 +- portage_with_autodep/pym/portage/elog/mod_save.pyo | Bin 2192 -> 2549 bytes .../pym/portage/elog/mod_save_summary.py | 40 +- .../pym/portage/elog/mod_save_summary.pyo | Bin 2342 -> 2862 bytes .../pym/portage/elog/mod_syslog.pyo | Bin 1292 -> 1288 bytes portage_with_autodep/pym/portage/env/__init__.pyo | Bin 133 -> 131 bytes portage_with_autodep/pym/portage/env/config.pyo | Bin 4454 -> 4424 bytes portage_with_autodep/pym/portage/env/loaders.py | 26 +- portage_with_autodep/pym/portage/env/loaders.pyo | Bin 11328 -> 11525 bytes .../pym/portage/env/validators.pyo | Bin 762 -> 758 bytes portage_with_autodep/pym/portage/exception.py | 45 +- portage_with_autodep/pym/portage/exception.pyo | Bin 11981 -> 12277 bytes portage_with_autodep/pym/portage/getbinpkg.py | 89 +- portage_with_autodep/pym/portage/getbinpkg.pyo | Bin 24428 -> 26147 bytes portage_with_autodep/pym/portage/glsa.py | 309 +-- portage_with_autodep/pym/portage/glsa.pyo | Bin 24474 -> 26320 bytes portage_with_autodep/pym/portage/localization.py | 12 +- portage_with_autodep/pym/portage/localization.pyo | Bin 793 -> 1090 bytes portage_with_autodep/pym/portage/locks.py | 62 +- portage_with_autodep/pym/portage/locks.pyo | Bin 12530 -> 13034 bytes portage_with_autodep/pym/portage/mail.pyo | Bin 4745 -> 4733 bytes portage_with_autodep/pym/portage/manifest.py | 114 +- portage_with_autodep/pym/portage/manifest.pyo | Bin 24109 -> 25119 bytes portage_with_autodep/pym/portage/news.py | 10 +- portage_with_autodep/pym/portage/news.pyo | Bin 15630 -> 15880 bytes portage_with_autodep/pym/portage/output.py | 103 +- portage_with_autodep/pym/portage/output.pyo | Bin 28175 -> 29076 bytes .../pym/portage/package/__init__.pyo | Bin 137 -> 135 bytes .../pym/portage/package/ebuild/__init__.pyo | Bin 144 -> 142 bytes .../package/ebuild/_config/KeywordsManager.py | 56 +- .../package/ebuild/_config/KeywordsManager.pyo | Bin 8961 -> 9775 bytes .../package/ebuild/_config/LicenseManager.pyo | Bin 8214 -> 8188 bytes .../package/ebuild/_config/LocationsManager.py | 135 +- .../package/ebuild/_config/LocationsManager.pyo | Bin 9666 -> 10282 bytes .../portage/package/ebuild/_config/MaskManager.py | 33 +- .../portage/package/ebuild/_config/MaskManager.pyo | Bin 8064 -> 7981 bytes .../portage/package/ebuild/_config/UseManager.py | 290 ++- .../portage/package/ebuild/_config/UseManager.pyo | Bin 9077 -> 16531 bytes .../package/ebuild/_config/VirtualsManager.pyo | Bin 6480 -> 6458 bytes .../portage/package/ebuild/_config/__init__.pyo | Bin 152 -> 150 bytes .../package/ebuild/_config/env_var_validation.pyo | Bin 1011 -> 1007 bytes .../package/ebuild/_config/features_set.pyo | Bin 5840 -> 5810 bytes .../pym/portage/package/ebuild/_config/helper.pyo | Bin 2235 -> 2229 bytes .../package/ebuild/_config/special_env_vars.py | 64 +- .../package/ebuild/_config/special_env_vars.pyo | Bin 5517 -> 6852 bytes .../pym/portage/package/ebuild/_eapi_invalid.py | 54 - .../pym/portage/package/ebuild/_eapi_invalid.pyo | Bin 1848 -> 0 bytes .../portage/package/ebuild/_ipc/ExitCommand.pyo | Bin 1057 -> 1049 bytes .../pym/portage/package/ebuild/_ipc/IpcCommand.pyo | Bin 612 -> 606 bytes .../portage/package/ebuild/_ipc/QueryCommand.py | 99 +- .../portage/package/ebuild/_ipc/QueryCommand.pyo | Bin 3629 -> 5194 bytes .../pym/portage/package/ebuild/_ipc/__init__.pyo | Bin 149 -> 147 bytes .../pym/portage/package/ebuild/_spawn_nofetch.py | 23 +- .../pym/portage/package/ebuild/_spawn_nofetch.pyo | Bin 3182 -> 3514 bytes .../pym/portage/package/ebuild/config.py | 667 ++++-- .../pym/portage/package/ebuild/config.pyo | Bin 65727 -> 74743 bytes .../package/ebuild/deprecated_profile_check.py | 63 +- .../package/ebuild/deprecated_profile_check.pyo | Bin 1949 -> 3029 bytes .../pym/portage/package/ebuild/digestcheck.py | 15 +- .../pym/portage/package/ebuild/digestcheck.pyo | Bin 4457 -> 4668 bytes .../pym/portage/package/ebuild/digestgen.py | 107 +- .../pym/portage/package/ebuild/digestgen.pyo | Bin 5721 -> 5723 bytes .../pym/portage/package/ebuild/doebuild.py | 647 +++-- .../pym/portage/package/ebuild/doebuild.pyo | Bin 55376 -> 63414 bytes .../pym/portage/package/ebuild/fetch.py | 90 +- .../pym/portage/package/ebuild/fetch.pyo | Bin 24287 -> 25049 bytes .../pym/portage/package/ebuild/getmaskingreason.py | 30 +- .../portage/package/ebuild/getmaskingreason.pyo | Bin 3654 -> 3467 bytes .../pym/portage/package/ebuild/getmaskingstatus.py | 31 +- .../portage/package/ebuild/getmaskingstatus.pyo | Bin 5230 -> 5785 bytes .../portage/package/ebuild/prepare_build_dirs.py | 8 +- .../portage/package/ebuild/prepare_build_dirs.pyo | Bin 11519 -> 11658 bytes portage_with_autodep/pym/portage/process.py | 340 ++- portage_with_autodep/pym/portage/process.pyo | Bin 12173 -> 17275 bytes .../pym/portage/proxy/__init__.pyo | Bin 135 -> 133 bytes .../pym/portage/proxy/lazyimport.py | 4 +- .../pym/portage/proxy/lazyimport.pyo | Bin 6140 -> 6146 bytes .../pym/portage/proxy/objectproxy.py | 9 +- .../pym/portage/proxy/objectproxy.pyo | Bin 5289 -> 5676 bytes .../pym/portage/repository/__init__.pyo | Bin 140 -> 138 bytes .../pym/portage/repository/config.py | 552 ++++- .../pym/portage/repository/config.pyo | Bin 24828 -> 33640 bytes portage_with_autodep/pym/portage/tests/__init__.py | 93 +- .../pym/portage/tests/__init__.pyo | Bin 10394 -> 12462 bytes .../pym/portage/tests/lint/__init__.pyo | Bin 140 -> 138 bytes .../pym/portage/tests/lint/test_bash_syntax.py | 26 +- .../pym/portage/tests/lint/test_bash_syntax.pyo | Bin 1944 -> 2508 bytes .../pym/portage/tests/lint/test_compile_modules.py | 20 +- .../portage/tests/lint/test_compile_modules.pyo | Bin 1855 -> 1829 bytes .../pym/portage/tests/lint/test_import_modules.py | 2 +- .../pym/portage/tests/lint/test_import_modules.pyo | Bin 1725 -> 1717 bytes portage_with_autodep/pym/portage/tests/runTests | 29 +- portage_with_autodep/pym/portage/update.py | 166 +- portage_with_autodep/pym/portage/update.pyo | Bin 10829 -> 12468 bytes .../pym/portage/util/ExtractKernelVersion.py | 6 +- .../pym/portage/util/ExtractKernelVersion.pyo | Bin 2297 -> 2293 bytes .../pym/portage/util/SlotObject.py | 1 - .../pym/portage/util/SlotObject.pyo | Bin 1719 -> 1711 bytes portage_with_autodep/pym/portage/util/__init__.py | 390 ++- portage_with_autodep/pym/portage/util/__init__.pyo | Bin 47487 -> 51257 bytes .../pym/portage/util/_desktop_entry.py | 85 +- .../pym/portage/util/_desktop_entry.pyo | Bin 2878 -> 3495 bytes .../pym/portage/util/_dyn_libs/LinkageMapELF.py | 24 +- .../pym/portage/util/_dyn_libs/LinkageMapELF.pyo | Bin 26399 -> 26552 bytes .../util/_dyn_libs/PreservedLibsRegistry.pyo | Bin 8884 -> 8858 bytes .../pym/portage/util/_dyn_libs/__init__.pyo | Bin 144 -> 142 bytes .../pym/portage/util/_eventloop/EventLoop.py | 364 ++- .../pym/portage/util/_eventloop/EventLoop.pyo | Bin 13508 -> 18011 bytes .../pym/portage/util/_eventloop/GlibEventLoop.pyo | Bin 1029 -> 1023 bytes .../pym/portage/util/_eventloop/PollConstants.pyo | Bin 787 -> 783 bytes .../portage/util/_eventloop/PollSelectAdapter.py | 2 +- .../portage/util/_eventloop/PollSelectAdapter.pyo | Bin 2220 -> 2224 bytes .../pym/portage/util/_eventloop/__init__.pyo | Bin 145 -> 143 bytes .../portage/util/_eventloop/global_event_loop.pyo | Bin 878 -> 874 bytes portage_with_autodep/pym/portage/util/_pty.pyo | Bin 1936 -> 1932 bytes portage_with_autodep/pym/portage/util/_urlopen.py | 99 +- portage_with_autodep/pym/portage/util/_urlopen.pyo | Bin 1626 -> 3962 bytes portage_with_autodep/pym/portage/util/digraph.py | 36 +- portage_with_autodep/pym/portage/util/digraph.pyo | Bin 10678 -> 10653 bytes .../pym/portage/util/env_update.py | 77 +- .../pym/portage/util/env_update.pyo | Bin 9095 -> 9804 bytes .../pym/portage/util/lafilefixer.py | 10 +- .../pym/portage/util/lafilefixer.pyo | Bin 3621 -> 3615 bytes portage_with_autodep/pym/portage/util/listdir.py | 128 +- portage_with_autodep/pym/portage/util/listdir.pyo | Bin 4088 -> 3899 bytes portage_with_autodep/pym/portage/util/movefile.py | 220 +- portage_with_autodep/pym/portage/util/movefile.pyo | Bin 8236 -> 10716 bytes portage_with_autodep/pym/portage/util/mtimedb.pyo | Bin 3770 -> 3760 bytes portage_with_autodep/pym/portage/util/whirlpool.py | 2 + .../pym/portage/util/whirlpool.pyo | Bin 38994 -> 39086 bytes portage_with_autodep/pym/portage/versions.py | 115 +- portage_with_autodep/pym/portage/versions.pyo | Bin 13125 -> 14999 bytes portage_with_autodep/pym/portage/xml/__init__.pyo | Bin 133 -> 131 bytes portage_with_autodep/pym/portage/xml/metadata.py | 25 +- portage_with_autodep/pym/portage/xml/metadata.pyo | Bin 15298 -> 15650 bytes portage_with_autodep/pym/portage/xpak.py | 2 +- portage_with_autodep/pym/portage/xpak.pyo | Bin 16218 -> 16169 bytes portage_with_autodep/pym/repoman/__init__.pyo | Bin 129 -> 127 bytes portage_with_autodep/pym/repoman/checks.py | 391 ++- portage_with_autodep/pym/repoman/checks.pyo | Bin 31426 -> 38169 bytes portage_with_autodep/pym/repoman/errors.py | 7 +- portage_with_autodep/pym/repoman/errors.pyo | Bin 1948 -> 1915 bytes portage_with_autodep/pym/repoman/herdbase.py | 17 +- portage_with_autodep/pym/repoman/herdbase.pyo | Bin 3401 -> 3719 bytes portage_with_autodep/pym/repoman/utilities.py | 164 +- portage_with_autodep/pym/repoman/utilities.pyo | Bin 24780 -> 25955 bytes src/hook_lib/file_hook.c | 2 +- 474 files changed, 17134 insertions(+), 11557 deletions(-) delete mode 100755 portage_with_autodep/bin/banned-helper delete mode 120000 portage_with_autodep/bin/ebuild-helpers/4/dodoc delete mode 120000 portage_with_autodep/bin/ebuild-helpers/4/dohard delete mode 120000 portage_with_autodep/bin/ebuild-helpers/4/dosed delete mode 120000 portage_with_autodep/bin/ebuild-helpers/4/prepalldocs mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newbin mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newconfd mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newdoc mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newenvd mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newexe mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newinitd mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newlib.a mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newlib.so mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newman mode change 100755 => 120000 portage_with_autodep/bin/ebuild-helpers/newsbin delete mode 100755 portage_with_autodep/bin/ebuild-helpers/preplib delete mode 100644 portage_with_autodep/integration_with_portage.patch delete mode 100644 portage_with_autodep/pym/_emerge/EbuildPhase.py.rej delete mode 100644 portage_with_autodep/pym/_emerge/QueueScheduler.py delete mode 100644 portage_with_autodep/pym/_emerge/QueueScheduler.pyo delete mode 100644 portage_with_autodep/pym/_emerge/TaskScheduler.py delete mode 100644 portage_with_autodep/pym/_emerge/TaskScheduler.pyo delete mode 100644 portage_with_autodep/pym/portage/cache/flat_list.py delete mode 100644 portage_with_autodep/pym/portage/cache/flat_list.pyo delete mode 100644 portage_with_autodep/pym/portage/const.py.rej delete mode 100644 portage_with_autodep/pym/portage/package/ebuild/_eapi_invalid.py delete mode 100644 portage_with_autodep/pym/portage/package/ebuild/_eapi_invalid.pyo diff --git a/.gitignore b/.gitignore index 0d20b64..52e4e61 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +*.pyo diff --git a/integration_with_portage.patch b/integration_with_portage.patch index a74beed..ff8f487 100644 --- a/integration_with_portage.patch +++ b/integration_with_portage.patch @@ -1,17 +1,16 @@ -diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py -index 0144cfc..1c423a3 100644 ---- a/pym/_emerge/EbuildBuild.py -+++ b/pym/_emerge/EbuildBuild.py -@@ -9,6 +9,8 @@ from _emerge.CompositeTask import CompositeTask +diff -urN /usr/lib/portage/pym/_emerge/EbuildBuild.py ./pym/_emerge/EbuildBuild.py +--- /usr/lib/portage/pym/_emerge/EbuildBuild.py 2014-01-23 14:09:03.647948532 +0600 ++++ ./pym/_emerge/EbuildBuild.py 2014-02-17 17:25:59.335376529 +0600 +@@ -9,6 +9,8 @@ from _emerge.EbuildMerge import EbuildMerge from _emerge.EbuildFetchonly import EbuildFetchonly from _emerge.EbuildBuildDir import EbuildBuildDir +from _emerge.EventsAnalyser import EventsAnalyser, FilterProcGenerator +from _emerge.EventsLogger import EventsLogger from _emerge.MiscFunctionsProcess import MiscFunctionsProcess - from portage.util import writemsg - import portage -@@ -21,7 +23,7 @@ from portage.package.ebuild._spawn_nofetch import spawn_nofetch + from _emerge.TaskSequence import TaskSequence + +@@ -24,7 +26,7 @@ class EbuildBuild(CompositeTask): __slots__ = ("args_set", "config_pool", "find_blockers", @@ -20,7 +19,7 @@ index 0144cfc..1c423a3 100644 "prefetcher", "settings", "world_atom") + \ ("_build_dir", "_buildpkg", "_ebuild_path", "_issyspkg", "_tree") -@@ -244,8 +246,54 @@ class EbuildBuild(CompositeTask): +@@ -259,8 +261,52 @@ build = EbuildExecuter(background=self.background, pkg=pkg, scheduler=scheduler, settings=settings) @@ -35,7 +34,7 @@ index 0144cfc..1c423a3 100644 + "depcheckstrict" in self.settings["FEATURES"]: + # Lets start a log listening server + temp_path=self.settings.get("T",self.settings["PORTAGE_TMPDIR"]) -+ ++ + if "depcheckstrict" not in self.settings["FEATURES"]: + # use default filter_proc + self.logserver=EventsLogger(socket_dir=temp_path) @@ -44,11 +43,11 @@ index 0144cfc..1c423a3 100644 + "This may take some time\n") + filter_gen=FilterProcGenerator(self.pkg.cpv, self.settings) + filter_proc=filter_gen.get_filter_proc() -+ self.logserver=EventsLogger(socket_dir=temp_path, ++ self.logserver=EventsLogger(socket_dir=temp_path, + filter_proc=filter_proc) -+ ++ + self.logserver.start() -+ ++ + # Copy socket path to LOG_SOCKET environment variable + env=self.settings.configdict["pkg"] + env['LOG_SOCKET'] = self.logserver.socket_name @@ -62,39 +61,34 @@ index 0144cfc..1c423a3 100644 + env=self.settings.configdict["pkg"] + if 'LOG_SOCKET' in env: + del env['LOG_SOCKET'] -+ ++ + events=self.logserver.stop() + self.logserver=None + analyser=EventsAnalyser(self.pkg.cpv, events, self.settings) + analyser.display() # show the analyse + + #import pdb; pdb.set_trace() -+ -+ + def _fetch_failed(self): # We only call the pkg_nofetch phase if either RESTRICT=fetch # is set or the package has explicitly overridden the default -diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py -index f53570a..82c165d 100644 ---- a/pym/_emerge/EbuildPhase.py -+++ b/pym/_emerge/EbuildPhase.py -@@ -33,7 +33,8 @@ class EbuildPhase(CompositeTask): - ("_ebuild_lock",) +diff -urN /usr/lib/portage/pym/_emerge/EbuildPhase.py ./pym/_emerge/EbuildPhase.py +--- /usr/lib/portage/pym/_emerge/EbuildPhase.py 2014-01-23 14:09:03.648948532 +0600 ++++ ./pym/_emerge/EbuildPhase.py 2014-02-17 17:27:57.509371559 +0600 +@@ -44,7 +44,8 @@ # FEATURES displayed prior to setup phase -- _features_display = ("ccache", "distcc", "distcc-pump", "fakeroot", -+ _features_display = ("ccache", "depcheck", "depcheckstrict" "distcc", -+ "distcc-pump", "fakeroot", + _features_display = ( +- "ccache", "compressdebug", "distcc", "distcc-pump", "fakeroot", ++ "ccache", "compressdebug", "depcheck", "depcheckstrict", ++ "distcc", "distcc-pump", "fakeroot", "installsources", "keeptemp", "keepwork", "nostrip", "preserve-libs", "sandbox", "selinux", "sesandbox", "splitdebug", "suidctl", "test", "userpriv", -diff --git a/pym/_emerge/EventsAnalyser.py b/pym/_emerge/EventsAnalyser.py -new file mode 100644 -index 0000000..65ece7b ---- /dev/null -+++ b/pym/_emerge/EventsAnalyser.py -@@ -0,0 +1,511 @@ +diff -urN /usr/lib/portage/pym/_emerge/EventsAnalyser.py ./pym/_emerge/EventsAnalyser.py +--- /usr/lib/portage/pym/_emerge/EventsAnalyser.py 1970-01-01 05:00:00.000000000 +0500 ++++ ./pym/_emerge/EventsAnalyser.py 2014-02-17 17:34:27.954355139 +0600 +@@ -0,0 +1,514 @@ +# Distributed under the terms of the GNU General Public License v2 + +import portage @@ -131,36 +125,36 @@ index 0000000..65ece7b + def get_dep(self,pkg,dep_type=["RDEPEND","DEPEND"]): + """ + Gets current dependencies of a package. Looks in portage db -+ ++ + :param pkg: name of package -+ :param dep_type: type of dependencies to recurse. Can be ["DEPEND"] or ++ :param dep_type: type of dependencies to recurse. Can be ["DEPEND"] or + ["RDEPEND", "DEPEND"] + :returns: **set** of packages names + """ + ret=set() -+ -+ pkg = self.get_best_visible_pkg(pkg) ++ ++ pkg = self.get_best_visible_pkg(pkg) + if not pkg: + return ret -+ ++ + # we found the best visible match in common tree + + -+ metadata = dict(zip(self.metadata_keys, ++ metadata = dict(zip(self.metadata_keys, + self.portdbapi.aux_get(pkg, self.metadata_keys))) + dep_str = " ".join(metadata[k] for k in dep_type) + + # the IUSE default are very important for us + iuse_defaults=[ + u[1:] for u in metadata.get("IUSE",'').split() if u.startswith("+")] -+ ++ + use=self.use.split() -+ ++ + for u in iuse_defaults: + if u not in use: + use.append(u) + -+ success, atoms = portage.dep_check(dep_str, None, self.settings, ++ success, atoms = portage.dep_check(dep_str, None, self.settings, + myuse=use, myroot=self.settings["ROOT"], + trees={self.settings["ROOT"]:{"vartree":self.vartree, "porttree": self.vartree}}) + if not success: @@ -171,7 +165,7 @@ index 0000000..65ece7b + + if not atomname: + continue -+ ++ + for unvirt_pkg in expand_new_virt(self.vardbapi,'='+atomname): + for pkg in self.vartree.dep_match(unvirt_pkg): + ret.add(pkg) @@ -180,12 +174,12 @@ index 0000000..65ece7b + + # recursive dependency getter + def get_deps(self,pkg,dep_type=["RDEPEND","DEPEND"]): -+ """ -+ Gets current dependencies of a package on any depth ++ """ ++ Gets current dependencies of a package on any depth + All dependencies **must** be installed -+ ++ + :param pkg: name of package -+ :param dep_type: type of dependencies to recurse. Can be ["DEPEND"] or ++ :param dep_type: type of dependencies to recurse. Can be ["DEPEND"] or + ["RDEPEND", "DEPEND"] + :returns: **set** of packages names + """ @@ -194,14 +188,14 @@ index 0000000..65ece7b + + # get porttree dependencies on the first package + -+ pkg = self.portdbapi.xmatch("bestmatch-visible", pkg) ++ pkg = self.portdbapi.xmatch("bestmatch-visible", pkg) + if not pkg: + return ret + + known_packages=set() + unknown_packages=self.get_dep(pkg,dep_type) + ret=ret.union(unknown_packages) -+ ++ + while unknown_packages: + p=unknown_packages.pop() + if p in known_packages: @@ -211,18 +205,18 @@ index 0000000..65ece7b + metadata = dict(zip(self.metadata_keys, self.vardbapi.aux_get(p, self.metadata_keys))) + + dep_str = " ".join(metadata[k] for k in dep_type) -+ ++ + # the IUSE default are very important for us + iuse_defaults=[ + u[1:] for u in metadata.get("IUSE",'').split() if u.startswith("+")] -+ ++ + use=self.use.split() -+ ++ + for u in iuse_defaults: + if u not in use: + use.append(u) -+ -+ success, atoms = portage.dep_check(dep_str, None, self.settings, ++ ++ success, atoms = portage.dep_check(dep_str, None, self.settings, + myuse=use, myroot=self.settings["ROOT"], + trees={self.settings["ROOT"]:{"vartree":self.vartree,"porttree": self.vartree}}) + @@ -233,7 +227,7 @@ index 0000000..65ece7b + atomname = self.vartree.dep_bestmatch(atom) + if not atomname: + continue -+ ++ + for unvirt_pkg in expand_new_virt(self.vardbapi,'='+atomname): + for pkg in self.vartree.dep_match(unvirt_pkg): + ret.add(pkg) @@ -241,8 +235,8 @@ index 0000000..65ece7b + return ret + + def get_deps_for_package_building(self, pkg): -+ """ -+ returns buildtime dependencies of current package and ++ """ ++ returns buildtime dependencies of current package and + all runtime dependencies of that buildtime dependencies + """ + buildtime_deps=self.get_dep(pkg, ["DEPEND"]) @@ -254,9 +248,9 @@ index 0000000..65ece7b + return ret + + def get_system_packages_list(self): -+ """ ++ """ + returns all packages from system set. They are always implicit dependencies -+ ++ + :returns: **list** of package names + """ + ret=[] @@ -269,11 +263,12 @@ index 0000000..65ece7b + + +class GentoolkitUtils: -+ """ -+ Interface with qfile and qlist utils. They are much faster than ++ """ ++ Interface with qfile and qlist utils. They are much faster than + internals. + """ + ++ @staticmethod + def getpackagesbyfiles(files): + """ + :param files: list of filenames @@ -287,14 +282,14 @@ index 0000000..65ece7b + ret[f]="directory" + else: + listtocheck.append(f) -+ ++ + try: + proc=subprocess.Popen(['qfile']+['--nocolor','--exact','','--from','-'], -+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE, ++ stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE, + bufsize=4096) -+ ++ + out,err=proc.communicate("\n".join(listtocheck).encode("utf8")) -+ ++ + lines=out.decode("utf8").split("\n") + #print lines + line_re=re.compile(r"^([^ ]+)\s+\(([^)]+)\)$") @@ -309,24 +304,25 @@ index 0000000..65ece7b + + except OSError as e: + portage.util.writemsg("Error while launching qfile: %s\n" % e) -+ -+ ++ ++ + return ret -+ ++ ++ @staticmethod + def getfilesbypackages(packagenames): + """ -+ ++ + :param packagename: name of package + :returns: **list** of files in package with name *packagename* + """ + ret=[] + try: + proc=subprocess.Popen(['qlist']+['--nocolor',"--obj"]+packagenames, -+ stdout=subprocess.PIPE,stderr=subprocess.PIPE, ++ stdout=subprocess.PIPE,stderr=subprocess.PIPE, + bufsize=4096) -+ ++ + out,err=proc.communicate() -+ ++ + ret=out.decode("utf8").split("\n") + if ret==['']: + ret=[] @@ -334,34 +330,35 @@ index 0000000..65ece7b + portage.util.writemsg("Error while launching qfile: %s\n" % e) + + return ret -+ -+ def get_all_packages_files(): ++ ++ @staticmethod ++ def get_all_packages_files(): + """ + Memory-hungry operation -+ ++ + :returns: **set** of all files that belongs to package + """ + ret=[] + try: + proc=subprocess.Popen(['qlist']+['--all',"--obj"], -+ stdout=subprocess.PIPE,stderr=subprocess.PIPE, ++ stdout=subprocess.PIPE,stderr=subprocess.PIPE, + bufsize=4096) -+ ++ + out,err=proc.communicate() -+ ++ + ret=out.decode("utf8").split("\n") + except OSError as e: + portage.util.writemsg("Error while launching qfile: %s\n" % e) + + return set(ret) -+ ++ +class FilterProcGenerator: + def __init__(self, pkgname, settings): + portageutils=PortageUtils(settings=settings) + + deps_all=portageutils.get_deps_for_package_building(pkgname) + deps_portage=portageutils.get_dep('portage',["RDEPEND"]) -+ ++ + system_packages=portageutils.get_system_packages_list() + + allfiles=GentoolkitUtils.get_all_packages_files() @@ -369,8 +366,8 @@ index 0000000..65ece7b + "a list of allowed files\n") + + -+ allowedpkgs=system_packages+list(deps_portage)+list(deps_all) -+ ++ allowedpkgs=system_packages+list(deps_portage)+list(deps_all) ++ + allowedfiles=GentoolkitUtils.getfilesbypackages(allowedpkgs) + #for pkg in allowedpkgs: + # allowedfiles+=GentoolkitUtils.getfilesbypackage(pkg) @@ -380,14 +377,14 @@ index 0000000..65ece7b + # manually add all python interpreters to this list + allowedfiles+=GentoolkitUtils.getfilesbypackages(['python']) + allowedfiles=set(allowedfiles) -+ ++ + deniedfiles=allfiles-allowedfiles + + def filter_proc(eventname,filename,stage): + if filename in deniedfiles: + return False + return True -+ ++ + self.filter_proc=filter_proc + def get_filter_proc(self): + return self.filter_proc @@ -402,10 +399,10 @@ index 0000000..65ece7b + self.deps_all=self.portageutils.get_deps_for_package_building(pkgname) + self.deps_direct=self.portageutils.get_dep(pkgname,["DEPEND"]) + self.deps_portage=self.portageutils.get_dep('portage',["RDEPEND"]) -+ ++ + self.system_packages=self.portageutils.get_system_packages_list() + # All analyse work is here -+ ++ + # get unique filenames + filenames=set() + for stage in events: @@ -416,7 +413,7 @@ index 0000000..65ece7b + filenames=list(filenames) + + file_to_package=GentoolkitUtils.getpackagesbyfiles(filenames) -+ # This part is completly unreadable. ++ # This part is completly unreadable. + # It converting one complex struct(returned by getfsevents) to another complex + # struct which good for generating output. + # @@ -427,24 +424,24 @@ index 0000000..65ece7b + for stage in sorted(events): + succ_events=events[stage][0] + fail_events=events[stage][1] -+ ++ + for filename in succ_events: + if filename in file_to_package: + package=file_to_package[filename] + else: + package="unknown" -+ ++ + if not package in packagesinfo: + packagesinfo[package]={} + stageinfo=packagesinfo[package] + if not stage in stageinfo: + stageinfo[stage]={} -+ ++ + filesinfo=stageinfo[stage] + if not filename in filesinfo: + filesinfo[filename]={"found":[],"notfound":[]} + filesinfo[filename]["found"]=succ_events[filename] -+ ++ + for filename in fail_events: + if filename in file_to_package: + package=file_to_package[filename] @@ -455,13 +452,13 @@ index 0000000..65ece7b + stageinfo=packagesinfo[package] + if not stage in stageinfo: + stageinfo[stage]={} -+ ++ + filesinfo=stageinfo[stage] + if not filename in filesinfo: + filesinfo[filename]={"found":[],"notfound":[]} + filesinfo[filename]["notfound"]=fail_events[filename] + self.packagesinfo=packagesinfo -+ ++ + def display(self): + portage.util.writemsg( + portage.output.colorize( @@ -470,12 +467,12 @@ index 0000000..65ece7b + stagesorder={"clean":1,"setup":2,"unpack":3,"prepare":4,"configure":5,"compile":6,"test":7, + "install":8,"preinst":9,"postinst":10,"prerm":11,"postrm":12,"unknown":13} + packagesinfo=self.packagesinfo -+ # print information grouped by package ++ # print information grouped by package + for package in sorted(packagesinfo): + # not showing special directory package + if package=="directory": + continue -+ ++ + if package=="unknown": + continue + @@ -492,7 +489,7 @@ index 0000000..65ece7b + + if len(stages)==0: + continue -+ ++ + filenames={} + for stage in stages: + for filename in packagesinfo[package][stage]: @@ -503,7 +500,7 @@ index 0000000..65ece7b + else: + status, old_was_readed, old_was_writed=filenames[filename] + filenames[filename]=[ -+ 'ok',old_was_readed | was_readed, old_was_writed | was_writed ++ 'ok',old_was_readed | was_readed, old_was_writed | was_writed + ] + if len(packagesinfo[package][stage][filename]["notfound"])!=0: + was_notfound,was_blocked=packagesinfo[package][stage][filename]["notfound"] @@ -512,9 +509,9 @@ index 0000000..65ece7b + else: + status, old_was_notfound, old_was_blocked=filenames[filename] + filenames[filename]=[ -+ 'err',old_was_notfound | was_notfound, old_was_blocked | was_blocked ++ 'err',old_was_notfound | was_notfound, old_was_blocked | was_blocked + ] -+ ++ + + if is_pkg_in_dep: + portage.util.writemsg("[OK]") @@ -543,9 +540,9 @@ index 0000000..65ece7b + ('err',False,True):"blocked", + ('err',True,True):"not found and blocked" + } -+ ++ + filescounter=0 -+ ++ + for filename in filenames: + event_info=tuple(filenames[filename]) + portage.util.writemsg(" %-56s %-21s\n" % (filename,action[event_info])) @@ -553,7 +550,7 @@ index 0000000..65ece7b + if filescounter>10: + portage.util.writemsg(" ... and %d more ...\n" % (len(filenames)-10)) + break -+ # ... and one more check. Making sure that direct build time ++ # ... and one more check. Making sure that direct build time + # dependencies were accessed + #import pdb; pdb.set_trace() + not_accessed_deps=set(self.deps_direct)-set(self.packagesinfo.keys()) @@ -562,7 +559,7 @@ index 0000000..65ece7b + portage.util.writemsg("Warning! Some build time dependencies " + \ + "of packages were not accessed: " + \ + " ".join(not_accessed_deps) + "\n") -+ ++ + def is_package_useful(self,pkg,stages,files): + """ some basic heuristics here to cut part of packages """ + @@ -596,22 +593,19 @@ index 0000000..65ece7b + for f in files: + if is_file_excluded(f): + continue -+ -+ # test 1: package is not useful if all files are *.desktop or *.xml or *.m4 ++ ++ # test 1: package is not useful if all files are *.desktop or *.xml or *.m4 + if not (f.endswith(".desktop") or f.endswith(".xml") or f.endswith(".m4") or f.endswith(".pc")): + break + else: + return False # we get here if cycle ends not with break -+ ++ + return True -+ -+ -\ No newline at end of file -diff --git a/pym/_emerge/EventsLogger.py b/pym/_emerge/EventsLogger.py -new file mode 100644 -index 0000000..68b3c67 ---- /dev/null -+++ b/pym/_emerge/EventsLogger.py ++ ++ +diff -urN /usr/lib/portage/pym/_emerge/EventsLogger.py ./pym/_emerge/EventsLogger.py +--- /usr/lib/portage/pym/_emerge/EventsLogger.py 1970-01-01 05:00:00.000000000 +0500 ++++ ./pym/_emerge/EventsLogger.py 2014-02-17 17:36:42.034349501 +0600 @@ -0,0 +1,180 @@ +# Distributed under the terms of the GNU General Public License v2 + @@ -629,17 +623,17 @@ index 0000000..68b3c67 +class EventsLogger(threading.Thread): + def default_filter(eventname, filename, stage): + return True -+ ++ + def __init__(self, socket_dir="/tmp/", filter_proc=default_filter): + threading.Thread.__init__(self) # init the Thread -+ ++ + self.alive=False -+ ++ + self.main_thread=threading.currentThread() -+ ++ + self.socket_dir=socket_dir + self.filter_proc=filter_proc -+ ++ + self.socket_name=None + self.socket_logger=None + @@ -648,16 +642,16 @@ index 0000000..68b3c67 + try: + socket_dir_name = tempfile.mkdtemp(dir=self.socket_dir, + prefix="log_socket_") -+ ++ + socket_name = os.path.join(socket_dir_name, 'socket') + + except OSError as e: + return -+ ++ + self.socket_name=socket_name -+ ++ + #print(self.socket_name) -+ ++ + try: + socket_logger=socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET) + socket_logger.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) @@ -680,21 +674,21 @@ index 0000000..68b3c67 + stat.S_IROTH|stat.S_IWOTH|stat.S_IXOTH) + except OSError as e: + return -+ ++ + def run(self): + """ Starts the log server """ + + self.alive=True + self.listen_thread=threading.currentThread() + clients={} -+ ++ + epoll=select.epoll() + epoll.register(self.socket_logger.fileno(), select.EPOLLIN) + + while self.alive: + try: + sock_events = epoll.poll(3) -+ ++ + for fileno, sock_event in sock_events: + if fileno == self.socket_logger.fileno(): + ret = self.socket_logger.accept() @@ -707,13 +701,13 @@ index 0000000..68b3c67 + elif sock_event & select.EPOLLIN: + s=clients[fileno] + record=s.recv(8192) -+ ++ + if not record: # if connection was closed + epoll.unregister(fileno) + clients[fileno].close() + del clients[fileno] + continue -+ ++ + #import pdb; pdb.set_trace() + try: + message=record.decode("utf8").split("\0") @@ -724,7 +718,7 @@ index 0000000..68b3c67 + # continue + + #print(message) -+ ++ + try: + if message[4]=="ASKING": + if self.filter_proc(message[1],message[2],message[3]): @@ -738,7 +732,7 @@ index 0000000..68b3c67 + + if not stage in self.events: + self.events[stage]=[{},{}] -+ ++ + hashofsucesses=self.events[stage][0] + hashoffailures=self.events[stage][1] + @@ -748,19 +742,19 @@ index 0000000..68b3c67 + if result=="OK": + if not filename in hashofsucesses: + hashofsucesses[filename]=[False,False] -+ ++ + readed_or_writed=hashofsucesses[filename] -+ ++ + if eventname=="read": + readed_or_writed[0]=True + elif eventname=="write": + readed_or_writed[1]=True -+ ++ + elif result[0:3]=="ERR" or result=="DENIED": + if not filename in hashoffailures: + hashoffailures[filename]=[False,False] + notfound_or_blocked=hashoffailures[filename] -+ ++ + if result=="ERR/2": + notfound_or_blocked[0]=True + elif result=="DENIED": @@ -768,74 +762,122 @@ index 0000000..68b3c67 + + else: + print("Error in logger module<->analyser protocol") -+ ++ + except IndexError: + print("IndexError while parsing %s" % record) + except IOError as e: + if e.errno!=4: # handling "Interrupted system call" errors + raise -+ -+ # if main thread doesnt exists then exit ++ ++ # if main thread doesnt exists then exit + if not self.main_thread.is_alive(): + break + epoll.unregister(self.socket_logger.fileno()) + epoll.close() + self.socket_logger.close() -+ ++ + def stop(self): + """ Stops the log server. Returns all events """ + + self.alive=False -+ ++ + # Block the main thread until listener exists + self.listen_thread.join() -+ ++ + # We assume portage clears tmp folder, so no deleting a socket file + # We assume that no new socket data will arrive after this moment + return self.events -diff --git a/pym/portage/const.py b/pym/portage/const.py -index ecaa8f1..f34398d 100644 ---- a/pym/portage/const.py -+++ b/pym/portage/const.py -@@ -67,6 +67,8 @@ FAKEROOT_BINARY = "/usr/bin/fakeroot" +diff -urN /usr/lib/portage/pym/portage/const.py ./pym/portage/const.py +--- /usr/lib/portage/pym/portage/const.py 2014-01-23 14:09:04.077948503 +0600 ++++ ./pym/portage/const.py 2014-02-17 17:38:12.197345709 +0600 +@@ -72,6 +72,7 @@ BASH_BINARY = "/bin/bash" MOVE_BINARY = "/bin/mv" PRELINK_BINARY = "/usr/sbin/prelink" -+AUTODEP_LIBRARY = "/usr/lib/file_hook.so" -+ ++AUTODEP_LIBRARY = "/usr/lib/file_hook.so" INVALID_ENV_FILE = "/etc/spork/is/not/valid/profile.env" REPO_NAME_FILE = "repo_name" -@@ -88,7 +90,8 @@ EBUILD_PHASES = ("pretend", "setup", "unpack", "prepare", "configure" - SUPPORTED_FEATURES = frozenset([ - "allow-missing-manifests", - "assume-digests", "binpkg-logs", "buildpkg", "buildsyspkg", "candy", -- "ccache", "chflags", "collision-protect", "compress-build-logs", -+ "ccache", "chflags", "collision-protect", "compress-build-logs", -+ "depcheck", "depcheckstrict", - "digest", "distcc", "distcc-pump", "distlocks", "ebuild-locks", "fakeroot", - "fail-clean", "fixpackages", "force-mirror", "getbinpkg", - "installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror", -diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py -index 87aa606..6d42809 100644 ---- a/pym/portage/package/ebuild/_config/special_env_vars.py -+++ b/pym/portage/package/ebuild/_config/special_env_vars.py -@@ -101,8 +101,8 @@ environ_whitelist += [ +@@ -133,6 +134,8 @@ + "compressdebug", + "compress-index", + "config-protect-if-modified", ++ "depcheck", ++ "depcheckstrict", + "digest", + "distcc", + "distcc-pump", +diff -urN /usr/lib/portage/pym/portage/package/ebuild/_config/special_env_vars.py ./pym/portage/package/ebuild/_config/special_env_vars.py +--- /usr/lib/portage/pym/portage/package/ebuild/_config/special_env_vars.py 2014-01-23 14:09:06.463948342 +0600 ++++ ./pym/portage/package/ebuild/_config/special_env_vars.py 2014-02-17 17:40:56.800338787 +0600 +@@ -113,7 +113,7 @@ # other variables inherited from the calling environment environ_whitelist += [ "CVS_RSH", "ECHANGELOG_USER", - "GPG_AGENT_INFO", -- "SSH_AGENT_PID", "SSH_AUTH_SOCK", + "GPG_AGENT_INFO", "LOG_SOCKET", -+ "SSH_AGENT_PID", "SSH_AUTH_SOCK" + "SSH_AGENT_PID", "SSH_AUTH_SOCK", "STY", "WINDOW", "XAUTHORITY", ] +diff -urN /usr/lib/portage/pym/portage/package/ebuild/doebuild.py ./pym/portage/package/ebuild/doebuild.py +--- /usr/lib/portage/pym/portage/package/ebuild/doebuild.py 2014-01-23 14:09:06.183948361 +0600 ++++ ./pym/portage/package/ebuild/doebuild.py 2014-02-17 17:43:25.387332538 +0600 +@@ -66,7 +66,7 @@ + from portage.util import apply_recursive_permissions, \ + apply_secpass_permissions, noiselimit, normalize_path, \ + writemsg, writemsg_stdout, write_atomic +-from portage.util.lafilefixer import rewrite_lafile ++from portage.util.lafilefixer import rewrite_lafile + from portage.versions import _pkgsplit + from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor + from _emerge.EbuildBuildDir import EbuildBuildDir +@@ -492,7 +492,7 @@ + """ + Wrapper function that invokes specific ebuild phases through the spawning + of ebuild.sh +- ++ + @param myebuild: name of the ebuild to invoke the phase on (CPV) + @type myebuild: String + @param mydo: Phase to run +@@ -535,13 +535,13 @@ + @return: + 1. 0 for success + 2. 1 for error +- ++ + Most errors have an accompanying error message. +- ++ + listonly and fetchonly are only really necessary for operations involving 'fetch' + prev_mtimes are only necessary for merge operations. + Other variables may not be strictly required, many have defaults that are set inside of doebuild. +- ++ + """ -diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py -index 49b67ac..c76c1ed 100644 ---- a/pym/portage/package/ebuild/doebuild.py -+++ b/pym/portage/package/ebuild/doebuild.py -@@ -1038,6 +1038,9 @@ def _spawn_actionmap(settings): + if settings is None: +@@ -563,8 +563,8 @@ + if not tree: + writemsg("Warning: tree not specified to doebuild\n") + tree = "porttree" +- +- # chunked out deps for each phase, so that ebuild binary can use it ++ ++ # chunked out deps for each phase, so that ebuild binary can use it + # to collapse targets down. + actionmap_deps={ + "pretend" : [], +@@ -579,7 +579,7 @@ + "package":["install"], + "merge" :["install"], + } +- ++ + if mydbapi is None: + mydbapi = portage.db[myroot][tree].dbapi + +@@ -1306,6 +1306,9 @@ nosandbox = ("sandbox" not in features and \ "usersandbox" not in features) @@ -845,7 +887,7 @@ index 49b67ac..c76c1ed 100644 if not portage.process.sandbox_capable: nosandbox = True -@@ -1215,7 +1218,10 @@ def spawn(mystring, mysettings, debug=0, free=0, droppriv=0, sesandbox=0, fakero +@@ -1551,7 +1554,10 @@ keywords["opt_name"] = "[%s/%s]" % \ (mysettings.get("CATEGORY",""), mysettings.get("PF","")) @@ -857,20 +899,19 @@ index 49b67ac..c76c1ed 100644 keywords["opt_name"] += " bash" spawn_func = portage.process.spawn_bash elif fakeroot: -diff --git a/pym/portage/process.py b/pym/portage/process.py -index 3c15370..6866a2f 100644 ---- a/pym/portage/process.py -+++ b/pym/portage/process.py -@@ -16,7 +16,7 @@ portage.proxy.lazyimport.lazyimport(globals(), - 'portage.util:dump_traceback', +diff -urN /usr/lib/portage/pym/portage/process.py ./pym/portage/process.py +--- /usr/lib/portage/pym/portage/process.py 2014-01-23 14:09:04.079948503 +0600 ++++ ./pym/portage/process.py 2014-02-17 17:45:29.526327317 +0600 +@@ -22,7 +22,7 @@ + 'portage.util:dump_traceback,writemsg', ) -from portage.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY +from portage.const import BASH_BINARY, SANDBOX_BINARY, FAKEROOT_BINARY, AUTODEP_LIBRARY from portage.exception import CommandNotFound + from portage.util._ctypes import find_library, LoadLibrary, ctypes - try: -@@ -39,6 +39,9 @@ else: +@@ -87,13 +87,16 @@ sandbox_capable = (os.path.isfile(SANDBOX_BINARY) and os.access(SANDBOX_BINARY, os.X_OK)) @@ -880,7 +921,15 @@ index 3c15370..6866a2f 100644 fakeroot_capable = (os.path.isfile(FAKEROOT_BINARY) and os.access(FAKEROOT_BINARY, os.X_OK)) -@@ -66,6 +69,16 @@ def spawn_bash(mycommand, debug=False, opt_name=None, **keywords): + def spawn_bash(mycommand, debug=False, opt_name=None, **keywords): + """ + Spawns a bash shell running a specific commands +- ++ + @param mycommand: The command for bash to run + @type mycommand: String + @param debug: Turn bash debugging on (set -x) +@@ -114,6 +117,16 @@ args.append(mycommand) return spawn(args, opt_name=opt_name, **keywords) @@ -892,8 +941,44 @@ index 3c15370..6866a2f 100644 + + # Core part: tell the loader to preload logging library + keywords["env"]["LD_PRELOAD"]=AUTODEP_LIBRARY -+ return spawn_bash(mycommand, opt_name=opt_name, **keywords) ++ return spawn_bash(mycommand, opt_name=opt_name, **keywords) + def spawn_sandbox(mycommand, opt_name=None, **keywords): if not sandbox_capable: return spawn_bash(mycommand, opt_name=opt_name, **keywords) +@@ -199,7 +212,7 @@ + unshare_ipc=False, cgroup=None): + """ + Spawns a given command. +- ++ + @param mycommand: the command to execute + @type mycommand: String or List (Popen style list) + @param env: A dict of Key=Value pairs for env variables +@@ -238,7 +251,7 @@ + + logfile requires stdout and stderr to be assigned to this process (ie not pointed + somewhere else.) +- ++ + """ + + # mycommand is either a str or a list +@@ -387,7 +400,7 @@ + + """ + Execute a given binary with options +- ++ + @param binary: Name of program to execute + @type binary: String + @param mycommand: Options for program +@@ -627,7 +640,7 @@ + def find_binary(binary): + """ + Given a binary name, find the binary in PATH +- ++ + @param binary: Name of the binary to find + @type string + @rtype: None or string diff --git a/portage_with_autodep/bin/archive-conf b/portage_with_autodep/bin/archive-conf index 7978668..2c34588 100755 --- a/portage_with_autodep/bin/archive-conf +++ b/portage_with_autodep/bin/archive-conf @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -12,43 +12,21 @@ from __future__ import print_function import sys -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True + +import portage.dispatch_conf from portage import os -from portage import dispatch_conf +from portage.checksum import perform_md5 FIND_EXTANT_CONTENTS = "find %s -name CONTENTS" MANDATORY_OPTS = [ 'archive-dir' ] -try: - import fchksum - def perform_checksum(filename): return fchksum.fmd5t(filename) -except ImportError: - import md5 - def md5_to_hex(md5sum): - hexform = "" - for ix in range(len(md5sum)): - hexform = hexform + "%02x" % ord(md5sum[ix]) - return hexform.lower() - - def perform_checksum(filename): - f = open(filename, 'rb') - blocksize=32768 - data = f.read(blocksize) - size = 0 - sum = md5.new() - while data: - sum.update(data) - size = size + len(data) - data = f.read(blocksize) - return (md5_to_hex(sum.digest()),size) - def archive_conf(): args = [] content_files = [] @@ -63,19 +41,19 @@ def archive_conf(): md5_match_hash[conf] = '' # Find all the CONTENT files in VDB_PATH. - content_files += os.popen(FIND_EXTANT_CONTENTS % - (os.path.join(portage.settings['EROOT'], portage.VDB_PATH))).readlines() + with os.popen(FIND_EXTANT_CONTENTS % (os.path.join(portage.settings['EROOT'], portage.VDB_PATH))) as f: + content_files += f.readlines() # Search for the saved md5 checksum of all the specified config files # and see if the current file is unmodified or not. try: todo_cnt = len(args) - for file in content_files: - file = file.rstrip() + for filename in content_files: + filename = filename.rstrip() try: - contents = open(file, "r") + contents = open(filename, "r") except IOError as e: - print('archive-conf: Unable to open %s: %s' % (file, e), file=sys.stderr) + print('archive-conf: Unable to open %s: %s' % (filename, e), file=sys.stderr) sys.exit(1) lines = contents.readlines() for line in lines: @@ -84,7 +62,7 @@ def archive_conf(): for conf in args: if items[1] == conf: stored = items[2].lower() - real = perform_checksum(conf)[0].lower() + real = perform_md5(conf).lower() if stored == real: md5_match_hash[conf] = conf todo_cnt -= 1 diff --git a/portage_with_autodep/bin/banned-helper b/portage_with_autodep/bin/banned-helper deleted file mode 100755 index 17ea991..0000000 --- a/portage_with_autodep/bin/banned-helper +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# Copyright 2009 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -die "'${0##*/}' has been banned for EAPI '$EAPI'" -exit 1 diff --git a/portage_with_autodep/bin/bashrc-functions.sh b/portage_with_autodep/bin/bashrc-functions.sh index 4da5585..503b172 100755 --- a/portage_with_autodep/bin/bashrc-functions.sh +++ b/portage_with_autodep/bin/bashrc-functions.sh @@ -1,9 +1,9 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 portageq() { - PYTHONPATH=${PORTAGE_PYM_PATH}${PYTHONPATH:+:}${PYTHONPATH} \ + PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}}\ "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/portageq" "$@" } @@ -23,71 +23,16 @@ register_success_hook() { done } -strip_duplicate_slashes() { +__strip_duplicate_slashes() { if [[ -n $1 ]] ; then local removed=$1 while [[ ${removed} == *//* ]] ; do removed=${removed//\/\///} done - echo ${removed} + echo "${removed}" fi } -# this is a function for removing any directory matching a passed in pattern from -# PATH -remove_path_entry() { - save_IFS - IFS=":" - stripped_path="${PATH}" - while [ -n "$1" ]; do - cur_path="" - for p in ${stripped_path}; do - if [ "${p/${1}}" == "${p}" ]; then - cur_path="${cur_path}:${p}" - fi - done - stripped_path="${cur_path#:*}" - shift - done - restore_IFS - PATH="${stripped_path}" -} - -# Set given variables unless these variable have been already set (e.g. during emerge -# invocation) to values different than values set in make.conf. -set_unless_changed() { - if [[ $# -lt 1 ]]; then - die "${FUNCNAME}() requires at least 1 argument: VARIABLE=VALUE" - fi - - local argument value variable - for argument in "$@"; do - if [[ ${argument} != *=* ]]; then - die "${FUNCNAME}(): Argument '${argument}' has incorrect syntax" - fi - variable="${argument%%=*}" - value="${argument#*=}" - if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then - eval "${variable}=\"\${value}\"" - fi - done -} - -# Unset given variables unless these variable have been set (e.g. during emerge -# invocation) to values different than values set in make.conf. -unset_unless_changed() { - if [[ $# -lt 1 ]]; then - die "${FUNCNAME}() requires at least 1 argument: VARIABLE" - fi - - local variable - for variable in "$@"; do - if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then - unset ${variable} - fi - done -} - KV_major() { [[ -z $1 ]] && return 1 diff --git a/portage_with_autodep/bin/binhost-snapshot b/portage_with_autodep/bin/binhost-snapshot index 9d2697d..376080c 100755 --- a/portage_with_autodep/bin/binhost-snapshot +++ b/portage_with_autodep/bin/binhost-snapshot @@ -1,9 +1,8 @@ #!/usr/bin/python -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import io -import optparse import os import sys import textwrap @@ -13,13 +12,12 @@ try: except ImportError: from urlparse import urlparse -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname( - osp.realpath(__file__))), "pym")) - import portage +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True +from portage.util._argparse import ArgumentParser def parse_args(argv): prog_name = os.path.basename(argv[0]) @@ -47,11 +45,12 @@ def parse_args(argv): "write Packages index with\n" + \ " snapshot_uri" - parser = optparse.OptionParser(usage=usage) - parser.add_option('--hardlinks', help='create hardlinks (y or n, default is y)', - choices=('y', 'n')) - parser.set_defaults(hardlinks='y') - options, args = parser.parse_args(argv[1:]) + parser = ArgumentParser(usage=usage) + parser.add_argument('--hardlinks', + help='create hardlinks (y or n, default is y)', + choices=('y', 'n'), + default='y') + options, args = parser.parse_known_args(argv[1:]) if len(args) != 4: parser.error("Required 4 arguments, got %d" % (len(args),)) diff --git a/portage_with_autodep/bin/chpathtool.py b/portage_with_autodep/bin/chpathtool.py index d0d49cb..0cb5d64 100755 --- a/portage_with_autodep/bin/chpathtool.py +++ b/portage_with_autodep/bin/chpathtool.py @@ -1,15 +1,26 @@ #!/usr/bin/python -# Copyright 2011 Gentoo Foundation +# Copyright 2011-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +"""Helper tool for converting installed files to custom prefixes. + +In other words, eprefixy $D for Gentoo/Prefix.""" + import io -import optparse import os import stat import sys -CONTENT_ENCODING = "utf_8" -FS_ENCODING = "utf_8" +from portage.util._argparse import ArgumentParser + +# Argument parsing compatibility for Python 2.6 using optparse. +if sys.hexversion < 0x2070000: + from optparse import OptionParser + +from optparse import OptionError + +CONTENT_ENCODING = 'utf_8' +FS_ENCODING = 'utf_8' try: import magic @@ -41,7 +52,9 @@ class IsTextFile(object): def _is_text_magic(self, filename): mime_type = self._m.file(filename) - return mime_type.startswith("text/") + if isinstance(mime_type, bytes): + mime_type = mime_type.decode('ascii', 'replace') + return mime_type.startswith('text/') def _is_text_encoding(self, filename): try: @@ -64,7 +77,7 @@ def chpath_inplace(filename, is_text_file, old, new): try: orig_mode = stat.S_IMODE(os.lstat(filename).st_mode) except OSError as e: - sys.stderr.write("%s: %s\n" % (e, filename)) + sys.stderr.write('%s: %s\n' % (e, filename)) return temp_mode = 0o200 | orig_mode os.chmod(filename, temp_mode) @@ -121,8 +134,12 @@ def chpath_inplace(filename, is_text_file, old, new): f.close() if modified: - orig_mtime = orig_stat[stat.ST_MTIME] - os.utime(filename, (orig_mtime, orig_mtime)) + if sys.hexversion >= 0x3030000: + orig_mtime = orig_stat.st_mtime_ns + os.utime(filename, ns=(orig_mtime, orig_mtime)) + else: + orig_mtime = orig_stat[stat.ST_MTIME] + os.utime(filename, (orig_mtime, orig_mtime)) return modified def chpath_inplace_symlink(filename, st, old, new): @@ -135,14 +152,37 @@ def chpath_inplace_symlink(filename, st, old, new): def main(argv): - usage = "%s [options] " % (os.path.basename(argv[0],)) - parser = optparse.OptionParser(usage=usage) - options, args = parser.parse_args(argv[1:]) - - if len(args) != 3: - parser.error("3 args required, got %s" % (len(args),)) - - location, old, new = args + parser = ArgumentParser(description=__doc__) + try: + parser.add_argument('location', default=None, + help='root directory (e.g. $D)') + parser.add_argument('old', default=None, + help='original build prefix (e.g. /)') + parser.add_argument('new', default=None, + help='new install prefix (e.g. $EPREFIX)') + opts = parser.parse_args(argv) + + location, old, new = opts.location, opts.old, opts.new + except OptionError: + # Argument parsing compatibility for Python 2.6 using optparse. + if sys.hexversion < 0x2070000: + parser = OptionParser(description=__doc__, + usage="usage: %prog [-h] location old new\n\n" + \ + " location: root directory (e.g. $D)\n" + \ + " old: original build prefix (e.g. /)\n" + \ + " new: new install prefix (e.g. $EPREFIX)") + + (opts, args) = parser.parse_args() + + if len(args) != 3: + parser.print_usage() + print("%s: error: expected 3 arguments, got %i" + % (__file__, len(args))) + return + + location, old, new = args[0:3] + else: + raise is_text_file = IsTextFile() @@ -178,5 +218,5 @@ def main(argv): return os.EX_OK -if __name__ == "__main__": - sys.exit(main(sys.argv)) +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/portage_with_autodep/bin/clean_locks b/portage_with_autodep/bin/clean_locks index 8c4299c..184e80c 100755 --- a/portage_with_autodep/bin/clean_locks +++ b/portage_with_autodep/bin/clean_locks @@ -1,21 +1,17 @@ #!/usr/bin/python -O -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function import sys, errno -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - -from portage import os +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv: - import portage print() print("You must specify directories with hardlink-locks to clean.") print("You may optionally specify --force, which will remove all") diff --git a/portage_with_autodep/bin/dispatch-conf b/portage_with_autodep/bin/dispatch-conf index 139a001..10455f4 100755 --- a/portage_with_autodep/bin/dispatch-conf +++ b/portage_with_autodep/bin/dispatch-conf @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -16,19 +16,15 @@ from __future__ import print_function from stat import ST_GID, ST_MODE, ST_UID from random import random import atexit, re, shutil, stat, sys - -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True from portage import os -from portage import dispatch_conf from portage import _unicode_decode from portage.dispatch_conf import diffstatusoutput -from portage.process import find_binary +from portage.process import find_binary, spawn FIND_EXTANT_CONFIGS = "find '%s' %s -name '._cfg????_%s' ! -name '.*~' ! -iname '.*.bak' -print" DIFF_CONTENTS = "diff -Nu '%s' '%s'" @@ -83,7 +79,7 @@ class dispatch: confs = [] count = 0 - config_root = portage.const.EPREFIX or os.sep + config_root = portage.settings["EPREFIX"] or os.sep self.options = portage.dispatch_conf.read_config(MANDATORY_OPTS) if "log-file" in self.options: @@ -411,7 +407,8 @@ class dispatch: def do_help (self): - print(); print + print() + print() print(' u -- update current config with new config and continue') print(' z -- zap (delete) new config and continue') @@ -431,7 +428,7 @@ class dispatch: def getch (): # from ASPN - Danny Yoo # - import sys, tty, termios + import tty, termios fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) @@ -456,17 +453,18 @@ def clear_screen(): pass os.system("clear 2>/dev/null") -from portage.process import find_binary, spawn shell = os.environ.get("SHELL") if not shell or not os.access(shell, os.EX_OK): shell = find_binary("sh") def spawn_shell(cmd): if shell: + sys.__stdout__.flush() + sys.__stderr__.flush() spawn([shell, "-c", cmd], env=os.environ, - fd_pipes = { 0 : sys.stdin.fileno(), - 1 : sys.stdout.fileno(), - 2 : sys.stderr.fileno()}) + fd_pipes = { 0 : portage._get_stdin().fileno(), + 1 : sys.__stdout__.fileno(), + 2 : sys.__stderr__.fileno()}) else: os.system(cmd) diff --git a/portage_with_autodep/bin/dohtml.py b/portage_with_autodep/bin/dohtml.py index f0a7f2c..f98557f 100755 --- a/portage_with_autodep/bin/dohtml.py +++ b/portage_with_autodep/bin/dohtml.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -11,18 +11,18 @@ # # # Detailed usage: -# dohtml -# - will install the files in the list of files (space-separated list) into -# /usr/share/doc/${PF}/html, provided the file ends in .htm, .html, .css, -# .js, ,gif, .jpeg, .jpg, or .png. +# dohtml +# - will install the files in the list of files (space-separated list) into +# /usr/share/doc/${PF}/html, provided the file ends in .css, .gif, .htm, +# .html, .jpeg, .jpg, .js or .png. # dohtml -r -# - will do as 'dohtml', but recurse into all directories, as long as the +# - will do as 'dohtml', but recurse into all directories, as long as the # directory name is not CVS # dohtml -A jpe,java [-r] # - will do as 'dohtml' but add .jpe,.java (default filter list is # added to your list) # dohtml -a png,gif,html,htm [-r] -# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter +# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter # list is ignored) # dohtml -x CVS,SCCS,RCS -r # - will do as 'dohtml -r', but ignore directories named CVS, SCCS, RCS @@ -31,13 +31,25 @@ from __future__ import print_function import os +import shutil import sys +from portage.util import normalize_path + +# Change back to original cwd _after_ all imports (bug #469338). +os.chdir(os.environ["__PORTAGE_HELPER_CWD"]) + def dodir(path): - os.spawnlp(os.P_WAIT, "install", "install", "-d", path) + try: + os.makedirs(path, 0o755) + except OSError: + if not os.path.isdir(path): + raise + os.chmod(path, 0o755) def dofile(src,dst): - os.spawnlp(os.P_WAIT, "install", "install", "-m0644", src, dst) + shutil.copy(src, dst) + os.chmod(dst, 0o644) def eqawarn(lines): cmd = "source '%s/isolated-functions.sh' ; " % \ @@ -47,32 +59,43 @@ def eqawarn(lines): os.spawnlp(os.P_WAIT, "bash", "bash", "-c", cmd) skipped_directories = [] +skipped_files = [] +warn_on_skipped_files = os.environ.get("PORTAGE_DOHTML_WARN_ON_SKIPPED_FILES") is not None +unwarned_skipped_extensions = os.environ.get("PORTAGE_DOHTML_UNWARNED_SKIPPED_EXTENSIONS", "").split() +unwarned_skipped_files = os.environ.get("PORTAGE_DOHTML_UNWARNED_SKIPPED_FILES", "").split() def install(basename, dirname, options, prefix=""): fullpath = basename if prefix: - fullpath = prefix + "/" + fullpath + fullpath = os.path.join(prefix, fullpath) if dirname: - fullpath = dirname + "/" + fullpath + fullpath = os.path.join(dirname, fullpath) if options.DOCDESTTREE: - destdir = options.ED + "usr/share/doc/" + options.PF + "/" + options.DOCDESTTREE + "/" + options.doc_prefix + "/" + prefix + desttree = options.DOCDESTTREE else: - destdir = options.ED + "usr/share/doc/" + options.PF + "/html/" + options.doc_prefix + "/" + prefix + desttree = "html" + + destdir = os.path.join(options.ED, "usr", "share", "doc", + options.PF.lstrip(os.sep), desttree.lstrip(os.sep), + options.doc_prefix.lstrip(os.sep), prefix).rstrip(os.sep) if not os.path.exists(fullpath): sys.stderr.write("!!! dohtml: %s does not exist\n" % fullpath) return False elif os.path.isfile(fullpath): - ext = os.path.splitext(basename)[1] - if (len(ext) and ext[1:] in options.allowed_exts) or basename in options.allowed_files: + ext = os.path.splitext(basename)[1][1:] + if ext in options.allowed_exts or basename in options.allowed_files: dodir(destdir) - dofile(fullpath, destdir + "/" + basename) + dofile(fullpath, os.path.join(destdir, basename)) + elif warn_on_skipped_files and ext not in unwarned_skipped_extensions and basename not in unwarned_skipped_files: + skipped_files.append(fullpath) elif options.recurse and os.path.isdir(fullpath) and \ basename not in options.disallowed_dirs: for i in os.listdir(fullpath): pfx = basename - if prefix: pfx = prefix + "/" + pfx + if prefix: + pfx = os.path.join(prefix, pfx) install(i, dirname, options, pfx) elif not options.recurse and os.path.isdir(fullpath): global skipped_directories @@ -88,21 +111,28 @@ class OptionsClass: self.PF = "" self.ED = "" self.DOCDESTTREE = "" - + if "PF" in os.environ: self.PF = os.environ["PF"] + if self.PF: + self.PF = normalize_path(self.PF) if "force-prefix" not in os.environ.get("FEATURES", "").split() and \ os.environ.get("EAPI", "0") in ("0", "1", "2"): self.ED = os.environ.get("D", "") else: self.ED = os.environ.get("ED", "") + if self.ED: + self.ED = normalize_path(self.ED) if "_E_DOCDESTTREE_" in os.environ: self.DOCDESTTREE = os.environ["_E_DOCDESTTREE_"] - - self.allowed_exts = [ 'htm', 'html', 'css', 'js', - 'gif', 'jpeg', 'jpg', 'png' ] + if self.DOCDESTTREE: + self.DOCDESTTREE = normalize_path(self.DOCDESTTREE) + + self.allowed_exts = ['css', 'gif', 'htm', 'html', 'jpeg', 'jpg', 'js', 'png'] + if os.environ.get("EAPI", "0") in ("4-python", "5-progress"): + self.allowed_exts += ['ico', 'svg', 'xhtml', 'xml'] self.allowed_files = [] - self.disallowed_dirs = [ 'CVS' ] + self.disallowed_dirs = ['CVS'] self.recurse = False self.verbose = False self.doc_prefix = "" @@ -127,7 +157,7 @@ def print_help(): def parse_args(): options = OptionsClass() args = [] - + x = 1 while x < len(sys.argv): arg = sys.argv[x] @@ -146,6 +176,8 @@ def parse_args(): sys.exit(0) elif arg == "-p": options.doc_prefix = sys.argv[x] + if options.doc_prefix: + options.doc_prefix = normalize_path(options.doc_prefix) else: values = sys.argv[x].split(",") if arg == "-A": @@ -159,7 +191,7 @@ def parse_args(): else: args.append(sys.argv[x]) x += 1 - + return (options, args) def main(): @@ -168,20 +200,29 @@ def main(): if options.verbose: print("Allowed extensions:", options.allowed_exts) - print("Document prefix : '" + options.doc_prefix + "'") + print("Document prefix : '" + options.doc_prefix + "'") print("Allowed files :", options.allowed_files) success = False - + endswith_slash = (os.sep, os.sep + ".") + for x in args: + trailing_slash = x.endswith(endswith_slash) + x = normalize_path(x) + if trailing_slash: + # Modify behavior of basename and dirname + # as noted in bug #425214, causing foo/ to + # behave similarly to the way that foo/* + # behaves. + x += os.sep basename = os.path.basename(x) dirname = os.path.dirname(x) success |= install(basename, dirname, options) - global skipped_directories for x in skipped_directories: - eqawarn(["QA Notice: dohtml on directory " + \ - "'%s' without recursion option" % x]) + eqawarn(["QA Notice: dohtml on directory '%s' without recursion option" % x]) + for x in skipped_files: + eqawarn(["dohtml: skipped file '%s'" % x]) if success: retcode = 0 diff --git a/portage_with_autodep/bin/ebuild b/portage_with_autodep/bin/ebuild index 35cdc14..262dab6 100755 --- a/portage_with_autodep/bin/ebuild +++ b/portage_with_autodep/bin/ebuild @@ -1,15 +1,16 @@ #!/usr/bin/python -O -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function +import platform import signal import sys # This block ensures that ^C interrupts are handled quietly. try: - def exithandler(signum,frame): + def exithandler(signum, _frame): signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) sys.exit(128 + signum) @@ -23,56 +24,61 @@ try: except KeyboardInterrupt: sys.exit(128 + signal.SIGINT) -def debug_signal(signum, frame): +def debug_signal(_signum, _frame): import pdb pdb.set_trace() -signal.signal(signal.SIGUSR1, debug_signal) -import imp +if platform.python_implementation() == 'Jython': + debug_signum = signal.SIGUSR2 # bug #424259 +else: + debug_signum = signal.SIGUSR1 + +signal.signal(debug_signum, debug_signal) + import io -import optparse import os +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True +from portage import os +from portage import _encodings +from portage import _shell_quote +from portage import _unicode_decode +from portage import _unicode_encode +from portage.const import VDB_PATH +from portage.util._argparse import ArgumentParser +from _emerge.Package import Package +from _emerge.RootConfig import RootConfig description = "See the ebuild(1) man page for more info" usage = "Usage: ebuild [command] ..." -parser = optparse.OptionParser(description=description, usage=usage) +parser = ArgumentParser(description=description, usage=usage) force_help = "When used together with the digest or manifest " + \ "command, this option forces regeneration of digests for all " + \ "distfiles associated with the current ebuild. Any distfiles " + \ "that do not already exist in ${DISTDIR} will be automatically fetched." -parser.add_option("--force", help=force_help, action="store_true", dest="force") -parser.add_option("--color", help="enable or disable color output", - type="choice", choices=("y", "n")) -parser.add_option("--debug", help="show debug output", - action="store_true", dest="debug") -parser.add_option("--version", help="show version and exit", - action="store_true", dest="version") -parser.add_option("--ignore-default-opts", +parser.add_argument("--force", help=force_help, action="store_true") +parser.add_argument("--color", help="enable or disable color output", + choices=("y", "n")) +parser.add_argument("--debug", help="show debug output", + action="store_true") +parser.add_argument("--version", help="show version and exit", + action="store_true") +parser.add_argument("--ignore-default-opts", action="store_true", help="do not use the EBUILD_DEFAULT_OPTS environment variable") -parser.add_option("--skip-manifest", help="skip all manifest checks", - action="store_true", dest="skip_manifest") - -opts, pargs = parser.parse_args(args=sys.argv[1:]) +parser.add_argument("--skip-manifest", help="skip all manifest checks", + action="store_true") -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage +opts, pargs = parser.parse_known_args(args=sys.argv[1:]) -portage.dep._internal_warnings = True -from portage import os -from portage import _encodings -from portage import _shell_quote -from portage import _unicode_decode -from portage import _unicode_encode -from portage.const import VDB_PATH -from _emerge.Package import Package -from _emerge.RootConfig import RootConfig +def err(txt): + portage.writemsg('ebuild: %s\n' % (txt,), noiselevel=-1) + sys.exit(1) if opts.version: print("Portage", portage.VERSION) @@ -82,8 +88,9 @@ if len(pargs) < 2: parser.error("missing required args") if not opts.ignore_default_opts: - default_opts = portage.settings.get("EBUILD_DEFAULT_OPTS", "").split() - opts, pargs = parser.parse_args(default_opts + sys.argv[1:]) + default_opts = portage.util.shlex_split( + portage.settings.get("EBUILD_DEFAULT_OPTS", "")) + opts, pargs = parser.parse_known_args(default_opts + sys.argv[1:]) debug = opts.debug force = opts.force @@ -112,9 +119,7 @@ if ebuild.endswith(".ebuild"): pf = os.path.basename(ebuild)[:-7] if pf is None: - portage.writemsg("'%s' does not end with '.ebuild'.\n" % \ - (ebuild,), noiselevel=-1) - sys.exit(1) + err("%s: does not end with '.ebuild'" % (ebuild,)) if not os.path.isabs(ebuild): mycwd = os.getcwd() @@ -153,15 +158,14 @@ if ebuild_portdir != vdb_path and \ encoding=_encodings['content'], errors='strict') print("Appending %s to PORTDIR_OVERLAY..." % ebuild_portdir) - imp.reload(portage) + portage._reset_legacy_globals() myrepo = None if ebuild_portdir != vdb_path: myrepo = portage.portdb.getRepositoryName(ebuild_portdir) if not os.path.exists(ebuild): - print("'%s' does not exist." % ebuild) - sys.exit(1) + err('%s: does not exist' % (ebuild,)) ebuild_split = ebuild.split("/") cpv = "%s/%s" % (ebuild_split[-3], pf) @@ -172,8 +176,7 @@ with io.open(_unicode_encode(ebuild, encoding=_encodings['fs'], errors='strict') if eapi is None: eapi = "0" if not portage.catpkgsplit(cpv, eapi=eapi): - print("!!! %s does not follow correct package syntax." % (cpv)) - sys.exit(1) + err('%s: %s: does not follow correct package syntax' % (ebuild, cpv)) if ebuild.startswith(vdb_path): mytree = "vartree" @@ -182,8 +185,7 @@ if ebuild.startswith(vdb_path): portage_ebuild = portage.db[portage.root][mytree].dbapi.findname(cpv, myrepo=myrepo) if os.path.realpath(portage_ebuild) != ebuild: - print("!!! Portage seems to think that %s is at %s" % (cpv, portage_ebuild)) - sys.exit(1) + err('Portage seems to think that %s is at %s' % (cpv, portage_ebuild)) else: mytree = "porttree" @@ -192,12 +194,10 @@ else: portage_ebuild = portage.portdb.findname(cpv, myrepo=myrepo) if not portage_ebuild or portage_ebuild != ebuild: - print("!!! %s does not seem to have a valid PORTDIR structure." % ebuild) - sys.exit(1) + err('%s: does not seem to have a valid PORTDIR structure' % (ebuild,)) if len(pargs) > 1 and "config" in pargs: - print("config must be called on it's own, not combined with any other phase") - sys.exit(1) + err('"config" must not be called with any other phase') def discard_digests(myebuild, mysettings, mydbapi): """Discard all distfiles digests for the given ebuild. This is useful when @@ -306,14 +306,16 @@ def stale_env_warning(): if ebuild_changed: open(os.path.join(tmpsettings['PORTAGE_BUILDDIR'], - '.ebuild_changed'), 'w') + '.ebuild_changed'), 'w').close() from portage.exception import PermissionDenied, \ PortagePackageException, UnsupportedAPIException -if 'digest' in tmpsettings.features and \ - not set(["digest", "manifest"]).intersection(pargs): - pargs = ['digest'] + pargs +if 'digest' in tmpsettings.features: + if pargs and pargs[0] not in ("digest", "manifest"): + pargs = ['digest'] + pargs + # We only need to build digests on the first pass. + tmpsettings.features.discard('digest') checked_for_stale_env = False @@ -327,7 +329,7 @@ for arg in pargs: if arg in ("digest", "manifest") and force: discard_digests(ebuild, tmpsettings, portage.portdb) - a = portage.doebuild(ebuild, arg, portage.root, tmpsettings, + a = portage.doebuild(ebuild, arg, settings=tmpsettings, debug=debug, tree=mytree, vartree=portage.db[portage.root]['vartree']) except KeyboardInterrupt: diff --git a/portage_with_autodep/bin/ebuild-helpers/4/dodoc b/portage_with_autodep/bin/ebuild-helpers/4/dodoc deleted file mode 120000 index 35080ad..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/dodoc +++ /dev/null @@ -1 +0,0 @@ -../doins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/4/dohard b/portage_with_autodep/bin/ebuild-helpers/4/dohard deleted file mode 120000 index 1a6b57a..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/dohard +++ /dev/null @@ -1 +0,0 @@ -../../banned-helper \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/4/dosed b/portage_with_autodep/bin/ebuild-helpers/4/dosed deleted file mode 120000 index 1a6b57a..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/dosed +++ /dev/null @@ -1 +0,0 @@ -../../banned-helper \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/4/prepalldocs b/portage_with_autodep/bin/ebuild-helpers/4/prepalldocs deleted file mode 120000 index 1a6b57a..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/prepalldocs +++ /dev/null @@ -1 +0,0 @@ -../../banned-helper \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/dobin b/portage_with_autodep/bin/ebuild-helpers/dobin index f90d893..0ba1eb0 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dobin +++ b/portage_with_autodep/bin/ebuild-helpers/dobin @@ -1,19 +1,20 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}${DESTTREE}/bin ]] ; then - install -d "${ED}${DESTTREE}/bin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; } + install -d "${ED}${DESTTREE}/bin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; } fi ret=0 @@ -28,5 +29,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/doconfd b/portage_with_autodep/bin/ebuild-helpers/doconfd index e146000..a3c09a5 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doconfd +++ b/portage_with_autodep/bin/ebuild-helpers/doconfd @@ -4,7 +4,7 @@ if [[ $# -lt 1 ]] ; then source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi diff --git a/portage_with_autodep/bin/ebuild-helpers/dodir b/portage_with_autodep/bin/ebuild-helpers/dodir index 90a3efe..e03ba9a 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dodir +++ b/portage_with_autodep/bin/ebuild-helpers/dodir @@ -1,13 +1,14 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi install -d ${DIROPTIONS} "${@/#/${ED}/}" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/dodoc b/portage_with_autodep/bin/ebuild-helpers/dodoc index 1f333a6..99122c4 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dodoc +++ b/portage_with_autodep/bin/ebuild-helpers/dodoc @@ -1,16 +1,24 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +if ___eapi_dodoc_supports_-r; then + exec \ + env \ + __PORTAGE_HELPER="dodoc" \ + doins "$@" +fi + if [ $# -lt 1 ] ; then - helpers_die "${0##*/}: at least one argument needed" - exit 1 + __helpers_die "${0##*/}: at least one argument needed" + exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi dir="${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" if [ ! -d "${dir}" ] ; then @@ -30,5 +38,5 @@ for x in "$@" ; do fi done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/doenvd b/portage_with_autodep/bin/ebuild-helpers/doenvd index 28ab5d2..9287933 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doenvd +++ b/portage_with_autodep/bin/ebuild-helpers/doenvd @@ -4,7 +4,7 @@ if [[ $# -lt 1 ]] ; then source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi diff --git a/portage_with_autodep/bin/ebuild-helpers/doexe b/portage_with_autodep/bin/ebuild-helpers/doexe index fb228f9..c34fcae 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doexe +++ b/portage_with_autodep/bin/ebuild-helpers/doexe @@ -1,23 +1,23 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}${_E_EXEDESTTREE_} ]] ; then install -d "${ED}${_E_EXEDESTTREE_}" fi -TMP=$T/.doexe_tmp -mkdir "$TMP" +TMP=$(mktemp -d "${T}/.doexe_tmp_XXXXXX") ret=0 @@ -26,7 +26,7 @@ for x in "$@" ; do cp "$x" "$TMP" mysrc=$TMP/${x##*/} elif [ -d "${x}" ] ; then - vecho "doexe: warning, skipping directory ${x}" + __vecho "doexe: warning, skipping directory ${x}" continue else mysrc="${x}" @@ -42,5 +42,5 @@ done rm -rf "$TMP" -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/dohard b/portage_with_autodep/bin/ebuild-helpers/dohard index b52fd7c..e0a44fa 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dohard +++ b/portage_with_autodep/bin/ebuild-helpers/dohard @@ -1,14 +1,22 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +if ! ___eapi_has_dohard; then + die "'${0##*/}' has been banned for EAPI '$EAPI'" + exit 1 +fi + if [[ $# -ne 2 ]] ; then echo "$0: two arguments needed" 1>&2 exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi destdir=${2%/*} [[ ! -d ${ED}${destdir} ]] && dodir "${destdir}" diff --git a/portage_with_autodep/bin/ebuild-helpers/dohtml b/portage_with_autodep/bin/ebuild-helpers/dohtml index 630629a..75d3d00 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dohtml +++ b/portage_with_autodep/bin/ebuild-helpers/dohtml @@ -1,14 +1,19 @@ #!/bin/bash -# Copyright 2009-2010 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ +# Use safe cwd, avoiding unsafe import for bug #469338. +export __PORTAGE_HELPER_CWD=${PWD} +cd "${PORTAGE_PYM_PATH}" +PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/dohtml.py" "$@" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +# Restore cwd for display by __helpers_die +cd "${__PORTAGE_HELPER_CWD}" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/doinfo b/portage_with_autodep/bin/ebuild-helpers/doinfo index 8fd7d45..2edbdc5 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doinfo +++ b/portage_with_autodep/bin/ebuild-helpers/doinfo @@ -1,19 +1,20 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ -z $1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" - exit 1 + __helpers_die "${0##*/}: at least one argument needed" + exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}usr/share/info ]] ; then - install -d "${ED}usr/share/info" || { helpers_die "${0##*/}: failed to install ${ED}usr/share/info"; exit 1; } + install -d "${ED}usr/share/info" || { __helpers_die "${0##*/}: failed to install ${ED}usr/share/info"; exit 1; } fi install -m0644 "$@" "${ED}usr/share/info" @@ -22,6 +23,6 @@ if [ $rval -ne 0 ] ; then for x in "$@" ; do [ -e "$x" ] || echo "!!! ${0##*/}: $x does not exist" 1>&2 done - helpers_die "${0##*/} failed" + __helpers_die "${0##*/} failed" fi exit $rval diff --git a/portage_with_autodep/bin/ebuild-helpers/doinitd b/portage_with_autodep/bin/ebuild-helpers/doinitd index b711e19..476b858 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doinitd +++ b/portage_with_autodep/bin/ebuild-helpers/doinitd @@ -4,7 +4,7 @@ if [[ $# -lt 1 ]] ; then source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi diff --git a/portage_with_autodep/bin/ebuild-helpers/doins b/portage_with_autodep/bin/ebuild-helpers/doins index 443bfdb..c60e057 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doins +++ b/portage_with_autodep/bin/ebuild-helpers/doins @@ -1,14 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -if [[ ${0##*/} == dodoc ]] ; then +helper=${__PORTAGE_HELPER:-${0##*/}} + +if [[ ${helper} == dodoc ]] ; then if [ $# -eq 0 ] ; then # default_src_install may call dodoc with no arguments # when DOC is defined but empty, so simply return # sucessfully in this case. + eqawarn "QA Notice: dodoc called with no arguments" exit 0 fi export INSOPTIONS=-m0644 @@ -16,7 +19,7 @@ if [[ ${0##*/} == dodoc ]] ; then fi if [ $# -lt 1 ] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${helper}: at least one argument needed" exit 1 fi @@ -27,28 +30,26 @@ else DOINSRECUR=n fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) export ED="${D}" ;; esac +if ! ___eapi_has_prefix_variables; then + export ED="${D}" +fi if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then - vecho "-------------------------------------------------------" 1>&2 - vecho "You should not use \${D} or \${ED} with helpers." 1>&2 - vecho " --> ${INSDESTTREE}" 1>&2 - vecho "-------------------------------------------------------" 1>&2 - helpers_die "${0##*/} used with \${D} or \${ED}" + __vecho "-------------------------------------------------------" 1>&2 + __vecho "You should not use \${D} or \${ED} with helpers." 1>&2 + __vecho " --> ${INSDESTTREE}" 1>&2 + __vecho "-------------------------------------------------------" 1>&2 + __helpers_die "${helper} used with \${D} or \${ED}" exit 1 fi -case "$EAPI" in - 0|1|2|3|3_pre2) - PRESERVE_SYMLINKS=n - ;; - *) - PRESERVE_SYMLINKS=y - ;; -esac +if ___eapi_doins_and_newins_preserve_symlinks; then + PRESERVE_SYMLINKS=y +else + PRESERVE_SYMLINKS=n +fi -export TMP=$T/.doins_tmp +export TMP=$(mktemp -d "${T}/.doins_tmp_XXXXXX") # Use separate directories to avoid potential name collisions. mkdir -p "$TMP"/{1,2} @@ -79,7 +80,7 @@ _doins() { install ${INSOPTIONS} "${mysrc}" "${ED}${INSDESTTREE}/${mydir}" rval=$? [[ -n ${cleanup} ]] && rm -f "${cleanup}" - [ $rval -ne 0 ] && echo "!!! ${0##*/}: $mysrc does not exist" 1>&2 + [ $rval -ne 0 ] && echo "!!! ${helper}: $mysrc does not exist" 1>&2 return $rval } @@ -99,8 +100,8 @@ for x in "$@" ; do if [[ $PRESERVE_SYMLINKS = n && -d $x ]] || \ [[ $PRESERVE_SYMLINKS = y && -d $x && ! -L $x ]] ; then if [ "${DOINSRECUR}" == "n" ] ; then - if [[ ${0##*/} == dodoc ]] ; then - echo "!!! ${0##*/}: $x is a directory" 1>&2 + if [[ ${helper} == dodoc ]] ; then + echo "!!! ${helper}: $x is a directory" 1>&2 ((failed|=1)) fi continue @@ -155,4 +156,4 @@ for x in "$@" ; do fi done rm -rf "$TMP" -[[ $failed -ne 0 || $success -eq 0 ]] && { helpers_die "${0##*/} failed"; exit 1; } || exit 0 +[[ $failed -ne 0 || $success -eq 0 ]] && { __helpers_die "${helper} failed"; exit 1; } || exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/dolib b/portage_with_autodep/bin/ebuild-helpers/dolib index 9af5418..fd92d7f 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dolib +++ b/portage_with_autodep/bin/ebuild-helpers/dolib @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi # Setup ABI cruft LIBDIR_VAR="LIBDIR_${ABI}" @@ -19,11 +20,11 @@ libdir="${ED}${DESTTREE}/${CONF_LIBDIR}" if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi if [[ ! -d ${libdir} ]] ; then - install -d "${libdir}" || { helpers_die "${0##*/}: failed to install ${libdir}"; exit 1; } + install -d "${libdir}" || { __helpers_die "${0##*/}: failed to install ${libdir}"; exit 1; } fi ret=0 @@ -42,5 +43,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/doman b/portage_with_autodep/bin/ebuild-helpers/doman index b4047ce..d680859 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doman +++ b/portage_with_autodep/bin/ebuild-helpers/doman @@ -1,16 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi i18n="" @@ -58,10 +59,10 @@ for x in "$@" ; do ((ret|=1)) fi else - vecho "doman: '${x}' is probably not a man page; skipping" 1>&2 + __vecho "doman: '${x}' is probably not a man page; skipping" 1>&2 ((ret|=1)) fi done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/domo b/portage_with_autodep/bin/ebuild-helpers/domo index d994343..9a8dda3 100755 --- a/portage_with_autodep/bin/ebuild-helpers/domo +++ b/portage_with_autodep/bin/ebuild-helpers/domo @@ -1,17 +1,18 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh mynum=${#} if [ ${mynum} -lt 1 ] ; then - helpers_die "${0}: at least one argument needed" + __helpers_die "${0}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [ ! -d "${ED}${DESTTREE}/share/locale" ] ; then install -d "${ED}${DESTTREE}/share/locale/" @@ -34,5 +35,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/dosbin b/portage_with_autodep/bin/ebuild-helpers/dosbin index d101c8a..361ca83 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dosbin +++ b/portage_with_autodep/bin/ebuild-helpers/dosbin @@ -1,19 +1,20 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}${DESTTREE}/sbin ]] ; then - install -d "${ED}${DESTTREE}/sbin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; } + install -d "${ED}${DESTTREE}/sbin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; } fi ret=0 @@ -28,5 +29,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/dosed b/portage_with_autodep/bin/ebuild-helpers/dosed index f202df7..7db0629 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dosed +++ b/portage_with_autodep/bin/ebuild-helpers/dosed @@ -1,14 +1,22 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +if ! ___eapi_has_dosed; then + die "'${0##*/}' has been banned for EAPI '$EAPI'" + exit 1 +fi + if [[ $# -lt 1 ]] ; then echo "!!! ${0##*/}: at least one argument needed" >&2 exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi ret=0 file_found=0 diff --git a/portage_with_autodep/bin/ebuild-helpers/dosym b/portage_with_autodep/bin/ebuild-helpers/dosym index 2489e22..649b100 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dosym +++ b/portage_with_autodep/bin/ebuild-helpers/dosym @@ -5,12 +5,13 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -ne 2 ]] ; then - helpers_die "${0##*/}: two arguments needed" + __helpers_die "${0##*/}: two arguments needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ${2} == */ ]] || \ [[ -d ${ED}${2} && ! -L ${ED}${2} ]] ; then @@ -26,5 +27,5 @@ target="${1}" ln -snf "${target}" "${ED}${2}" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/ecompress b/portage_with_autodep/bin/ebuild-helpers/ecompress index b61421b..71287b4 100755 --- a/portage_with_autodep/bin/ebuild-helpers/ecompress +++ b/portage_with_autodep/bin/ebuild-helpers/ecompress @@ -5,7 +5,7 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ -z $1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi @@ -68,7 +68,7 @@ decompress_args() { case $1 in --suffix) - [[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --suffix takes no additional arguments" 1>&2 if [[ ! -e ${T}/.ecompress.suffix ]] ; then set -e @@ -93,7 +93,7 @@ case $1 in cat "${T}/.ecompress.suffix" ;; --bin) - [[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --bin takes no additional arguments" 1>&2 echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}" ;; @@ -104,18 +104,18 @@ case $1 in >> "$x" ((ret|=$?)) done - [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" + [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret ;; --dequeue) - [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 find "${D}" -name '*.ecompress.file' -print0 \ | sed -e 's:\.ecompress\.file::g' \ | ${XARGS} -0 ecompress find "${D}" -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f ;; --*) - helpers_die "${0##*/}: unknown arguments '$*'" + __helpers_die "${0##*/}: unknown arguments '$*'" exit 1 ;; *) @@ -155,7 +155,7 @@ case $1 in # Finally, let's actually do some real work "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@" ret=$? - [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" + [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret ;; esac diff --git a/portage_with_autodep/bin/ebuild-helpers/ecompressdir b/portage_with_autodep/bin/ebuild-helpers/ecompressdir index a2c9e52..eca5888 100755 --- a/portage_with_autodep/bin/ebuild-helpers/ecompressdir +++ b/portage_with_autodep/bin/ebuild-helpers/ecompressdir @@ -1,18 +1,21 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh if [[ -z $1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} EPREFIX= ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} EPREFIX= +fi -case $1 in +SIZE_LIMIT='' +while [[ $# -gt 0 ]] ; do + case $1 in --ignore) shift for skip in "$@" ; do @@ -27,45 +30,66 @@ case $1 in set -- "${@/#/${ED}}" ret=0 for x in "$@" ; do - >> "$x" + # Stash the limit in the .dir file so we can reload it later. + printf "${SIZE_LIMIT}" > "${x}" ((ret|=$?)) done - [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" + [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret ;; --dequeue) - [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 find "${ED}" -name '*.ecompress.dir' -print0 \ | sed -e 's:\.ecompress\.dir::g' -e "s:${ED}:/:g" \ | ${XARGS} -0 ecompressdir find "${ED}" -name '*.ecompress.skip' -print0 | ${XARGS} -0 rm -f exit 0 ;; + --limit) + SIZE_LIMIT=$2 + shift + ;; --*) - helpers_die "${0##*/}: unknown arguments '$*'" + __helpers_die "${0##*/}: unknown arguments '$*'" exit 1 ;; -esac + *) + break + ;; + esac + shift +done # figure out the new suffix suffix=$(ecompress --suffix) -# funk_up_dir(action, suffix, binary) +# funk_up_dir(action, suffix, binary, [size_limit]) # - action: compress or decompress # - suffix: the compression suffix to work with # - binary: the program to execute that'll compress/decompress +# - size_limit: if compressing, skip files smaller than this # The directory we act on is implied in the ${dir} variable funk_up_dir() { - local act=$1 suffix=$2 binary=$3 + local act=$1 suffix=$2 binary=$3 size_limit=$4 local negate="" [[ ${act} == "compress" ]] && negate="!" + local ret=0 # first we act on all the files - find "${dir}" -type f ${negate} -iname '*'${suffix} -print0 | ${XARGS} -0 ${binary} + local args=( + -type f + ${negate} -iname "*${suffix}" + ) + [[ -n ${size_limit} ]] && args+=( -size "+${size_limit}c" ) + find "${dir}" "${args[@]}" -print0 | ${XARGS} -0 ${binary} ((ret|=$?)) - find "${dir}" -type l -print0 | \ + # Repeat until nothing changes, in order to handle multiple + # levels of indirection (see bug #470916). + local -i indirection=0 + while true ; do + local something_changed= while read -r -d $'\0' brokenlink ; do [[ -e ${brokenlink} ]] && continue olddest=$(readlink "${brokenlink}") @@ -80,15 +104,34 @@ funk_up_dir() { skip_dir_dest=${T}/ecompress-skip/${actual_dir#${ED}}/${brokenlink%/*}/${olddest} fi [[ -e ${skip_dir_dest} ]] && continue - [[ ${act} == "compress" ]] \ - && newdest="${olddest}${suffix}" \ - || newdest="${olddest%${suffix}}" + if [[ ${act} == "compress" ]] ; then + newdest=${olddest}${suffix} + else + [[ ${olddest} == *${suffix} ]] || continue + newdest=${olddest%${suffix}} + fi + if [[ "${newdest}" == /* ]] ; then + [[ -f "${D}${newdest}" ]] || continue + else + [[ -f "${dir}/${brokenlink%/*}/${newdest}" ]] || continue + fi + something_changed=${brokenlink} rm -f "${brokenlink}" [[ ${act} == "compress" ]] \ && ln -snf "${newdest}" "${brokenlink}${suffix}" \ || ln -snf "${newdest}" "${brokenlink%${suffix}}" ((ret|=$?)) + done < <(find "${dir}" -type l -print0) + [[ -n ${something_changed} ]] || break + (( indirection++ )) + if (( indirection >= 100 )) ; then + # Protect against possibility of a bug triggering an endless loop. + eerror "ecompressdir: too many levels of indirection for" \ + "'${actual_dir#${ED}}/${something_changed#./}'" + break + fi done + return ${ret} } # _relocate_skip_dirs(srctree, dsttree) @@ -124,13 +167,13 @@ decompressors=( ".lzma" "unxz -f" ) -multijob_init +__multijob_init for dir in "$@" ; do dir=${dir#/} dir="${ED}${dir}" if [[ ! -d ${dir} ]] ; then - vecho "${0##*/}: /${dir#${ED}} does not exist!" + __vecho "${0##*/}: /${dir#${ED}} does not exist!" continue fi cd "${dir}" @@ -142,39 +185,41 @@ for dir in "$@" ; do # since we've been requested to compress the whole dir, # delete any individual queued requests + size_limit=${SIZE_LIMIT:-$(<"${actual_dir}.ecompress.dir")} rm -f "${actual_dir}.ecompress.dir" find "${dir}" -type f -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f # not uncommon for packages to compress doc files themselves - for (( d = 0; d < ${#decompressors[@]}; d += 2 )) ; do + for (( i = 0; i < ${#decompressors[@]}; i += 2 )) ; do # It's faster to parallelize at this stage than to try to # parallelize the compressors. This is because the find|xargs # ends up launching less compressors overall, so the overhead # of forking children ends up dominating. ( - multijob_child_init + __multijob_child_init funk_up_dir "decompress" "${decompressors[i]}" "${decompressors[i+1]}" ) & - multijob_post_fork + __multijob_post_fork : $(( ret |= $? )) done + __multijob_finish + : $(( ret |= $? )) + # forcibly break all hard links as some compressors whine about it find "${dir}" -type f -links +1 -exec env file="{}" sh -c \ 'cp -p "${file}" "${file}.ecompress.break" ; mv -f "${file}.ecompress.break" "${file}"' \; - multijob_finish - : $(( ret |= $? )) - # now lets do our work if [[ -n ${suffix} ]] ; then - vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${ED}}" - funk_up_dir "compress" "${suffix}" "ecompress" + __vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${ED}}" + funk_up_dir "compress" "${suffix}" "ecompress" "${size_limit}" + : $(( ret |= $? )) fi # finally, restore the skipped stuff restore_skip_dirs done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/emake b/portage_with_autodep/bin/ebuild-helpers/emake index d842781..69d836f 100755 --- a/portage_with_autodep/bin/ebuild-helpers/emake +++ b/portage_with_autodep/bin/ebuild-helpers/emake @@ -24,5 +24,5 @@ fi ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/fowners b/portage_with_autodep/bin/ebuild-helpers/fowners index a213c9e..cee4108 100755 --- a/portage_with_autodep/bin/ebuild-helpers/fowners +++ b/portage_with_autodep/bin/ebuild-helpers/fowners @@ -4,8 +4,9 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) EPREFIX= ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + EPREFIX= ED=${D} +fi # we can't prefix all arguments because # chown takes random options @@ -13,10 +14,5 @@ slash="/" chown "${@/#${slash}/${ED}${slash}}" ret=$? -if [[ ${ret} != 0 && -n ${EPREFIX} && ${EUID} != 0 ]] ; then - ewarn "fowners failure ignored in Prefix with non-privileged user" - exit 0 -fi - -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/fperms b/portage_with_autodep/bin/ebuild-helpers/fperms index a2f77ea..d854ebb 100755 --- a/portage_with_autodep/bin/ebuild-helpers/fperms +++ b/portage_with_autodep/bin/ebuild-helpers/fperms @@ -1,16 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi # we can't prefix all arguments because # chmod takes random options slash="/" chmod "${@/#${slash}/${ED}${slash}}" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/newbin b/portage_with_autodep/bin/ebuild-helpers/newbin deleted file mode 100755 index bf98744..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newbin +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dobin "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newbin b/portage_with_autodep/bin/ebuild-helpers/newbin new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newbin @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newconfd b/portage_with_autodep/bin/ebuild-helpers/newconfd deleted file mode 100755 index fa3710d..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newconfd +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doconfd "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newconfd b/portage_with_autodep/bin/ebuild-helpers/newconfd new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newconfd @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newdoc b/portage_with_autodep/bin/ebuild-helpers/newdoc deleted file mode 100755 index df6fb1d..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newdoc +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dodoc "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newdoc b/portage_with_autodep/bin/ebuild-helpers/newdoc new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newdoc @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newenvd b/portage_with_autodep/bin/ebuild-helpers/newenvd deleted file mode 100755 index c54af05..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newenvd +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doenvd "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newenvd b/portage_with_autodep/bin/ebuild-helpers/newenvd new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newenvd @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newexe b/portage_with_autodep/bin/ebuild-helpers/newexe deleted file mode 100755 index 9bcf64b..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newexe +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doexe "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newexe b/portage_with_autodep/bin/ebuild-helpers/newexe new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newexe @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newinitd b/portage_with_autodep/bin/ebuild-helpers/newinitd deleted file mode 100755 index 03bbe68..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newinitd +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doinitd "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newinitd b/portage_with_autodep/bin/ebuild-helpers/newinitd new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newinitd @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newins b/portage_with_autodep/bin/ebuild-helpers/newins index adf2d80..0335985 100755 --- a/portage_with_autodep/bin/ebuild-helpers/newins +++ b/portage_with_autodep/bin/ebuild-helpers/newins @@ -1,38 +1,57 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +helper=${0##*/} + if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" + __helpers_die "${helper}: Need two arguments, old file and new file" exit 1 fi -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 +(($#>2)) && \ + eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${@:3}" + +stdin= +if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then + stdin=yes fi -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" || exit $? -case "$EAPI" in - 0|1|2|3|3_pre2) - cp "$1" "$T/$2" || exit $? - ;; - *) - cp -P "$1" "$T/$2" - ret=$? - if [[ $ret -ne 0 ]] ; then - helpers_die "${0##*/} failed" - exit $ret +TMP=$(mktemp -d "${T}/.newins_tmp_XXXXXX") +trap 'rm -rf "${TMP}"' EXIT + +if [[ ${stdin} ]] ; then + if [[ -t 0 ]] ; then + __helpers_die "!!! ${helper}: Input is from a terminal" + exit 1 + fi + cat > "${TMP}/$2" + ret=$? +else + if [[ ! -e $1 ]] ; then + __helpers_die "!!! ${helper}: $1 does not exist" + exit 1 + fi + + cp_args="-f" + if [[ ${helper} == newins ]] ; then + if ___eapi_doins_and_newins_preserve_symlinks; then + cp_args+=" -P" fi - ;; -esac -doins "${T}/${2}" + fi + + cp ${cp_args} "$1" "${TMP}/$2" + ret=$? +fi + +if [[ ${ret} -ne 0 ]] ; then + __helpers_die "${0##*/} failed" + exit ${ret} +fi + +do${helper#new} "${TMP}/$2" ret=$? -rm -rf "${T}/${2}" -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${helper} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/newlib.a b/portage_with_autodep/bin/ebuild-helpers/newlib.a deleted file mode 100755 index 7ff8195..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newlib.a +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dolib.a "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newlib.a b/portage_with_autodep/bin/ebuild-helpers/newlib.a new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newlib.a @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newlib.so b/portage_with_autodep/bin/ebuild-helpers/newlib.so deleted file mode 100755 index fd4c097..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newlib.so +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dolib.so "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newlib.so b/portage_with_autodep/bin/ebuild-helpers/newlib.so new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newlib.so @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newman b/portage_with_autodep/bin/ebuild-helpers/newman deleted file mode 100755 index 889e0f9..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newman +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doman "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newman b/portage_with_autodep/bin/ebuild-helpers/newman new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newman @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newsbin b/portage_with_autodep/bin/ebuild-helpers/newsbin deleted file mode 100755 index 9df0af2..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/newsbin +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dosbin "${T}/${2}" diff --git a/portage_with_autodep/bin/ebuild-helpers/newsbin b/portage_with_autodep/bin/ebuild-helpers/newsbin new file mode 120000 index 0000000..59a0db2 --- /dev/null +++ b/portage_with_autodep/bin/ebuild-helpers/newsbin @@ -0,0 +1 @@ +newins \ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/portageq b/portage_with_autodep/bin/ebuild-helpers/portageq index ec30b66..b67b03f 100755 --- a/portage_with_autodep/bin/ebuild-helpers/portageq +++ b/portage_with_autodep/bin/ebuild-helpers/portageq @@ -1,8 +1,10 @@ #!/bin/bash -# Copyright 2009-2010 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ +# Use safe cwd, avoiding unsafe import for bug #469338. +cd "${PORTAGE_PYM_PATH}" +PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ exec "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/portageq" "$@" diff --git a/portage_with_autodep/bin/ebuild-helpers/prepall b/portage_with_autodep/bin/ebuild-helpers/prepall index 49e646c..fb5c2db 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepall +++ b/portage_with_autodep/bin/ebuild-helpers/prepall @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if has chflags $FEATURES ; then # Save all the file flags for restoration at the end of prepall. diff --git a/portage_with_autodep/bin/ebuild-helpers/prepalldocs b/portage_with_autodep/bin/ebuild-helpers/prepalldocs index 560a02b..3094661 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepalldocs +++ b/portage_with_autodep/bin/ebuild-helpers/prepalldocs @@ -1,15 +1,21 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +if ___eapi_has_docompress; then + die "'${0##*/}' has been banned for EAPI '$EAPI'" + exit 1 +fi + if [[ -n $1 ]] ; then - vecho "${0##*/}: invalid usage; takes no arguments" 1>&2 + __vecho "${0##*/}: invalid usage; takes no arguments" 1>&2 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi [[ -d ${ED}usr/share/doc ]] || exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/prepallinfo b/portage_with_autodep/bin/ebuild-helpers/prepallinfo index db9bbfa..1a20275 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepallinfo +++ b/portage_with_autodep/bin/ebuild-helpers/prepallinfo @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi [[ -d ${ED}usr/share/info ]] || exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/prepallman b/portage_with_autodep/bin/ebuild-helpers/prepallman index dee1c72..5331eaf 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepallman +++ b/portage_with_autodep/bin/ebuild-helpers/prepallman @@ -1,22 +1,22 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh # replaced by controllable compression in EAPI 4 -has "${EAPI}" 0 1 2 3 || exit 0 +___eapi_has_docompress && exit 0 -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi ret=0 -find "${ED}" -type d -name man > "${T}"/prepallman.filelist -while read -r mandir ; do +while IFS= read -r -d '' mandir ; do mandir=${mandir#${ED}} prepman "${mandir%/man}" ((ret|=$?)) -done < "${T}"/prepallman.filelist +done < <(find "${ED}" -type d -name man -print0) exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/prepallstrip b/portage_with_autodep/bin/ebuild-helpers/prepallstrip index 28320d9..1aa6686 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepallstrip +++ b/portage_with_autodep/bin/ebuild-helpers/prepallstrip @@ -1,8 +1,11 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi exec prepstrip "${ED}" diff --git a/portage_with_autodep/bin/ebuild-helpers/prepinfo b/portage_with_autodep/bin/ebuild-helpers/prepinfo index ffe2ece..5afc18a 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepinfo +++ b/portage_with_autodep/bin/ebuild-helpers/prepinfo @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ -z $1 ]] ; then infodir="/usr/share/info" @@ -19,7 +20,7 @@ fi if [[ ! -d ${ED}${infodir} ]] ; then if [[ -n $1 ]] ; then - vecho "${0##*/}: '${infodir}' does not exist!" + __vecho "${0##*/}: '${infodir}' does not exist!" exit 1 else exit 0 @@ -33,5 +34,5 @@ find "${ED}${infodir}" -type d -print0 | while read -r -d $'\0' x ; do rm -f "${x}"/dir{,.info}{,.gz,.bz2} done -has "${EAPI}" 0 1 2 3 || exit 0 +___eapi_has_docompress && exit 0 exec ecompressdir --queue "${infodir}" diff --git a/portage_with_autodep/bin/ebuild-helpers/preplib b/portage_with_autodep/bin/ebuild-helpers/preplib deleted file mode 100755 index 6e91cf3..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/preplib +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -eqawarn "QA Notice: Deprecated call to 'preplib'" - -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac - -LIBDIR_VAR="LIBDIR_${ABI}" -if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then - CONF_LIBDIR="${!LIBDIR_VAR}" -fi -unset LIBDIR_VAR - -if [ -z "${CONF_LIBDIR}" ]; then - # we need this to default to lib so that things dont break - CONF_LIBDIR="lib" -fi - -if [ -z "$1" ] ; then - z="${ED}usr/${CONF_LIBDIR}" -else - z="${ED}$1/${CONF_LIBDIR}" -fi - -if [ -d "${z}" ] ; then - ldconfig -n -N "${z}" -fi diff --git a/portage_with_autodep/bin/ebuild-helpers/prepman b/portage_with_autodep/bin/ebuild-helpers/prepman index f96b641..fb5dcb4 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepman +++ b/portage_with_autodep/bin/ebuild-helpers/prepman @@ -1,13 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +# Do not compress man pages which are smaller than this (in bytes). #169260 +SIZE_LIMIT='128' + source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi -if [[ -z $1 ]] ; then +if [[ -z $1 ]] ; then mandir="${ED}usr/share/man" else mandir="${ED}$1/man" @@ -19,7 +23,7 @@ if [[ ! -d ${mandir} ]] ; then fi # replaced by controllable compression in EAPI 4 -has "${EAPI}" 0 1 2 3 || exit 0 +___eapi_has_docompress && exit 0 shopt -s nullglob @@ -30,6 +34,6 @@ for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do [[ -d ${subdir} ]] && really_is_mandir=1 && break done -[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --queue "${mandir#${ED}}" +[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --limit ${SIZE_LIMIT} --queue "${mandir#${ED}}" exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/prepstrip b/portage_with_autodep/bin/ebuild-helpers/prepstrip index 85d5d6a..2332388 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepstrip +++ b/portage_with_autodep/bin/ebuild-helpers/prepstrip @@ -1,7 +1,8 @@ #!/bin/bash -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh # avoid multiple calls to `has`. this creates things like: @@ -15,11 +16,12 @@ exp_tf() { eval ${var}_${flag}=$(tf has ${flag} ${!var}) done } -exp_tf FEATURES compressdebug installsources nostrip splitdebug -exp_tf RESTRICT binchecks installsources strip +exp_tf FEATURES compressdebug installsources nostrip splitdebug xattr +exp_tf RESTRICT binchecks installsources splitdebug strip -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "${EAPI}" in 0|1|2) EPREFIX= ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + EPREFIX= ED=${D} +fi banner=false SKIP_STRIP=false @@ -29,6 +31,30 @@ if ${RESTRICT_strip} || ${FEATURES_nostrip} ; then ${FEATURES_installsources} || exit 0 fi +PRESERVE_XATTR=false +if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then + PRESERVE_XATTR=true + if type -P getfattr >/dev/null && type -P setfattr >/dev/null ; then + dump_xattrs() { + getfattr -d --absolute-names "$1" + } + restore_xattrs() { + setfattr --restore=- + } + else + dump_xattrs() { + PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ + "${PORTAGE_PYTHON:-/usr/bin/python}" \ + "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo -n "$1") + } + restore_xattrs() { + PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ + "${PORTAGE_PYTHON:-/usr/bin/python}" \ + "${PORTAGE_BIN_PATH}/xattr-helper.py" --restore + } + fi +fi + # look up the tools we might be using for t in STRIP:strip OBJCOPY:objcopy READELF:readelf ; do v=${t%:*} # STRIP @@ -51,7 +77,7 @@ case $(${STRIP} --version 2>/dev/null) in # We'll leave out -R .note for now until we can check out the relevance # of the section when it has the ALLOC flag set on it ... SAFE_STRIP_FLAGS="--strip-unneeded" - DEF_STRIP_FLAGS="-R .comment -R .GCC.command.line" + DEF_STRIP_FLAGS="-R .comment -R .GCC.command.line -R .note.gnu.gold-version" SPLIT_STRIP_FLAGS= ;; esac @@ -62,23 +88,13 @@ prepstrip_sources_dir=${EPREFIX}/usr/src/debug/${CATEGORY}/${PF} type -P debugedit >/dev/null && debugedit_found=true || debugedit_found=false debugedit_warned=false -multijob_init +__multijob_init # Setup $T filesystem layout that we care about. tmpdir="${T}/prepstrip" rm -rf "${tmpdir}" mkdir -p "${tmpdir}"/{inodes,splitdebug,sources} -# Usage: inode_var_name: -inode_file_link() { - echo -n "${tmpdir}/inodes/" - if [[ ${USERLAND} == "BSD" ]] ; then - stat -f '%i' "$1" - else - stat -c '%i' "$1" - fi -} - # Usage: save_elf_sources save_elf_sources() { ${FEATURES_installsources} || return 0 @@ -93,7 +109,6 @@ save_elf_sources() { fi local x=$1 - [[ -f $(inode_file_link "${x}") ]] && return 0 # since we're editing the ELF here, we should recompute the build-id # (the -i flag below). save that output so we don't need to recompute @@ -101,20 +116,22 @@ save_elf_sources() { buildid=$(debugedit -i \ -b "${WORKDIR}" \ -d "${prepstrip_sources_dir}" \ - -l "${tmpdir}/sources/${x##*/}.${BASHPID}" \ + -l "${tmpdir}/sources/${x##*/}.${BASHPID:-$(__bashpid)}" \ "${x}") } # Usage: save_elf_debug [splitdebug file] save_elf_debug() { ${FEATURES_splitdebug} || return 0 + ${RESTRICT_splitdebug} && return 0 # NOTE: Debug files must be installed in # ${EPREFIX}/usr/lib/debug/${EPREFIX} (note that ${EPREFIX} occurs # twice in this path) in order for gdb's debug-file-directory # lookup to work correctly. local x=$1 - local splitdebug=$2 + local inode_debug=$2 + local splitdebug=$3 local y=${ED}usr/lib/debug/${x:${#D}}.debug # dont save debug info twice @@ -122,9 +139,8 @@ save_elf_debug() { mkdir -p "${y%/*}" - local inode=$(inode_file_link "${x}") - if [[ -f ${inode} ]] ; then - ln "${inode}" "${y}" + if [ -f "${inode_debug}" ] ; then + ln "${inode_debug}" "${y}" || die "ln failed unexpectedly" else if [[ -n ${splitdebug} ]] ; then mv "${splitdebug}" "${y}" @@ -134,64 +150,89 @@ save_elf_debug() { ${OBJCOPY} ${objcopy_flags} "${x}" "${y}" ${OBJCOPY} --add-gnu-debuglink="${y}" "${x}" fi - local args="a-x,o-w" - [[ -g ${x} || -u ${x} ]] && args+=",go-r" - chmod ${args} "${y}" - ln "${y}" "${inode}" + # Only do the following if the debug file was + # successfully created (see bug #446774). + if [ $? -eq 0 ] ; then + local args="a-x,o-w" + [[ -g ${x} || -u ${x} ]] && args+=",go-r" + chmod ${args} "${y}" + ln "${y}" "${inode_debug}" || die "ln failed unexpectedly" + fi fi # if we don't already have build-id from debugedit, look it up if [[ -z ${buildid} ]] ; then # convert the readelf output to something useful - buildid=$(${READELF} -x .note.gnu.build-id "${x}" 2>/dev/null \ - | awk '$NF ~ /GNU/ { getline; printf $2$3$4$5; getline; print $2 }') + buildid=$(${READELF} -n "${x}" 2>/dev/null | awk '/Build ID:/{ print $NF; exit }') fi if [[ -n ${buildid} ]] ; then local buildid_dir="${ED}usr/lib/debug/.build-id/${buildid:0:2}" local buildid_file="${buildid_dir}/${buildid:2}" mkdir -p "${buildid_dir}" - ln -s "../../${x:${#D}}.debug" "${buildid_file}.debug" - ln -s "/${x:${#D}}" "${buildid_file}" + [ -L "${buildid_file}".debug ] || ln -s "../../${x:${#D}}.debug" "${buildid_file}.debug" + [ -L "${buildid_file}" ] || ln -s "/${x:${#D}}" "${buildid_file}" fi } # Usage: process_elf process_elf() { - local x=$1 strip_flags=${*:2} - - vecho " ${x:${#ED}}" - save_elf_sources "${x}" + local x=$1 inode_link=$2 strip_flags=${*:3} + local already_stripped lockfile xt_data + + __vecho " ${x:${#ED}}" + + # If two processes try to debugedit or strip the same hardlink at the + # same time, it may corrupt files or cause loss of splitdebug info. + # So, use a lockfile to prevent interference (easily observed with + # dev-vcs/git which creates ~111 hardlinks to one file in + # /usr/libexec/git-core). + lockfile=${inode_link}_lockfile + if ! ln "${inode_link}" "${lockfile}" 2>/dev/null ; then + while [[ -f ${lockfile} ]] ; do + sleep 1 + done + unset lockfile + fi - if ${strip_this} ; then + [ -f "${inode_link}_stripped" ] && already_stripped=true || already_stripped=false - # If two processes try to strip the same hardlink at the same - # time, it will cause one of them to lose the splitdebug info. - # So, use a lockfile to prevent interference (easily observed - # with dev-vcs/git which creates ~109 hardlinks to one file in - # /usr/libexec/git-core). - local lockfile=$(inode_file_link "${x}")_lockfile - if ! ln "${x}" "${lockfile}" ; then - while [[ -f ${lockfile} ]] ; do - sleep 1 - done - unset lockfile + if ! ${already_stripped} ; then + if ${PRESERVE_XATTR} ; then + xt_data=$(dump_xattrs "${x}") fi + save_elf_sources "${x}" + fi + + if ${strip_this} ; then # see if we can split & strip at the same time if [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then local shortname="${x##*/}.debug" - local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID}" + local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID:-$(__bashpid)}" + ${already_stripped} || \ ${STRIP} ${strip_flags} \ -f "${splitdebug}" \ -F "${shortname}" \ "${x}" - save_elf_debug "${x}" "${splitdebug}" + save_elf_debug "${x}" "${inode_link}_debug" "${splitdebug}" else - save_elf_debug "${x}" + save_elf_debug "${x}" "${inode_link}_debug" + ${already_stripped} || \ ${STRIP} ${strip_flags} "${x}" fi - [[ -n ${lockfile} ]] && rm -f "${lockfile}" fi + + if ${already_stripped} ; then + rm -f "${x}" || die "rm failed unexpectedly" + ln "${inode_link}_stripped" "${x}" || die "ln failed unexpectedly" + else + ln "${x}" "${inode_link}_stripped" || die "ln failed unexpectedly" + if [[ ${xt_data} ]] ; then + restore_xattrs <<< "${xt_data}" + fi + fi + + [[ -n ${lockfile} ]] && rm -f "${lockfile}" } # The existance of the section .symtab tells us that a binary is stripped. @@ -204,7 +245,7 @@ if ! ${RESTRICT_binchecks} && ! ${RESTRICT_strip} ; then log=${tmpdir}/scanelf-already-stripped.log scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^${ED}##" > "${log}" ( - multijob_child_init + __multijob_child_init qa_var="QA_PRESTRIPPED_${ARCH/-/_}" [[ -n ${!qa_var} ]] && QA_PRESTRIPPED="${!qa_var}" if [[ -n ${QA_PRESTRIPPED} && -s ${log} && \ @@ -219,28 +260,49 @@ if ! ${RESTRICT_binchecks} && ! ${RESTRICT_strip} ; then fi sed -e "/^\$/d" -e "s#^#/#" -i "${log}" if [[ -s ${log} ]] ; then - vecho -e "\n" + __vecho -e "\n" eqawarn "QA Notice: Pre-stripped files found:" eqawarn "$(<"${log}")" else rm -f "${log}" fi ) & - multijob_post_fork + __multijob_post_fork +fi + +# Since strip creates a new inode, we need to know the initial set of +# inodes in advance, so that we can avoid interference due to trying +# to strip the same (hardlinked) file multiple times in parallel. +# See bug #421099. +if [[ ${USERLAND} == BSD ]] ; then + get_inode_number() { stat -f '%i' "$1"; } +else + get_inode_number() { stat -c '%i' "$1"; } fi +cd "${tmpdir}/inodes" || die "cd failed unexpectedly" +while read -r x ; do + inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly" + echo "${x}" >> "${inode_link}" || die "echo failed unexpectedly" +done < <( + # Use sort -u to eliminate duplicates for bug #445336. + ( + scanelf -yqRBF '#k%F' -k '.symtab' "$@" + find "$@" -type f ! -type l -name '*.a' + ) | LC_ALL=C sort -u +) # Now we look for unstripped binaries. -for x in \ - $(scanelf -yqRBF '#k%F' -k '.symtab' "$@") \ - $(find "$@" -type f -name '*.a') +for inode_link in $(shopt -s nullglob; echo *) ; do +while read -r x do + if ! ${banner} ; then - vecho "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}" + __vecho "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}" banner=true fi ( - multijob_child_init + __multijob_child_init f=$(file "${x}") || exit 0 [[ -z ${f} ]] && exit 0 @@ -275,27 +337,34 @@ do buildid= if [[ ${f} == *"current ar archive"* ]] ; then - vecho " ${x:${#ED}}" + __vecho " ${x:${#ED}}" if ${strip_this} ; then - # hmm, can we split debug/sources for .a ? - ${STRIP} -g "${x}" + # If we have split debug enabled, then do not strip this. + # There is no concept of splitdebug for objects not yet + # linked in (only for finally linked ELFs), so we have to + # retain the debug info in the archive itself. + if ! ${FEATURES_splitdebug} || ${RESTRICT_splitdebug} ; then + ${STRIP} -g "${x}" + fi fi elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then - process_elf "${x}" ${PORTAGE_STRIP_FLAGS} + process_elf "${x}" "${inode_link}" ${PORTAGE_STRIP_FLAGS} elif [[ ${f} == *"SB relocatable"* ]] ; then - process_elf "${x}" ${SAFE_STRIP_FLAGS} + process_elf "${x}" "${inode_link}" ${SAFE_STRIP_FLAGS} fi if ${was_not_writable} ; then chmod u-w "${x}" fi ) & - multijob_post_fork + __multijob_post_fork + +done < "${inode_link}" done # With a bit more work, we could run the rsync processes below in # parallel, but not sure that'd be an overall improvement. -multijob_finish +__multijob_finish cd "${tmpdir}"/sources/ && cat * > "${tmpdir}/debug.sources" 2>/dev/null if [[ -s ${tmpdir}/debug.sources ]] && \ @@ -303,11 +372,11 @@ if [[ -s ${tmpdir}/debug.sources ]] && \ ! ${RESTRICT_installsources} && \ ${debugedit_found} then - vecho "installsources: rsyncing source files" + __vecho "installsources: rsyncing source files" [[ -d ${D}${prepstrip_sources_dir} ]] || mkdir -p "${D}${prepstrip_sources_dir}" grep -zv '/<[^/>]*>$' "${tmpdir}"/debug.sources | \ (cd "${WORKDIR}"; LANG=C sort -z -u | \ - rsync -tL0 --files-from=- "${WORKDIR}/" "${D}${prepstrip_sources_dir}/" ) + rsync -tL0 --chmod=ugo-st,a+r,go-w,Da+x,Fa-x --files-from=- "${WORKDIR}/" "${D}${prepstrip_sources_dir}/" ) # Preserve directory structure. # Needed after running save_elf_sources. @@ -318,4 +387,5 @@ then done < <(find "${D}${prepstrip_sources_dir}/" -type d -empty -print0) fi +cd "${T}" rm -rf "${tmpdir}" diff --git a/portage_with_autodep/bin/ebuild-ipc b/portage_with_autodep/bin/ebuild-ipc index 43e4a02..820005f 100755 --- a/portage_with_autodep/bin/ebuild-ipc +++ b/portage_with_autodep/bin/ebuild-ipc @@ -1,8 +1,10 @@ #!/bin/bash -# Copyright 2010 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ +# Use safe cwd, avoiding unsafe import for bug #469338. +cd "${PORTAGE_PYM_PATH}" +PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ exec "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/ebuild-ipc.py" "$@" diff --git a/portage_with_autodep/bin/ebuild-ipc.py b/portage_with_autodep/bin/ebuild-ipc.py index 29d4c23..d351e94 100755 --- a/portage_with_autodep/bin/ebuild-ipc.py +++ b/portage_with_autodep/bin/ebuild-ipc.py @@ -1,24 +1,28 @@ #!/usr/bin/python -# Copyright 2010-2011 Gentoo Foundation +# Copyright 2010-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # # This is a helper which ebuild processes can use # to communicate with portage's main python process. -import errno import logging import os import pickle -import select +import platform import signal import sys import time -import traceback def debug_signal(signum, frame): import pdb pdb.set_trace() -signal.signal(signal.SIGUSR1, debug_signal) + +if platform.python_implementation() == 'Jython': + debug_signum = signal.SIGUSR2 # bug #424259 +else: + debug_signum = signal.SIGUSR1 + +signal.signal(debug_signum, debug_signal) # Avoid sandbox violations after python upgrade. pym_path = os.path.join(os.path.dirname( @@ -31,14 +35,28 @@ if os.environ.get("SANDBOX_ON") == "1": ":".join(filter(None, sandbox_write)) import portage +portage._internal_caller = True portage._disable_legacy_globals() +from portage.util._async.ForkProcess import ForkProcess +from portage.util._eventloop.global_event_loop import global_event_loop +from _emerge.PipeReader import PipeReader + +class FifoWriter(ForkProcess): + + __slots__ = ('buf', 'fifo',) + + def _run(self): + # Atomically write the whole buffer into the fifo. + with open(self.fifo, 'wb', 0) as f: + f.write(self.buf) + return os.EX_OK + class EbuildIpc(object): # Timeout for each individual communication attempt (we retry # as long as the daemon process appears to be alive). - _COMMUNICATE_RETRY_TIMEOUT_SECONDS = 15 - _BUFSIZE = 4096 + _COMMUNICATE_RETRY_TIMEOUT_MS = 15000 def __init__(self): self.fifo_dir = os.environ['PORTAGE_BUILDDIR'] @@ -82,7 +100,7 @@ class EbuildIpc(object): 'ebuild-ipc: daemon process not detected\n'), level=logging.ERROR, noiselevel=-1) - def _wait(self, pid, pr, msg): + def _run_writer(self, fifo_writer, msg): """ Wait on pid and return an appropriate exit code. This may return unsuccessfully due to timeout if the daemon @@ -91,88 +109,48 @@ class EbuildIpc(object): start_time = time.time() - while True: - try: - events = select.select([pr], [], [], - self._COMMUNICATE_RETRY_TIMEOUT_SECONDS) - except select.error as e: - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % \ - (portage.localization._('during select'), e), - level=logging.ERROR, noiselevel=-1) - continue + fifo_writer.start() + eof = fifo_writer.poll() is not None - if events[0]: - break + while not eof: + fifo_writer._wait_loop(timeout=self._COMMUNICATE_RETRY_TIMEOUT_MS) - if self._daemon_is_alive(): + eof = fifo_writer.poll() is not None + if eof: + break + elif self._daemon_is_alive(): self._timeout_retry_msg(start_time, msg) else: + fifo_writer.cancel() self._no_daemon_msg() - try: - os.kill(pid, signal.SIGKILL) - os.waitpid(pid, 0) - except OSError as e: - portage.util.writemsg_level( - "ebuild-ipc: %s\n" % (e,), - level=logging.ERROR, noiselevel=-1) + fifo_writer.wait() return 2 - try: - wait_retval = os.waitpid(pid, 0) - except OSError as e: - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % (msg, e), - level=logging.ERROR, noiselevel=-1) - return 2 + return fifo_writer.wait() - if not os.WIFEXITED(wait_retval[1]): - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % (msg, - portage.localization._('subprocess failure: %s') % \ - wait_retval[1]), - level=logging.ERROR, noiselevel=-1) - return 2 + def _receive_reply(self, input_fd): - return os.WEXITSTATUS(wait_retval[1]) + start_time = time.time() - def _receive_reply(self, input_fd): + pipe_reader = PipeReader(input_files={"input_fd":input_fd}, + scheduler=global_event_loop()) + pipe_reader.start() - # Timeouts are handled by the parent process, so just - # block until input is available. For maximum portability, - # use a single atomic read. - buf = None - while True: - try: - events = select.select([input_fd], [], []) - except select.error as e: - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % \ - (portage.localization._('during select for read'), e), - level=logging.ERROR, noiselevel=-1) - continue - - if events[0]: - # For maximum portability, use os.read() here since - # array.fromfile() and file.read() are both known to - # erroneously return an empty string from this - # non-blocking fifo stream on FreeBSD (bug #337465). - try: - buf = os.read(input_fd, self._BUFSIZE) - except OSError as e: - if e.errno != errno.EAGAIN: - portage.util.writemsg_level( - "ebuild-ipc: %s: %s\n" % \ - (portage.localization._('read error'), e), - level=logging.ERROR, noiselevel=-1) - break - # Assume that another event will be generated - # if there's any relevant data. - continue - - # Only one (atomic) read should be necessary. - if buf: - break + eof = pipe_reader.poll() is not None + + while not eof: + pipe_reader._wait_loop(timeout=self._COMMUNICATE_RETRY_TIMEOUT_MS) + eof = pipe_reader.poll() is not None + if not eof: + if self._daemon_is_alive(): + self._timeout_retry_msg(start_time, + portage.localization._('during read')) + else: + pipe_reader.cancel() + self._no_daemon_msg() + return 2 + + buf = pipe_reader.getvalue() retval = 2 @@ -225,32 +203,9 @@ class EbuildIpc(object): # un-interrupted, while the parent handles all timeout # considerations. This helps to avoid possible race conditions # from interference between timeouts and blocking IO operations. - pr, pw = os.pipe() - pid = os.fork() - - if pid == 0: - retval = 2 - try: - os.close(pr) - - # File streams are in unbuffered mode since we do atomic - # read and write of whole pickles. - output_file = open(self.ipc_in_fifo, 'wb', 0) - output_file.write(pickle.dumps(args)) - output_file.close() - retval = os.EX_OK - except SystemExit: - raise - except: - traceback.print_exc() - finally: - os._exit(retval) - - os.close(pw) - msg = portage.localization._('during write') - retval = self._wait(pid, pr, msg) - os.close(pr) + retval = self._run_writer(FifoWriter(buf=pickle.dumps(args), + fifo=self.ipc_in_fifo, scheduler=global_event_loop()), msg) if retval != os.EX_OK: portage.util.writemsg_level( @@ -263,26 +218,7 @@ class EbuildIpc(object): self._no_daemon_msg() return 2 - pr, pw = os.pipe() - pid = os.fork() - - if pid == 0: - retval = 2 - try: - os.close(pr) - retval = self._receive_reply(input_fd) - except SystemExit: - raise - except: - traceback.print_exc() - finally: - os._exit(retval) - - os.close(pw) - retval = self._wait(pid, pr, portage.localization._('during read')) - os.close(pr) - os.close(input_fd) - return retval + return self._receive_reply(input_fd) def ebuild_ipc_main(args): ebuild_ipc = EbuildIpc() diff --git a/portage_with_autodep/bin/ebuild.sh b/portage_with_autodep/bin/ebuild.sh index 2589113..be044e0 100755 --- a/portage_with_autodep/bin/ebuild.sh +++ b/portage_with_autodep/bin/ebuild.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 PORTAGE_BIN_PATH="${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}" @@ -21,21 +21,23 @@ else # in global scope, even though they are completely useless during # the "depend" phase. for x in diropts docompress exeopts get_KV insopts \ - keepdir KV_major KV_micro KV_minor KV_to_int \ + KV_major KV_micro KV_minor KV_to_int \ libopts register_die_hook register_success_hook \ - remove_path_entry set_unless_changed strip_duplicate_slashes \ - unset_unless_changed use_with use_enable ; do + __strip_duplicate_slashes \ + use_with use_enable ; do eval "${x}() { - if has \"\${EAPI:-0}\" 4-python; then + if ___eapi_disallows_helpers_in_global_scope; then die \"\${FUNCNAME}() calls are not allowed in global scope\" fi }" done - # These dummy functions return false in older EAPIs, in order to ensure that + # These dummy functions return false in non-strict EAPIs, in order to ensure that # `use multislot` is false for the "depend" phase. - for x in use useq usev ; do + funcs="use useq usev" + ___eapi_has_usex && funcs+=" usex" + for x in ${funcs} ; do eval "${x}() { - if has \"\${EAPI:-0}\" 4-python; then + if ___eapi_disallows_helpers_in_global_scope; then die \"\${FUNCNAME}() calls are not allowed in global scope\" else return 1 @@ -44,10 +46,16 @@ else done # These functions die because calls to them during the "depend" phase # are considered to be severe QA violations. - for x in best_version has_version portageq ; do + funcs="best_version has_version portageq" + ___eapi_has_master_repositories && funcs+=" master_repositories" + ___eapi_has_repository_path && funcs+=" repository_path" + ___eapi_has_available_eclasses && funcs+=" available_eclasses" + ___eapi_has_eclass_path && funcs+=" eclass_path" + ___eapi_has_license_path && funcs+=" license_path" + for x in ${funcs} ; do eval "${x}() { die \"\${FUNCNAME}() calls are not allowed in global scope\"; }" done - unset x + unset funcs x fi # Don't use sandbox's BASH_ENV for new shells because it does @@ -66,7 +74,7 @@ export PORTAGE_BZIP2_COMMAND=${PORTAGE_BZIP2_COMMAND:-bzip2} # with shell opts (shopts). Ebuilds/eclasses changing shopts should reset them # when they are done. -qa_source() { +__qa_source() { local shopts=$(shopt) OLDIFS="$IFS" local retval source "$@" @@ -79,7 +87,7 @@ qa_source() { return $retval } -qa_call() { +__qa_call() { local shopts=$(shopt) OLDIFS="$IFS" local retval "$@" @@ -102,20 +110,19 @@ unset GZIP BZIP BZIP2 CDPATH GREP_OPTIONS GREP_COLOR GLOBIGNORE [[ $PORTAGE_QUIET != "" ]] && export PORTAGE_QUIET # sandbox support functions; defined prior to profile.bashrc srcing, since the profile might need to add a default exception (/usr/lib64/conftest fex) -_sb_append_var() { +__sb_append_var() { local _v=$1 ; shift local var="SANDBOX_${_v}" - [[ -z $1 || -n $2 ]] && die "Usage: add$(echo ${_v} | \ - LC_ALL=C tr [:upper:] [:lower:]) " + [[ -z $1 || -n $2 ]] && die "Usage: add$(LC_ALL=C tr "[:upper:]" "[:lower:]" <<< "${_v}") " export ${var}="${!var:+${!var}:}$1" } # bash-4 version: # local var="SANDBOX_${1^^}" -# addread() { _sb_append_var ${0#add} "$@" ; } -addread() { _sb_append_var READ "$@" ; } -addwrite() { _sb_append_var WRITE "$@" ; } -adddeny() { _sb_append_var DENY "$@" ; } -addpredict() { _sb_append_var PREDICT "$@" ; } +# addread() { __sb_append_var ${0#add} "$@" ; } +addread() { __sb_append_var READ "$@" ; } +addwrite() { __sb_append_var WRITE "$@" ; } +adddeny() { __sb_append_var DENY "$@" ; } +addpredict() { __sb_append_var PREDICT "$@" ; } addwrite "${PORTAGE_TMPDIR}" addread "/:${PORTAGE_TMPDIR}" @@ -136,19 +143,11 @@ fi # the sandbox is disabled by default except when overridden in the relevant stages export SANDBOX_ON=0 -esyslog() { - # Custom version of esyslog() to take care of the "Red Star" bug. - # MUST follow functions.sh to override the "" parameter problem. - return 0 -} - # Ensure that $PWD is sane whenever possible, to protect against # exploitation of insecure search path for python -c in ebuilds. -# See bug #239560. -if ! has "$EBUILD_PHASE" clean cleanrm depend help ; then - cd "$PORTAGE_BUILDDIR" || \ - die "PORTAGE_BUILDDIR does not exist: '$PORTAGE_BUILDDIR'" -fi +# See bug #239560 and bug #469338. +cd "${PORTAGE_PYM_PATH}" || \ + die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'" #if no perms are specified, dirs/files will have decent defaults #(not secretive, but not stupid) @@ -178,8 +177,8 @@ debug-print() { # default target printf '%s\n' "${@}" >> "${T}/eclass-debug.log" # let the portage user own/write to this file - chgrp portage "${T}/eclass-debug.log" &>/dev/null - chmod g+w "${T}/eclass-debug.log" &>/dev/null + chgrp "${PORTAGE_GRPNAME:-portage}" "${T}/eclass-debug.log" + chmod g+w "${T}/eclass-debug.log" fi } @@ -208,8 +207,9 @@ inherit() { | fmt -w 75 | while read -r ; do eqawarn "$REPLY" ; done fi + local repo_location local location - local olocation + local potential_location local x # These variables must be restored before returning. @@ -221,9 +221,10 @@ inherit() { local B_DEPEND local B_RDEPEND local B_PDEPEND + local B_HDEPEND while [ "$1" ]; do - location="${ECLASSDIR}/${1}.eclass" - olocation="" + location="" + potential_location="" export ECLASS="$1" __export_funcs_var=__export_functions_$ECLASS_DEPTH @@ -244,43 +245,36 @@ inherit() { fi fi - # any future resolution code goes here - if [ -n "$PORTDIR_OVERLAY" ]; then - local overlay - for overlay in ${PORTDIR_OVERLAY}; do - olocation="${overlay}/eclass/${1}.eclass" - if [ -e "$olocation" ]; then - location="${olocation}" - debug-print " eclass exists: ${location}" - fi - done - fi + for repo_location in "${PORTAGE_ECLASS_LOCATIONS[@]}"; do + potential_location="${repo_location}/eclass/${1}.eclass" + if [[ -f ${potential_location} ]]; then + location="${potential_location}" + debug-print " eclass exists: ${location}" + break + fi + done debug-print "inherit: $1 -> $location" - [ ! -e "$location" ] && die "${1}.eclass could not be found by inherit()" + [[ -z ${location} ]] && die "${1}.eclass could not be found by inherit()" - if [ "${location}" == "${olocation}" ] && \ - ! has "${location}" ${EBUILD_OVERLAY_ECLASSES} ; then - EBUILD_OVERLAY_ECLASSES="${EBUILD_OVERLAY_ECLASSES} ${location}" - fi - - #We need to back up the value of DEPEND and RDEPEND to B_DEPEND and B_RDEPEND + #We need to back up the values of *DEPEND to B_*DEPEND #(if set).. and then restore them after the inherit call. #turn off glob expansion set -f # Retain the old data and restore it later. - unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND + unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND [ "${IUSE+set}" = set ] && B_IUSE="${IUSE}" [ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}" [ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}" [ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}" [ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}" - unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND + [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}" + unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND #turn on glob expansion set +f - qa_source "$location" || die "died sourcing $location in inherit()" + __qa_source "$location" || die "died sourcing $location in inherit()" #turn off glob expansion set -f @@ -292,6 +286,7 @@ inherit() { [ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}" [ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}" [ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}" + [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}" [ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}" [ "${B_IUSE+set}" = set ] || unset IUSE @@ -308,6 +303,9 @@ inherit() { [ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}" [ "${B_PDEPEND+set}" = set ] || unset PDEPEND + [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}" + [ "${B_HDEPEND+set}" = set ] || unset HDEPEND + #turn on glob expansion set +f @@ -348,7 +346,7 @@ EXPORT_FUNCTIONS() { PORTAGE_BASHRCS_SOURCED=0 -# @FUNCTION: source_all_bashrcs +# @FUNCTION: __source_all_bashrcs # @DESCRIPTION: # Source a relevant bashrc files and perform other miscellaneous # environment initialization when appropriate. @@ -359,7 +357,7 @@ PORTAGE_BASHRCS_SOURCED=0 # * A "default" function which is an alias for the default phase # function for the current phase. # -source_all_bashrcs() { +__source_all_bashrcs() { [[ $PORTAGE_BASHRCS_SOURCED = 1 ]] && return 0 PORTAGE_BASHRCS_SOURCED=1 local x @@ -373,7 +371,7 @@ source_all_bashrcs() { local path_array=($PROFILE_PATHS) restore_IFS for x in "${path_array[@]}" ; do - [ -f "$x/profile.bashrc" ] && qa_source "$x/profile.bashrc" + [ -f "$x/profile.bashrc" ] && __qa_source "$x/profile.bashrc" done fi @@ -390,7 +388,7 @@ source_all_bashrcs() { if [[ $EBUILD_PHASE != depend ]] ; then # The user's bashrc is the ONLY non-portage bit of code that can # change shopts without a QA violation. - for x in "${PM_EBUILD_HOOK_DIR}"/${CATEGORY}/{${PN},${PN}:${SLOT},${P},${PF}}; do + for x in "${PM_EBUILD_HOOK_DIR}"/${CATEGORY}/{${PN},${PN}:${SLOT%/*},${P},${PF}}; do if [ -r "${x}" ]; then # If $- contains x, then tracing has already been enabled # elsewhere for some reason. We preserve it's state so as @@ -470,7 +468,7 @@ if [[ -n ${QA_INTERCEPTORS} ]] ; then fi # Subshell/helper die support (must export for the die helper). -export EBUILD_MASTER_PID=$BASHPID +export EBUILD_MASTER_PID=${BASHPID:-$(__bashpid)} trap 'exit 1' SIGTERM if ! has "$EBUILD_PHASE" clean cleanrm depend && \ @@ -479,7 +477,7 @@ if ! has "$EBUILD_PHASE" clean cleanrm depend && \ # may have come from another version of ebuild.sh or something. # In any case, preprocess it to prevent any potential interference. # NOTE: export ${FOO}=... requires quoting, unlike normal exports - preprocess_ebuild_env || \ + __preprocess_ebuild_env || \ die "error processing environment" # Colon separated SANDBOX_* variables need to be cumulative. for x in SANDBOX_DENY SANDBOX_READ SANDBOX_PREDICT SANDBOX_WRITE ; do @@ -512,17 +510,22 @@ if ! has "$EBUILD_PHASE" clean cleanrm depend && \ [[ -n $EAPI ]] || EAPI=0 fi -if has "${EAPI:-0}" 4-python; then +if ___eapi_enables_globstar; then shopt -s globstar fi +# Convert quoted paths to array. +eval "PORTAGE_ECLASS_LOCATIONS=(${PORTAGE_ECLASS_LOCATIONS})" + +# Source the ebuild every time for FEATURES=noauto, so that ebuild +# modifications take effect immediately. if ! has "$EBUILD_PHASE" clean cleanrm ; then if [[ $EBUILD_PHASE = depend || ! -f $T/environment || \ - -f $PORTAGE_BUILDDIR/.ebuild_changed ]] || \ - has noauto $FEATURES ; then + -f $PORTAGE_BUILDDIR/.ebuild_changed || \ + " ${FEATURES} " == *" noauto "* ]] ; then # The bashrcs get an opportunity here to set aliases that will be expanded # during sourcing of ebuilds and eclasses. - source_all_bashrcs + __source_all_bashrcs # When EBUILD_PHASE != depend, INHERITED comes pre-initialized # from cache. In order to make INHERITED content independent of @@ -534,8 +537,9 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then # In order to ensure correct interaction between ebuilds and # eclasses, they need to be unset before this process of # interaction begins. - unset EAPI DEPEND RDEPEND PDEPEND INHERITED IUSE REQUIRED_USE \ - ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND + unset EAPI DEPEND RDEPEND PDEPEND HDEPEND INHERITED IUSE REQUIRED_USE \ + ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND \ + E_HDEPEND if [[ $PORTAGE_DEBUG != 1 || ${-/x/} != $- ]] ; then source "$EBUILD" || die "error sourcing ebuild" @@ -553,7 +557,10 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then [ "${EAPI+set}" = set ] || EAPI=0 - if has "$EAPI" 0 1 2 3 3_pre2 ; then + # export EAPI for helpers (especially since we unset it above) + export EAPI + + if ___eapi_has_RDEPEND_DEPEND_fallback; then export RDEPEND=${RDEPEND-${DEPEND}} debug-print "RDEPEND: not set... Setting to: ${DEPEND}" fi @@ -563,19 +570,20 @@ if ! has "$EBUILD_PHASE" clean cleanrm ; then DEPEND+="${DEPEND:+ }${E_DEPEND}" RDEPEND+="${RDEPEND:+ }${E_RDEPEND}" PDEPEND+="${PDEPEND:+ }${E_PDEPEND}" + HDEPEND+="${HDEPEND:+ }${E_HDEPEND}" REQUIRED_USE+="${REQUIRED_USE:+ }${E_REQUIRED_USE}" - unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND \ + unset ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND E_HDEPEND \ __INHERITED_QA_CACHE # alphabetically ordered by $EBUILD_PHASE value - case "$EAPI" in + case ${EAPI} in 0|1) _valid_phases="src_compile pkg_config pkg_info src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm pkg_setup src_test src_unpack" ;; - 2|3|3_pre2) + 2|3) _valid_phases="src_compile pkg_config src_configure pkg_info src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst src_prepare pkg_prerm pkg_setup src_test src_unpack" @@ -667,9 +675,13 @@ if [[ $EBUILD_PHASE = depend ]] ; then auxdbkeys="DEPEND RDEPEND SLOT SRC_URI RESTRICT HOMEPAGE LICENSE DESCRIPTION KEYWORDS INHERITED IUSE REQUIRED_USE PDEPEND PROVIDE EAPI - PROPERTIES DEFINED_PHASES UNUSED_05 UNUSED_04 + PROPERTIES DEFINED_PHASES HDEPEND UNUSED_04 UNUSED_03 UNUSED_02 UNUSED_01" + if ! ___eapi_has_HDEPEND; then + unset HDEPEND + fi + # The extra $(echo) commands remove newlines. if [ -n "${dbkey}" ] ; then > "${dbkey}" @@ -678,31 +690,28 @@ if [[ $EBUILD_PHASE = depend ]] ; then done else for f in ${auxdbkeys} ; do - echo $(echo ${!f}) 1>&9 || exit $? + eval "echo \$(echo \${!f}) 1>&${PORTAGE_PIPE_FD}" || exit $? done - exec 9>&- + eval "exec ${PORTAGE_PIPE_FD}>&-" fi set +f else - # Note: readonly variables interfere with preprocess_ebuild_env(), so + # Note: readonly variables interfere with __preprocess_ebuild_env(), so # declare them only after it has already run. declare -r $PORTAGE_READONLY_METADATA $PORTAGE_READONLY_VARS - case "$EAPI" in - 0|1|2) - [[ " ${FEATURES} " == *" force-prefix "* ]] && \ - declare -r ED EPREFIX EROOT - ;; - *) - declare -r ED EPREFIX EROOT - ;; - esac + if ___eapi_has_prefix_variables; then + declare -r ED EPREFIX EROOT + fi if [[ -n $EBUILD_SH_ARGS ]] ; then ( # Don't allow subprocesses to inherit the pipe which # emerge uses to monitor ebuild.sh. - exec 9>&- - ebuild_main ${EBUILD_SH_ARGS} + if [[ -n ${PORTAGE_PIPE_FD} ]] ; then + eval "exec ${PORTAGE_PIPE_FD}>&-" + unset PORTAGE_PIPE_FD + fi + __ebuild_main ${EBUILD_SH_ARGS} exit 0 ) exit $? diff --git a/portage_with_autodep/bin/egencache b/portage_with_autodep/bin/egencache index 2f53b40..9b22363 100755 --- a/portage_with_autodep/bin/egencache +++ b/portage_with_autodep/bin/egencache @@ -1,15 +1,17 @@ #!/usr/bin/python -# Copyright 2009-2012 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -from __future__ import print_function +# unicode_literals for compat with TextIOWrapper in Python 2 +from __future__ import print_function, unicode_literals +import platform import signal import sys # This block ensures that ^C interrupts are handled quietly. try: - def exithandler(signum,frame): + def exithandler(signum, _frame): signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN) sys.exit(128 + signum) @@ -20,26 +22,39 @@ try: except KeyboardInterrupt: sys.exit(128 + signal.SIGINT) +def debug_signal(_signum, _frame): + import pdb + pdb.set_trace() + +if platform.python_implementation() == 'Jython': + debug_signum = signal.SIGUSR2 # bug #424259 +else: + debug_signum = signal.SIGUSR1 + +signal.signal(debug_signum, debug_signal) + import io import logging -import optparse import subprocess import time import textwrap import re -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True from portage import os, _encodings, _unicode_encode, _unicode_decode from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision +from portage.const import TIMESTAMP_FORMAT from portage.manifest import guessManifestFileType +from portage.package.ebuild._parallel_manifest.ManifestScheduler import ManifestScheduler from portage.util import cmp_sort_key, writemsg_level +from portage.util._argparse import ArgumentParser +from portage.util._async.run_main_scheduler import run_main_scheduler +from portage.util._eventloop.global_event_loop import global_event_loop from portage import cpv_getkey from portage.dep import Atom, isjustname from portage.versions import pkgsplit, vercmp @@ -59,72 +74,98 @@ else: from repoman.utilities import FindVCS if sys.hexversion >= 0x3000000: + # pylint: disable=W0622 long = int def parse_args(args): usage = "egencache [options] ... [atom] ..." - parser = optparse.OptionParser(usage=usage) + parser = ArgumentParser(usage=usage) - actions = optparse.OptionGroup(parser, 'Actions') - actions.add_option("--update", + actions = parser.add_argument_group('Actions') + actions.add_argument("--update", action="store_true", - help="update metadata/cache/ (generate as necessary)") - actions.add_option("--update-use-local-desc", + help="update metadata/md5-cache/ (generate as necessary)") + actions.add_argument("--update-use-local-desc", action="store_true", help="update the use.local.desc file from metadata.xml") - actions.add_option("--update-changelogs", + actions.add_argument("--update-changelogs", action="store_true", help="update the ChangeLog files from SCM logs") - parser.add_option_group(actions) + actions.add_argument("--update-manifests", + action="store_true", + help="update manifests") - common = optparse.OptionGroup(parser, 'Common options') - common.add_option("--repo", + common = parser.add_argument_group('Common options') + common.add_argument("--repo", action="store", - help="name of repo to operate on (default repo is located at $PORTDIR)") - common.add_option("--config-root", + help="name of repo to operate on") + common.add_argument("--config-root", help="location of portage config files", dest="portage_configroot") - common.add_option("--portdir", - help="override the portage tree location", + common.add_argument("--gpg-dir", + help="override the PORTAGE_GPG_DIR variable", + dest="gpg_dir") + common.add_argument("--gpg-key", + help="override the PORTAGE_GPG_KEY variable", + dest="gpg_key") + common.add_argument("--portdir", + help="override the PORTDIR variable (deprecated in favor of --repositories-configuration)", dest="portdir") - common.add_option("--portdir-overlay", - help="override the PORTDIR_OVERLAY variable (requires that --repo is also specified)", + common.add_argument("--portdir-overlay", + help="override the PORTDIR_OVERLAY variable (deprecated in favor of --repositories-configuration)", dest="portdir_overlay") - common.add_option("--tolerant", + common.add_argument("--repositories-configuration", + help="override configuration of repositories (in format of repos.conf)", + dest="repositories_configuration") + common.add_argument("--sign-manifests", + choices=('y', 'n'), + metavar="", + help="manually override layout.conf sign-manifests setting") + common.add_argument("--strict-manifests", + choices=('y', 'n'), + metavar="", + help="manually override \"strict\" FEATURES setting") + common.add_argument("--thin-manifests", + choices=('y', 'n'), + metavar="", + help="manually override layout.conf thin-manifests setting") + common.add_argument("--tolerant", action="store_true", help="exit successfully if only minor errors occurred") - common.add_option("--ignore-default-opts", + common.add_argument("--ignore-default-opts", action="store_true", help="do not use the EGENCACHE_DEFAULT_OPTS environment variable") - parser.add_option_group(common) + common.add_argument("--write-timestamp", + action="store_true", + help="write metadata/timestamp.chk as required for rsync repositories") - update = optparse.OptionGroup(parser, '--update options') - update.add_option("--cache-dir", + update = parser.add_argument_group('--update options') + update.add_argument("--cache-dir", help="location of the metadata cache", dest="cache_dir") - update.add_option("--jobs", + update.add_argument("-j", "--jobs", + type=int, action="store", help="max ebuild processes to spawn") - update.add_option("--load-average", + update.add_argument("--load-average", + type=float, action="store", help="max load allowed when spawning multiple jobs", dest="load_average") - update.add_option("--rsync", + update.add_argument("--rsync", action="store_true", help="enable rsync stat collision workaround " + \ "for bug 139134 (use with --update)") - parser.add_option_group(update) - uld = optparse.OptionGroup(parser, '--update-use-local-desc options') - uld.add_option("--preserve-comments", + uld = parser.add_argument_group('--update-use-local-desc options') + uld.add_argument("--preserve-comments", action="store_true", help="preserve the comments from the existing use.local.desc file") - uld.add_option("--use-local-desc-output", + uld.add_argument("--use-local-desc-output", help="output file for use.local.desc data (or '-' for stdout)", dest="uld_output") - parser.add_option_group(uld) - options, args = parser.parse_args(args) + options, args = parser.parse_known_args(args) if options.jobs: jobs = None @@ -171,9 +212,12 @@ def parse_args(args): parser.error("Write access denied: --cache-dir='%s'" % \ (options.cache_dir,)) - if options.portdir_overlay is not None and \ - options.repo is None: - parser.error("--portdir-overlay option requires --repo option") + if options.portdir is not None: + writemsg_level("egencache: warning: --portdir option is deprecated in favor of --repositories-configuration option\n", + level=logging.WARNING, noiselevel=-1) + if options.portdir_overlay is not None: + writemsg_level("egencache: warning: --portdir-overlay option is deprecated in favor of --repositories-configuration option\n", + level=logging.WARNING, noiselevel=-1) for atom in args: try: @@ -215,9 +259,11 @@ class GenCache(object): else: self._cp_set = None self._cp_missing = set() + write_auxdb = "metadata-transfer" in portdb.settings.features self._regen = MetadataRegen(portdb, cp_iter=cp_iter, consumer=self._metadata_callback, - max_jobs=max_jobs, max_load=max_load) + max_jobs=max_jobs, max_load=max_load, + write_auxdb=write_auxdb, main=True) self.returncode = os.EX_OK conf = portdb.repositories.get_repo_for_location(tree) self._trg_caches = tuple(conf.iter_pregenerated_caches( @@ -255,98 +301,74 @@ class GenCache(object): def _write_cache(self, trg_cache, cpv, repo_path, metadata, ebuild_hash): - if not hasattr(trg_cache, 'raise_stat_collision'): - # This cache does not avoid redundant writes automatically, - # so check for an identical existing entry before writing. - # This prevents unnecessary disk writes and can also prevent - # unnecessary rsync transfers. - try: - dest = trg_cache[cpv] - except (KeyError, CacheError): - pass - else: - if trg_cache.validate_entry(dest, - ebuild_hash, self._eclass_db): - identical = True - for k in self._auxdbkeys: - if dest.get(k, '') != metadata.get(k, ''): - identical = False - break - if identical: - return + if not hasattr(trg_cache, 'raise_stat_collision'): + # This cache does not avoid redundant writes automatically, + # so check for an identical existing entry before writing. + # This prevents unnecessary disk writes and can also prevent + # unnecessary rsync transfers. + try: + dest = trg_cache[cpv] + except (KeyError, CacheError): + pass + else: + if trg_cache.validate_entry(dest, + ebuild_hash, self._eclass_db): + identical = True + for k in self._auxdbkeys: + if dest.get(k, '') != metadata.get(k, ''): + identical = False + break + if identical: + return + try: + chf = trg_cache.validation_chf + metadata['_%s_' % chf] = getattr(ebuild_hash, chf) try: - chf = trg_cache.validation_chf - metadata['_%s_' % chf] = getattr(ebuild_hash, chf) + trg_cache[cpv] = metadata + except StatCollision as sc: + # If the content of a cache entry changes and neither the + # file mtime nor size changes, it will prevent rsync from + # detecting changes. Cache backends may raise this + # exception from _setitem() if they detect this type of stat + # collision. These exceptions are handled by bumping the + # mtime on the ebuild (and the corresponding cache entry). + # See bug #139134. It is convenient to include checks for + # redundant writes along with the internal StatCollision + # detection code, so for caches with the + # raise_stat_collision attribute, we do not need to + # explicitly check for redundant writes like we do for the + # other cache types above. + max_mtime = sc.mtime + for _ec, ec_hash in metadata['_eclasses_'].items(): + if max_mtime < ec_hash.mtime: + max_mtime = ec_hash.mtime + if max_mtime == sc.mtime: + max_mtime += 1 + max_mtime = long(max_mtime) try: + os.utime(ebuild_hash.location, (max_mtime, max_mtime)) + except OSError as e: + self.returncode |= 1 + writemsg_level( + "%s writing target: %s\n" % (cpv, e), + level=logging.ERROR, noiselevel=-1) + else: + ebuild_hash.mtime = max_mtime + metadata['_mtime_'] = max_mtime trg_cache[cpv] = metadata - except StatCollision as sc: - # If the content of a cache entry changes and neither the - # file mtime nor size changes, it will prevent rsync from - # detecting changes. Cache backends may raise this - # exception from _setitem() if they detect this type of stat - # collision. These exceptions are handled by bumping the - # mtime on the ebuild (and the corresponding cache entry). - # See bug #139134. It is convenient to include checks for - # redundant writes along with the internal StatCollision - # detection code, so for caches with the - # raise_stat_collision attribute, we do not need to - # explicitly check for redundant writes like we do for the - # other cache types above. - max_mtime = sc.mtime - for ec, ec_hash in metadata['_eclasses_'].items(): - if max_mtime < ec_hash.mtime: - max_mtime = ec_hash.mtime - if max_mtime == sc.mtime: - max_mtime += 1 - max_mtime = long(max_mtime) - try: - os.utime(ebuild_hash.location, (max_mtime, max_mtime)) - except OSError as e: - self.returncode |= 1 - writemsg_level( - "%s writing target: %s\n" % (cpv, e), - level=logging.ERROR, noiselevel=-1) - else: - ebuild_hash.mtime = max_mtime - metadata['_mtime_'] = max_mtime - trg_cache[cpv] = metadata - self._portdb.auxdb[repo_path][cpv] = metadata + self._portdb.auxdb[repo_path][cpv] = metadata - except CacheError as ce: - self.returncode |= 1 - writemsg_level( - "%s writing target: %s\n" % (cpv, ce), - level=logging.ERROR, noiselevel=-1) + except CacheError as ce: + self.returncode |= 1 + writemsg_level( + "%s writing target: %s\n" % (cpv, ce), + level=logging.ERROR, noiselevel=-1) def run(self): - - received_signal = [] - - def sighandler(signum, frame): - signal.signal(signal.SIGINT, signal.SIG_IGN) - signal.signal(signal.SIGTERM, signal.SIG_IGN) - self._regen.terminate() - received_signal.append(128 + signum) - - earlier_sigint_handler = signal.signal(signal.SIGINT, sighandler) - earlier_sigterm_handler = signal.signal(signal.SIGTERM, sighandler) - - try: - self._regen.run() - finally: - # Restore previous handlers - if earlier_sigint_handler is not None: - signal.signal(signal.SIGINT, earlier_sigint_handler) - else: - signal.signal(signal.SIGINT, signal.SIG_DFL) - if earlier_sigterm_handler is not None: - signal.signal(signal.SIGTERM, earlier_sigterm_handler) - else: - signal.signal(signal.SIGTERM, signal.SIG_DFL) - - if received_signal: - sys.exit(received_signal[0]) + signum = run_main_scheduler(self._regen) + if signum is not None: + sys.exit(128 + signum) self.returncode |= self._regen.returncode @@ -371,8 +393,8 @@ class GenCache(object): self.returncode |= 1 writemsg_level( "Error listing cache entries for " + \ - "'%s/metadata/cache': %s, continuing...\n" % \ - (self._portdb.porttree_root, ce), + "'%s': %s, continuing...\n" % \ + (trg_cache.location, ce), level=logging.ERROR, noiselevel=-1) else: @@ -393,8 +415,8 @@ class GenCache(object): self.returncode |= 1 writemsg_level( "Error listing cache entries for " + \ - "'%s/metadata/cache': %s, continuing...\n" % \ - (self._portdb.porttree_root, ce), + "'%s': %s, continuing...\n" % \ + (trg_cache.location, ce), level=logging.ERROR, noiselevel=-1) if cp_missing: @@ -426,6 +448,9 @@ class GenCache(object): "committing target: %s\n" % (ce,), level=logging.ERROR, noiselevel=-1) + if hasattr(trg_cache, '_prune_empty_dirs'): + trg_cache._prune_empty_dirs() + class GenUseLocalDesc(object): def __init__(self, portdb, output=None, preserve_comments=False): @@ -433,7 +458,7 @@ class GenUseLocalDesc(object): self._portdb = portdb self._output = output self._preserve_comments = preserve_comments - + def run(self): repo_path = self._portdb.porttrees[0] ops = {'<':0, '<=':1, '=':2, '>=':3, '>':4} @@ -506,14 +531,14 @@ class GenUseLocalDesc(object): encoding=_encodings['fs'], errors='strict'), mode='a', encoding=_encodings['repo.content'], errors='backslashreplace') - output.write(_unicode_decode('\n')) + output.write('\n') else: - output.write(textwrap.dedent(_unicode_decode('''\ + output.write(textwrap.dedent('''\ # This file is deprecated as per GLEP 56 in favor of metadata.xml. Please add # your descriptions to your package's metadata.xml ONLY. # * generated automatically using egencache * - '''))) + ''')) # The cmp function no longer exists in python3, so we'll # implement our own here under a slightly different name @@ -541,7 +566,8 @@ class GenUseLocalDesc(object): for cp in self._portdb.cp_all(): metadata_path = os.path.join(repo_path, cp, 'metadata.xml') try: - metadata = ElementTree.parse(metadata_path, + metadata = ElementTree.parse(_unicode_encode(metadata_path, + encoding=_encodings['fs'], errors='strict'), parser=ElementTree.XMLParser( target=_MetadataTreeBuilder())) except IOError: @@ -597,8 +623,7 @@ class GenUseLocalDesc(object): resatoms = sorted(reskeys, key=cmp_sort_key(atomcmp)) resdesc = resdict[reskeys[resatoms[-1]]] - output.write(_unicode_decode( - '%s:%s - %s\n' % (cp, flag, resdesc))) + output.write('%s:%s - %s\n' % (cp, flag, resdesc)) output.close() @@ -620,7 +645,8 @@ class _special_filename(_filename_base): self.file_name = file_name self.file_type = guessManifestFileType(file_name) - def file_type_lt(self, a, b): + @staticmethod + def file_type_lt(a, b): """ Defines an ordering between file types. """ @@ -695,12 +721,12 @@ class GenChangeLogs(object): self.returncode |= 2 return - output.write(textwrap.dedent(_unicode_decode('''\ + output.write(textwrap.dedent('''\ # ChangeLog for %s # Copyright 1999-%s Gentoo Foundation; Distributed under the GPL v2 # $Header: $ - ''' % (cp, time.strftime('%Y'))))) + ''' % (cp, time.strftime('%Y')))) # now grab all the commits commits = self.grab(['git', 'rev-list', 'HEAD', '--', '.']).split() @@ -764,11 +790,10 @@ class GenChangeLogs(object): # Reverse the sort order for headers. for c in reversed(changed): if c.startswith('+') and c.endswith('.ebuild'): - output.write(_unicode_decode( - '*%s (%s)\n' % (c[1:-7], date))) + output.write('*%s (%s)\n' % (c[1:-7], date)) wroteheader = True if wroteheader: - output.write(_unicode_decode('\n')) + output.write('\n') # strip ': ', '[] ', and similar body[0] = re.sub(r'^\W*' + re.escape(cp) + r'\W+', '', body[0]) @@ -788,13 +813,12 @@ class GenChangeLogs(object): # don't break filenames on hyphens self._wrapper.break_on_hyphens = False - output.write(_unicode_decode( - self._wrapper.fill( - '%s; %s %s:' % (date, author, ', '.join(changed))))) + output.write(self._wrapper.fill( + '%s; %s %s:' % (date, author, ', '.join(changed)))) # but feel free to break commit messages there self._wrapper.break_on_hyphens = True - output.write(_unicode_decode( - '\n%s\n\n' % '\n'.join(self._wrapper.fill(x) for x in body))) + output.write( + '\n%s\n\n' % '\n'.join(self._wrapper.fill(x) for x in body)) output.close() @@ -827,17 +851,22 @@ class GenChangeLogs(object): self.generate_changelog(cp) def egencache_main(args): - parser, options, atoms = parse_args(args) - - config_root = options.config_root # The calling environment is ignored, so the program is # completely controlled by commandline arguments. env = {} - if options.repo is None: - env['PORTDIR_OVERLAY'] = '' - elif options.portdir_overlay: + if not sys.stdout.isatty(): + portage.output.nocolor() + env['NOCOLOR'] = 'true' + + parser, options, atoms = parse_args(args) + + config_root = options.config_root + + if options.repositories_configuration is not None: + env['PORTAGE_REPOSITORIES'] = options.repositories_configuration + elif options.portdir_overlay is not None: env['PORTDIR_OVERLAY'] = options.portdir_overlay if options.cache_dir is not None: @@ -851,7 +880,8 @@ def egencache_main(args): default_opts = None if not options.ignore_default_opts: - default_opts = settings.get('EGENCACHE_DEFAULT_OPTS', '').split() + default_opts = portage.util.shlex_split( + settings.get('EGENCACHE_DEFAULT_OPTS', '')) if default_opts: parser, options, args = parse_args(default_opts + args) @@ -862,18 +892,50 @@ def egencache_main(args): settings = portage.config(config_root=config_root, local_config=False, env=env) - if not options.update and not options.update_use_local_desc \ - and not options.update_changelogs: + if not (options.update or options.update_use_local_desc or + options.update_changelogs or options.update_manifests): parser.error('No action specified') return 1 + if options.repo is None: + if len(settings.repositories.prepos) == 2: + for repo in settings.repositories: + if repo.name != "DEFAULT": + options.repo = repo.name + break + + if options.repo is None: + parser.error("--repo option is required") + + repo_path = settings.repositories.treemap.get(options.repo) + if repo_path is None: + parser.error("Unable to locate repository named '%s'" % (options.repo,)) + return 1 + + repo_config = settings.repositories.get_repo_for_location(repo_path) + + if options.strict_manifests is not None: + if options.strict_manifests == "y": + settings.features.add("strict") + else: + settings.features.discard("strict") + if options.update and 'metadata-transfer' not in settings.features: - settings.features.add('metadata-transfer') + # Forcibly enable metadata-transfer if portdbapi has a pregenerated + # cache that does not support eclass validation. + cache = repo_config.get_pregenerated_cache( + portage.dbapi.dbapi._known_keys, readonly=True) + if cache is not None and not cache.complete_eclass_entries: + settings.features.add('metadata-transfer') + cache = None settings.lock() portdb = portage.portdbapi(mysettings=settings) + # Limit ebuilds to the specified repo. + portdb.porttrees = [repo_path] + if options.update: if options.cache_dir is not None: # already validated earlier @@ -889,17 +951,71 @@ def egencache_main(args): level=logging.ERROR, noiselevel=-1) return 1 - if options.repo is not None: - repo_path = portdb.getRepositoryPath(options.repo) - if repo_path is None: - parser.error("Unable to locate repository named '%s'" % \ - (options.repo,)) - return 1 + if options.sign_manifests is not None: + repo_config.sign_manifest = options.sign_manifests == 'y' - # Limit ebuilds to the specified repo. - portdb.porttrees = [repo_path] - else: - portdb.porttrees = [portdb.porttree_root] + if options.thin_manifests is not None: + repo_config.thin_manifest = options.thin_manifests == 'y' + + gpg_cmd = None + gpg_vars = None + force_sign_key = None + + if options.update_manifests: + if repo_config.sign_manifest: + + sign_problem = False + gpg_dir = None + gpg_cmd = settings.get("PORTAGE_GPG_SIGNING_COMMAND") + if gpg_cmd is None: + writemsg_level("egencache: error: " + "PORTAGE_GPG_SIGNING_COMMAND is unset! " + "Is make.globals missing?\n", + level=logging.ERROR, noiselevel=-1) + sign_problem = True + elif "${PORTAGE_GPG_KEY}" in gpg_cmd and \ + options.gpg_key is None and \ + "PORTAGE_GPG_KEY" not in settings: + writemsg_level("egencache: error: " + "PORTAGE_GPG_KEY is unset!\n", + level=logging.ERROR, noiselevel=-1) + sign_problem = True + elif "${PORTAGE_GPG_DIR}" in gpg_cmd: + if options.gpg_dir is not None: + gpg_dir = options.gpg_dir + elif "PORTAGE_GPG_DIR" not in settings: + gpg_dir = os.path.expanduser("~/.gnupg") + else: + gpg_dir = os.path.expanduser(settings["PORTAGE_GPG_DIR"]) + if not os.access(gpg_dir, os.X_OK): + writemsg_level(("egencache: error: " + "Unable to access directory: " + "PORTAGE_GPG_DIR='%s'\n") % gpg_dir, + level=logging.ERROR, noiselevel=-1) + sign_problem = True + + if sign_problem: + writemsg_level("egencache: You may disable manifest " + "signatures with --sign-manifests=n or by setting " + "\"sign-manifests = false\" in metadata/layout.conf\n", + level=logging.ERROR, noiselevel=-1) + return 1 + + gpg_vars = {} + if gpg_dir is not None: + gpg_vars["PORTAGE_GPG_DIR"] = gpg_dir + gpg_var_names = [] + if options.gpg_key is None: + gpg_var_names.append("PORTAGE_GPG_KEY") + else: + gpg_vars["PORTAGE_GPG_KEY"] = options.gpg_key + + for k in gpg_var_names: + v = settings.get(k) + if v is not None: + gpg_vars[k] = v + + force_sign_key = gpg_vars.get("PORTAGE_GPG_KEY") ret = [os.EX_OK] @@ -918,6 +1034,29 @@ def egencache_main(args): else: ret.append(gen_cache.returncode) + if options.update_manifests: + + cp_iter = None + if atoms: + cp_iter = iter(atoms) + + event_loop = global_event_loop() + scheduler = ManifestScheduler(portdb, cp_iter=cp_iter, + gpg_cmd=gpg_cmd, gpg_vars=gpg_vars, + force_sign_key=force_sign_key, + max_jobs=options.jobs, + max_load=options.load_average, + event_loop=event_loop) + + signum = run_main_scheduler(scheduler) + if signum is not None: + sys.exit(128 + signum) + + if options.tolerant: + ret.append(os.EX_OK) + else: + ret.append(scheduler.returncode) + if options.update_use_local_desc: gen_desc = GenUseLocalDesc(portdb, output=options.uld_output, @@ -930,6 +1069,16 @@ def egencache_main(args): gen_clogs.run() ret.append(gen_clogs.returncode) + if options.write_timestamp: + timestamp_path = os.path.join(repo_path, 'metadata', 'timestamp.chk') + try: + with open(timestamp_path, 'w') as f: + f.write(time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime())) + except IOError: + ret.append(os.EX_IOERR) + else: + ret.append(os.EX_OK) + return max(ret) if __name__ == "__main__": diff --git a/portage_with_autodep/bin/emaint b/portage_with_autodep/bin/emaint index 1bee0fe..adf44d0 100755 --- a/portage_with_autodep/bin/emaint +++ b/portage_with_autodep/bin/emaint @@ -1,654 +1,42 @@ #!/usr/bin/python -O -# vim: noet : +# Copyright 2005-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +"""System health checks and maintenance utilities. +""" from __future__ import print_function -import errno -import re -import signal -import stat import sys -import textwrap -import time -from optparse import OptionParser, OptionValueError - +import errno +# This block ensures that ^C interrupts are handled quietly. try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - -from portage import os -from portage.util import writemsg - -if sys.hexversion >= 0x3000000: - long = int - -class WorldHandler(object): - - short_desc = "Fix problems in the world file" - - def name(): - return "world" - name = staticmethod(name) - - def __init__(self): - self.invalid = [] - self.not_installed = [] - self.invalid_category = [] - self.okay = [] - from portage._sets import load_default_config - setconfig = load_default_config(portage.settings, - portage.db[portage.settings['EROOT']]) - self._sets = setconfig.getSets() - - def _check_world(self, onProgress): - categories = set(portage.settings.categories) - eroot = portage.settings['EROOT'] - self.world_file = os.path.join(eroot, portage.const.WORLD_FILE) - self.found = os.access(self.world_file, os.R_OK) - vardb = portage.db[eroot]["vartree"].dbapi - - from portage._sets import SETPREFIX - sets = self._sets - world_atoms = list(sets["selected"]) - maxval = len(world_atoms) - if onProgress: - onProgress(maxval, 0) - for i, atom in enumerate(world_atoms): - if not isinstance(atom, portage.dep.Atom): - if atom.startswith(SETPREFIX): - s = atom[len(SETPREFIX):] - if s in sets: - self.okay.append(atom) - else: - self.not_installed.append(atom) - else: - self.invalid.append(atom) - if onProgress: - onProgress(maxval, i+1) - continue - okay = True - if not vardb.match(atom): - self.not_installed.append(atom) - okay = False - if portage.catsplit(atom.cp)[0] not in categories: - self.invalid_category.append(atom) - okay = False - if okay: - self.okay.append(atom) - if onProgress: - onProgress(maxval, i+1) - - def check(self, onProgress=None): - self._check_world(onProgress) - errors = [] - if self.found: - errors += ["'%s' is not a valid atom" % x for x in self.invalid] - errors += ["'%s' is not installed" % x for x in self.not_installed] - errors += ["'%s' has a category that is not listed in /etc/portage/categories" % x for x in self.invalid_category] - else: - errors.append(self.world_file + " could not be opened for reading") - return errors - - def fix(self, onProgress=None): - world_set = self._sets["selected"] - world_set.lock() - try: - world_set.load() # maybe it's changed on disk - before = set(world_set) - self._check_world(onProgress) - after = set(self.okay) - errors = [] - if before != after: - try: - world_set.replace(self.okay) - except portage.exception.PortageException: - errors.append("%s could not be opened for writing" % \ - self.world_file) - return errors - finally: - world_set.unlock() - -class BinhostHandler(object): - - short_desc = "Generate a metadata index for binary packages" - - def name(): - return "binhost" - name = staticmethod(name) - - def __init__(self): - eroot = portage.settings['EROOT'] - self._bintree = portage.db[eroot]["bintree"] - self._bintree.populate() - self._pkgindex_file = self._bintree._pkgindex_file - self._pkgindex = self._bintree._load_pkgindex() - - def _need_update(self, cpv, data): - - if "MD5" not in data: - return True - - size = data.get("SIZE") - if size is None: - return True - - mtime = data.get("MTIME") - if mtime is None: - return True - - pkg_path = self._bintree.getname(cpv) - try: - s = os.lstat(pkg_path) - except OSError as e: - if e.errno not in (errno.ENOENT, errno.ESTALE): - raise - # We can't update the index for this one because - # it disappeared. - return False - - try: - if long(mtime) != s[stat.ST_MTIME]: - return True - if long(size) != long(s.st_size): - return True - except ValueError: - return True - - return False - - def check(self, onProgress=None): - missing = [] - cpv_all = self._bintree.dbapi.cpv_all() - cpv_all.sort() - maxval = len(cpv_all) - if onProgress: - onProgress(maxval, 0) - pkgindex = self._pkgindex - missing = [] - metadata = {} - for d in pkgindex.packages: - metadata[d["CPV"]] = d - for i, cpv in enumerate(cpv_all): - d = metadata.get(cpv) - if not d or self._need_update(cpv, d): - missing.append(cpv) - if onProgress: - onProgress(maxval, i+1) - errors = ["'%s' is not in Packages" % cpv for cpv in missing] - stale = set(metadata).difference(cpv_all) - for cpv in stale: - errors.append("'%s' is not in the repository" % cpv) - return errors - - def fix(self, onProgress=None): - bintree = self._bintree - cpv_all = self._bintree.dbapi.cpv_all() - cpv_all.sort() - missing = [] - maxval = 0 - if onProgress: - onProgress(maxval, 0) - pkgindex = self._pkgindex - missing = [] - metadata = {} - for d in pkgindex.packages: - metadata[d["CPV"]] = d - - for i, cpv in enumerate(cpv_all): - d = metadata.get(cpv) - if not d or self._need_update(cpv, d): - missing.append(cpv) - - stale = set(metadata).difference(cpv_all) - if missing or stale: - from portage import locks - pkgindex_lock = locks.lockfile( - self._pkgindex_file, wantnewlockfile=1) - try: - # Repopulate with lock held. - bintree._populate() - cpv_all = self._bintree.dbapi.cpv_all() - cpv_all.sort() - - pkgindex = bintree._load_pkgindex() - self._pkgindex = pkgindex - - metadata = {} - for d in pkgindex.packages: - metadata[d["CPV"]] = d - - # Recount missing packages, with lock held. - del missing[:] - for i, cpv in enumerate(cpv_all): - d = metadata.get(cpv) - if not d or self._need_update(cpv, d): - missing.append(cpv) - - maxval = len(missing) - for i, cpv in enumerate(missing): - try: - metadata[cpv] = bintree._pkgindex_entry(cpv) - except portage.exception.InvalidDependString: - writemsg("!!! Invalid binary package: '%s'\n" % \ - bintree.getname(cpv), noiselevel=-1) - - if onProgress: - onProgress(maxval, i+1) - - for cpv in set(metadata).difference( - self._bintree.dbapi.cpv_all()): - del metadata[cpv] - - # We've updated the pkgindex, so set it to - # repopulate when necessary. - bintree.populated = False - - del pkgindex.packages[:] - pkgindex.packages.extend(metadata.values()) - from portage.util import atomic_ofstream - f = atomic_ofstream(self._pkgindex_file) - try: - self._pkgindex.write(f) - finally: - f.close() - finally: - locks.unlockfile(pkgindex_lock) - - if onProgress: - if maxval == 0: - maxval = 1 - onProgress(maxval, maxval) - return None - -class MoveHandler(object): - - def __init__(self, tree, porttree): - self._tree = tree - self._portdb = porttree.dbapi - self._update_keys = ["DEPEND", "RDEPEND", "PDEPEND", "PROVIDE"] - self._master_repo = \ - self._portdb.getRepositoryName(self._portdb.porttree_root) - - def _grab_global_updates(self): - from portage.update import grab_updates, parse_updates - retupdates = {} - errors = [] - - for repo_name in self._portdb.getRepositories(): - repo = self._portdb.getRepositoryPath(repo_name) - updpath = os.path.join(repo, "profiles", "updates") - if not os.path.isdir(updpath): - continue - - try: - rawupdates = grab_updates(updpath) - except portage.exception.DirectoryNotFound: - rawupdates = [] - upd_commands = [] - for mykey, mystat, mycontent in rawupdates: - commands, errors = parse_updates(mycontent) - upd_commands.extend(commands) - errors.extend(errors) - retupdates[repo_name] = upd_commands - - if self._master_repo in retupdates: - retupdates['DEFAULT'] = retupdates[self._master_repo] + import signal - return retupdates, errors + def exithandler(signum, _frame): + signal.signal(signal.SIGINT, signal.SIG_IGN) + signal.signal(signal.SIGTERM, signal.SIG_IGN) + sys.exit(128 + signum) - def check(self, onProgress=None): - allupdates, errors = self._grab_global_updates() - # Matching packages and moving them is relatively fast, so the - # progress bar is updated in indeterminate mode. - match = self._tree.dbapi.match - aux_get = self._tree.dbapi.aux_get - if onProgress: - onProgress(0, 0) - for repo, updates in allupdates.items(): - if repo == 'DEFAULT': - continue - if not updates: - continue + signal.signal(signal.SIGINT, exithandler) + signal.signal(signal.SIGTERM, exithandler) + signal.signal(signal.SIGPIPE, signal.SIG_DFL) - def repo_match(repository): - return repository == repo or \ - (repo == self._master_repo and \ - repository not in allupdates) +except KeyboardInterrupt: + sys.exit(1) - for i, update_cmd in enumerate(updates): - if update_cmd[0] == "move": - origcp, newcp = update_cmd[1:] - for cpv in match(origcp): - if repo_match(aux_get(cpv, ["repository"])[0]): - errors.append("'%s' moved to '%s'" % (cpv, newcp)) - elif update_cmd[0] == "slotmove": - pkg, origslot, newslot = update_cmd[1:] - for cpv in match(pkg): - slot, prepo = aux_get(cpv, ["SLOT", "repository"]) - if slot == origslot and repo_match(prepo): - errors.append("'%s' slot moved from '%s' to '%s'" % \ - (cpv, origslot, newslot)) - if onProgress: - onProgress(0, 0) +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True +from portage.emaint.main import emaint_main - # Searching for updates in all the metadata is relatively slow, so this - # is where the progress bar comes out of indeterminate mode. - cpv_all = self._tree.dbapi.cpv_all() - cpv_all.sort() - maxval = len(cpv_all) - aux_update = self._tree.dbapi.aux_update - meta_keys = self._update_keys + ['repository'] - from portage.update import update_dbentries - if onProgress: - onProgress(maxval, 0) - for i, cpv in enumerate(cpv_all): - metadata = dict(zip(meta_keys, aux_get(cpv, meta_keys))) - repository = metadata.pop('repository') - try: - updates = allupdates[repository] - except KeyError: - try: - updates = allupdates['DEFAULT'] - except KeyError: - continue - if not updates: - continue - metadata_updates = update_dbentries(updates, metadata) - if metadata_updates: - errors.append("'%s' has outdated metadata" % cpv) - if onProgress: - onProgress(maxval, i+1) - return errors - - def fix(self, onProgress=None): - allupdates, errors = self._grab_global_updates() - # Matching packages and moving them is relatively fast, so the - # progress bar is updated in indeterminate mode. - move = self._tree.dbapi.move_ent - slotmove = self._tree.dbapi.move_slot_ent - if onProgress: - onProgress(0, 0) - for repo, updates in allupdates.items(): - if repo == 'DEFAULT': - continue - if not updates: - continue - - def repo_match(repository): - return repository == repo or \ - (repo == self._master_repo and \ - repository not in allupdates) - - for i, update_cmd in enumerate(updates): - if update_cmd[0] == "move": - move(update_cmd, repo_match=repo_match) - elif update_cmd[0] == "slotmove": - slotmove(update_cmd, repo_match=repo_match) - if onProgress: - onProgress(0, 0) - - # Searching for updates in all the metadata is relatively slow, so this - # is where the progress bar comes out of indeterminate mode. - self._tree.dbapi.update_ents(allupdates, onProgress=onProgress) - return errors - -class MoveInstalled(MoveHandler): - - short_desc = "Perform package move updates for installed packages" - - def name(): - return "moveinst" - name = staticmethod(name) - def __init__(self): - eroot = portage.settings['EROOT'] - MoveHandler.__init__(self, portage.db[eroot]["vartree"], portage.db[eroot]["porttree"]) - -class MoveBinary(MoveHandler): - - short_desc = "Perform package move updates for binary packages" - - def name(): - return "movebin" - name = staticmethod(name) - def __init__(self): - eroot = portage.settings['EROOT'] - MoveHandler.__init__(self, portage.db[eroot]["bintree"], portage.db[eroot]['porttree']) - -class VdbKeyHandler(object): - def name(): - return "vdbkeys" - name = staticmethod(name) - - def __init__(self): - self.list = portage.db[portage.settings["EROOT"]]["vartree"].dbapi.cpv_all() - self.missing = [] - self.keys = ["HOMEPAGE", "SRC_URI", "KEYWORDS", "DESCRIPTION"] - - for p in self.list: - mydir = os.path.join(portage.settings["EROOT"], portage.const.VDB_PATH, p)+os.sep - ismissing = True - for k in self.keys: - if os.path.exists(mydir+k): - ismissing = False - break - if ismissing: - self.missing.append(p) - - def check(self): - return ["%s has missing keys" % x for x in self.missing] - - def fix(self): - - errors = [] - - for p in self.missing: - mydir = os.path.join(portage.settings["EROOT"], portage.const.VDB_PATH, p)+os.sep - if not os.access(mydir+"environment.bz2", os.R_OK): - errors.append("Can't access %s" % (mydir+"environment.bz2")) - elif not os.access(mydir, os.W_OK): - errors.append("Can't create files in %s" % mydir) - else: - env = os.popen("bzip2 -dcq "+mydir+"environment.bz2", "r") - envlines = env.read().split("\n") - env.close() - for k in self.keys: - s = [l for l in envlines if l.startswith(k+"=")] - if len(s) > 1: - errors.append("multiple matches for %s found in %senvironment.bz2" % (k, mydir)) - elif len(s) == 0: - s = "" - else: - s = s[0].split("=",1)[1] - s = s.lstrip("$").strip("\'\"") - s = re.sub("(\\\\[nrt])+", " ", s) - s = " ".join(s.split()).strip() - if s != "": - try: - keyfile = open(mydir+os.sep+k, "w") - keyfile.write(s+"\n") - keyfile.close() - except (IOError, OSError) as e: - errors.append("Could not write %s, reason was: %s" % (mydir+k, e)) - - return errors - -class ProgressHandler(object): - def __init__(self): - self.curval = 0 - self.maxval = 0 - self.last_update = 0 - self.min_display_latency = 0.2 - - def onProgress(self, maxval, curval): - self.maxval = maxval - self.curval = curval - cur_time = time.time() - if cur_time - self.last_update >= self.min_display_latency: - self.last_update = cur_time - self.display() - - def display(self): - raise NotImplementedError(self) - -class CleanResume(object): - - short_desc = "Discard emerge --resume merge lists" - - def name(): - return "cleanresume" - name = staticmethod(name) - - def check(self, onProgress=None): - messages = [] - mtimedb = portage.mtimedb - resume_keys = ("resume", "resume_backup") - maxval = len(resume_keys) - if onProgress: - onProgress(maxval, 0) - for i, k in enumerate(resume_keys): - try: - d = mtimedb.get(k) - if d is None: - continue - if not isinstance(d, dict): - messages.append("unrecognized resume list: '%s'" % k) - continue - mergelist = d.get("mergelist") - if mergelist is None or not hasattr(mergelist, "__len__"): - messages.append("unrecognized resume list: '%s'" % k) - continue - messages.append("resume list '%s' contains %d packages" % \ - (k, len(mergelist))) - finally: - if onProgress: - onProgress(maxval, i+1) - return messages - - def fix(self, onProgress=None): - delete_count = 0 - mtimedb = portage.mtimedb - resume_keys = ("resume", "resume_backup") - maxval = len(resume_keys) - if onProgress: - onProgress(maxval, 0) - for i, k in enumerate(resume_keys): - try: - if mtimedb.pop(k, None) is not None: - delete_count += 1 - finally: - if onProgress: - onProgress(maxval, i+1) - if delete_count: - mtimedb.commit() - -def emaint_main(myargv): - - # Similar to emerge, emaint needs a default umask so that created - # files (such as the world file) have sane permissions. - os.umask(0o22) - - # TODO: Create a system that allows external modules to be added without - # the need for hard coding. - modules = { - "world" : WorldHandler, - "binhost":BinhostHandler, - "moveinst":MoveInstalled, - "movebin":MoveBinary, - "cleanresume":CleanResume - } - - module_names = list(modules) - module_names.sort() - module_names.insert(0, "all") - - def exclusive(option, *args, **kw): - var = kw.get("var", None) - if var is None: - raise ValueError("var not specified to exclusive()") - if getattr(parser, var, ""): - raise OptionValueError("%s and %s are exclusive options" % (getattr(parser, var), option)) - setattr(parser, var, str(option)) - - - usage = "usage: emaint [options] COMMAND" - - desc = "The emaint program provides an interface to system health " + \ - "checks and maintenance. See the emaint(1) man page " + \ - "for additional information about the following commands:" - - usage += "\n\n" - for line in textwrap.wrap(desc, 65): - usage += "%s\n" % line - usage += "\n" - usage += " %s" % "all".ljust(15) + \ - "Perform all supported commands\n" - for m in module_names[1:]: - usage += " %s%s\n" % (m.ljust(15), modules[m].short_desc) - - parser = OptionParser(usage=usage, version=portage.VERSION) - parser.add_option("-c", "--check", help="check for problems", - action="callback", callback=exclusive, callback_kwargs={"var":"action"}) - parser.add_option("-f", "--fix", help="attempt to fix problems", - action="callback", callback=exclusive, callback_kwargs={"var":"action"}) - parser.action = None - - - (options, args) = parser.parse_args(args=myargv) - if len(args) != 1: - parser.error("Incorrect number of arguments") - if args[0] not in module_names: - parser.error("%s target is not a known target" % args[0]) - - if parser.action: - action = parser.action - else: - print("Defaulting to --check") - action = "-c/--check" - - if args[0] == "all": - tasks = modules.values() - else: - tasks = [modules[args[0]]] - - - if action == "-c/--check": - status = "Checking %s for problems" - func = "check" - else: - status = "Attempting to fix %s" - func = "fix" - - isatty = os.environ.get('TERM') != 'dumb' and sys.stdout.isatty() - for task in tasks: - print(status % task.name()) - inst = task() - onProgress = None - if isatty: - progressBar = portage.output.TermProgressBar() - progressHandler = ProgressHandler() - onProgress = progressHandler.onProgress - def display(): - progressBar.set(progressHandler.curval, progressHandler.maxval) - progressHandler.display = display - def sigwinch_handler(signum, frame): - lines, progressBar.term_columns = \ - portage.output.get_term_size() - signal.signal(signal.SIGWINCH, sigwinch_handler) - result = getattr(inst, func)(onProgress=onProgress) - if isatty: - # make sure the final progress is displayed - progressHandler.display() - print() - signal.signal(signal.SIGWINCH, signal.SIG_DFL) - if result: - print() - print("\n".join(result)) - print("\n") - - print("Finished") - -if __name__ == "__main__": +try: emaint_main(sys.argv[1:]) +except IOError as e: + if e.errno == errno.EACCES: + print("\nemaint: Need superuser access") + sys.exit(1) + else: + raise diff --git a/portage_with_autodep/bin/emerge b/portage_with_autodep/bin/emerge index 6f69244..4d9ea5a 100755 --- a/portage_with_autodep/bin/emerge +++ b/portage_with_autodep/bin/emerge @@ -1,66 +1,79 @@ #!/usr/bin/python -# Copyright 2006-2011 Gentoo Foundation +# Copyright 2006-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function +import platform import signal import sys -# This block ensures that ^C interrupts are handled quietly. + +# This block ensures that ^C interrupts are handled quietly. We handle +# KeyboardInterrupt instead of installing a SIGINT handler, since +# exiting from signal handlers intermittently causes python to ignore +# the SystemExit exception with a message like this: +# Exception SystemExit: 130 in ignored try: - def exithandler(signum,frame): - signal.signal(signal.SIGINT, signal.SIG_IGN) + def exithandler(signum, _frame): signal.signal(signal.SIGTERM, signal.SIG_IGN) sys.exit(128 + signum) - signal.signal(signal.SIGINT, exithandler) signal.signal(signal.SIGTERM, exithandler) # Prevent "[Errno 32] Broken pipe" exceptions when # writing to a pipe. signal.signal(signal.SIGPIPE, signal.SIG_DFL) -except KeyboardInterrupt: - sys.exit(128 + signal.SIGINT) + def debug_signal(_signum, _frame): + import pdb + pdb.set_trace() -def debug_signal(signum, frame): - import pdb - pdb.set_trace() -signal.signal(signal.SIGUSR1, debug_signal) + if platform.python_implementation() == 'Jython': + debug_signum = signal.SIGUSR2 # bug #424259 + else: + debug_signum = signal.SIGUSR1 + + signal.signal(debug_signum, debug_signal) -try: - from _emerge.main import emerge_main -except ImportError: from os import path as osp - import sys - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) + pym_path = osp.join(osp.dirname(osp.dirname( + osp.realpath(__file__))), "pym") + sys.path.insert(0, pym_path) + import portage + portage._internal_caller = True + portage._disable_legacy_globals() from _emerge.main import emerge_main -if __name__ == "__main__": - import sys - from portage.exception import ParseError, PermissionDenied - try: - retval = emerge_main() - except PermissionDenied as e: - sys.stderr.write("Permission denied: '%s'\n" % str(e)) - sys.exit(e.errno) - except ParseError as e: - sys.stderr.write("%s\n" % str(e)) - sys.exit(1) - except SystemExit: - raise - except Exception: - # If an unexpected exception occurs then we don't want the mod_echo - # output to obscure the traceback, so dump the mod_echo output before - # showing the traceback. - import traceback - tb_str = traceback.format_exc() + if __name__ == "__main__": + from portage.exception import ParseError, PermissionDenied try: - from portage.elog import mod_echo - except ImportError: - pass - else: - mod_echo.finalize() - sys.stderr.write(tb_str) - sys.exit(1) - sys.exit(retval) + retval = emerge_main() + except PermissionDenied as e: + sys.stderr.write("Permission denied: '%s'\n" % str(e)) + sys.exit(e.errno) + except ParseError as e: + sys.stderr.write("%s\n" % str(e)) + sys.exit(1) + except (KeyboardInterrupt, SystemExit): + raise + except Exception: + # If an unexpected exception occurs then we don't want the + # mod_echo output to obscure the traceback, so dump the + # mod_echo output before showing the traceback. + import traceback + tb_str = traceback.format_exc() + try: + from portage.elog import mod_echo + except ImportError: + pass + else: + mod_echo.finalize() + sys.stderr.write(tb_str) + sys.exit(1) + sys.exit(retval) + +except KeyboardInterrupt: + sys.stderr.write("\n\nExiting on signal %(signal)s\n" % + {"signal": signal.SIGINT}) + sys.stderr.flush() + sys.exit(128 + signal.SIGINT) diff --git a/portage_with_autodep/bin/emerge-webrsync b/portage_with_autodep/bin/emerge-webrsync index bfd9aa2..85730a2 100755 --- a/portage_with_autodep/bin/emerge-webrsync +++ b/portage_with_autodep/bin/emerge-webrsync @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # Author: Karl Trygve Kalleberg # Rewritten from the old, Perl-based emerge-webrsync script @@ -22,9 +22,9 @@ vvecho() { [[ ${do_verbose} -eq 1 ]] && echo "$@" ; } # Only echo if not in verbose mode nvecho() { [[ ${do_verbose} -eq 0 ]] && echo "$@" ; } # warning echos -wecho() { echo "${argv0}: warning: $*" 1>&2 ; } +wecho() { echo "${argv0##*/}: warning: $*" 1>&2 ; } # error echos -eecho() { echo "${argv0}: error: $*" 1>&2 ; } +eecho() { echo "${argv0##*/}: error: $*" 1>&2 ; } argv0=$0 @@ -39,23 +39,33 @@ else eecho "could not find 'portageq'; aborting" exit 1 fi -eval $("${portageq}" envvar -v FEATURES FETCHCOMMAND GENTOO_MIRRORS \ - PORTAGE_BIN_PATH PORTAGE_GPG_DIR \ - PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS PORTAGE_TMPDIR PORTDIR \ - SYNC http_proxy ftp_proxy) -DISTDIR="${PORTAGE_TMPDIR}/emerge-webrsync" +eval "$("${portageq}" envvar -v DISTDIR EPREFIX FEATURES \ + FETCHCOMMAND GENTOO_MIRRORS \ + PORTAGE_BIN_PATH PORTAGE_CONFIGROOT PORTAGE_GPG_DIR \ + PORTAGE_NICENESS PORTAGE_REPOSITORIES PORTAGE_RSYNC_EXTRA_OPTS \ + PORTAGE_RSYNC_OPTS PORTAGE_TMPDIR \ + USERLAND http_proxy ftp_proxy)" export http_proxy ftp_proxy +source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 + +repo_name=gentoo +repo_location=$(__repo_key "${repo_name}" location) +if [[ -z ${repo_location} ]]; then + eecho "Repository '${repo_name}' not found" + exit 1 +fi +repo_sync_type=$(__repo_key "${repo_name}" sync-type) + # If PORTAGE_NICENESS is overriden via the env then it will # still pass through the portageq call and override properly. if [ -n "${PORTAGE_NICENESS}" ]; then renice $PORTAGE_NICENESS $$ > /dev/null fi -source "${PORTAGE_BIN_PATH}"/isolated-functions.sh || exit 1 - do_verbose=0 do_debug=0 +keep=false if has webrsync-gpg ${FEATURES} ; then WEBSYNC_VERIFY_SIGNATURE=1 @@ -99,7 +109,9 @@ get_date_part() { get_utc_second_from_string() { local s="$1" if [[ ${USERLAND} == BSD ]] ; then - date -juf "%Y%m%d" "$s" +"%s" + # Specify zeros for the least significant digits, or else those + # digits are inherited from the current system clock time. + date -juf "%Y%m%d%H%M.%S" "${s}0000.00" +"%s" else date -d "${s:0:4}-${s:4:2}-${s:6:2}" -u +"%s" fi @@ -108,8 +120,8 @@ get_utc_second_from_string() { get_portage_timestamp() { local portage_current_timestamp=0 - if [ -f "${PORTDIR}/metadata/timestamp.x" ]; then - portage_current_timestamp=$(cut -f 1 -d " " "${PORTDIR}/metadata/timestamp.x" ) + if [ -f "${repo_location}/metadata/timestamp.x" ]; then + portage_current_timestamp=$(cut -f 1 -d " " "${repo_location}/metadata/timestamp.x" ) fi echo "${portage_current_timestamp}" @@ -125,13 +137,18 @@ fetch_file() { elif [ "${FETCHCOMMAND/curl/}" != "${FETCHCOMMAND}" ]; then opts="--continue-at - $(nvecho -s -f)" else - rm -f "${FILE}" + rm -f "${DISTDIR}/${FILE}" fi - vecho "Fetching file ${FILE} ..." + __vecho "Fetching file ${FILE} ..." # already set DISTDIR= - eval "${FETCHCOMMAND}" ${opts} - [ -s "${FILE}" ] + eval "${FETCHCOMMAND} ${opts}" + if [[ $? -eq 0 && -s ${DISTDIR}/${FILE} ]] ; then + return 0 + else + rm -f "${DISTDIR}/${FILE}" + return 1 + fi } check_file_digest() { @@ -139,10 +156,12 @@ check_file_digest() { local file="$2" local r=1 - vecho "Checking digest ..." + __vecho "Checking digest ..." if type -P md5sum > /dev/null; then - md5sum -c $digest && r=0 + local md5sum_output=$(md5sum "${file}") + local digest_content=$(< "${digest}") + [ "${md5sum_output%%[[:space:]]*}" = "${digest_content%%[[:space:]]*}" ] && r=0 elif type -P md5 > /dev/null; then [ "$(md5 -q "${file}")" == "$(cut -d ' ' -f 1 "${digest}")" ] && r=0 else @@ -159,7 +178,7 @@ check_file_signature() { if [ ${WEBSYNC_VERIFY_SIGNATURE} != 0 ]; then - vecho "Checking signature ..." + __vecho "Checking signature ..." if type -P gpg > /dev/null; then gpg --homedir "${PORTAGE_GPG_DIR}" --verify "$signature" "$file" && r=0 @@ -183,13 +202,25 @@ get_snapshot_timestamp() { sync_local() { local file="$1" - vecho "Syncing local tree ..." + __vecho "Syncing local tree ..." + + local ownership="portage:portage" + if has usersync ${FEATURES} ; then + case "${USERLAND}" in + BSD) + ownership=$(stat -f '%Su:%Sg' "${repo_location}") + ;; + *) + ownership=$(stat -c '%U:%G' "${repo_location}") + ;; + esac + fi if type -P tarsync > /dev/null ; then - local chown_opts="-o portage -g portage" - chown portage:portage portage > /dev/null 2>&1 || chown_opts="" + local chown_opts="-o ${ownership%:*} -g ${ownership#*:}" + chown ${ownership} "${repo_location}" > /dev/null 2>&1 || chown_opts="" if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \ - -e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then + -e /distfiles -e /packages -e /local "${file}" "${repo_location}"; then eecho "tarsync failed; tarball is corrupt? (${file})" return 1 fi @@ -201,27 +232,29 @@ sync_local() { fi # Free disk space - rm -f "${file}" + ${keep} || rm -f "${file}" - chown portage:portage portage > /dev/null 2>&1 && \ - chown -R portage:portage portage + local rsync_opts="${PORTAGE_RSYNC_OPTS} ${PORTAGE_RSYNC_EXTRA_OPTS}" + if chown ${ownership} portage > /dev/null 2>&1; then + chown -R ${ownership} portage + rsync_opts+=" --owner --group" + fi cd portage - rsync -av --progress --stats --delete --delete-after \ - --exclude='/distfiles' --exclude='/packages' \ - --exclude='/local' ${PORTAGE_RSYNC_EXTRA_OPTS} . "${PORTDIR%%/}" + rsync ${rsync_opts} . "${repo_location%%/}" cd .. - vecho "Cleaning up ..." + __vecho "Cleaning up ..." rm -fr portage fi if has metadata-transfer ${FEATURES} ; then - vecho "Updating cache ..." - emerge --metadata + __vecho "Updating cache ..." + "${PORTAGE_BIN_PATH}/emerge" --metadata fi - [ -x /etc/portage/bin/post_sync ] && /etc/portage/bin/post_sync + local post_sync=${PORTAGE_CONFIGROOT}etc/portage/bin/post_sync + [ -x "${post_sync}" ] && "${post_sync}" # --quiet suppresses output if there are no relevant news items - has news ${FEATURES} && emerge --check-news --quiet + has news ${FEATURES} && "${PORTAGE_BIN_PATH}/emerge" --check-news --quiet return 0 } @@ -251,14 +284,15 @@ do_snapshot() { for mirror in ${GENTOO_MIRRORS} ; do - vecho "Trying to retrieve ${date} snapshot from ${mirror} ..." + mirror=${mirror%/} + __vecho "Trying to retrieve ${date} snapshot from ${mirror} ..." for compression in ${compressions} ; do local file="portage-${date}.tar.${compression}" local digest="${file}.md5sum" local signature="${file}.gpgsig" - if [ -s "${file}" -a -s "${digest}" -a -s "${signature}" ] ; then + if [ -s "${DISTDIR}/${file}" -a -s "${DISTDIR}/${digest}" -a -s "${DISTDIR}/${signature}" ] ; then check_file_digest "${DISTDIR}/${digest}" "${DISTDIR}/${file}" && \ check_file_signature "${DISTDIR}/${signature}" "${DISTDIR}/${file}" && \ have_files=1 @@ -280,8 +314,8 @@ do_snapshot() { # if [ ${have_files} -eq 1 ]; then - vecho "Getting snapshot timestamp ..." - local snapshot_timestamp=$(get_snapshot_timestamp "${file}") + __vecho "Getting snapshot timestamp ..." + local snapshot_timestamp=$(get_snapshot_timestamp "${DISTDIR}/${file}") if [ ${ignore_timestamp} == 0 ]; then if [ ${snapshot_timestamp} -lt $(get_portage_timestamp) ]; then @@ -310,7 +344,7 @@ do_snapshot() { # # Remove files and use a different mirror # - rm -f "${file}" "${digest}" "${signature}" + rm -f "${DISTDIR}/${file}" "${DISTDIR}/${digest}" "${DISTDIR}/${signature}" fi done @@ -318,12 +352,12 @@ do_snapshot() { done if [ ${have_files} -eq 1 ]; then - sync_local "${file}" && r=0 + sync_local "${DISTDIR}/${file}" && r=0 else - vecho "${date} snapshot was not found" + __vecho "${date} snapshot was not found" fi - - rm -f "${file}" "${digest}" "${signature}" + + ${keep} || rm -f "${DISTDIR}/${file}" "${DISTDIR}/${digest}" "${DISTDIR}/${signature}" return "${r}" } @@ -331,9 +365,9 @@ do_latest_snapshot() { local attempts=0 local r=1 - vecho "Fetching most recent snapshot ..." + __vecho "Fetching most recent snapshot ..." - # The snapshot for a given day is generated at 01:45 UTC on the following + # The snapshot for a given day is generated at 00:45 UTC on the following # day, so the current day's snapshot (going by UTC time) hasn't been # generated yet. Therefore, always start by looking for the previous day's # snapshot (for attempts=1, subtract 1 day from the current UTC time). @@ -349,10 +383,10 @@ do_latest_snapshot() { local start_time=$(get_utc_date_in_seconds) local start_hour=$(get_date_part ${start_time} "%H") - # Daily snapshots are created at 1:45 AM and are not - # available until after 2 AM. Don't waste time trying + # Daily snapshots are created at 00:45 and are not + # available until after 01:00. Don't waste time trying # to fetch a snapshot before it's been created. - if [ ${start_hour} -lt 2 ] ; then + if [ ${start_hour} -lt 1 ] ; then (( start_time -= 86400 )) fi local snapshot_date=$(get_date_part ${start_time} "%Y%m%d") @@ -361,8 +395,8 @@ do_latest_snapshot() { while (( ${attempts} < 40 )) ; do (( attempts++ )) (( snapshot_date_seconds -= 86400 )) - # snapshots are created at 1:45 AM - (( approx_snapshot_time = snapshot_date_seconds + 86400 + 6300 )) + # snapshots are created at 00:45 + (( approx_snapshot_time = snapshot_date_seconds + 86400 + 2700 )) (( timestamp_difference = existing_timestamp - approx_snapshot_time )) [ ${timestamp_difference} -lt 0 ] && (( timestamp_difference = -1 * timestamp_difference )) snapshot_date=$(get_date_part ${snapshot_date_seconds} "%Y%m%d") @@ -388,7 +422,7 @@ do_latest_snapshot() { "snapshot. In order to force sync," \ "use the --revert option or remove" \ "the timestamp file located at" \ - "'${PORTDIR}/metadata/timestamp.x'." | fmt -w 70 | \ + "'${repo_location}/metadata/timestamp.x'." | fmt -w 70 | \ while read -r line ; do ewarn "${line}" done @@ -408,9 +442,10 @@ do_latest_snapshot() { usage() { cat <<-EOF Usage: $0 [options] - + Options: --revert=yyyymmdd Revert to snapshot + -k, --keep Keep snapshots in DISTDIR (don't delete) -q, --quiet Only output errors -v, --verbose Enable verbose output -x, --debug Enable debug output @@ -427,14 +462,12 @@ usage() { main() { local arg local revert_date - - [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}" - cd "${DISTDIR}" for arg in "$@" ; do local v=${arg#*=} case ${arg} in -h|--help) usage ;; + -k|--keep) keep=true ;; -q|--quiet) PORTAGE_QUIET=1 ;; -v|--verbose) do_verbose=1 ;; -x|--debug) do_debug=1 ;; @@ -443,16 +476,39 @@ main() { esac done + [[ -d ${repo_location} ]] || mkdir -p "${repo_location}" + if [[ ! -w ${repo_location} ]] ; then + eecho "Repository '${repo_name}' is not writable: ${repo_location}" + exit 1 + fi + + [[ -d ${PORTAGE_TMPDIR}/portage ]] || mkdir -p "${PORTAGE_TMPDIR}/portage" + TMPDIR=$(mktemp -d "${PORTAGE_TMPDIR}/portage/webrsync-XXXXXX") + if [[ ! -w ${TMPDIR} ]] ; then + eecho "TMPDIR is not writable: ${TMPDIR}" + exit 1 + fi + trap 'cd / ; rm -rf "${TMPDIR}"' EXIT + cd "${TMPDIR}" || exit 1 + + ${keep} || DISTDIR=${TMPDIR} + [ ! -d "${DISTDIR}" ] && mkdir -p "${DISTDIR}" + + if ${keep} && [[ ! -w ${DISTDIR} ]] ; then + eecho "DISTDIR is not writable: ${DISTDIR}" + exit 1 + fi + # This is a sanity check to help prevent people like funtoo users # from accidentally wiping out their git tree. - if [[ -n $SYNC && ${SYNC#rsync:} = $SYNC ]] ; then - echo "The current SYNC variable setting does not refer to an rsync URI:" >&2 + if [[ -n ${repo_sync_type} && ${repo_sync_type} != rsync ]] ; then + echo "The current sync-type attribute of repository 'gentoo' is not set to 'rsync':" >&2 echo >&2 - echo " SYNC=$SYNC" >&2 + echo " sync-type=${repo_sync_type}" >&2 echo >&2 echo "If you intend to use emerge-webrsync then please" >&2 - echo "adjust SYNC to refer to an rsync URI." >&2 - echo "emerge-webrsync exiting due to abnormal SYNC setting." >&2 + echo "adjust sync-type and sync-uri attributes to refer to rsync." >&2 + echo "emerge-webrsync exiting due to abnormal sync-type setting." >&2 exit 1 fi diff --git a/portage_with_autodep/bin/env-update b/portage_with_autodep/bin/env-update index 8a69f2b..b500c54 100755 --- a/portage_with_autodep/bin/env-update +++ b/portage_with_autodep/bin/env-update @@ -1,5 +1,5 @@ #!/usr/bin/python -O -# Copyright 1999-2006 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -25,12 +25,12 @@ if len(sys.argv) > 1: print("!!! Invalid command line options!\n") usage(1) -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True + try: portage.env_update(makelinks) except IOError as e: diff --git a/portage_with_autodep/bin/etc-update b/portage_with_autodep/bin/etc-update index 1edc91f..1a99231 100755 --- a/portage_with_autodep/bin/etc-update +++ b/portage_with_autodep/bin/etc-update @@ -62,7 +62,7 @@ do_mv_ln() { } scan() { - echo "Scanning Configuration files..." + ${QUIET} || echo "Scanning Configuration files..." rm -rf "${TMP}"/files > /dev/null 2>&1 mkdir "${TMP}"/files || die "Failed mkdir command!" count=0 @@ -107,13 +107,13 @@ scan() { for mpath in ${CONFIG_PROTECT_MASK}; do mpath="${EROOT%/}${mpath}" if [[ "${rpath}" == "${mpath}"* ]] ; then - echo "Updating masked file: ${live_file}" + ${QUIET} || echo "Updating masked file: ${live_file}" mv "${cfg_file}" "${live_file}" continue 2 fi done if [[ ! -f ${file} ]] ; then - echo "Skipping non-file ${file} ..." + ${QUIET} || echo "Skipping non-file ${file} ..." continue fi @@ -140,7 +140,7 @@ scan() { fi if [[ ${MATCHES} == 1 ]] ; then - echo "Automerging trivial changes in: ${live_file}" + ${QUIET} || echo "Automerging trivial changes in: ${live_file}" do_mv_ln "${cfg_file}" "${live_file}" continue else @@ -190,6 +190,7 @@ parse_automode_flag() { parse_automode_flag -3 export mv_opts=" ${mv_opts} " mv_opts="${mv_opts// -i / }" + NONINTERACTIVE_MV=true ;; -3) input=0 @@ -547,9 +548,9 @@ die() { local msg=$1 exitcode=${2:-1} if [ ${exitcode} -eq 0 ] ; then - printf 'Exiting: %b\n' "${msg}" + ${QUIET} || printf 'Exiting: %b\n' "${msg}" scan > /dev/null - [ ${count} -gt 0 ] && echo "NOTE: ${count} updates remaining" + ! ${QUIET} && [ ${count} -gt 0 ] && echo "NOTE: ${count} updates remaining" else error "${msg}" fi @@ -574,6 +575,7 @@ usage() { -d, --debug Enable shell debugging -h, --help Show help and run away -p, --preen Automerge trivial changes only and quit + -q, --quiet Show only essential output -v, --verbose Show settings and such along the way -V, --version Show version and trundle away @@ -599,12 +601,15 @@ declare title="Gentoo's etc-update tool!" PREEN=false SET_X=false +QUIET=false VERBOSE=false +NONINTERACTIVE_MV=false while [[ -n $1 ]] ; do case $1 in -d|--debug) SET_X=true;; -h|--help) usage;; -p|--preen) PREEN=true;; + -q|--quiet) QUIET=true;; -v|--verbose) VERBOSE=true;; -V|--version) emerge --version; exit 0;; --automode) parse_automode_flag $2 && shift || usage 1 "Invalid mode '$2'";; @@ -615,7 +620,7 @@ while [[ -n $1 ]] ; do done ${SET_X} && set -x -type portageq >/dev/null || die "missing portageq" +type -P portageq >/dev/null || die "missing portageq" portage_vars=( CONFIG_PROTECT{,_MASK} PORTAGE_CONFIGROOT @@ -625,7 +630,7 @@ portage_vars=( USERLAND NOCOLOR ) -eval $(portageq envvar -v ${portage_vars[@]}) +eval $(${PORTAGE_PYTHON:+"${PORTAGE_PYTHON}"} "$(type -P portageq)" envvar -v ${portage_vars[@]}) export PORTAGE_TMPDIR SCAN_PATHS=${*:-${CONFIG_PROTECT}} @@ -692,6 +697,11 @@ else fi fi +if ${NONINTERACTIVE_MV} ; then + export mv_opts=" ${mv_opts} " + mv_opts="${mv_opts// -i / }" +fi + if ${VERBOSE} ; then for v in ${portage_vars[@]} ${cfg_vars[@]} TMP SCAN_PATHS ; do echo "${v}=${!v}" diff --git a/portage_with_autodep/bin/filter-bash-environment.py b/portage_with_autodep/bin/filter-bash-environment.py index b9aec96..3d4b3ec 100755 --- a/portage_with_autodep/bin/filter-bash-environment.py +++ b/portage_with_autodep/bin/filter-bash-environment.py @@ -1,10 +1,9 @@ #!/usr/bin/python -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import codecs import io -import optparse import os import re import sys @@ -126,10 +125,19 @@ if __name__ == "__main__": "intact. The PATTERN is a space separated list of variable names" + \ " and it supports python regular expression syntax." usage = "usage: %s PATTERN" % os.path.basename(sys.argv[0]) - parser = optparse.OptionParser(description=description, usage=usage) - options, args = parser.parse_args(sys.argv[1:]) + args = sys.argv[1:] + + if '-h' in args or '--help' in args: + sys.stdout.write(usage + "\n") + sys.stdout.flush() + sys.exit(os.EX_OK) + if len(args) != 1: - parser.error("Missing required PATTERN argument.") + sys.stderr.write(usage + "\n") + sys.stderr.write("Exactly one PATTERN argument required.\n") + sys.stderr.flush() + sys.exit(2) + file_in = sys.stdin file_out = sys.stdout if sys.hexversion >= 0x3000000: diff --git a/portage_with_autodep/bin/fixpackages b/portage_with_autodep/bin/fixpackages index dc43ed2..e29d6ee 100755 --- a/portage_with_autodep/bin/fixpackages +++ b/portage_with_autodep/bin/fixpackages @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function @@ -7,21 +7,27 @@ from __future__ import print_function import os import sys -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True from portage import os from portage.output import EOutput +from portage.util._argparse import ArgumentParser from textwrap import wrap from portage._global_updates import _global_updates mysettings = portage.settings mytrees = portage.db mtimedb = portage.mtimedb +description = """The fixpackages program performs package move updates on + configuration files, installed packages, and binary packages.""" +description = " ".join(description.split()) + +parser = ArgumentParser(description=description) +parser.parse_args() + if mysettings['ROOT'] != "/": out = EOutput() msg = "The fixpackages program is not intended for use with " + \ diff --git a/portage_with_autodep/bin/glsa-check b/portage_with_autodep/bin/glsa-check index a840c32..7fa3688 100755 --- a/portage_with_autodep/bin/glsa-check +++ b/portage_with_autodep/bin/glsa-check @@ -1,81 +1,79 @@ #!/usr/bin/python -# Copyright 2008-2011 Gentoo Foundation +# Copyright 2008-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 from __future__ import print_function import sys +import codecs -try: - import portage -except ImportError: - from os import path as osp - sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) - import portage - +from os import path as osp +pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym") +sys.path.insert(0, pym_path) +import portage +portage._internal_caller = True from portage import os -from portage.output import * - -from optparse import OptionGroup, OptionParser +from portage.output import green, red, nocolor, white +from portage.util._argparse import ArgumentParser __program__ = "glsa-check" __author__ = "Marius Mauch " __version__ = "1.0" -def cb_version(*args, **kwargs): - """Callback for --version""" - sys.stderr.write("\n"+ __program__ + ", version " + __version__ + "\n") - sys.stderr.write("Author: " + __author__ + "\n") - sys.stderr.write("This program is licensed under the GPL, version 2\n\n") - sys.exit(0) - # option parsing -parser = OptionParser(usage="%prog