Frameworks-/Plasma-build-instructions: simplification of the while loop
| Newsgroups | gmane.linux.lfs.beyond.devel |
|---|---|
| Message-ID | <[email protected]> |
I find the instructions at the beginning of the while loop in chapters
Frameworks and Plasma needlessly complicated. None of the "echo",
"cut", "grep" and "sed" constructs are necessary. Instead, bash's
parameter expansion can be used. The variable "name" in the framework
loop can also be avoided. The following code shows the original for
framework and a simplified version. The lines read are like this:
647b2f9cfd55930e86ebb8c1734df140 kapidox-6.11.0.tar.xz
# Original:
while read -r line; do
# Get the file name, ignoring comments and blank lines
if $(echo $line | grep -E -q '^ *$|^#' ); then continue; fi
file=$(echo $line | cut -d" " -f2)
pkg=$(echo $file|sed 's|^.*/||') # Remove directory
packagedir=$(echo $pkg|sed 's|\.tar.*||') # Package directory
name=$(echo $pkg|sed 's|-6.*$||') # Isolate package name
tar -xf $file
pushd $packagedir
# kapidox is a python module
case $name in
kapidox)
pip3 wheel -w dist --no-build-isolation --no-deps
--no-cache-dir $PWD
as_root pip3 install --no-index --find-links dist --no-user
kapidox
popd
rm -rf $packagedir
continue
;;
esac
[...]
done < frameworks-6.11.0.md5
# Simplified version:
while read -r line; do
# Skip comments and blank lines:
if [[ $line =~ ^#|^$ ]]; then
continue
fi
# Get names of package and packagedir:
package=${line##*[[:blank:]]}
packagedir=${package%.tar.xz}
tar -xf $package
pushd $packagedir
# kapidox is a python module:
if [[ $package =~ kapidox ]]; then
pip3 wheel -w dist --no-build-isolation --no-deps --no-cache-dir $PWD
as_root pip3 install --no-index --find-links dist --no-user kapidox
popd
rm -rf $packagedir
continue
fi
[...]
done < frameworks-6.11.0.md5
Rainer
--
The truth always turns out to be simpler than you thought.
Richard Feynman
--
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page