Whitelist helper function works for /etc but not for the home directory as mentioned in the wiki #215
-
General description of the problem:I am trying to use the Whitelist method mentioned in the examples to backup some files from home. I tried to use the function white_list=(
'pacman.conf'
)
IgnorePathsExcept '/etc' "${white_list[@]}" I see that it works and only the Though, this does not work in my home directory. When I try The Configuration:01-helpers.sh
function IgnorePathsExcept() {
# Ignore all path in given directory (first parameter)
# that do not math the given white list (second parameter)
local search_dir=$1
shift
local white_list=("$@")
local find_args=()
local ignore_path
for ignore_path in "${white_list[@]}"; do
local base="$ignore_path"
# Add all base paths to the argument list as well otherwise
# -prune will prevent us from reaching the whitelisted files.
while [ "$base" != '.' ]; do
find_args+=(-path "$search_dir/$base" -o)
base="$(dirname "$base")"
done
done
# Find everything except given whitelist and the directory
# searched from.
find "$search_dir" -not \( "${find_args[@]}" -path "$search_dir" \) -prune | \
while read file; do
if [[ -d "$file" ]]; then
IgnorePath "$file/*"
else
IgnorePath "$file"
fi
done
} 30-extra.sh
Expected result:
Actual result:
Log:$aconfmgr save
: Collecting data...
:: Compiling user configuration...
::: Using configuration in /home/username/.config/aconfmgr
::: Sourcing /home/username/.config/aconfmgr/01-helpers.sh...
::: Sourcing /home/username/.config/aconfmgr/02-ignores.sh...
::: Sourcing /home/username/.config/aconfmgr/20-packages.sh...
::: Sourcing /home/username/.config/aconfmgr/30-home.sh...
::: Sourcing /home/saipavanchitta/.config/aconfmgr/99-unsorted.sh...
::: Done (248 native packages, 1 foreign packages, 1 files).
:: Inspecting system state...
::: Querying package list...
:::: Done.
::: Enumerating owned files...
:::: Done.
::: Searching for stray files...
:::: Done (3 stray files).
::: Cleaning up ignored files' directories...
:::: Done.
::: Searching for modified files...
:::: pacman: /etc/pacman.conf
:::: Done (1 modified files).
::: Reading file attributes...
:::: Reading file types...
:::: Reading file sizes...
:::: Reading file modes...
:::: Reading file owners...
:::: Reading file groups...
:::: Done.
::: Checking disk space...
:::: Done.
::: Processing found files...
:::: Done.
::: Done (248 native packages, 1 foreign packages, 1 files).
:: Examining files...
::: Loading data...
:::: Done.
::: Comparing file data...
::: Done (0 only in system, 0 changed, 0 only in config).
:: Examining file properties...
::: Loading data...
:::: Done.
::: Comparing file properties...
:::: Done.
::: Done (0 only in system, 0 changed, 0 only in config).
:: Done.
: Saving configuration...
:: Examining packages...
::: Done.
:: Registering files...
::: Done.
:: Registering file properties...
::: Comparing file properties...
:::: Done.
::: Done.
:: Done (configuration unchanged). |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
|
Beta Was this translation helpful? Give feedback.
Yes, just add code to remove undesired elements to your configuration, or redefine the array entirely.
From the top of my head, unfortunately that seems to be quite far from how things work under the hood, so unlikely to be reasonably implementable in that form.