do-extract: change cwd to $extractdir to check number of files

In order to simplify the next change, to simplify the processing steps
for PHP and/or Macintosh metadata.
This commit is contained in:
Đoàn Trần Công Danh 2023-01-05 09:13:55 +07:00 committed by Đoàn Trần Công Danh
parent 2ca6cb7a67
commit c57c2b8a90
1 changed files with 5 additions and 2 deletions

View File

@ -163,13 +163,14 @@ hook() {
esac
done
cd "$extractdir"
# find "$extractdir" -mindepth 1 -maxdepth 1 -printf '1\n' | wc -l
# However, it requires GNU's find
num_dirs=0
for f in "$extractdir"/* "$extractdir"/.*; do
for f in * .*; do
if [ -e "$f" ] || [ -L "$f" ]; then
case "$f" in
*/. | */..) ;;
. | ..) ;;
*)
innerdir="$f"
num_dirs=$(( num_dirs + 1 ))
@ -178,6 +179,8 @@ hook() {
fi
done
rm -rf "$wrksrc"
innerdir="$extractdir/$innerdir"
cd "$XBPS_BUILDDIR"
if [ "$num_dirs" = 1 ] && [ -d "$innerdir" ] && [ -z "$create_wrksrc" ]; then
# rename the subdirectory (top-level of distfiles) to $wrksrc
mv "$innerdir" "$wrksrc" &&