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

add the files operation to slackpkg #44

Merged
merged 9 commits into from
Oct 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion cpm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,33 @@ elif [ "$(whoami)" != root ]; then
SUDO='su root -c '\''"$@"'\'' -- -'
fi

# mainly for slackware: list lines after string $3 in directory $2, file $1
# usage: filelistftr pkgname /directory/example "String to look for"
# usage: filelistftr FILE [DIR] [STR]

filelistftr() {
willeccles marked this conversation as resolved.
Show resolved Hide resolved
file="${1}"
dir="${2:-/var/log/packages}"
str="${3:-"FILE LIST:"}"
pkginfo="$dir/$file"
if [ -f "$pkginfo" ]; then
unset found
willeccles marked this conversation as resolved.
Show resolved Hide resolved
while IFS= read -r line; do
[ "$line" = "$3" ] && found=1
[ "$line" = "$str" ] && found=1
[ "$found" ] && printf "%s\n" "$line"
done <"$pkginfo"
elif [ -d $2 ]; then
willeccles marked this conversation as resolved.
Show resolved Hide resolved
pem "Not in $2, check input or try updating."
elif [ -d "$dir" ]; then
pem "Not in $dir, check input or try updating."
else
pem "$2 does not exist, are you using the right PM?"
pem "$dir does not exist, are you using the right PM?"
fi
}


_apk() {
case "$OP" in
install) $SUDO apk add "$@";;
Expand Down Expand Up @@ -305,7 +332,7 @@ _slackpkg() {
search) slackpkg search "$@";;
show) slackpkg info "$@";;
from) slackpkg file-search "$@";;
files) pem "unsupported because PM does not support it natively: see CONTRUBITING.md.";;
files) filelistftr "$1";;
clean) $SUDO slackpkg clean-system;;
esac
}
Expand Down