├── .gitignore ├── CMakeLists.txt ├── ChangeLog.md ├── LICENSE ├── README.md ├── TODO.md ├── auto-patch ├── auto-patch.bash.in └── auto-patch.conf.in ├── cmake └── modules │ ├── AddFSMTest.cmake │ ├── AddShellFunctionsTest.cmake │ └── run_shell_test.cmake.in ├── env.d └── 90cave ├── filesystem-manager ├── CMakeLists.txt ├── commands │ ├── cmd-mkdir.sh │ ├── cmd-mv.sh │ ├── cmd-rm-inverted.sh │ ├── cmd-rm.sh │ ├── cmd-symlink.sh │ ├── cmd-use-pretend.sh │ └── cmd-use.sh ├── filesystem-manager.bash.in ├── filesystem-manager.conf.example.in ├── filesystem-manager.dtd ├── filesystem-manager.xsl ├── test.sh └── test │ ├── CMakeLists.txt │ ├── cmd-mkdir-test-1 │ └── run_test.sh.in │ ├── cmd-mv-not-existed-target │ └── run_test.sh.in │ ├── cmd-mv-test-1 │ └── run_test.sh.in │ ├── cmd-mv-test-2 │ └── run_test.sh.in │ ├── cmd-rm-dummy-dir │ └── run_test.sh.in │ ├── cmd-rm-not-existed-target │ └── run_test.sh.in │ ├── cmd-rm-test-1 │ └── run_test.sh.in │ ├── cmd-rm-test-2 │ └── run_test.sh.in │ ├── cmd-rm-with-starglobe │ └── run_test.sh.in │ ├── cmd-symlink-not-existed-base │ └── run_test.sh.in │ ├── cmd-symlink-test-1 │ └── run_test.sh.in │ ├── cmd-symlink-test-2 │ └── run_test.sh.in │ ├── commands-renderer │ ├── expected.output │ └── input.xml.in │ ├── exec-transform.cmake.in │ ├── matching-partial │ ├── expected.output │ └── input.xml.in │ ├── matching │ ├── expected.output │ └── input.xml.in │ ├── run-cmd-test.bash.in │ ├── run-cmd-test.cmake.in │ ├── run-test.cmake.in │ └── update-expected-output.cmake.in ├── package.env ├── default-deps-trk.conf ├── default-silent-rules.conf ├── extra-optimize.conf ├── ld-no-gc-sections.conf ├── ld-no-hash-style.conf ├── ld-no-new-dtags.conf ├── ld-no-sort-common.conf ├── lto.conf ├── max-debug.conf ├── no-debug.conf ├── no-gnu-tls.conf ├── no-lto.conf ├── no-modern-c++.conf ├── setup_pkg_env.bash.in ├── spam.conf ├── use-bfd-linker.conf ├── use-gold-linker.conf ├── use-latest-gcc.conf └── use-modern-c++.conf ├── print-ebuild-path ├── profile.d ├── 00-make-completion-wrapper.sh ├── cave-addons.sh └── cave-aliases.sh └── workdir-tmpfs ├── workdir-tmpfs.bash.in └── workdir-tmpfs.conf.in /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # "Build" script for my paludis-hooks package 2 | # Copyright 2012-2017 by Alex Turbov 3 | # 4 | 5 | cmake_minimum_required(VERSION 3.4) 6 | project(paludis-hooks VERSION 1.3 LANGUAGES NONE) 7 | 8 | option(WITH_AUTOPATCH "Install autopatch hook" ON) 9 | option(WITH_FS_MANAGER "Install filesystem manager hook" ON) 10 | option(WITH_PACKAGE_ENV "Install per package environment manager" ON) 11 | option(WITH_PYTHON_EXTENSIONS "Install some `cave` aux commands" AUTO) 12 | 13 | list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules") 14 | 15 | # seek for xmllint to validate our XML files 16 | find_program(XMLLINT_EXECUTABLE xmllint REQUIRED) 17 | # check if xsltproc is even installed 18 | find_program(XSLTPROC_EXECUTABLE xsltproc REQUIRED) 19 | # `diff` is needed for some unit tests 20 | find_program(DIFF_EXECUTABLE diff) 21 | # python interpreter is needed for some optional scripts 22 | if(WITH_PYTHON_EXTENSIONS AND (WITH_PYTHON_EXTENSIONS STREQUAL ON OR WITH_PYTHON_EXTENSIONS STREQUAL AUTO)) 23 | find_package(PythonInterp) 24 | if(NOT PYTHONINTERP_FOUND) 25 | if(WITH_PYTHON_EXTENSIONS STREQUAL AUTO) 26 | message(STATUS "Python scripts will not be installed") 27 | elseif(WITH_PYTHON_EXTENSIONS STREQUAL ON) 28 | message(FATAL_ERROR "Python extensions has requested, but interpreter not found") 29 | endif() 30 | endif() 31 | endif() 32 | 33 | # Define install destination dirs 34 | # ATTENTION Define CMAKE_SIZEOF_VOID_P to some not important value 35 | # to suppress a warning from GNUInstallDirs... 36 | set(CMAKE_SIZEOF_VOID_P 8) 37 | include(GNUInstallDirs) 38 | 39 | # For tests 40 | include(CTest) 41 | include(AddShellFunctionsTest) 42 | 43 | # Autopatch hook 44 | if(WITH_AUTOPATCH) 45 | configure_file(auto-patch/auto-patch.bash.in auto-patch/auto-patch.bash @ONLY) 46 | configure_file(auto-patch/auto-patch.conf.in auto-patch/auto-patch.conf @ONLY) 47 | install( 48 | PROGRAMS "${CMAKE_BINARY_DIR}/auto-patch/auto-patch.bash" 49 | DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks" 50 | ) 51 | install( 52 | FILES "${CMAKE_BINARY_DIR}/auto-patch/auto-patch.conf" 53 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/paludis/hooks/configs" 54 | ) 55 | endif() 56 | 57 | # Filesystem manager hook 58 | if(WITH_FS_MANAGER) 59 | add_subdirectory(filesystem-manager) 60 | endif() 61 | 62 | # Package environment configurator 63 | if(WITH_PACKAGE_ENV) 64 | configure_file(package.env/setup_pkg_env.bash.in package.env/setup_pkg_env.bash @ONLY) 65 | install( 66 | FILES "${CMAKE_BINARY_DIR}/package.env/setup_pkg_env.bash" 67 | DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/paludis-hooks" 68 | ) 69 | install( 70 | FILES 71 | package.env/default-deps-trk.conf 72 | package.env/default-silent-rules.conf 73 | package.env/extra-optimize.conf 74 | package.env/ld-no-gc-sections.conf 75 | package.env/ld-no-hash-style.conf 76 | package.env/ld-no-new-dtags.conf 77 | package.env/ld-no-sort-common.conf 78 | package.env/lto.conf 79 | package.env/max-debug.conf 80 | package.env/no-debug.conf 81 | package.env/no-modern-c++.conf 82 | package.env/no-gnu-tls.conf 83 | package.env/no-lto.conf 84 | package.env/spam.conf 85 | package.env/use-bfd-linker.conf 86 | package.env/use-gold-linker.conf 87 | package.env/use-latest-gcc.conf 88 | package.env/use-modern-c++.conf 89 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/paludis/env.conf.d" 90 | ) 91 | endif() 92 | 93 | # In Memory Build hook 94 | if(WITH_WORKDIR_TMPFS) 95 | configure_file(workdir-tmpfs/workdir-tmpfs.bash.in workdir-tmpfs/workdir-tmpfs.bash @ONLY) 96 | configure_file(workdir-tmpfs/workdir-tmpfs.conf.in workdir-tmpfs/workdir-tmpfs.conf @ONLY) 97 | 98 | install( 99 | PROGRAMS "${CMAKE_BINARY_DIR}/workdir-tmpfs/workdir-tmpfs.bash" 100 | DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks" 101 | ) 102 | install( 103 | FILES "${CMAKE_BINARY_DIR}/workdir-tmpfs/workdir-tmpfs.conf" 104 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/paludis/hooks/configs" 105 | ) 106 | endif() 107 | 108 | # Some other helpers... 109 | install( 110 | FILES profile.d/00-make-completion-wrapper.sh profile.d/cave-aliases.sh 111 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d" 112 | ) 113 | install( 114 | FILES env.d/90cave 115 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/env.d" 116 | ) 117 | 118 | if(PYTHONINTERP_FOUND) 119 | install( 120 | PROGRAMS print-ebuild-path 121 | DESTINATION "${CMAKE_INSTALL_FULL_LIBEXECDIR}/cave/commands" 122 | ) 123 | install( 124 | FILES profile.d/cave-addons.sh 125 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/profile.d" 126 | ) 127 | endif() 128 | 129 | # Docs (not much) 130 | install( 131 | FILES ChangeLog.md LICENSE README.md 132 | DESTINATION "${CMAKE_INSTALL_FULL_DOCDIR}" 133 | ) 134 | 135 | # vim:ts=4:expandtab: 136 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | Changelog 2 | ========= 3 | 4 | Unreleased 5 | ---------- 6 | 7 | * Autopatch: Do not apply same patch twice, if found in multiple directories; 8 | * Review bash code and replace backticks with `$(...)`, also `[` has replaced with `[[` and 9 | cleaned from redundant quotes. Replace some external program calls w/ bash built-in equivalent. 10 | Some optimizations and code deduplication has been done as well ;-) 11 | 12 | Version 1.2 13 | ----------- 14 | 15 | * Add a runtime option to the filesystem management hook to suppress a warning; 16 | * Rename `reverse` attribute of the Filesystem Manager's config to `negate`; 17 | * Better docs and a bunch of fixes (thanks to Kapshuna Alexander, @kapsh); 18 | * Fix for issue #11; 19 | * A bunch of improvements in the environment manager: now it is possible to use 20 | functions from `flag-o-matic.eclss` to manage compiler/linker options; 21 | * Add `pretend-use` attribute to `package` element of the Filesystem Manager hook config; 22 | * Introduce `mv` element to Filesystem Manager hook config. 23 | 24 | Version 1.1 25 | ----------- 26 | 27 | * Few improvements to `auto-patch` (thanks to Julian Ospald); 28 | * Remove the autoconf cache hook.. that was a bad idea! ;-) 29 | 30 | Version 1.0 31 | ----------- 32 | * Add a hook to clean a "shared" autotools' `config.cache` before build (see rationale and the hook 33 | description of a project's homepage); 34 | * Add a hook to make it possible to build packages (smoothly) in a RAM (disk) 35 | * Little refactorings in some other hooks. 36 | 37 | Version 0.9 38 | ----------- 39 | * Add the `if` element to Filesystem Manager and the only, nowadays, expression type to check presence of some `USE`; 40 | * Add `config-cache-clear` hook to remove some harmful cached values from a `config.cache` 41 | shared among packages. 42 | 43 | Version 0.8 44 | ----------- 45 | * Add a boolean attribute `reverse` (w/ values `true` or `false` (default)) to allow removal 46 | of everything except selected targets. 47 | 48 | Version 0.7 49 | ----------- 50 | * `package` nodes now matched according full featured package specification; 51 | * Also package matching was rewritten, so now it is possible to combine actions 52 | for different (partial) specs. 53 | 54 | Version 0.6 55 | ----------- 56 | * Add remove command, so one may remove some files/directories from an image. If there is 57 | no files remain, empty directories will be removed as well, to avoid warnings from `cave`; 58 | * Validate configuration file against DTD. 59 | 60 | Version 0.5 61 | ----------- 62 | * Initial commit to github 63 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Paludis-hooks is free software: you can redistribute it and/or modify it 2 | under the terms of the GNU General Public License as published by the 3 | Free Software Foundation, either version 3 of the License, or 4 | (at your option) any later version. 5 | 6 | Paludis-hooks is distributed in the hope that it will be useful, but 7 | WITHOUT ANY WARRANTY; without even the implied warranty of 8 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 | See the GNU General Public License for more details. 10 | 11 | You should have received a copy of the GNU General Public License along 12 | with this program. If not, see . 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | What is this? 2 | ============= 3 | 4 | Here is a set of my hooks (plugins) for [paludis](http://paludis.exherbo.org) I wrote and use few years already. 5 | 6 | Briefly this package consists of: 7 | * __Autopatch__ hook -- an easy way to apply patches ([here](https://github.com/zaufi/paludis-autopatches) is my set of patches) 8 | * __Filesystem Manager__ hook -- a better way to avoid installation of some files than `INSTALL_MASK` + 9 | some other interesting usage practices w/o direct analogues in the portage 10 | * A smart way to build packages in a RAM disk with `workdir-tmpfs` hook 11 | * A bunch of helper functions usable in a daily work w/ Paludis 12 | * A hook to organize compiler/linker options into various sets and apply to packages 13 | 14 | 15 | Configuration details 16 | ===================== 17 | 18 | Autopatch 19 | --------- 20 | 21 | The only one option in `/etc/paludis/hooks/configs/auto-patch.conf` is location of patches tree 22 | (default: `/var/paludis/autopatches`). 23 | `.patch` files should be placed under this directory with such hierarchy: 24 | ``` 25 | autopatches 26 | ├── hook_name1 27 | │   └── cate-gory 28 | │   └── package_name 29 | │   └── fix_some_crap.patch 30 | ├── hook_name2 31 | │   ├── cate-gory 32 | │   │ └── package-ver 33 | │ │   └── version-specific.patch 34 | │   ├── cate-gory 35 | │   │ └── package-ver_r1 36 | │ │   └── some-cve-hotfix.patch 37 | │   └── cate-gory 38 | │   └── any_spec:SLOT 39 | │ └── slot-specific.patch 40 | ``` 41 | and so on. 42 | 43 | Supported hooks for autopatch are: 44 | `ebuild_install_pre, install_all_post, ebuild_configure_post, ebuild_compile_post, ebuild_configure_pre, ebuild_compile_pre, ebuild_unpack_post`. 45 | 46 | This hook is also controlled by this variables in paludis' `bashrc`: 47 | * `PALUDIS_AUTOPATCH_HOOK_DO_NOTHING="yes"` disables all actions of this hook. 48 | * `PALUDIS_AUTOPATCH_HOOK_NO_WARNING="yes"` mutes annoying warnings about altered packages. 49 | 50 | 51 | Filesystem Manager 52 | ------------------ 53 | 54 | `/etc/paludis/hooks/configs/filesystem-manager.conf` is a set of rules in XML which format is explained 55 | by the comments in it or in more details 56 | [here](https://github.com/zaufi/paludis-config/blob/hardware/notebook/MSI-GP60-2PE-Leopard/hooks/configs/filesystem-manager.conf). 57 | 58 | This hook is also controlled by this variables in paludis' `bashrc`: 59 | * `PALUDIS_HOOK_DEBUG="yes"` dumps enviroment variables to file `/tmp/paludis-fsm-hook-env.log`. 60 | * `PALUDIS_FILESYSTEM_HOOK_DO_NOTHING="yes"` disables all actions of this hook. 61 | * `PALUDIS_FILESYSTEM_HOOK_NO_WARNING="yes"` mutes annoying warnings about altered packages. 62 | 63 | 64 | package.env 65 | ----------- 66 | 67 | For using this hook add to Paludis' `bashrc` line: 68 | 69 | [ -e /usr/libexec/paludis-hooks/setup_pkg_env.bash ] && source /usr/libexec/paludis-hooks/setup_pkg_env.bash 70 | 71 | and to `/etc/paludis/package_env.conf`: 72 | 73 | category/some_package some_env another_env ... 74 | 75 | So, at build time of `category/some_package`, all lines from the mentioned env files (`/etc/paludis/env.conf.d/some_env.conf` and 76 | `/etc/paludis/env.conf.d/another_env.conf`) will be sourced at `init` ebuild phase. Hence, changing compiler/linker flags 77 | or setting another compiler would affect the build process only for given package. 78 | 79 | 80 | Workdir-tmpfs 81 | ------------- 82 | 83 | Most important boolean parameter in `/etc/paludis/hooks/configs/workdir-tmpfs.conf` is `IN_MEMORY_BUILD_ENABLED`. 84 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | TODO 2 | ==== 3 | 4 | * Add more commands! Like `*zip` smth... 5 | * Add ability to find target objects (files, dirs, whatever) by introducing smth 6 | like `find` item and iterate over results applying some other actions (`ln`, `rm`, & etc...). 7 | For example `dev-python/PyQt5` have a lot of useless `README` files in every `examples/*` directory 8 | * Implement FSM commands as **real** plugins... need to think about how to update (merge) DTD then. 9 | * Predefine some useful entities? Like `&docdir;` for `/usr/share/doc` 10 | * Add option to ignore `SLOT` when build certain packages w/ `wokrdir-tmpfs` hook -- i.e. 11 | when it is known apriory that required size doesn't change much (like `gentoo-sources`) 12 | * Add element to inject `USE=doc` for packages where it is not defined, so it'll be possible 13 | to continue processing and avoid rules duplication in FMS hook. (alsmost done) 14 | * Add some command to get last entries for ebuild Changelog 15 | * Add `debug` attribute to command(s) to show `pwd` and contents of a directory before apply some action 16 | * Add sync post hook to update a repo with auto patches 17 | * Make it possible to remove by Ant-like wildcard `**/some` (hint: bash has `shopt globstar`) 18 | * Case insensitive glob expressions match, so `announce*`, `ANNOUNCE*` and `Announce*` can be replaced 19 | with only one rule 20 | * Allow loops? 21 | 22 | 23 | 24 | notepad 25 | winefile 26 | ... 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /auto-patch/auto-patch.bash.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Paludis hook script to apply patch (w/o modifying corresponding ebuild file). 4 | # 5 | # Copyright (c), 2010-2017 by Alex Turbov 6 | # 7 | # Version: @PROJECT_VERSION@ 8 | # 9 | 10 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 11 | 12 | declare -r CONFIG_FILE="@CMAKE_INSTALL_FULL_SYSCONFDIR@/paludis/hooks/configs/auto-patch.conf" 13 | PATCH_DIR="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/db/paludis/autopatches" 14 | 15 | # Configuration override 16 | [[ -f ${CONFIG_FILE} ]] && source ${CONFIG_FILE} 17 | 18 | 19 | if [[ ${PALUDIS_AUTOPATCH_HOOK_DO_NOTHING} = yes ]]; then 20 | einfo "Autopatch Hook: Do not apply any patches due explicit request" 21 | exit 0 22 | fi 23 | 24 | _ap_rememberfile="${T}/.autopatch_was_here_${PALUDIS_PID}" 25 | 26 | issue_a_warning() 27 | { 28 | if [[ ${PALUDIS_AUTOPATCH_HOOK_NO_WARNING} != yes ]]; then 29 | local -r tobe="$1" 30 | ewarn "WARNING: ${CATEGORY}/${PF} package $tobe installed with additional patches applied by auto-patch hook." 31 | ewarn "WARNING: Before filing a bug, remove all patches, reinstall, and try again..." 32 | fi 33 | } 34 | 35 | contains() 36 | { 37 | local element 38 | for element in "${@:2}"; do 39 | [[ ${element} = $1 ]] && return 0 40 | done 41 | return 1 42 | } 43 | 44 | try_to_apply_patches() 45 | { 46 | local check 47 | # TODO: Maybe implement dynamically detecting correct -pN for patch? 48 | local patch_cmd='patch -p1' 49 | local -a applied_patches 50 | 51 | for check in "${PATCH_DIR}/${HOOK}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}}; do 52 | if [[ -d ${check} ]] ; then 53 | # Store `nullglob` state and enforce it set 54 | local saved_opt=$(shopt -p nullglob) 55 | shopt -s nullglob 56 | 57 | cd "${S}" || die "Failed to cd into ${S}!" 58 | for pfull in "${check}"/*.patch ; do 59 | local pname="$(basename ${pfull})" 60 | 61 | # Check if already applied 62 | if contains "${pname}" "${applied_patches[@]}"; then 63 | einfo "Skip already applied ${pname} ..." 64 | continue 65 | fi 66 | 67 | # Remember for further checking 68 | applied_patches+=( "${pname}" ) 69 | 70 | # Check if patch could be applied 71 | ${patch_cmd} --dry-run -f < "${pfull}" 2>&1 72 | local pret="$?" 73 | if [[ ${pret} = 0 ]]; then 74 | # Ok, dry run successed, then try to apply 75 | einfo "Applying ${pname} ..." 76 | ${patch_cmd} < "${pfull}" 2>&1 77 | pret="$?" 78 | [[ ${pret} = 0 ]] || die "Dry-run patching with ${pname} succeeded but actually failed" 79 | else 80 | die "Patch ${pname} can not be used" 81 | fi 82 | touch "${_ap_rememberfile}" || die "Failed to touch ${_ap_rememberfile}!" 83 | done 84 | 85 | # Restore `nullglob` state 86 | eval "${saved_opt}" 87 | 88 | if [[ -e ${_ap_rememberfile} ]]; then 89 | issue_a_warning "will be" 90 | else 91 | einfo "No patches in for this package." 92 | fi 93 | fi 94 | done 95 | } 96 | 97 | case "${HOOK}" in 98 | # ATTENTION This script must be symlinked to the following hook dirs: 99 | ebuild_compile_post | \ 100 | ebuild_compile_pre | \ 101 | ebuild_configure_post | \ 102 | ebuild_configure_pre | \ 103 | ebuild_install_pre | \ 104 | ebuild_unpack_post ) 105 | try_to_apply_patches 106 | ;; 107 | install_all_post) 108 | if [[ -e ${_ap_rememberfile} ]] ; then 109 | issue_a_warning "was" 110 | fi 111 | ;; 112 | esac 113 | 114 | # kate: hl bash; 115 | -------------------------------------------------------------------------------- /auto-patch/auto-patch.conf.in: -------------------------------------------------------------------------------- 1 | # 2 | # auto-patch.conf 3 | # 4 | 5 | # REMINDER: autopatch hook applies patches AFTER ebuild has done all 6 | # unpacking and patching. 7 | 8 | # Home directory for the patches. 9 | # Put the patches in ${PATCH_DIR}/hook/cat/pkg-ver/ subdirectory 10 | # NOTE Uncomment the following line to override default location 11 | # PATCH_DIR="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/paludis/autopatches" 12 | -------------------------------------------------------------------------------- /cmake/modules/AddFSMTest.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Macro to add filesystem manager hook test 3 | # 4 | macro(add_fsm_test directory) 5 | # Preset some variables expected by tests 6 | set(REPOSITORY "gentoo") 7 | set(CATEGORY "dev-util") 8 | set(PN "cmake") 9 | set(PV "3.4.3") 10 | set(PR "r1") 11 | set(PVR "${PV}-${PR}") 12 | set(P "${PN}-${PV}") 13 | set(PF "${PN}-${PVR}") 14 | set(SLOT "0") 15 | set(D "${CMAKE_CURRENT_BINARY_DIR}/${directory}") 16 | set(T "${CMAKE_CURRENT_BINARY_DIR}/${directory}") 17 | 18 | # We expect some partucular file in there 19 | if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${directory}/input.xml.in") 20 | message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/${directory}/input.xml.in not found") 21 | endif() 22 | 23 | # Set test specific variables 24 | set(_aft_input_test_conf "input.xml") 25 | set(_aft_working_directory "${CMAKE_CURRENT_BINARY_DIR}/${directory}") 26 | set(_aft_output_test_conf "${_aft_working_directory}/${directory}.output") 27 | set(_aft_expected_output "${CMAKE_CURRENT_SOURCE_DIR}/${directory}/expected.output") 28 | 29 | configure_file("${directory}/input.xml.in" "${directory}/input.xml") 30 | configure_file("exec-transform.cmake.in" "${directory}/exec-transform.cmake") 31 | configure_file("run-test.cmake.in" "${directory}/run-test.cmake") 32 | configure_file("update-expected-output.cmake.in" "${directory}/update-expected-output.cmake") 33 | 34 | list( 35 | APPEND ADDITIONAL_MAKE_CLEAN_FILES 36 | "${_aft_output_test_conf}" 37 | ) 38 | 39 | add_test( 40 | NAME ${directory} 41 | COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/${directory}/run-test.cmake" 42 | ) 43 | 44 | add_custom_target( 45 | update-${directory}-expectations 46 | COMMAND "${CMAKE_COMMAND}" -P "${_aft_working_directory}/update-expected-output.cmake" 47 | COMMENT "Update test output expectations at test directory: ${CMAKE_CURRENT_SOURCE_DIR}/${directory}" 48 | ) 49 | 50 | unset(REPOSITORY) 51 | unset(CATEGORY) 52 | unset(PN) 53 | unset(PV) 54 | unset(PR) 55 | unset(PVR) 56 | unset(P) 57 | unset(PF) 58 | unset(SLOT) 59 | unset(D) 60 | unset(T) 61 | endmacro() 62 | -------------------------------------------------------------------------------- /cmake/modules/AddShellFunctionsTest.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Helper function to add OnixS shell functions tests 3 | # 4 | 5 | set(_ASFT_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") 6 | 7 | function(add_shell_functions_test) 8 | set(_options) 9 | set(_one_value_args NAME PASS_REGULAR_EXPRESSION) 10 | set(_multi_value_args AUX_FILES_TO_RENDER) 11 | cmake_parse_arguments(_add_shell_functions_test "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN}) 12 | 13 | if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_add_shell_functions_test_NAME}/run_test.sh") 14 | if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${_add_shell_functions_test_NAME}/run_test.sh.in") 15 | message(FATAL_ERROR "No shell script to test found in ${CMAKE_CURRENT_SOURCE_DIR}/${_add_shell_functions_test_NAME}") 16 | else() 17 | configure_file( 18 | "${CMAKE_CURRENT_SOURCE_DIR}/${_add_shell_functions_test_NAME}/run_test.sh.in" 19 | "${CMAKE_CURRENT_BINARY_DIR}/${_add_shell_functions_test_NAME}/run_test.sh" 20 | @ONLY 21 | ) 22 | set(_add_shell_functions_test_RUN_TEST_SH "${CMAKE_CURRENT_BINARY_DIR}/${_add_shell_functions_test_NAME}/run_test.sh") 23 | endif() 24 | else() 25 | set(_add_shell_functions_test_RUN_TEST_SH "${CMAKE_CURRENT_SOURCE_DIR}/${_add_shell_functions_test_NAME}/run_test.sh") 26 | endif() 27 | 28 | configure_file( 29 | "${_ASFT_BASE_DIR}/run_shell_test.cmake.in" 30 | "${_add_shell_functions_test_NAME}/run_shell_test.cmake" 31 | @ONLY 32 | ) 33 | 34 | # Render aux files needed by test 35 | foreach(_f ${_add_shell_functions_test_AUX_FILES_TO_RENDER}) 36 | get_filename_component(_name "${_f}" NAME) 37 | string(REGEX REPLACE ".in$" "" _new_name "${_name}") 38 | configure_file( 39 | "${CMAKE_CURRENT_SOURCE_DIR}/${_add_shell_functions_test_NAME}/${_f}" 40 | "${CMAKE_CURRENT_BINARY_DIR}/${_add_shell_functions_test_NAME}/${_new_name}" 41 | @ONLY 42 | ) 43 | endforeach() 44 | 45 | add_test( 46 | NAME "${_add_shell_functions_test_NAME}" 47 | COMMAND "${CMAKE_COMMAND}" -P run_shell_test.cmake 48 | WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_add_shell_functions_test_NAME}" 49 | ) 50 | 51 | if(_add_shell_functions_test_PASS_REGULAR_EXPRESSION) 52 | set_property( 53 | TEST "${_add_shell_functions_test_NAME}" 54 | PROPERTY PASS_REGULAR_EXPRESSION "${_add_shell_functions_test_PASS_REGULAR_EXPRESSION}" 55 | ) 56 | endif() 57 | endfunction() 58 | -------------------------------------------------------------------------------- /cmake/modules/run_shell_test.cmake.in: -------------------------------------------------------------------------------- 1 | execute_process( 2 | COMMAND /bin/sh "@_add_shell_functions_test_RUN_TEST_SH@" 3 | RESULT_VARIABLE EXIT_CODE 4 | ) 5 | 6 | if(NOT EXIT_CODE EQUAL "0") 7 | message(FATAL_ERROR "@_add_shell_functions_test_NAME@: Failed") 8 | endif() 9 | -------------------------------------------------------------------------------- /env.d/90cave: -------------------------------------------------------------------------------- 1 | # 2 | # Configuration options for paludis addons 3 | # 4 | 5 | # Protect self 6 | CONFIG_PROTECT='/etc/env.d/90cave' 7 | 8 | # Options for profile.d/ based stuff 9 | # (ATTENTION Not for `cave` itself!) 10 | CAVE_SEARCH_INDEX_FILE=/var/cache/paludis/csi 11 | CAVE_RESUME_FILE_OPT='--resume-file /tmp/cave.resume' 12 | 13 | # Here is options for vairous `cave` subcommands 14 | CAVE_FIX_LINKAGE_OPTIONS=" -- ${CAVE_RESUME_FILE_OPT}" 15 | 16 | # Options for pkg-meta-diff 17 | PKG_META_DIFF_OPTIONS='-u' 18 | 19 | # kate: hl bash; 20 | -------------------------------------------------------------------------------- /filesystem-manager/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(FILESYSTEM_MANAGER_DTD "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks/filesystem-manager/filesystem-manager.dtd") 2 | set(FILESYSTEM_MANAGER_XSL "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks/filesystem-manager/filesystem-manager.xsl") 3 | 4 | configure_file(filesystem-manager.conf.example.in filesystem-manager.conf.example @ONLY) 5 | configure_file(filesystem-manager.bash.in filesystem-manager.bash @ONLY) 6 | 7 | install( 8 | PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/filesystem-manager.bash" 9 | DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks" 10 | ) 11 | install( 12 | FILES "${CMAKE_CURRENT_BINARY_DIR}/filesystem-manager.conf.example" 13 | DESTINATION "${CMAKE_INSTALL_FULL_SYSCONFDIR}/paludis/hooks/configs/" 14 | ) 15 | install( 16 | FILES 17 | filesystem-manager.xsl 18 | filesystem-manager.dtd 19 | DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks/filesystem-manager" 20 | ) 21 | install( 22 | DIRECTORY commands 23 | DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/paludis-hooks/filesystem-manager" 24 | ) 25 | 26 | if(BUILD_TESTING) 27 | add_subdirectory(test) 28 | endif() 29 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-mkdir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `mkdir` command of the config file 4 | # 5 | 6 | # @param cd -- directory to change to before making a directory (can be empty) 7 | # @param dst... -- directory name(s) to make 8 | # 9 | function cmd_mkdir() 10 | { 11 | local cd="$1" 12 | shift 1 13 | 14 | if ! verify_dir "${cd}"; then 15 | eerror "Package image dir is undefined! Skip any actions..." 16 | return 0 17 | fi 18 | 19 | if [[ -d ${D}/${cd} ]]; then 20 | cd "${D}/${cd}" \ 21 | && mkdir -vp "$@" \ 22 | && schedule_a_warning_after_all \ 23 | && cd - >/dev/null 24 | fi 25 | 26 | return 0 27 | } 28 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-mv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `mv` command of the config file 4 | # 5 | 6 | # 7 | # Function to move smth in a given directory 8 | # 9 | # @param cd -- directory to change to, before remove 10 | # @param dst -- destination: directory or new file name 11 | # @param src... -- what to move (possible w/ wildcards) 12 | function cmd_mv() 13 | { 14 | local cd="$1" 15 | local dst="$2" 16 | shift 2 17 | 18 | if ! verify_dir "${cd}"; then 19 | eerror "Package image dir is undefined! Skip any actions..." 20 | return 21 | fi 22 | 23 | if [[ -z $@ ]]; then 24 | # NOTE This shouldn't happened! Config file will be validated with DTD... 25 | eerror "No source(s) to move has specified" 26 | return 27 | fi 28 | 29 | if [[ -d ${D}/${cd} ]]; then 30 | cd "${D}/${cd}" 31 | mv -vf $@ "${dst}" 2>/dev/null && schedule_a_warning_after_all 32 | cd - >/dev/null 33 | cleanup_empty_dirs 34 | fi 35 | return 0 36 | } 37 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-rm-inverted.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `rm` command of the config file 4 | # which would remove everything except target(s) 5 | # 6 | 7 | # 8 | # Function to remove everything except a specified list in a given directory 9 | # 10 | # @param cd -- directory to change to, before remove 11 | # @param dst -- targets what must stay 12 | # 13 | function cmd_rm_inverted() 14 | { 15 | local cd="$1" 16 | local dst="$2" 17 | 18 | if ! verify_dir "${cd}"; then 19 | eerror "Package image dir is undefined! Skip any actions..." 20 | return 21 | fi 22 | if [ -z "${T}" ]; then 23 | eerror "Package temp dir is undefined! Skip any actions..." 24 | return 25 | fi 26 | 27 | if [ -d "${D}/${cd}" ]; then 28 | cd "${D}/${cd}" 29 | eval find ${dst} 2>/dev/null | sed 's,^\./,,' | sort > ${T}/rm_except.lst 30 | find | sed 's,^\./,,' | sort | comm -3 ${T}/rm_except.lst - >${T}/rm.lst 31 | if [[ -s ${T}/rm.lst ]]; then 32 | rm -vrf $(< ${T}/rm.lst) 2>/dev/null && schedule_a_warning_after_all 33 | fi 34 | cd - >/dev/null 35 | cleanup_empty_dirs 36 | fi 37 | } 38 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-rm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `rm` command of the config file 4 | # 5 | 6 | # 7 | # Function to remove smth in a given directory 8 | # 9 | # @param cd -- directory to change to, before remove 10 | # @param dst... -- what to remove (possible w/ wildcards) 11 | function cmd_rm() 12 | { 13 | local cd="$1" 14 | shift 1 15 | 16 | if ! verify_dir "${cd}"; then 17 | eerror "Package image dir is undefined! Skip any actions..." 18 | return 0 19 | fi 20 | 21 | if [[ -d ${D}/${cd} ]]; then 22 | cd "${D}/${cd}" 23 | local -r files=( ${@} ) 24 | [[ -n ${files} ]] && rm -vrf ${files[@]} && schedule_a_warning_after_all 25 | cd - >/dev/null 26 | cleanup_empty_dirs 27 | fi 28 | 29 | return 0 30 | } 31 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-symlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `symlink` command of the config file 4 | # 5 | 6 | # @param cd -- directory to change to before making a symlink 7 | # @param src -- source name 8 | # @param dst -- destination name 9 | # 10 | function cmd_symlink() 11 | { 12 | local cd="$1" 13 | local src="$2" 14 | local dst="$3" 15 | 16 | if ! verify_dir "${cd}"; then 17 | eerror "Package image dir is undefined! Skip any actions..." 18 | return 0 19 | fi 20 | 21 | [[ -d ${D}/$cd && -e ${D}/${cd}/${src} ]] \ 22 | && cd "${D}/${cd}" \ 23 | && ln -vs ${src} ${dst} \ 24 | && schedule_a_warning_after_all \ 25 | && cd - >/dev/null 26 | 27 | return 0 28 | } 29 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-use-pretend.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `pretend use` command 4 | # 5 | 6 | # 7 | # Function to modify USE variable 8 | # 9 | # It accepts a variadic count of parameters each of which should be preceded 10 | # w/ action flag '+' to add or '-' to remove the flag specified. 11 | # 12 | # Example: 13 | # pretend-use +doc -static 14 | # will add 'doc' and remove 'static' for USE variable, so latter rules may 15 | # act differently... 16 | # 17 | # The main reason to intruduce this is to avoid rules duplication. 18 | # 19 | # @param list of USE modifications 20 | # 21 | function cmd_pretend_use() 22 | { 23 | for use in $*; do 24 | # Ok, need to add a given USE (if latter still not here) 25 | if [[ ${use} =~ \+(.*) ]]; then 26 | local -r pure_use=${BASH_REMATCH[1]} 27 | [[ $USE =~ ${pure_use} ]] || USE="${USE} ${pure_use}" 28 | einfo "Pretending USE=${use} for ${P}" 29 | fi 30 | # TODO Handle '-use'... 31 | done 32 | } 33 | -------------------------------------------------------------------------------- /filesystem-manager/commands/cmd-use.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Plugin to implement the `use` command 4 | # 5 | 6 | # 7 | # Function to check if given use flag is in action 8 | # 9 | # @param use -- USE flag to check 10 | function cmd_use() 11 | { 12 | local use="$1" 13 | 14 | local e 15 | for e in ${USE} xxx-dummy; do 16 | [[ ${e} == ${use} ]] && return 0 17 | done 18 | 19 | return 1 20 | } 21 | -------------------------------------------------------------------------------- /filesystem-manager/filesystem-manager.bash.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Paludis hook script to do some manipulations right after a package 4 | # installed self into an image directory and before actual installing 5 | # into a system will take place. 6 | # 7 | # Copyright (c), 2010-2017 by Alex Turbov 8 | # 9 | # Version: @PROJECT_VERSION@ 10 | # 11 | 12 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 13 | 14 | CONFIG_FILE="@CMAKE_INSTALL_FULL_SYSCONFDIR@/paludis/hooks/configs/filesystem-manager.conf" 15 | TEMPLATE_FILE="@CMAKE_INSTALL_FULL_DATAROOTDIR@/paludis-hooks/filesystem-manager/filesystem-manager.xsl" 16 | 17 | if [[ ${PALUDIS_FILESYSTEM_HOOK_DO_NOTHING} = yes ]]; then 18 | einfo "Filesystem Manager Hook: Do not process any actions due explicit request" 19 | exit 0 20 | fi 21 | 22 | # Output environment to log, if debug enabled 23 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 24 | env | sort > /tmp/paludis-fsm-hook-env.log 25 | fi 26 | 27 | if [[ ! -f ${CONFIG_FILE} ]]; then 28 | ewarn "Filesystem Manager hook: Config file is missing. Nothing to do..." 29 | exit 1 # Nothing to do w/o config 30 | fi 31 | 32 | # Validate config file 33 | if ! /usr/bin/xmllint --valid --noout ${CONFIG_FILE}; then 34 | eerror "Filesystem Manager hook: Config file is invalid. Ignoring any actions..." 35 | exit 1 # Nothing to do w/ incorrect config 36 | fi 37 | 38 | _fsm_rememberfile="${T}/.filesystem_manager_was_here_${PALUDIS_PID}" 39 | export _fsm_rememberfile 40 | 41 | function issue_a_warning() 42 | { 43 | if [[ ${PALUDIS_FILESYSTEM_HOOK_NO_WARNING} != yes ]]; then 44 | ewarn "WARNING: ${CATEGORY}/${PF} package installation was altered by the filesystem manager hook." 45 | ewarn "WARNING: Before filing a bug, remove all configured rules, reinstall, and try again..." 46 | fi 47 | } 48 | 49 | function schedule_a_warning_after_all() 50 | { 51 | [[ ! -e ${_fsm_rememberfile} ]] && touch "${_fsm_rememberfile}" 52 | return 53 | } 54 | export -f schedule_a_warning_after_all 55 | 56 | function verify_dir() 57 | { 58 | if [[ -n ${D} ]]; then 59 | # Make sure we have smth real in `D`! 60 | local -r _vd_p1=$(realpath -mq "${1}") 61 | local -r _vd_p2=$(realpath -mq "${D}/$1") 62 | [[ ${_vd_p1} != ${_vd_p2} ]] 63 | return 64 | fi 65 | return 1 66 | } 67 | export -f verify_dir 68 | 69 | function cleanup_empty_dirs() 70 | { 71 | # Walk through whole image and try to remove possible empty dirs 72 | # ATTENTION According EAPI it is incorrect to install empty directories! 73 | # If a package need some, then its ebuild must use `keepdir` for this! 74 | # So this action also can be considered as sanitize an image before install :) 75 | find ${D} -type d -a -empty -exec rmdir -p --ignore-fail-on-non-empty {} + 76 | # Sometimes (if u really don't want a WHOLE package, but have to install it, 77 | # like boring kde-wallpapers) the last command may delete even ${D} directory, 78 | # so paludis will complain about broken image :) -- Ok, lets restore it! 79 | [[ ! -e ${D} ]] && mkdir -p "${D}" 80 | } 81 | export -f cleanup_empty_dirs 82 | 83 | result=0 84 | case "${HOOK}" in 85 | # ATTENTION This script must be symlinked to the following hook dirs: 86 | ebuild_install_post) 87 | tmp_file=$(mktemp "${T}/fsmh.XXXXXXX.sh") 88 | /usr/bin/xsltproc -o "${tmp_file}" \ 89 | --stringparam 'PN' "${PN}" \ 90 | --stringparam 'PF' "${PF}" \ 91 | --stringparam 'PR' "${PR}" \ 92 | --stringparam 'PV' "${PV}" \ 93 | --stringparam 'PVR' "${PVR}" \ 94 | --stringparam 'CATEGORY' "${CATEGORY}" \ 95 | --stringparam 'REPOSITORY' "${REPOSITORY}" \ 96 | --stringparam 'SLOT' "${SLOT}" \ 97 | --stringparam 'debug' "${PALUDIS_HOOK_DEBUG}" \ 98 | "${TEMPLATE_FILE}" "${CONFIG_FILE}" 99 | 100 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 101 | einfo "Script to execute:" 102 | cat "${tmp_file}" 103 | fi 104 | 105 | /bin/bash "${tmp_file}" 106 | result=$? 107 | 108 | [[ -e ${_fsm_rememberfile} ]] && issue_a_warning 109 | ;; 110 | esac 111 | 112 | exit ${result} 113 | 114 | # kate: hl bash; 115 | -------------------------------------------------------------------------------- /filesystem-manager/filesystem-manager.conf.example.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 59 | 60 | 61 | 62 | 63 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /filesystem-manager/filesystem-manager.dtd: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 15 | 16 | 17 | 21 | 22 | 23 | 28 | 29 | 30 | 35 | 36 | 37 | 42 | 43 | 44 | 48 | 49 | 50 | 54 | -------------------------------------------------------------------------------- /filesystem-manager/filesystem-manager.xsl: -------------------------------------------------------------------------------- 1 | 2 | 6 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | > Render a shell script for 30 | #!/bin/sh 31 | # 32 | # ATTENTION: This script produced by filesystem-manager paludis hook 33 | # on installing package 34 | # 35 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 36 | 37 | # Save some shell options status 38 | _fsm_shopt_extglob=$(shopt -p extglob) 39 | _fsm_shopt_globstar=$(shopt -p globstar) 40 | _fsm_shopt_nullglob=$(shopt -p nullglob) 41 | 42 | # Enable some shell options 43 | shopt -qs extglob 44 | shopt -qs globstar 45 | shopt -qs nullglob 46 | 47 | # Loading command plug-ins 48 | for _fsm_cmd in /usr/share/paludis-hooks/filesystem-manager/commands/*.sh; do 49 | source "${_fsm_cmd}" 50 | done 51 | unset _fsm_cmd 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | < Rendering done for 60 | 61 | # Restore saved shell options 62 | eval "${_fsm_shopt_extglob}" 63 | eval "${_fsm_shopt_globstar}" 64 | eval "${_fsm_shopt_nullglob}" 65 | unset _fsm_shopt_globstar 66 | unset _fsm_shopt_nullglob 67 | 68 | 69 | 100 | 101 | 102 | 103 | 104 | >> Dispatching by priority 105 | 106 | 107 | 108 | 109 | 110 | 112 | 113 | 114 | 115 | 116 | 117 | 119 | 120 | 121 | 122 | 123 | 124 | 126 | 127 | 128 | 129 | 130 | 131 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 141 | 142 | 143 | 144 | 145 | 146 | 148 | 149 | 150 | 151 | 152 | 153 | 155 | 156 | 157 | 158 | 159 | 160 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 170 | 171 | 172 | 173 | 174 | 175 | 177 | 178 | 179 | 180 | 181 | 182 | 184 | 185 | 186 | 187 | 188 | 189 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 199 | 200 | 201 | 202 | 203 | 204 | 206 | 207 | 208 | 209 | 210 | 211 | 213 | 214 | 215 | 216 | 217 | 218 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 228 | 229 | 230 | 231 | 232 | 233 | 235 | 236 | 237 | 238 | 239 | 240 | 242 | 243 | 244 | 245 | 246 | 247 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 257 | 258 | 259 | 260 | 261 | 262 | 264 | 265 | 266 | 267 | 268 | 269 | 271 | 272 | 273 | 274 | 275 | 276 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | ==== Recursion terminated === 285 | 286 | 287 | 288 | 289 | *** ERROR: unexpected priority 290 | 291 | 292 | 293 | << Dispatching done 294 | 295 | 296 | 297 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | ==== Matched package nodes w/ priority 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | ==== ... nothing has matched: trying lower priority ... 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 332 | 333 | 334 | 335 | >>> Package matched: (priority=, stop=) 336 | 337 | 338 | 339 | einfo "Filesystem Management Hook: Apply actions '' for " 341 | 342 | 343 | 344 | cmd_pretend_use 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | ==== continue matching packages w/ lower priority ... 354 | 355 | 356 | 357 | 358 | 359 | 360 | <<< Matching done: (priority=) 361 | 362 | 363 | 364 | 367 | 368 | 369 | ==== rendering `symlink`: cd=, src=, dst= 370 | 371 | 372 | # Make a symlink --> @ 373 | cmd_symlink \ 374 | "" \ 375 | "" \ 376 | "" 377 | 378 | 379 | 382 | 383 | 384 | ==== rendering `symlink`: cd=, src=none, dst=none 385 | 386 | # Symlink a bunch of items in 387 | 388 | 389 | 390 | cmd_symlink \ 391 | "" \ 392 | "" \ 393 | "" 394 | 395 | 396 | 397 | 398 | 401 | 402 | 403 | ==== rendering `symlink`: cd=, src=, dst=none 404 | 405 | # Symlink a bunch of items in to 406 | 407 | 408 | 409 | 410 | cmd_symlink \ 411 | "" \ 412 | "" \ 413 | "" 414 | 415 | 416 | 417 | 418 | 422 | 423 | 424 | ==== rendering `rm`: cd=, dst=, negate=true 425 | 426 | # Remove everything except @ 427 | cmd_rm_inverted "" "" 428 | 429 | 430 | 433 | 434 | 435 | ==== rendering `rm`: cd=, dst=, negate=false 436 | 437 | # Remove @ 438 | cmd_rm "" "" 439 | 440 | 441 | 444 | 445 | 446 | ==== rendering `rm`: cd=, dst=none 447 | 448 | # Remove a bunch of items in 449 | 450 | 451 | 452 | cmd_rm "" "" 453 | 454 | 455 | 456 | 457 | 460 | 461 | 462 | ==== rendering `mv`: cd=, dst=, src= 463 | 464 | # Move to @ 465 | cmd_mv "" "" "" 466 | 467 | 468 | 471 | 472 | 473 | ==== rendering `mv`: cd=, dst=, src=none 474 | 475 | 476 | 477 | 478 | 479 | # Move to @ 480 | cmd_mv "" "" "" 481 | 482 | 483 | 484 | 485 | 488 | 489 | 490 | ==== rendering `if`: use=, negate=false 491 | 492 | # Check use flags: 493 | if cmd_use ""; then 494 | einfo "'' found in USE flags!" 495 | 496 | 497 | fi 498 | 499 | 500 | 501 | ==== rendering `if`: use=, negate=true 502 | 503 | # Check use flags: 504 | if cmd_use ""; then 505 | true 506 | else 507 | einfo "'' not found in USE flags!" 508 | 509 | 510 | fi 511 | 512 | 513 | 516 | 517 | 518 | ==== rendering `mkdir`: cd=, dst= 519 | 520 | # Make directory @ 521 | cmd_mkdir "" 522 | 523 | 524 | 527 | 528 | 529 | ==== rendering `mkdir`: cd=, dst=none 530 | 531 | 532 | 533 | 534 | # Make directory @ 535 | cmd_mkdir "" "" 536 | 537 | 538 | 539 | 540 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | -------------------------------------------------------------------------------- /filesystem-manager/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | sample=${1:-sample.xml} 4 | xsltproc \ 5 | --stringparam 'PN' cmake \ 6 | --stringparam 'PF' cmake-2.8.9-r4 \ 7 | --stringparam 'PR' r4 \ 8 | --stringparam 'PV' 2.8.9 \ 9 | --stringparam 'PVR' 2.8.9-r4 \ 10 | --stringparam 'CATEGORY' dev-utils \ 11 | --stringparam 'REPOSITORY' zaufi-overlay \ 12 | --stringparam 'SLOT' 0 \ 13 | --stringparam 'debug' yes \ 14 | filesystem-manager.xsl ${sample} 15 | -------------------------------------------------------------------------------- /filesystem-manager/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(FILESYSTEM_MANAGER_DTD "${PROJECT_SOURCE_DIR}/filesystem-manager/filesystem-manager.dtd") 2 | set(FILESYSTEM_MANAGER_XSL "${PROJECT_SOURCE_DIR}/filesystem-manager/filesystem-manager.xsl") 3 | set(FILESYSTEM_CMD_DIR "${PROJECT_SOURCE_DIR}/filesystem-manager/commands") 4 | # TODO Get rid of hardcoded path. Replace w/ stub. 5 | set(PALUDIS_EBUILD_DIR "/etc/init.d/functions.sh") 6 | 7 | include(AddFSMTest) 8 | 9 | if(DIFF_EXECUTABLE) 10 | add_fsm_test(matching) 11 | add_fsm_test(matching-partial) 12 | add_fsm_test(commands-renderer) 13 | else() 14 | message(STATUS "WARNING: `diff` was not found. Do not add FSM unit tests...") 15 | endif() 16 | 17 | add_shell_functions_test( 18 | NAME cmd-rm-not-existed-target 19 | PASS_REGULAR_EXPRESSION "Passed" 20 | ) 21 | add_shell_functions_test( 22 | NAME cmd-rm-dummy-dir 23 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 24 | ) 25 | add_shell_functions_test( 26 | NAME cmd-rm-test-1 27 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 28 | ) 29 | add_shell_functions_test( 30 | NAME cmd-rm-test-2 31 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 32 | ) 33 | add_shell_functions_test( 34 | NAME cmd-rm-with-starglobe 35 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 36 | ) 37 | 38 | add_shell_functions_test( 39 | NAME cmd-symlink-not-existed-base 40 | PASS_REGULAR_EXPRESSION "Passed" 41 | ) 42 | add_shell_functions_test( 43 | NAME cmd-symlink-test-1 44 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 45 | ) 46 | add_shell_functions_test( 47 | NAME cmd-symlink-test-2 48 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 49 | ) 50 | 51 | add_shell_functions_test( 52 | NAME cmd-mkdir-test-1 53 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 54 | ) 55 | 56 | add_shell_functions_test( 57 | NAME cmd-mv-not-existed-target 58 | PASS_REGULAR_EXPRESSION "Passed" 59 | ) 60 | add_shell_functions_test( 61 | NAME cmd-mv-test-1 62 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 63 | ) 64 | add_shell_functions_test( 65 | NAME cmd-mv-test-2 66 | PASS_REGULAR_EXPRESSION "Going to leave a warning.*Passed" 67 | ) 68 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-mkdir-test-1/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | function ebegin() 14 | { 15 | echo "$@" 16 | } 17 | function eend() 18 | { 19 | return $? 20 | } 21 | 22 | # Bring testing command into scope 23 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-mkdir.sh" 24 | 25 | # Remove possible results from previous run 26 | [ -d D ] && rm -rf D 27 | 28 | set -x 29 | # Make a fresh D directory 30 | mkdir -p D/pkg 31 | 32 | D="`pwd`/D" cmd_mkdir pkg sample-directory-1 sample-directory-2/nested-directory 33 | 34 | if [ "$?" = '0' -a -d "${D}/pkg/sample-directory-1" -a -d "${D}/pkg/sample-directory-2/nested-directory" ]; then 35 | echo Passed 36 | else 37 | echo Failed 38 | exit 1 39 | fi 40 | set +x 41 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-mv-not-existed-target/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | # Bring testing command into scope 14 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-mv.sh" 15 | 16 | # Remove possible results from previous run 17 | [ -d D ] && rm -rf D 18 | 19 | # Make a fresh D directory 20 | mkdir -p D/pkg 21 | 22 | set -x 23 | D="`pwd`/D" cmd_mv pkg not-existed-dir another-not-existed-dir 24 | set +x 25 | 26 | if [ "$?" = '0' -a -d "${D}" ]; then 27 | echo Passed 28 | else 29 | echo Failed 30 | exit 1 31 | fi 32 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-mv-test-1/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function cleanup_empty_dirs() 4 | { 5 | find ${D} -type d -a -empty -exec rmdir -p --ignore-fail-on-non-empty {} + 6 | [[ ! -e ${D} ]] && mkdir -p "${D}" 7 | } 8 | 9 | function verify_dir 10 | { 11 | return 0 12 | } 13 | 14 | function schedule_a_warning_after_all() 15 | { 16 | echo "Going to leave a warning" 17 | } 18 | 19 | # Bring testing command into scope 20 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-mv.sh" 21 | 22 | # Remove possible results from previous run 23 | [ -d D ] && rm -rf D 24 | 25 | # Make a fresh D directory 26 | mkdir -p D/pkg{,-r1} 27 | touch D/pkg/sample.file 28 | 29 | set -x 30 | D="`pwd`/D" cmd_mv pkg ../pkg-r1 sample.file 31 | set +x 32 | 33 | if [ "$?" = '0' -a ! -e "${D}/pkg" -a -e "${D}/pkg-r1/sample.file" ]; then 34 | echo Passed 35 | else 36 | echo Failed 37 | exit 1 38 | fi 39 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-mv-test-2/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function cleanup_empty_dirs() 4 | { 5 | find ${D} -type d -a -empty -exec rmdir -p --ignore-fail-on-non-empty {} + 6 | [[ ! -e ${D} ]] && mkdir -p "${D}" 7 | } 8 | 9 | function verify_dir 10 | { 11 | return 0 12 | } 13 | 14 | function schedule_a_warning_after_all() 15 | { 16 | echo "Going to leave a warning" 17 | } 18 | 19 | # Bring testing command into scope 20 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-mv.sh" 21 | 22 | # Remove possible results from previous run 23 | [ -d D ] && rm -rf D 24 | 25 | # Make a fresh D directory 26 | mkdir -p D/pkg{,-r1} 27 | touch D/pkg/sample.file 28 | 29 | set -x 30 | D="`pwd`/D" 31 | cmd_mv pkg "${D}/pkg-r1" "*" 32 | 33 | if [ "$?" = '0' -a ! -e "${D}/pkg" -a -e "${D}/pkg-r1/sample.file" ]; then 34 | echo Passed 35 | else 36 | echo Failed 37 | exit 1 38 | fi 39 | set +x 40 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-rm-dummy-dir/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function cleanup_empty_dirs() 4 | { 5 | find ${D} -type d -a -empty -exec rmdir -p --ignore-fail-on-non-empty {} + 6 | [[ ! -e ${D} ]] && mkdir -p "${D}" 7 | } 8 | 9 | function verify_dir 10 | { 11 | return 0 12 | } 13 | 14 | function schedule_a_warning_after_all() 15 | { 16 | echo "Going to leave a warning" 17 | } 18 | 19 | # Bring testing command into scope 20 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-rm.sh" 21 | 22 | # Remove possible results from previous run 23 | [ -d D ] && rm -rf D 24 | 25 | # Make a fresh D directory 26 | mkdir -p D/nested/dummy 27 | 28 | set -x 29 | D="`pwd`/D" 30 | cmd_rm nested dummy 31 | set +x 32 | 33 | if [ "$?" = '0' -a ! -d "${D}/nested" -a -d "${D}" ]; then 34 | echo Passed 35 | else 36 | echo Failed 37 | exit 1 38 | fi 39 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-rm-not-existed-target/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | # Bring testing command into scope 14 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-rm.sh" 15 | 16 | # Remove possible results from previous run 17 | [ -d D ] && rm -rf D 18 | 19 | # Make a fresh D directory 20 | mkdir -p D 21 | 22 | set -x 23 | D="`pwd`/D" cmd_rm not-existed-dir 24 | set +x 25 | 26 | if [ "$?" = '0' -a -d "${D}" ]; then 27 | echo Passed 28 | else 29 | echo Failed 30 | exit 1 31 | fi 32 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-rm-test-1/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function cleanup_empty_dirs() 4 | { 5 | find ${D} -type d -a -empty -exec rmdir -p --ignore-fail-on-non-empty {} + 6 | [[ ! -e ${D} ]] && mkdir -p "${D}" 7 | } 8 | 9 | function verify_dir 10 | { 11 | return 0 12 | } 13 | 14 | function schedule_a_warning_after_all() 15 | { 16 | echo "Going to leave a warning" 17 | } 18 | 19 | # Bring testing command into scope 20 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-rm.sh" 21 | 22 | # Remove possible results from previous run 23 | [ -d D ] && rm -rf D 24 | 25 | # Make a fresh D directory 26 | mkdir -p D/doc 27 | touch D/doc/README.md 28 | touch D/doc/SOME-README 29 | 30 | set -x 31 | 32 | D="`pwd`/D" 33 | cmd_rm doc "*README*" 34 | 35 | if [ "$?" = '0' -a ! -d "${D}/doc" -a -d "${D}" ]; then 36 | echo Passed 37 | else 38 | echo Failed 39 | exit 1 40 | fi 41 | 42 | set +x 43 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-rm-test-2/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | # Bring testing command into scope 14 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-rm.sh" 15 | 16 | # Remove possible results from previous run 17 | [ -d D ] && rm -rf D 18 | 19 | # Make a fresh D directory 20 | mkdir -p D/doc 21 | touch D/doc/README.md 22 | 23 | set -x 24 | 25 | D="`pwd`/D" 26 | cmd_rm doc "*NEWS*" 27 | 28 | set +x 29 | 30 | if [ "$?" = '0' -a -f "${D}/doc/README.md" ]; then 31 | echo Passed 32 | else 33 | echo Failed 34 | exit 1 35 | fi 36 | 37 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-rm-with-starglobe/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | # Bring testing command into scope 14 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-rm.sh" 15 | 16 | # Remove possible results from previous run 17 | [ -d D ] && rm -rf D 18 | 19 | # NOTE This options will be set in a generated script! 20 | shopt -qs globstar 21 | shopt -qs nullglob 22 | 23 | # Make a fresh D directory 24 | mkdir -p D/some/{one,two,tree}/{satu,dua,tiga} 25 | touch D/some/{one,two,tree}/2b-deleted 26 | touch D/some/{one,two,tree}/{satu,tiga}/2b-deleted 27 | touch D/some/{one,two,tree}/{satu,dua,tiga}/2b-kept 28 | touch D/some/2b-kept 29 | 30 | set -x 31 | D="`pwd`/D" 32 | cmd_rm some "**/2b-deleted" 33 | result="$?" 34 | set +x 35 | 36 | kept_count=$(find . -name 2b-kept | wc -l) 37 | deleted_count=$(find . -name 2b-deleted | wc -l) 38 | if [ "${result}" = '0' -a "${kept_count}" = '10' -a "${deleted_count}" = '0' ]; then 39 | echo Passed 40 | else 41 | echo Failed 42 | exit 1 43 | fi 44 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-symlink-not-existed-base/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | # Bring testing command into scope 14 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-symlink.sh" 15 | 16 | # Remove possible results from previous run 17 | [ -d D ] && rm -rf D 18 | 19 | # Make a fresh D directory 20 | mkdir -p D/test-dir 21 | 22 | set -x 23 | D="`pwd`/D" cmd_symlink not-existed-dir dummy dummy 24 | D="`pwd`/D" cmd_symlink test-dir dummy ../dummy 25 | set +x 26 | 27 | if [ "$?" = '0' -a ! -e "${D}/dummy" ]; then 28 | echo Passed 29 | else 30 | echo Failed 31 | exit 1 32 | fi 33 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-symlink-test-1/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | function ebegin() 14 | { 15 | echo "$@" 16 | } 17 | function eend() 18 | { 19 | return $? 20 | } 21 | 22 | # Bring testing command into scope 23 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-symlink.sh" 24 | 25 | # Remove possible results from previous run 26 | [ -d D ] && rm -rf D 27 | 28 | set -x 29 | # Make a fresh D directory 30 | mkdir -p D/src && mkdir -p D/dst 31 | touch D/src/sample.file 32 | 33 | D="`pwd`/D" cmd_symlink dst ../src/sample.file sample.symlink 34 | 35 | if [ "$?" = '0' -a -L "${D}/dst/sample.symlink" ]; then 36 | echo Passed 37 | else 38 | echo Failed 39 | exit 1 40 | fi 41 | set +x 42 | -------------------------------------------------------------------------------- /filesystem-manager/test/cmd-symlink-test-2/run_test.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function verify_dir 4 | { 5 | return 0 6 | } 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | echo "Going to leave a warning" 11 | } 12 | 13 | function ebegin() 14 | { 15 | echo "$@" 16 | } 17 | function eend() 18 | { 19 | return $? 20 | } 21 | 22 | # Bring testing command into scope 23 | . "@PROJECT_SOURCE_DIR@/filesystem-manager/commands/cmd-symlink.sh" 24 | 25 | # Remove possible results from previous run 26 | [ -d D ] && rm -rf D 27 | 28 | set -x 29 | # Make a fresh D directory 30 | mkdir -p D/doc/pkg/html 31 | 32 | D="`pwd`/D" cmd_symlink doc pkg/html pkg-html 33 | 34 | if [ "$?" = '0' -a -L "${D}/doc/pkg-html" ]; then 35 | echo Passed 36 | else 37 | echo Failed 38 | exit 1 39 | fi 40 | set +x 41 | -------------------------------------------------------------------------------- /filesystem-manager/test/commands-renderer/expected.output: -------------------------------------------------------------------------------- 1 | > Render a shell script for dev-util/cmake-3.4.3-r1:0::gentoo 2 | >> Dispatching by priority 24 3 | ==== ... nothing has matched: trying lower priority ... 4 | >> Dispatching by priority 23 5 | ==== ... nothing has matched: trying lower priority ... 6 | >> Dispatching by priority 22 7 | ==== ... nothing has matched: trying lower priority ... 8 | >> Dispatching by priority 21 9 | ==== ... nothing has matched: trying lower priority ... 10 | >> Dispatching by priority 20 11 | ==== ... nothing has matched: trying lower priority ... 12 | >> Dispatching by priority 19 13 | ==== ... nothing has matched: trying lower priority ... 14 | >> Dispatching by priority 18 15 | ==== ... nothing has matched: trying lower priority ... 16 | >> Dispatching by priority 17 17 | ==== Matched 1 package nodes w/ priority 17 18 | >>> Package matched: dev-util/cmake (priority=17, stop=false) 19 | ==== rendering `mkdir`: cd=/usr/share/doc, dst=cmake-3.4.3-r1 20 | ==== rendering `mv`: cd=/usr/share/doc/cmake-3.4.3, dst=../cmake-3.4.3-r1, src=html 21 | ==== continue matching packages w/ lower priority ... 22 | >> Dispatching by priority 16 23 | ==== ... nothing has matched: trying lower priority ... 24 | >> Dispatching by priority 15 25 | ==== ... nothing has matched: trying lower priority ... 26 | >> Dispatching by priority 14 27 | ==== ... nothing has matched: trying lower priority ... 28 | >> Dispatching by priority 13 29 | ==== ... nothing has matched: trying lower priority ... 30 | >> Dispatching by priority 12 31 | ==== ... nothing has matched: trying lower priority ... 32 | >> Dispatching by priority 11 33 | ==== ... nothing has matched: trying lower priority ... 34 | >> Dispatching by priority 10 35 | ==== ... nothing has matched: trying lower priority ... 36 | >> Dispatching by priority 9 37 | ==== Matched 1 package nodes w/ priority 9 38 | >>> Package matched: cmake (priority=9, stop=false) 39 | ==== rendering `symlink`: cd=/usr/share/doc, src=cmake-3.4.3-r1/html/, dst=cmake 40 | ==== rendering `rm`: cd=/usr/share/doc/cmake-3.4.3-r1, dst=none 41 | ==== continue matching packages w/ lower priority ... 42 | >> Dispatching by priority 8 43 | ==== ... nothing has matched: trying lower priority ... 44 | >> Dispatching by priority 7 45 | ==== ... nothing has matched: trying lower priority ... 46 | >> Dispatching by priority 6 47 | ==== ... nothing has matched: trying lower priority ... 48 | >> Dispatching by priority 5 49 | ==== Matched 1 package nodes w/ priority 5 50 | >>> Package matched: dev-util/* (priority=5, stop=false) 51 | ==== rendering `if`: use=doc, negate=true 52 | ==== rendering `rm`: cd=/usr/share, dst=doc, negate=false 53 | ==== continue matching packages w/ lower priority ... 54 | >> Dispatching by priority 4 55 | ==== ... nothing has matched: trying lower priority ... 56 | >> Dispatching by priority 3 57 | ==== ... nothing has matched: trying lower priority ... 58 | >> Dispatching by priority 2 59 | ==== ... nothing has matched: trying lower priority ... 60 | >> Dispatching by priority 1 61 | ==== Matched 2 package nodes w/ priority 1 62 | >>> Package matched: */* (priority=1, stop=false) 63 | ==== rendering `rm`: cd=/usr/share/locale/, dst=*/LC_MESSAGES/*.mo, negate=false 64 | ==== continue matching packages w/ lower priority ... 65 | >> Dispatching by priority 0 66 | ==== Recursion terminated === 67 | << Dispatching done 0 68 | <<< Matching done: */* (priority=1) 69 | >>> Package matched: */* (priority=1, stop=false) 70 | ==== rendering `rm`: cd=/usr/share/doc/cmake-3.4.3-r1, dst=none 71 | ==== continue matching packages w/ lower priority ... 72 | >> Dispatching by priority 0 73 | ==== Recursion terminated === 74 | << Dispatching done 0 75 | <<< Matching done: */* (priority=1) 76 | << Dispatching done 1 77 | << Dispatching done 2 78 | << Dispatching done 3 79 | << Dispatching done 4 80 | <<< Matching done: dev-util/* (priority=5) 81 | << Dispatching done 5 82 | << Dispatching done 6 83 | << Dispatching done 7 84 | << Dispatching done 8 85 | <<< Matching done: cmake (priority=9) 86 | << Dispatching done 9 87 | << Dispatching done 10 88 | << Dispatching done 11 89 | << Dispatching done 12 90 | << Dispatching done 13 91 | << Dispatching done 14 92 | << Dispatching done 15 93 | << Dispatching done 16 94 | <<< Matching done: dev-util/cmake (priority=17) 95 | << Dispatching done 17 96 | << Dispatching done 18 97 | << Dispatching done 19 98 | << Dispatching done 20 99 | << Dispatching done 21 100 | << Dispatching done 22 101 | << Dispatching done 23 102 | << Dispatching done 24 103 | < Rendering done for dev-util/cmake-3.4.3-r1:0::gentoo 104 | #!/bin/sh 105 | # 106 | # ATTENTION: This script produced by filesystem-manager paludis hook 107 | # on installing dev-util/cmake-3.4.3-r1:0::gentoo package 108 | # 109 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 110 | 111 | # Save some shell options status 112 | _fsm_shopt_globstar=$(shopt -p globstar) 113 | _fsm_shopt_nullglob=$(shopt -p nullglob) 114 | 115 | # Enable some shell options 116 | shopt -qs globstar 117 | shopt -qs nullglob 118 | 119 | # Loading command plug-ins 120 | for _fsm_cmd in /usr/share/paludis-hooks/filesystem-manager/commands/*.sh; do 121 | source "${_fsm_cmd}" 122 | done 123 | unset _fsm_cmd 124 | 125 | 126 | einfo "Filesystem Management Hook: Apply actions for dev-util/cmake" 127 | 128 | 129 | # Make directory cmake-3.4.3-r1 @ /usr/share/doc 130 | cmd_mkdir "/usr/share/doc" cmake-3.4.3-r1 131 | # Move html to ../cmake-3.4.3-r1 @ /usr/share/doc/cmake-3.4.3 132 | cmd_mv "/usr/share/doc/cmake-3.4.3" "../cmake-3.4.3-r1" "html" 133 | 134 | einfo "Filesystem Management Hook: Apply actions for cmake" 135 | 136 | 137 | 138 | # Make a symlink cmake-3.4.3-r1/html/ --> cmake @ /usr/share/doc 139 | cmd_symlink \ 140 | "/usr/share/doc" \ 141 | "cmake-3.4.3-r1/html/" \ 142 | "cmake" 143 | 144 | # Remove a bunch of items in /usr/share/doc/cmake-3.4.3-r1 145 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "html/_sources" 146 | 147 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "cmcompress/" 148 | 149 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "cmcurl/" 150 | 151 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "cmexpat/" 152 | 153 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "cmlibarchive/" 154 | 155 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "cmsys/" 156 | 157 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "cmzlib/" 158 | 159 | einfo "Filesystem Management Hook: Apply actions 'USE=-doc remover' for dev-util/*" 160 | 161 | 162 | # Check use flags: doc 163 | if cmd_use "doc"; then 164 | true 165 | else 166 | einfo "'doc' not found in USE flags!" 167 | 168 | # Remove doc @ /usr/share 169 | cmd_rm "/usr/share" "doc" 170 | 171 | fi 172 | 173 | einfo "Filesystem Management Hook: Apply actions 'locale-cleaner' for */*" 174 | 175 | 176 | # Remove */LC_MESSAGES/*.mo @ /usr/share/locale/ 177 | cmd_rm "/usr/share/locale/" "*/LC_MESSAGES/*.mo" 178 | 179 | einfo "Filesystem Management Hook: Apply actions 'docs-cleaner' for */*" 180 | 181 | 182 | # Remove a bunch of items in /usr/share/doc/cmake-3.4.3-r1 183 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "AUTHORS*" 184 | 185 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "*.AUTHORS*" 186 | 187 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "BUGS*" 188 | 189 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "CHANGELOG*" 190 | 191 | cmd_rm "/usr/share/doc/cmake-3.4.3-r1" "CHANGES*" 192 | 193 | # Restore saved shell options 194 | eval "${_fsm_shopt_globstar}" 195 | eval "${_fsm_shopt_nullglob}" 196 | unset _fsm_shopt_globstar 197 | unset _fsm_shopt_nullglob 198 | -------------------------------------------------------------------------------- /filesystem-manager/test/commands-renderer/input.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /filesystem-manager/test/exec-transform.cmake.in: -------------------------------------------------------------------------------- 1 | execute_process( 2 | COMMAND @XSLTPROC_EXECUTABLE@ 3 | --stringparam "PN" "@PN@" 4 | --stringparam "PF" "@PF@" 5 | --stringparam "PR" "@PR@" 6 | --stringparam "PV" "@PV@" 7 | --stringparam "PVR" "@PVR@" 8 | --stringparam "CATEGORY" "@CATEGORY@" 9 | --stringparam "REPOSITORY" "@REPOSITORY@" 10 | --stringparam "SLOT" "@SLOT@" 11 | --stringparam "debug" "yes" 12 | "@PROJECT_SOURCE_DIR@/filesystem-manager/filesystem-manager.xsl" 13 | "@_aft_input_test_conf@" 14 | WORKING_DIRECTORY "@_aft_working_directory@" 15 | OUTPUT_FILE "@_aft_output_test_conf@" 16 | ERROR_FILE "@_aft_output_test_conf@" 17 | RESULT_VARIABLE GENERATOR_EXIT_CODE 18 | ) 19 | -------------------------------------------------------------------------------- /filesystem-manager/test/matching-partial/expected.output: -------------------------------------------------------------------------------- 1 | > Render a shell script for dev-util/cmake-3.4.3-r1:0::gentoo 2 | >> Dispatching by priority 24 3 | ==== Matched 1 package nodes w/ priority 24 4 | >>> Package matched: dev-util/cmake-3.4.3-r1:0::gentoo (priority=24, stop=false) 5 | ==== continue matching packages w/ lower priority ... 6 | >> Dispatching by priority 23 7 | ==== Matched 1 package nodes w/ priority 23 8 | >>> Package matched: dev-util/cmake-3.4.3-r1:0 (priority=23, stop=false) 9 | ==== continue matching packages w/ lower priority ... 10 | >> Dispatching by priority 22 11 | ==== Matched 1 package nodes w/ priority 22 12 | >>> Package matched: dev-util/cmake-3.4.3-r1::gentoo (priority=22, stop=false) 13 | ==== continue matching packages w/ lower priority ... 14 | >> Dispatching by priority 21 15 | ==== Matched 1 package nodes w/ priority 21 16 | >>> Package matched: dev-util/cmake-3.4.3-r1 (priority=21, stop=false) 17 | ==== continue matching packages w/ lower priority ... 18 | >> Dispatching by priority 20 19 | ==== Matched 1 package nodes w/ priority 20 20 | >>> Package matched: dev-util/cmake:0::gentoo (priority=20, stop=false) 21 | ==== continue matching packages w/ lower priority ... 22 | >> Dispatching by priority 19 23 | ==== Matched 1 package nodes w/ priority 19 24 | >>> Package matched: dev-util/cmake:0 (priority=19, stop=false) 25 | ==== continue matching packages w/ lower priority ... 26 | >> Dispatching by priority 18 27 | ==== Matched 1 package nodes w/ priority 18 28 | >>> Package matched: dev-util/cmake::gentoo (priority=18, stop=false) 29 | ==== continue matching packages w/ lower priority ... 30 | >> Dispatching by priority 17 31 | ==== Matched 1 package nodes w/ priority 17 32 | >>> Package matched: dev-util/cmake (priority=17, stop=false) 33 | ==== continue matching packages w/ lower priority ... 34 | >> Dispatching by priority 16 35 | ==== Matched 1 package nodes w/ priority 16 36 | >>> Package matched: cmake-3.4.3-r1:0::gentoo (priority=16, stop=false) 37 | ==== continue matching packages w/ lower priority ... 38 | >> Dispatching by priority 15 39 | ==== Matched 1 package nodes w/ priority 15 40 | >>> Package matched: cmake-3.4.3-r1:0 (priority=15, stop=false) 41 | ==== continue matching packages w/ lower priority ... 42 | >> Dispatching by priority 14 43 | ==== Matched 1 package nodes w/ priority 14 44 | >>> Package matched: cmake-3.4.3-r1::gentoo (priority=14, stop=false) 45 | ==== continue matching packages w/ lower priority ... 46 | >> Dispatching by priority 13 47 | ==== Matched 1 package nodes w/ priority 13 48 | >>> Package matched: cmake-3.4.3-r1 (priority=13, stop=true) 49 | <<< Matching done: cmake-3.4.3-r1 (priority=13) 50 | << Dispatching done 13 51 | <<< Matching done: cmake-3.4.3-r1::gentoo (priority=14) 52 | << Dispatching done 14 53 | <<< Matching done: cmake-3.4.3-r1:0 (priority=15) 54 | << Dispatching done 15 55 | <<< Matching done: cmake-3.4.3-r1:0::gentoo (priority=16) 56 | << Dispatching done 16 57 | <<< Matching done: dev-util/cmake (priority=17) 58 | << Dispatching done 17 59 | <<< Matching done: dev-util/cmake::gentoo (priority=18) 60 | << Dispatching done 18 61 | <<< Matching done: dev-util/cmake:0 (priority=19) 62 | << Dispatching done 19 63 | <<< Matching done: dev-util/cmake:0::gentoo (priority=20) 64 | << Dispatching done 20 65 | <<< Matching done: dev-util/cmake-3.4.3-r1 (priority=21) 66 | << Dispatching done 21 67 | <<< Matching done: dev-util/cmake-3.4.3-r1::gentoo (priority=22) 68 | << Dispatching done 22 69 | <<< Matching done: dev-util/cmake-3.4.3-r1:0 (priority=23) 70 | << Dispatching done 23 71 | <<< Matching done: dev-util/cmake-3.4.3-r1:0::gentoo (priority=24) 72 | << Dispatching done 24 73 | < Rendering done for dev-util/cmake-3.4.3-r1:0::gentoo 74 | #!/bin/sh 75 | # 76 | # ATTENTION: This script produced by filesystem-manager paludis hook 77 | # on installing dev-util/cmake-3.4.3-r1:0::gentoo package 78 | # 79 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 80 | 81 | # Save some shell options status 82 | _fsm_shopt_globstar=$(shopt -p globstar) 83 | _fsm_shopt_nullglob=$(shopt -p nullglob) 84 | 85 | # Enable some shell options 86 | shopt -qs globstar 87 | shopt -qs nullglob 88 | 89 | # Loading command plug-ins 90 | for _fsm_cmd in /usr/share/paludis-hooks/filesystem-manager/commands/*.sh; do 91 | source "${_fsm_cmd}" 92 | done 93 | unset _fsm_cmd 94 | 95 | 96 | einfo "Filesystem Management Hook: Apply actions 'priority 24' for dev-util/cmake-3.4.3-r1:0::gentoo" 97 | 98 | 99 | einfo "Filesystem Management Hook: Apply actions 'priority 23' for dev-util/cmake-3.4.3-r1:0" 100 | 101 | 102 | einfo "Filesystem Management Hook: Apply actions 'priority 22' for dev-util/cmake-3.4.3-r1::gentoo" 103 | 104 | 105 | einfo "Filesystem Management Hook: Apply actions 'priority 21' for dev-util/cmake-3.4.3-r1" 106 | 107 | 108 | einfo "Filesystem Management Hook: Apply actions 'priority 20' for dev-util/cmake:0::gentoo" 109 | 110 | 111 | einfo "Filesystem Management Hook: Apply actions 'priority 19' for dev-util/cmake:0" 112 | 113 | 114 | einfo "Filesystem Management Hook: Apply actions 'priority 18' for dev-util/cmake::gentoo" 115 | 116 | 117 | einfo "Filesystem Management Hook: Apply actions 'priority 17' for dev-util/cmake" 118 | 119 | 120 | einfo "Filesystem Management Hook: Apply actions 'priority 16' for cmake-3.4.3-r1:0::gentoo" 121 | 122 | 123 | einfo "Filesystem Management Hook: Apply actions 'priority 15' for cmake-3.4.3-r1:0" 124 | 125 | 126 | einfo "Filesystem Management Hook: Apply actions 'priority 14' for cmake-3.4.3-r1::gentoo" 127 | 128 | 129 | einfo "Filesystem Management Hook: Apply actions 'priority 13' for cmake-3.4.3-r1" 130 | 131 | 132 | # Restore saved shell options 133 | eval "${_fsm_shopt_globstar}" 134 | eval "${_fsm_shopt_nullglob}" 135 | unset _fsm_shopt_globstar 136 | unset _fsm_shopt_nullglob 137 | -------------------------------------------------------------------------------- /filesystem-manager/test/matching-partial/input.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /filesystem-manager/test/matching/expected.output: -------------------------------------------------------------------------------- 1 | > Render a shell script for dev-util/cmake-3.4.3-r1:0::gentoo 2 | >> Dispatching by priority 24 3 | ==== Matched 1 package nodes w/ priority 24 4 | >>> Package matched: dev-util/cmake-3.4.3-r1:0::gentoo (priority=24, stop=false) 5 | ==== continue matching packages w/ lower priority ... 6 | >> Dispatching by priority 23 7 | ==== Matched 1 package nodes w/ priority 23 8 | >>> Package matched: dev-util/cmake-3.4.3-r1:0 (priority=23, stop=false) 9 | ==== continue matching packages w/ lower priority ... 10 | >> Dispatching by priority 22 11 | ==== Matched 1 package nodes w/ priority 22 12 | >>> Package matched: dev-util/cmake-3.4.3-r1::gentoo (priority=22, stop=false) 13 | ==== continue matching packages w/ lower priority ... 14 | >> Dispatching by priority 21 15 | ==== Matched 1 package nodes w/ priority 21 16 | >>> Package matched: dev-util/cmake-3.4.3-r1 (priority=21, stop=false) 17 | ==== continue matching packages w/ lower priority ... 18 | >> Dispatching by priority 20 19 | ==== Matched 1 package nodes w/ priority 20 20 | >>> Package matched: dev-util/cmake:0::gentoo (priority=20, stop=false) 21 | ==== continue matching packages w/ lower priority ... 22 | >> Dispatching by priority 19 23 | ==== Matched 1 package nodes w/ priority 19 24 | >>> Package matched: dev-util/cmake:0 (priority=19, stop=false) 25 | ==== continue matching packages w/ lower priority ... 26 | >> Dispatching by priority 18 27 | ==== Matched 1 package nodes w/ priority 18 28 | >>> Package matched: dev-util/cmake::gentoo (priority=18, stop=false) 29 | ==== continue matching packages w/ lower priority ... 30 | >> Dispatching by priority 17 31 | ==== Matched 1 package nodes w/ priority 17 32 | >>> Package matched: dev-util/cmake (priority=17, stop=false) 33 | ==== continue matching packages w/ lower priority ... 34 | >> Dispatching by priority 16 35 | ==== Matched 1 package nodes w/ priority 16 36 | >>> Package matched: cmake-3.4.3-r1:0::gentoo (priority=16, stop=false) 37 | ==== continue matching packages w/ lower priority ... 38 | >> Dispatching by priority 15 39 | ==== Matched 1 package nodes w/ priority 15 40 | >>> Package matched: cmake-3.4.3-r1:0 (priority=15, stop=false) 41 | ==== continue matching packages w/ lower priority ... 42 | >> Dispatching by priority 14 43 | ==== Matched 1 package nodes w/ priority 14 44 | >>> Package matched: cmake-3.4.3-r1::gentoo (priority=14, stop=false) 45 | ==== continue matching packages w/ lower priority ... 46 | >> Dispatching by priority 13 47 | ==== Matched 1 package nodes w/ priority 13 48 | >>> Package matched: cmake-3.4.3-r1 (priority=13, stop=false) 49 | ==== continue matching packages w/ lower priority ... 50 | >> Dispatching by priority 12 51 | ==== Matched 1 package nodes w/ priority 12 52 | >>> Package matched: cmake:0::gentoo (priority=12, stop=false) 53 | ==== continue matching packages w/ lower priority ... 54 | >> Dispatching by priority 11 55 | ==== Matched 1 package nodes w/ priority 11 56 | >>> Package matched: cmake:0 (priority=11, stop=false) 57 | ==== continue matching packages w/ lower priority ... 58 | >> Dispatching by priority 10 59 | ==== Matched 1 package nodes w/ priority 10 60 | >>> Package matched: cmake::gentoo (priority=10, stop=false) 61 | ==== continue matching packages w/ lower priority ... 62 | >> Dispatching by priority 9 63 | ==== Matched 1 package nodes w/ priority 9 64 | >>> Package matched: cmake (priority=9, stop=false) 65 | ==== continue matching packages w/ lower priority ... 66 | >> Dispatching by priority 8 67 | ==== Matched 1 package nodes w/ priority 8 68 | >>> Package matched: dev-util/*:0::gentoo (priority=8, stop=false) 69 | ==== continue matching packages w/ lower priority ... 70 | >> Dispatching by priority 7 71 | ==== Matched 1 package nodes w/ priority 7 72 | >>> Package matched: dev-util/*:0 (priority=7, stop=false) 73 | ==== continue matching packages w/ lower priority ... 74 | >> Dispatching by priority 6 75 | ==== Matched 1 package nodes w/ priority 6 76 | >>> Package matched: dev-util/*::gentoo (priority=6, stop=false) 77 | ==== continue matching packages w/ lower priority ... 78 | >> Dispatching by priority 5 79 | ==== Matched 1 package nodes w/ priority 5 80 | >>> Package matched: dev-util/* (priority=5, stop=false) 81 | ==== continue matching packages w/ lower priority ... 82 | >> Dispatching by priority 4 83 | ==== Matched 1 package nodes w/ priority 4 84 | >>> Package matched: */*:0::gentoo (priority=4, stop=false) 85 | ==== continue matching packages w/ lower priority ... 86 | >> Dispatching by priority 3 87 | ==== Matched 1 package nodes w/ priority 3 88 | >>> Package matched: */*:0 (priority=3, stop=false) 89 | ==== continue matching packages w/ lower priority ... 90 | >> Dispatching by priority 2 91 | ==== Matched 1 package nodes w/ priority 2 92 | >>> Package matched: */*::gentoo (priority=2, stop=false) 93 | ==== continue matching packages w/ lower priority ... 94 | >> Dispatching by priority 1 95 | ==== Matched 1 package nodes w/ priority 1 96 | >>> Package matched: */* (priority=1, stop=false) 97 | ==== continue matching packages w/ lower priority ... 98 | >> Dispatching by priority 0 99 | ==== Recursion terminated === 100 | << Dispatching done 0 101 | <<< Matching done: */* (priority=1) 102 | << Dispatching done 1 103 | <<< Matching done: */*::gentoo (priority=2) 104 | << Dispatching done 2 105 | <<< Matching done: */*:0 (priority=3) 106 | << Dispatching done 3 107 | <<< Matching done: */*:0::gentoo (priority=4) 108 | << Dispatching done 4 109 | <<< Matching done: dev-util/* (priority=5) 110 | << Dispatching done 5 111 | <<< Matching done: dev-util/*::gentoo (priority=6) 112 | << Dispatching done 6 113 | <<< Matching done: dev-util/*:0 (priority=7) 114 | << Dispatching done 7 115 | <<< Matching done: dev-util/*:0::gentoo (priority=8) 116 | << Dispatching done 8 117 | <<< Matching done: cmake (priority=9) 118 | << Dispatching done 9 119 | <<< Matching done: cmake::gentoo (priority=10) 120 | << Dispatching done 10 121 | <<< Matching done: cmake:0 (priority=11) 122 | << Dispatching done 11 123 | <<< Matching done: cmake:0::gentoo (priority=12) 124 | << Dispatching done 12 125 | <<< Matching done: cmake-3.4.3-r1 (priority=13) 126 | << Dispatching done 13 127 | <<< Matching done: cmake-3.4.3-r1::gentoo (priority=14) 128 | << Dispatching done 14 129 | <<< Matching done: cmake-3.4.3-r1:0 (priority=15) 130 | << Dispatching done 15 131 | <<< Matching done: cmake-3.4.3-r1:0::gentoo (priority=16) 132 | << Dispatching done 16 133 | <<< Matching done: dev-util/cmake (priority=17) 134 | << Dispatching done 17 135 | <<< Matching done: dev-util/cmake::gentoo (priority=18) 136 | << Dispatching done 18 137 | <<< Matching done: dev-util/cmake:0 (priority=19) 138 | << Dispatching done 19 139 | <<< Matching done: dev-util/cmake:0::gentoo (priority=20) 140 | << Dispatching done 20 141 | <<< Matching done: dev-util/cmake-3.4.3-r1 (priority=21) 142 | << Dispatching done 21 143 | <<< Matching done: dev-util/cmake-3.4.3-r1::gentoo (priority=22) 144 | << Dispatching done 22 145 | <<< Matching done: dev-util/cmake-3.4.3-r1:0 (priority=23) 146 | << Dispatching done 23 147 | <<< Matching done: dev-util/cmake-3.4.3-r1:0::gentoo (priority=24) 148 | << Dispatching done 24 149 | < Rendering done for dev-util/cmake-3.4.3-r1:0::gentoo 150 | #!/bin/sh 151 | # 152 | # ATTENTION: This script produced by filesystem-manager paludis hook 153 | # on installing dev-util/cmake-3.4.3-r1:0::gentoo package 154 | # 155 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 156 | 157 | # Save some shell options status 158 | _fsm_shopt_globstar=$(shopt -p globstar) 159 | _fsm_shopt_nullglob=$(shopt -p nullglob) 160 | 161 | # Enable some shell options 162 | shopt -qs globstar 163 | shopt -qs nullglob 164 | 165 | # Loading command plug-ins 166 | for _fsm_cmd in /usr/share/paludis-hooks/filesystem-manager/commands/*.sh; do 167 | source "${_fsm_cmd}" 168 | done 169 | unset _fsm_cmd 170 | 171 | 172 | einfo "Filesystem Management Hook: Apply actions 'priority 24' for dev-util/cmake-3.4.3-r1:0::gentoo" 173 | 174 | 175 | einfo "Filesystem Management Hook: Apply actions 'priority 23' for dev-util/cmake-3.4.3-r1:0" 176 | 177 | 178 | einfo "Filesystem Management Hook: Apply actions 'priority 22' for dev-util/cmake-3.4.3-r1::gentoo" 179 | 180 | 181 | einfo "Filesystem Management Hook: Apply actions 'priority 21' for dev-util/cmake-3.4.3-r1" 182 | 183 | 184 | einfo "Filesystem Management Hook: Apply actions 'priority 20' for dev-util/cmake:0::gentoo" 185 | 186 | 187 | einfo "Filesystem Management Hook: Apply actions 'priority 19' for dev-util/cmake:0" 188 | 189 | 190 | einfo "Filesystem Management Hook: Apply actions 'priority 18' for dev-util/cmake::gentoo" 191 | 192 | 193 | einfo "Filesystem Management Hook: Apply actions 'priority 17' for dev-util/cmake" 194 | 195 | 196 | einfo "Filesystem Management Hook: Apply actions 'priority 16' for cmake-3.4.3-r1:0::gentoo" 197 | 198 | 199 | einfo "Filesystem Management Hook: Apply actions 'priority 15' for cmake-3.4.3-r1:0" 200 | 201 | 202 | einfo "Filesystem Management Hook: Apply actions 'priority 14' for cmake-3.4.3-r1::gentoo" 203 | 204 | 205 | einfo "Filesystem Management Hook: Apply actions 'priority 13' for cmake-3.4.3-r1" 206 | 207 | 208 | einfo "Filesystem Management Hook: Apply actions 'priority 12' for cmake:0::gentoo" 209 | 210 | 211 | einfo "Filesystem Management Hook: Apply actions 'priority 11' for cmake:0" 212 | 213 | 214 | einfo "Filesystem Management Hook: Apply actions 'priority 10' for cmake::gentoo" 215 | 216 | 217 | einfo "Filesystem Management Hook: Apply actions 'priority 9' for cmake" 218 | 219 | 220 | einfo "Filesystem Management Hook: Apply actions 'priority 8' for dev-util/*:0::gentoo" 221 | 222 | 223 | einfo "Filesystem Management Hook: Apply actions 'priority 7' for dev-util/*:0" 224 | 225 | 226 | einfo "Filesystem Management Hook: Apply actions 'priority 6' for dev-util/*::gentoo" 227 | 228 | 229 | einfo "Filesystem Management Hook: Apply actions 'priority 5' for dev-util/*" 230 | 231 | 232 | einfo "Filesystem Management Hook: Apply actions 'priority 4' for */*:0::gentoo" 233 | 234 | 235 | einfo "Filesystem Management Hook: Apply actions 'priority 3' for */*:0" 236 | 237 | 238 | einfo "Filesystem Management Hook: Apply actions 'priority 2' for */*::gentoo" 239 | 240 | 241 | einfo "Filesystem Management Hook: Apply actions 'priority 1' for */*" 242 | 243 | 244 | # Restore saved shell options 245 | eval "${_fsm_shopt_globstar}" 246 | eval "${_fsm_shopt_nullglob}" 247 | unset _fsm_shopt_globstar 248 | unset _fsm_shopt_nullglob 249 | -------------------------------------------------------------------------------- /filesystem-manager/test/matching/input.xml.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /filesystem-manager/test/run-cmd-test.bash.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -x 3 | 4 | source @FILESYSTEM_CMD_DIR@/@_afct_cmd@.sh 5 | 6 | #BEGIN Dummy functions, a replacement instead of extected to be exported by FSM hook 7 | 8 | function schedule_a_warning_after_all() 9 | { 10 | return 0 11 | } 12 | export -f schedule_a_warning_after_all 13 | 14 | function verify_dir() 15 | { 16 | return 0 17 | } 18 | export -f verify_dir 19 | #END Dummy functions, a replacement instead of extected to be exported by FSM hook 20 | 21 | @_afct_cmd_fn@ . @_afct_args@ 22 | 23 | set +x 24 | -------------------------------------------------------------------------------- /filesystem-manager/test/run-cmd-test.cmake.in: -------------------------------------------------------------------------------- 1 | include("@_afct_working_directory@/prepare.cmake") 2 | 3 | set(ENV{D} "@D@") 4 | 5 | execute_process( 6 | COMMAND /bin/bash run-cmd-test.bash 7 | WORKING_DIRECTORY "@_afct_working_directory@" 8 | RESULT_VARIABLE BASH_EXIT_CODE 9 | ) 10 | -------------------------------------------------------------------------------- /filesystem-manager/test/run-test.cmake.in: -------------------------------------------------------------------------------- 1 | include("@_aft_working_directory@/exec-transform.cmake") 2 | 3 | # Analyze result code 4 | if(NOT GENERATOR_EXIT_CODE STREQUAL "0") 5 | message(FATAL_ERROR "XSLT transformation failed") 6 | endif() 7 | 8 | # Compare generated putput w/ expected 9 | if(NOT EXISTS "@_aft_expected_output@") 10 | message(FATAL_ERROR "Expected output file not found: @_aft_expected_output@") 11 | endif() 12 | 13 | execute_process( 14 | COMMAND @DIFF_EXECUTABLE@ -ub 15 | "@_aft_output_test_conf@" 16 | "@_aft_expected_output@" 17 | WORKING_DIRECTORY "@_aft_working_directory@" 18 | OUTPUT_FILE "@_aft_diff_output@" 19 | ERROR_FILE "@_aft_diff_output@" 20 | RESULT_VARIABLE DIFF_EXIT_CODE 21 | ) 22 | 23 | if(NOT DIFF_EXIT_CODE STREQUAL "0") 24 | file(READ "@_aft_output_test_conf@" _diff) 25 | message(FATAL_ERROR "Output doesn't match to expected result:\n ${_diff}") 26 | endif() 27 | -------------------------------------------------------------------------------- /filesystem-manager/test/update-expected-output.cmake.in: -------------------------------------------------------------------------------- 1 | include("@_aft_working_directory@/exec-transform.cmake") 2 | 3 | # Analyze result code 4 | if(NOT GENERATOR_EXIT_CODE STREQUAL "0") 5 | message(FATAL_ERROR "XSLT transformation failed") 6 | endif() 7 | 8 | message(STATUS "Moving '@_aft_output_test_conf@' -> '@_aft_expected_output@'") 9 | file(RENAME "@_aft_output_test_conf@" "@_aft_expected_output@") 10 | -------------------------------------------------------------------------------- /package.env/default-deps-trk.conf: -------------------------------------------------------------------------------- 1 | # NOTE I have `--disable-dependency-tracking` in `EXTRA_ECONF` variable of my `bashrc`, 2 | # but there is some ugly packages, that can't build w/ this option... 3 | 4 | phenv-filter-var EXTRA_ECONF --disable-dependency-tracking --enable-dependency-tracking 5 | einfo "Set dependecy traking to default: EXTRA_ECONF=${EXTRA_ECONF}" 6 | 7 | # kate: hl bash; 8 | -------------------------------------------------------------------------------- /package.env/default-silent-rules.conf: -------------------------------------------------------------------------------- 1 | phenv-filter-var EXTRA_ECONF --enable-silent-rules --disable-silent-rules 2 | einfo "Set silent rules to default: EXTRA_ECONF=${EXTRA_ECONF}" 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/extra-optimize.conf: -------------------------------------------------------------------------------- 1 | einfo "Use -O3 optimization level" 2 | 3 | filter-flags -O* 4 | append-cflags -O3 5 | append-cxxflags -O3 6 | 7 | # kate: hl bash; 8 | -------------------------------------------------------------------------------- /package.env/ld-no-gc-sections.conf: -------------------------------------------------------------------------------- 1 | einfo "Remove --gc-sections from linker flags" 2 | filter-ldflags -Wl,--gc-sections 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/ld-no-hash-style.conf: -------------------------------------------------------------------------------- 1 | einfo "Remove --hash-style from linker flags" 2 | filter-ldflags -Wl,--hash-style=* 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/ld-no-new-dtags.conf: -------------------------------------------------------------------------------- 1 | einfo "Remove --enable-new-dtags from linker flags" 2 | filter-ldflags -Wl,--enable-new-dtags 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/ld-no-sort-common.conf: -------------------------------------------------------------------------------- 1 | einfo "Remove --sort-common from linker flags" 2 | filter-ldflags -Wl,--sort-common 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/lto.conf: -------------------------------------------------------------------------------- 1 | # NOTE Here is only basic LTO flags, one may add some more in bashrc in LTO_EXTRA_FLAGS variable 2 | LTO_FLAGS="$(test-flags -flto=$(phenv-get-cpu-available) -fuse-linker-plugin ${LTO_EXTRA_FLAGS})" 3 | if [[ -n ${LTO_FLAGS} ]]; then 4 | einfo "Add LTO related flags: ${LTO_FLAGS}" 5 | 6 | append-cflags ${LTO_FLAGS} 7 | append-cxxflags ${LTO_FLAGS} 8 | append-ldflags ${LTO_FLAGS} 9 | 10 | # ATTENTION It is important to use GCC's wrappers instead of binutils' provided tools 11 | export AR=$(phenv-getAR) 12 | export RANLIB=$(phenv-getRANLIB) 13 | export NM=$(phenv-getNM) 14 | einfo "Using ${AR}, ${RANLIB}" 15 | fi 16 | unset LTO_FLAGS 17 | # Keep silence (as supposed by PMS) if LTO do not supported by the current compiler 18 | 19 | # kate: hl bash; 20 | -------------------------------------------------------------------------------- /package.env/max-debug.conf: -------------------------------------------------------------------------------- 1 | einfo "Turn OFF all optimizations! Entering full debug mode" 2 | CFLAGS="-O0 -ggdb -UNDEBUG -DDEBUG -D_DEBUG" 3 | CXXFLAGS="${CFLAGS}" 4 | LDFLAGS="-Wl,--as-needed" 5 | 6 | # kate: hl bash; 7 | -------------------------------------------------------------------------------- /package.env/no-debug.conf: -------------------------------------------------------------------------------- 1 | einfo "Disable debug info" 2 | filter-flags -g -ggdb 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/no-gnu-tls.conf: -------------------------------------------------------------------------------- 1 | einfo "Remove -mtls-dialect=gnu2 from compiler flags" 2 | filter-flags -mtls-dialect=gnu2 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/no-lto.conf: -------------------------------------------------------------------------------- 1 | einfo "Disable LTO" 2 | filter-flags -flto* -fuse-linker-plugin 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/no-modern-c++.conf: -------------------------------------------------------------------------------- 1 | einfo "Do not use C++14 to build this ugly package" 2 | filter-flags -std=gnu++14 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /package.env/setup_pkg_env.bash.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Helper functions to use from /etc/paludis/bashrc and 4 | # package environment control files. 5 | # 6 | # Copyright 2014-2017 by Alex Turbov 7 | # 8 | 9 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 10 | 11 | # Do nothing on sync or fetch action. 12 | # 13 | # NOTE When `WORKDIR` is defined -- we are ready to really build the package! 14 | # (i.e. fetch has completed) 15 | # 16 | if [[ ${PALUDIS_ACTION} != sync && -n ${WORKDIR} ]]; then 17 | # Bring flag-o-matic.eclass into the scope, so env files may use functions from it to manupulate compiler/linker flags 18 | inherit flag-o-matic 19 | fi 20 | 21 | 22 | # 23 | # Get current GCC version 24 | # 25 | phenv-get-gcc-version() 26 | { 27 | local gcc_bin="${CC:-gcc}" 28 | set -- $("${gcc_bin}" -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__") 29 | echo $1.$2.$3 30 | } 31 | 32 | # 33 | # Get a number of CPUs available 34 | # 35 | phenv-get-cpu-available() 36 | { 37 | nproc 38 | } 39 | 40 | #BEGIN Helper functions named after toolchain-funcs.eclass 41 | # 42 | # Helper function to build a full path to requested GCC utility 43 | # based on current GCC (found in `PATH`) or `CC` environment variable. 44 | # 45 | # $1 -- program name 46 | # 47 | _phenv-getPROG() 48 | { 49 | local prog="${1}" 50 | echo /usr/${CHOST}/gcc-bin/$(phenv-get-gcc-version)/gcc-${prog} 51 | } 52 | # 53 | # Get a full path to GCC's `ar` wrapper 54 | # 55 | phenv-getAR() 56 | { 57 | _phenv-getPROG ar 58 | } 59 | # 60 | # Get a full path to GCC's `nm` wrapper 61 | # 62 | phenv-getNM() 63 | { 64 | _phenv-getPROG nm 65 | } 66 | # 67 | # Get a full path to GCC's `ranlib` wrapper 68 | # 69 | phenv-getRANLIB() 70 | { 71 | _phenv-getPROG ranlib 72 | } 73 | #END Helper functions named after toolchain-funcs.eclass 74 | 75 | # 76 | # Add options to the end of a given var 77 | # $1 - variable to modify 78 | # $2..$n - options to add 79 | # 80 | phenv-append-var() 81 | { 82 | local var=$1 83 | shift 84 | local stmt="$var=\"\$${var} $*\"" 85 | eval "$stmt" 86 | } 87 | 88 | # 89 | # Remove options from a given var 90 | # $1 - variable to modify 91 | # $2..$n - options to remove 92 | # 93 | phenv-filter-var() 94 | { 95 | local -r _ro_var="$1" 96 | shift 97 | local -a _ro_new_value 98 | local _ro_opt 99 | local _ro_del_value 100 | 101 | # Iterate over options in a variable 102 | for _ro_opt in ${!_ro_var}; do 103 | # Iterate over options to remove passed as function parameters 104 | for _ro_del_value in "$@"; do 105 | [[ ${_ro_opt} == ${_ro_del_value} ]] && continue 2 106 | done 107 | _ro_new_value+=( "${_ro_opt}" ) 108 | done 109 | eval "${_ro_var}=\"${_ro_new_value[@]}\"" 110 | } 111 | 112 | # 113 | # The main function to be used from ${PALUDIS_CONFIG_DIR}/bashrc 114 | # 115 | setup_pkg_env() 116 | { 117 | [[ ! -f ${PALUDIS_CONFIG_DIR}/package_env.conf || ${EBUILD_PHASE} = initmisc ]] && return 118 | # Select configured environments 119 | # NOTE It is important to apply them in the same order! (even duplicates) 120 | local envs=$(for i in $(egrep "^${CATEGORY}/(${PN}|\*)(:[^\s]+)?\s" ${PALUDIS_CONFIG_DIR}/package_env.conf | sed 's,[^ ]\+\s,,'); do echo "${i}"; done) 121 | for conf in $envs; do 122 | if [[ -f ${PALUDIS_CONFIG_DIR}/env.conf.d/${conf}.conf ]]; then 123 | source ${PALUDIS_CONFIG_DIR}/env.conf.d/${conf}.conf 124 | fi 125 | # NOTE Silently ignore undefined environment. 126 | # To avoid any output from bashrc, as supposed by [docs](http://paludis.exherbo.org/configuration/bashrc.html) 127 | done 128 | } 129 | 130 | # Do nothing on sync or fetch action. 131 | # 132 | # NOTE When `WORKDIR` is defined -- we are ready to really build the package! 133 | # (i.e. fetch has completed) 134 | # 135 | # TODO What other actions possible? 136 | # 137 | # TODO Make sure the rest will run only on real build of some package. 138 | # 139 | [[ ${PALUDIS_ACTION} != sync && -n ${WORKDIR} ]] && setup_pkg_env 140 | 141 | # kate: hl bash; 142 | -------------------------------------------------------------------------------- /package.env/spam.conf: -------------------------------------------------------------------------------- 1 | env_log=/tmp/${PF}.env-${PALUDIS_PID}.log 2 | set_log=/tmp/${PF}.set-${PALUDIS_PID}.log 3 | 4 | einfo "Output env+set to debug log files: ${env_log}, ${set_log}" 5 | 6 | echo "---[ `date` ] ---" >> ${env_log} 7 | env >> ${env_log} 8 | 9 | echo "---[ `date` ] ---" >> ${set_log} 10 | set >> ${set_log} 11 | 12 | unset env_log 13 | unset set_log 14 | 15 | # kate: hl bash; 16 | -------------------------------------------------------------------------------- /package.env/use-bfd-linker.conf: -------------------------------------------------------------------------------- 1 | if [[ bfd != $(readlink -f $(which ld) | sed 's,.*\.\(bfd$\),\1,') ]]; then 2 | einfo "Use ld.bfd linker" 3 | append-ldflags -Wl,-fuse-ld=bfd 4 | fi 5 | 6 | # kate: hl bash; 7 | -------------------------------------------------------------------------------- /package.env/use-gold-linker.conf: -------------------------------------------------------------------------------- 1 | if [[ gold != $(readlink -f $(which ld) | sed 's,.*\.\(gold$\),\1,') ]]; then 2 | einfo "Use ld.gold linker" 3 | append-ldflags -Wl,-fuse-ld=gold 4 | fi 5 | 6 | # kate: hl bash; 7 | -------------------------------------------------------------------------------- /package.env/use-latest-gcc.conf: -------------------------------------------------------------------------------- 1 | gcc_bin=$(basename $(ls -1 /usr/bin/gcc-[0-9].[0-9].[0-9] | sort | tail -n 1)) 2 | if [[ -n ${gcc_bin} ]]; then 3 | export CC="${gcc_bin}" 4 | fi 5 | gplusplus_bin=$(basename $(ls -1 /usr/bin/g++-[0-9].[0-9].[0-9] | sort | tail -n 1)) 6 | if [[ -n ${gplusplus_bin} ]]; then 7 | export CXX="${gplusplus_bin}" 8 | fi 9 | 10 | einfo "Use latest GCC to build this package: ${gcc_bin}/${gplusplus_bin}" 11 | 12 | unset gcc_bin 13 | unset gplusplus_bin 14 | 15 | # kate: hl bash; 16 | -------------------------------------------------------------------------------- /package.env/use-modern-c++.conf: -------------------------------------------------------------------------------- 1 | einfo "Use C++14 to build this package" 2 | append-cxxflags -std=gnu++14 3 | 4 | # kate: hl bash; 5 | -------------------------------------------------------------------------------- /print-ebuild-path: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # Get path to the ebuild by package specification. 4 | # 5 | # Copyright (c) 2013 Alex Turbov 6 | # 7 | # This command can be used in bash scripts as `cave print-ebuild-path ` 8 | # 9 | 10 | import argparse 11 | import paludis 12 | import os 13 | import portage.output 14 | import sys 15 | 16 | 17 | 18 | def main(): 19 | log = portage.output.EOutput() 20 | parser = argparse.ArgumentParser(description='Get ebuild path for a given spec') 21 | parser.add_argument( 22 | '-i' 23 | , '--installed' 24 | , action='store_true' 25 | , help='Use `installed` repository' 26 | ) 27 | parser.add_argument( 28 | 'spec' 29 | , metavar='pkg-spec' 30 | , type=str 31 | , nargs='+' 32 | , help='package specification' 33 | ) 34 | args = parser.parse_args() 35 | 36 | try: 37 | env = paludis.EnvironmentFactory.instance.create('') 38 | installed = env.fetch_repository('installed') 39 | fltr = paludis.Filter.And(paludis.Filter.SupportsInstallAction(), paludis.Filter.NotMasked()) 40 | 41 | for dep in args.spec: 42 | # Normalize user provided spec 43 | ds = paludis.parse_user_package_dep_spec(dep, env, paludis.UserPackageDepSpecOptions()) 44 | # Where we have to look for package? 45 | ebuilds = [] 46 | if args.installed: 47 | # Look into installed packages 48 | for pkg in installed.package_ids(str(ds.package), []): 49 | path = pkg.fs_location_key().parse_value() 50 | ebuilds.append(os.path.join(path, '{}.ebuild'.format(os.path.basename(path)))) 51 | else: 52 | # Look for packages that can be installed (and not masked) 53 | gen = paludis.Generator.Matches(ds, paludis.MatchPackageOptions()) 54 | fg = paludis.FilteredGenerator(gen, fltr) 55 | s = paludis.Selection.BestVersionOnly(fg) 56 | found_smth = False 57 | for pkg in env[s]: 58 | ebuild = pkg.fs_location_key().parse_value() 59 | if ebuild: 60 | ebuilds.append(ebuild) 61 | found_smth = True 62 | 63 | if not found_smth: 64 | log.eerror('Package not found or masked: {pkg}'.format(pkg=dep)) 65 | 66 | if ebuilds: 67 | for e in ebuilds: 68 | print(e) 69 | 70 | except paludis.BaseException as e: 71 | log.eerror(str(e)) 72 | 73 | 74 | if __name__ == '__main__': 75 | main() 76 | -------------------------------------------------------------------------------- /profile.d/00-make-completion-wrapper.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Helper function to generate completion wrappers for aliased commands 3 | # 4 | 5 | function make_completion_wrapper() 6 | { 7 | local function_name="$2" 8 | local arg_count=$(($#-3)) 9 | local comp_function_name="$1" 10 | shift 2 11 | local function=" 12 | function $function_name { 13 | ((COMP_CWORD+=$arg_count)) 14 | COMP_WORDS=( "$@" \${COMP_WORDS[@]:1} ) 15 | "$comp_function_name" 16 | return 0 17 | }" 18 | eval "$function" 19 | test "$(type -t _completion_loader)" = 'function' && _completion_loader "$@" 20 | } 21 | -------------------------------------------------------------------------------- /profile.d/cave-addons.sh: -------------------------------------------------------------------------------- 1 | # 2 | # A bunch of helper functions to investigate some troubles 3 | # 4 | 5 | # 6 | # Get full ebuild path for package spec 7 | # 8 | function ebuild_for() 9 | { 10 | cave print-ebuild-path $* || exit 1 11 | } 12 | 13 | # 14 | # Display ebuild contents for package spec 15 | # 16 | function show_ebuild_for() 17 | { 18 | ${PAGER:-less} $(ebuild_for $*) 19 | } 20 | 21 | function _pkg_ebuilds_diff() 22 | { 23 | local op="$1" 24 | local pkg="$2" 25 | 26 | [[ -z ${pkg} ]] && return 27 | 28 | local i 29 | for i in `ebuild_for -i "${pkg}"`; do 30 | p=$(ebuild_for "${op}$(basename "${i}" .ebuild)") 31 | if [[ -n ${p} ]]; then 32 | diff ${PKG_META_DIFF_OPTIONS} "${i}" "${p}" 33 | else 34 | return 35 | fi 36 | done 37 | } 38 | 39 | # 40 | # Show difference between installed package and the same in the portage tree 41 | # 42 | # TODO Better name? 43 | # 44 | function pkg_meta_diff() 45 | { 46 | _pkg_ebuilds_diff '=' $* 47 | } 48 | 49 | # 50 | # Show difference between installed ebuild and the next best available version 51 | # 52 | # TODO Better name? 53 | # 54 | function pkg_ebuild_diff() 55 | { 56 | _pkg_ebuilds_diff '>' $* 57 | } 58 | -------------------------------------------------------------------------------- /profile.d/cave-aliases.sh: -------------------------------------------------------------------------------- 1 | # 2 | # Short aliases for various `cave` (sub)commands 3 | # 4 | 5 | alias cs='cave search --index ${CAVE_SEARCH_INDEX_FILE}' 6 | alias cm='cave manage-search-index --create ${CAVE_SEARCH_INDEX_FILE}' 7 | alias cc='cave contents' 8 | alias cr='cave resolve' 9 | alias crz='cave resolve ${CAVE_RESUME_FILE_OPT}' 10 | alias cw='cave show' 11 | alias co='cave owner' 12 | alias cu='cave uninstall' 13 | alias cy='cave sync' 14 | alias cz='cave resume -Cs ${CAVE_RESUME_FILE_OPT}' 15 | alias cfl='cave fix-linkage' 16 | alias world-up='cave resolve ${CAVE_RESUME_FILE_OPT} -c -km -Km -Cs -P "*/*" -U "*/*" -Si -si -Rn --dump-restarts world' 17 | alias system-up='cave resolve ${CAVE_RESUME_FILE_OPT} -c -km -Km -Cs -P "*/*" -U "*/*" -Si -si -Rn --dump-restarts system' 18 | alias everything-up='cave resolve ${CAVE_RESUME_FILE_OPT} -c -km -Km -Cs -P "*/*" -U "*/*" -Si -si -Rn --dump-restarts installed-packages' 19 | 20 | # 21 | # Reuse cave bash completer to generate completions for just introduced aliases 22 | # 23 | make_completion_wrapper _cave _cs cave search 24 | complete -o bashdefault -o default -F _cs cs 25 | make_completion_wrapper _cave _cm cave manage-search-index 26 | complete -o bashdefault -o default -F _cm cm 27 | make_completion_wrapper _cave _cc cave contents 28 | complete -o bashdefault -o default -F _cc cc 29 | make_completion_wrapper _cave _cr cave resolve 30 | complete -o bashdefault -o default -F _cr cr 31 | make_completion_wrapper _cave _crz cave resolve 32 | complete -o bashdefault -o default -F _crz crz 33 | make_completion_wrapper _cave _cw cave show 34 | complete -o bashdefault -o default -F _cw cw 35 | make_completion_wrapper _cave _co cave owner 36 | complete -o bashdefault -o default -F _co co 37 | make_completion_wrapper _cave _cu cave uninstall 38 | complete -o bashdefault -o default -F _cu cu 39 | make_completion_wrapper _cave _cy cave sync 40 | complete -o bashdefault -o default -F _cy cy 41 | make_completion_wrapper _cave _cz cave resume 42 | complete -o bashdefault -o default -F _cz cz 43 | -------------------------------------------------------------------------------- /workdir-tmpfs/workdir-tmpfs.bash.in: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Paludis hook script to manage build directory in the RAM. 4 | # 5 | # Copyright (c), 2014-2017 by Alex Turbov 6 | # 7 | # Version: @PROJECT_VERSION@ 8 | # 9 | 10 | source ${PALUDIS_EBUILD_DIR}/echo_functions.bash 11 | 12 | declare -r CONFIG_FILE="@CMAKE_INSTALL_FULL_SYSCONFDIR@/paludis/hooks/configs/workdir-tmpfs.conf" 13 | 14 | # Preset defaults 15 | MIN_RESERVED_SPACE=$(( 1024 * 1024 * 10 )) 16 | MAX_RESERVED_SPACE=$(( 1024 * 1024 * 100 )) 17 | DISK_USAGE_STATS_CACHE="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/paludis/disk_usage_stats.cache" 18 | IN_MEMORY_BUILD_ENABLED=${IN_MEMORY_BUILD_ENABLED:-yes} 19 | 20 | # Configuration override 21 | [[ -f ${CONFIG_FILE} ]] && source ${CONFIG_FILE} 22 | 23 | # Check if hook enabled 24 | if [[ ! ${IN_MEMORY_BUILD_ENABLED} =~ (yes|true) ]]; then 25 | ewarn "In-memory-build hook disabled" 26 | exit 0 27 | fi 28 | 29 | # Output environment to log, if debug enabled 30 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 31 | env | sort >> /tmp/paludis-wdm-hook-env.log 32 | fi 33 | 34 | _wdm_shmbasedir="/dev/shm" 35 | 36 | declare -r _B2H_PROGRAM=$(cat <<_EOF 37 | { 38 | hum[1024**3] = "Gb"; 39 | hum[1024**2] = "Mb"; 40 | hum[1024] = "Kb"; 41 | for (x = 1024**3; x >= 1024; x /= 1024) 42 | { 43 | if (bytes >= x) 44 | { 45 | printf "%.2f%s", bytes / x, hum[x]; 46 | break; 47 | } 48 | } 49 | } 50 | _EOF 51 | ) 52 | 53 | 54 | _bytes_to_human() 55 | { 56 | echo 1 | awk -v bytes="$1" "${_B2H_PROGRAM}" 57 | } 58 | 59 | _aux_check_action() 60 | { 61 | case "${PALUDIS_PACKAGE_BUILDDIR}" in 62 | '' | *-uninstall | *-pretend) 63 | # Do nothing for uninstalled package and pretend action 64 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 65 | einfo "${1}: Do nothing for uninstall/pretend action!" 66 | fi 67 | exit 0 68 | ;; 69 | esac 70 | } 71 | 72 | try_prepare_workdir() 73 | { 74 | _aux_check_action "PrepareWorkdir" # Make sure we can proceed 75 | 76 | # Check if package can be build in tmpfs 77 | # 0) try to get estimated size required to build package 78 | if [[ -f ${DISK_USAGE_STATS_CACHE} ]]; then 79 | source "${DISK_USAGE_STATS_CACHE}" 80 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 81 | einfo "Loading disk usage stats cache: ${DISK_USAGE_STATS_CACHE}" 82 | declare -p _wdm_disk_usage_stats 83 | fi 84 | fi 85 | 86 | local -r _tpwd_pkg_name="${CATEGORY}/${PN}:${SLOT}" 87 | if [[ ${_wdm_disk_usage_stats[${_tpwd_pkg_name}]+_} ]]; then 88 | local _tpwd_estimated_size=${_wdm_disk_usage_stats[${_tpwd_pkg_name}]} 89 | local -r _tpwd_10_percents=$(( _tpwd_estimated_size / 10 )) 90 | local _tpwd_reserved="${_tpwd_10_percents}" 91 | if (( _tpwd_10_percents < MIN_RESERVED_SPACE )); then 92 | _tpwd_reserved="${MIN_RESERVED_SPACE}" 93 | fi 94 | if (( MAX_RESERVED_SPACE < _tpwd_10_percents )); then 95 | _tpwd_reserved="${MAX_RESERVED_SPACE}" 96 | fi 97 | _tpwd_estimated_size=$(( _tpwd_estimated_size + _tpwd_reserved )) 98 | # 1) get RAM disk space available 99 | local -r _tpwd_shm_avail=$(df -B1 --output=avail "${_wdm_shmbasedir}" | tail -n1) 100 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 101 | einfo "${P}: prev=${_wdm_disk_usage_stats[${_tpwd_pkg_name}]}, est=${_tpwd_estimated_size}, avail=${_tpwd_shm_avail}" 102 | fi 103 | if (( _tpwd_shm_avail < _tpwd_estimated_size )); then 104 | einfo "Not enough RAM to build this package --" \ 105 | "~$(_bytes_to_human ${_tpwd_estimated_size}) required, but $(_bytes_to_human ${_tpwd_shm_avail}) available. " 106 | einfo "Will use disk instead..." 107 | # TODO Check disk space availabe? ;-) 108 | return 0 109 | fi 110 | else 111 | einfo "RAM usage stats for ${P} is not available. Will build the package on disk this time..." 112 | return 0 113 | fi 114 | 115 | if [[ -d ${PALUDIS_PACKAGE_BUILDDIR} ]]; then 116 | # TODO Handle errors 117 | local -r _tpwd_pwd=$(pwd) 118 | local -r _tpwd_pkg_dir=$(basename ${PALUDIS_PACKAGE_BUILDDIR}) 119 | einfo "Moving ${PALUDIS_PACKAGE_BUILDDIR} --> ${_wdm_shmbasedir}" 120 | test -e "${_wdm_shmbasedir}/${_tpwd_pkg_dir}" && rm -rf "${_wdm_shmbasedir}/${_tpwd_pkg_dir}" 121 | mv "${PALUDIS_PACKAGE_BUILDDIR}" "${_wdm_shmbasedir}" 122 | einfo "Link it back ${_wdm_shmbasedir}/${_tpwd_pkg_dir} --> ${PALUDIS_PACKAGE_BUILDDIR}" 123 | ln -sdf "${_wdm_shmbasedir}/${_tpwd_pkg_dir}" "$(dirname ${PALUDIS_PACKAGE_BUILDDIR})" 124 | cd "${_tpwd_pwd}" 125 | fi 126 | } 127 | 128 | try_update_disk_usage_stats() 129 | { 130 | _aux_check_action "UpdateUsageStats" # Make sure we can proceed 131 | 132 | local -r _tudus_total_size=$(du -LsB1 "${PALUDIS_PACKAGE_BUILDDIR}" 2>/dev/null | cut -f1) 133 | local -r _tudus_total_size_human=$(du -Lhs "${PALUDIS_PACKAGE_BUILDDIR}" 2>/dev/null | cut -f1) 134 | if [[ ${_tudus_total_size_human} = 0 ]]; then 135 | # NOTE "pretend" phase do not generate any content, 136 | # so no need to update anything 137 | return 0 138 | fi 139 | einfo "${_tudus_total_size_human} used for working directory [${PALUDIS_PACKAGE_BUILDDIR}]" 140 | # Update disk usage stats cache 141 | if [[ -f ${DISK_USAGE_STATS_CACHE} ]]; then 142 | source "${DISK_USAGE_STATS_CACHE}" 143 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 144 | einfo "Loading disk usage stats cache: ${DISK_USAGE_STATS_CACHE}" 145 | declare -p _wdm_disk_usage_stats 146 | fi 147 | fi 148 | # Make a new associative array if still not declared 149 | if [[ ! -v _wdm_disk_usage_stats ]]; then 150 | declare -A _wdm_disk_usage_stats 151 | fi 152 | # Add or update the usage value 153 | local -r _tcwd_pkg_name="${CATEGORY}/${PN}:${SLOT}" 154 | local _tudus_need_update='0' 155 | if [[ ${_wdm_disk_usage_stats[${_tcwd_pkg_name}]+_} ]]; then 156 | # Update the key 157 | local -r _tuwd_prev_total_size=${_wdm_disk_usage_stats[${_tcwd_pkg_name}]} 158 | if (( _tuwd_prev_total_size < _tudus_total_size )); then 159 | _tudus_need_update='1' 160 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 161 | einfo "Going to update an entry: ${_tcwd_pkg_name} -> ${_tudus_total_size} (${_tuwd_prev_total_size})" 162 | fi 163 | elif [[ ${WDM_FORCE_UPDATE_STATS} = yes ]]; then 164 | _tudus_need_update='1' 165 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 166 | einfo "Going to force-update an entry: ${_tcwd_pkg_name} -> ${_tudus_total_size}" 167 | fi 168 | fi 169 | else 170 | # Set a new key/value 171 | _tudus_need_update='1' 172 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 173 | einfo "Going to add a new entry: ${_tcwd_pkg_name} -> ${_tudus_total_size}" 174 | fi 175 | fi 176 | if [[ ${_tudus_need_update} = 1 ]]; then 177 | _wdm_disk_usage_stats[${_tcwd_pkg_name}]="${_tudus_total_size}" 178 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 179 | einfo "Storing disk usage stats cache: ${DISK_USAGE_STATS_CACHE}" 180 | declare -p _wdm_disk_usage_stats 181 | fi 182 | # Write stats back to the file 183 | local -r _tudus_cache_dir=$(dirname "${DISK_USAGE_STATS_CACHE}") 184 | if [[ ! -d ${_tudus_cache_dir} ]]; then 185 | mkdir -p "${_tudus_cache_dir}" 186 | # TODO Handle `mkdir` errors 187 | fi 188 | declare -p _wdm_disk_usage_stats >"${DISK_USAGE_STATS_CACHE}" 2>/dev/null 189 | if [[ $? != 0 ]]; then 190 | ewarn "Unable to update cache file: ${DISK_USAGE_STATS_CACHE}. Check permissions!" 191 | fi 192 | fi 193 | } 194 | 195 | try_clean_workdir() 196 | { 197 | _aux_check_action "Clean" # Make sure we can proceed 198 | 199 | local -r _tcwd_pkg_dir=$(basename ${PALUDIS_PACKAGE_BUILDDIR}) 200 | if [[ -d ${_wdm_shmbasedir}/${_tcwd_pkg_dir} ]]; then 201 | if [[ ${PALUDIS_HOOK_DEBUG} = yes ]]; then 202 | einfo "Going to clean: ${_wdm_shmbasedir}/${_tcwd_pkg_dir}" 203 | fi 204 | rm -rf "${_wdm_shmbasedir}/${_tcwd_pkg_dir}" 205 | fi 206 | } 207 | 208 | try_keep_workdir() 209 | { 210 | # NOTE At this point PALUDIS_PACKAGE_BUILDDIR is not defined! 211 | # So we have to assemble it manually. It is also known, that 212 | # `pwd` is a paludis build dir... 213 | local -r _tkwd_pwd=$(pwd) 214 | local -r _tkwd_pkg_dir=$(sed -e 's,:.*,,' -e 's,/,-,' <<<${TARGET}) 215 | local -r PALUDIS_PACKAGE_BUILDDIR="${_tkwd_pwd}/${_tkwd_pkg_dir}" 216 | if [[ -L ${PALUDIS_PACKAGE_BUILDDIR} ]]; then 217 | echo "Moving failed build out of RAM: ${_wdm_shmbasedir}/${_tkwd_pkg_dir} --> ${PALUDIS_PACKAGE_BUILDDIR}" 218 | rm "${PALUDIS_PACKAGE_BUILDDIR}" && mv "${_wdm_shmbasedir}/${_tkwd_pkg_dir}" "${_tkwd_pwd}" 219 | fi 220 | } 221 | 222 | case "${HOOK}" in 223 | # ATTENTION This script must be symlinked to the following hook dirs: 224 | ebuild_init_post) 225 | try_prepare_workdir 226 | ;; 227 | ebuild_tidyup_pre) 228 | try_update_disk_usage_stats 229 | ;; 230 | ebuild_tidyup_post) 231 | try_clean_workdir 232 | ;; 233 | *_fail) 234 | try_keep_workdir 235 | ;; 236 | esac 237 | 238 | # kate: hl bash; 239 | -------------------------------------------------------------------------------- /workdir-tmpfs/workdir-tmpfs.conf.in: -------------------------------------------------------------------------------- 1 | # Use in memory builds (default 'yes'). 2 | # Any other value than 'yes' or 'true' considered as 'no'/'false'. 3 | IN_MEMORY_BUILD_ENABLED=${IN_MEMORY_BUILD_ENABLED:-yes} 4 | 5 | # Location of disk usage statistics file. 6 | # This file used to "predict" how much memory required 7 | # (and will be checked for availability) to build a package 8 | # in memory. 9 | DISK_USAGE_STATS_CACHE=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/paludis/disk_usage_stats.cache 10 | 11 | # TODO Documentation 12 | MIN_RESERVED_SPACE=10485760 13 | 14 | # TODO Documentation 15 | MAX_RESERVED_SPACE=104857600 16 | --------------------------------------------------------------------------------