kiss: simplify pkg_etcsums

- Removes subshell usage.
- Removes cd usage.
This commit is contained in:
Dylan Araps 2021-07-03 14:37:26 +00:00
parent 95e3fc8f8e
commit d107c43098
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

12
kiss
View File

@ -580,23 +580,19 @@ pkg_manifest() (
sort -r | sed '/^\.\/$/d;ss.ss' > "$PWD/$pkg_db/$1/manifest" sort -r | sed '/^\.\/$/d;ss.ss' > "$PWD/$pkg_db/$1/manifest"
) )
pkg_etcsums() ( pkg_etcsums() {
# Generate checksums for each configuration file in the package's /etc/ # Generate checksums for each configuration file in the package's /etc/
# directory for use in "smart" handling of these files. # directory for use in "smart" handling of these files.
log "$1" "Generating etcsums" log "$1" "Generating etcsums"
# This function runs as a sub-shell to avoid having to 'cd' back to the ! [ -d "$pkg_dir/$1/etc" ] ||
# prior directory before being able to continue.
[ -d "$pkg_dir/$1/etc" ] || return 0
cd "$pkg_dir/$1"
# This can't be a simple 'find -exec' as 'sh256' is a shell function # This can't be a simple 'find -exec' as 'sh256' is a shell function
# and not a real command of any kind. This is the shell equivalent. # and not a real command of any kind. This is the shell equivalent.
find etc ! -type d | sort | while read -r line; do find "$pkg_dir/$1/etc" ! -type d | sort | while read -r line; do
sh256 "$line" sh256 "$line"
done > "$pkg_dir/$1/$pkg_db/$1/etcsums" done > "$pkg_dir/$1/$pkg_db/$1/etcsums"
) }
pkg_tar() ( pkg_tar() (
# Create a tarball from the built package's files. This tarball also # Create a tarball from the built package's files. This tarball also