Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor edits to readme + random notes #34

Closed
milahu opened this issue Dec 20, 2018 · 2 comments
Closed

minor edits to readme + random notes #34

milahu opened this issue Dec 20, 2018 · 2 comments

Comments

@milahu
Copy link

milahu commented Dec 20, 2018

in readme, i miss the closing quote in

echo '127.0.1.1 laptop.example.net laptop >> "$f"

bash heredoc format

in section Inlining files, please add more samples for the bash heredoc format, including ...

... quoted heredoc format, with 'No parameter expansion, command substitution, arithmetic expansion, or pathname expansion'

# append constant string to file
# variables are not expanded
# note the quotes around the first EOF
cat >>/etc/profile <<'EOF'
if [[ ! $DISPLAY && $XDG_VTNR -eq 1 && $UID -eq 1000 ]]
then
        exec startxfce4
fi
EOF

... unquoted heredoc format, with both constants and expressions

# template variables
cmd_start_x_session=startxfce4
my_uid=$UID
my_vtnr=1

# template
# no quotes around first EOF
cat >>/etc/profile <<EOF
if [[ ! \$DISPLAY && \$XDG_VTNR -eq $my_vtnr && \$UID -eq $my_uid ]]
then
        exec $cmd_start_x_session
fi
EOF

the result is identic, but in version 2, you can use 'template variables'

ignore.sh samples

please add one [or more] ignore.sh sample files, like here

i would add, for example ...

IgnorePath '/usr/share/*'
IgnorePath '/usr/share/webapps/*'

IgnorePath '/var/lib/*'
IgnorePath '/var/lib/swap*' # swapspace files
IgnorePath '/var/swap*' # static swap files

IgnorePath '/usr/lib/*'
IgnorePath '/opt/*' # might be too strict

IgnorePath '/usr/libexec/darling/*' # darling, the macOS emulator
IgnorePath '/var/log/*'
IgnorePath '*/lost+found/*'

IgnorePath '/usr/local/include/*'
IgnorePath '/usr/local/lib/*'
IgnorePath '/var/tmp/*'

find -regex, instead of find -wholename

let me append custom filters to ignore_args, like ...

IgnorePathArgs -regextype posix-extended -regex '.*[.-][a-zA-Z0-9_-]{11}\.(mp4|mkv)'
IgnorePathArgs -regextype posix-extended -regex '/home/[^/]+/\.(cache|local/share|local/lib|thumbnails|npm/_cacache|ipfs|gnupg|purple/logs)/.*' \)
IgnorePathArgs -size +1M # ignore files of size > 1MebiByte = 1048576 Byte

i am aware, that scanning /home is out-of-scope for aconfmgr.
these are just samples, for what PE-regex can look like.

filtering by file size could be more useful.

perl regex

problem: find from findutils does not support perl regex.
i need perl regex, to use 'negative lookahead' (?!pattern), to ...

  • exclude /opt/*
  • and re-include /opt/i2p/router.config and /opt/i2p/.i2p/router.config

... for example.

workaround: use perl to filter the output of find

{
cat <<EOF
/opt/exclude-me
/opt/i2p/.i2p/i2psnark/exclude-me
/opt/i2p/.i2p/include-me.config
/opt/i2p/include-me.config
/etc/include-me
EOF
} | perl -ne 'print if not m#^/opt/(?!i2p/[^/]+\.config$|i2p/\.i2p/[^/]+\.config$)#'

to un-ignore paths:

function UnIgnorePath() {
	#global ignore_paths
	local delete="$@"
	local result=()

	while read -d $'\0' ignore_path
	do
		if [[ ! "$ignore_path" = "$delete" ]]
		then
			result+=("$ignore_path")
		fi
	done < <(
		printf '%s\0' "${ignore_paths[@]}"
	)
	ignore_paths=("${result[@]}")
}

ignore_paths should be unique:

	while read -d $'\0' ignore_path
	do
		ignore_args+=(-wholename "$ignore_path" -o)
	done < <(
		printf '%s\0' "${ignore_paths[@]}" \
		| uniq -z -u
	)

... so to include some files in /home

UnIgnorePath '/home'

{
cat <<EOF
/etc/include-me
/home/u1/.bashrc
/home/u2/.cache/medit-1/include-me
/home/u3/.cache/exclude-me
/home/u4/src/exclude-me
EOF
} | perl -ne 'print if not m#^/home/[^/]+/(?!\.bashrc$|\.cache/medit-1/)#'

bash exec magic

[ this is more a note to my self ]

this is called: bash automatic file descriptor allocation

as i found out after some time of searching

in common.bash

    exec {progress_fd}> \
         >( gawk '
...
        sudo find /                                 \
...
            | tee /dev/fd/$progress_fd              \
...
    exec {progress_fd}<&-

hope to help : ]

all my content is published under ZeroBSD license = zero restrictions + zero warranty

@CyberShadow
Copy link
Owner

Thanks for submitting this. However, generally, it is better to submit one actionable topic as a separate issue, so that they can be tracked and discussed individually.

in readme, i miss the closing quote in

Fixed, thanks.

bash heredoc format

I think the aconfmgr README is not really the best place to document bash features.

ignore.sh samples

I would like aconfmgr to generate a sensible default configuration with ignore rules for currently installed packages in a future version.

find -regex, instead of find -wholename

IgnorePath parameters are used not just for lost files (i.e. passed to find), but also for modified files. Perhaps IgnorePathRegex would be feasible for the subset / intersection of regular expression syntax shared by GNU find and bash. Some kind of hook to further filter found files might also be an idea worth pursuing.

perl regex

Using lookahead wouldn't work anyway, because subtrees are pruned immediately on a match, to avoid scanning ignored trees (which might be large or network filesystems). See #12 for some discussion for a possible AddPath command to un-ignore a subdirectory of an ignored directory.

all my content is published under ZeroBSD license = zero restrictions + zero warranty

FYI, as the content is still owned by you and under a different license than aconfmgr, it cannot be incorporated as part of aconfmgr. For that, the author would either need to release it under the same license as aconfmgr (MIT), disclaim copyright on the content (i.e. place it under the public domain), or assign copyright to the copyright holder of aconfmgr (currently authors retain copyright).

CyberShadow added a commit that referenced this issue Dec 20, 2018
@CyberShadow
Copy link
Owner

I would like aconfmgr to generate a sensible default configuration with ignore rules for currently installed packages in a future version.

This has now been filed as its own issue in #37.

As this was the only remaining actionable item from your list, I am going to close this issue. Thank you again for the feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants