From 6c24bad53be2792cfa1377a73d94656537f0cf3b Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sat, 30 Mar 2019 16:18:11 +0100 Subject: [PATCH] Add helper function to produce a file listing from a directory Signed-off-by: David Oberhollenzer --- pkg/linux/build | 8 +------- pkg/linux_headers/build | 10 +--------- pkg/nginx/build | 11 +---------- pkg/tc-gcc2/build | 8 +------- util/misc.sh | 6 ++++++ 5 files changed, 10 insertions(+), 33 deletions(-) diff --git a/pkg/linux/build b/pkg/linux/build index 6afb202..0cf583f 100755 --- a/pkg/linux/build +++ b/pkg/linux/build @@ -73,13 +73,7 @@ deploy() { echo "dir lib 0755 0 0" >> "$PKGDEPLOYDIR/$PKGNAME.files" echo "dir lib/modules 0755 0 0" >> "$PKGDEPLOYDIR/$PKGNAME.files" - find -H "$PKGDEPLOYDIR/lib" -type d -printf "dir %p 0%m 0 0\\n" |\ - tail -n +2 | sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/$PKGNAME.files" - - find -H "$PKGDEPLOYDIR/lib" -type l -printf "slink %p 0%m 0 0 %l\\n" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/$PKGNAME.files" - - find -H "$PKGDEPLOYDIR/lib" -type f -printf "file %p 0%m 0 0\\n" |\ + pkg_scan_dir "$PKGDEPLOYDIR/lib" |\ sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/$PKGNAME.files" ;; esac diff --git a/pkg/linux_headers/build b/pkg/linux_headers/build index cf868ef..ad4d43d 100755 --- a/pkg/linux_headers/build +++ b/pkg/linux_headers/build @@ -20,14 +20,6 @@ deploy() { echo "dir include 0755 0 0" > "$PKGDEPLOYDIR/linux-dev.files" - find -H "$PKGDEPLOYDIR/include" -type d -printf "dir %p 0%m 0 0\\n" |\ - tail -n +2 |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/linux-dev.files" - - find -H "$PKGDEPLOYDIR/include" -type l \ - -printf "slink %p 0%m 0 0 %l\\n" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/linux-dev.files" - - find -H "$PKGDEPLOYDIR/include" -type f -printf "file %p 0%m 0 0\\n" |\ + pkg_scan_dir "$PKGDEPLOYDIR/include" |\ sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/linux-dev.files" } diff --git a/pkg/nginx/build b/pkg/nginx/build index 6001734..07d5e19 100755 --- a/pkg/nginx/build +++ b/pkg/nginx/build @@ -84,16 +84,7 @@ deploy() { echo "dir srv 0755 0 0" >> "$PKGDEPLOYDIR/nginx.files" echo "dir srv/www 0755 0 0" >> "$PKGDEPLOYDIR/nginx.files" - find -H "$PKGDEPLOYDIR/srv/www" -type d \ - -printf "dir %p 0%m 0 0\\n" | tail -n +2 |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/nginx.files" - - find -H "$PKGDEPLOYDIR/srv/www" -type l \ - -printf "slink %p 0%m 0 0 %l\\n" | \ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/nginx.files" - - find -H "$PKGDEPLOYDIR/srv/www" -type f \ - -printf "file %p 0%m 0 0\\n" |\ + pkg_scan_dir "$PKGDEPLOYDIR/srv/www" |\ sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/nginx.files" fi diff --git a/pkg/tc-gcc2/build b/pkg/tc-gcc2/build index 0eebc2f..5e6eb41 100755 --- a/pkg/tc-gcc2/build +++ b/pkg/tc-gcc2/build @@ -33,13 +33,7 @@ deploy() { mv ${TCDIR}/${TARGET}/{include,lib} "$PKGDEPLOYDIR" cp $SCRIPTDIR/pkg/$PKGNAME/*.{files,desc} "$PKGDEPLOYDIR" - find -H "$PKGDEPLOYDIR/include/c++" -type d -printf "dir %p 0%m 0 0\\n" |\ - tail -n +2 | sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/libstdc++-dev.files" - - find -H "$PKGDEPLOYDIR/include/c++" -type l -printf "slink %p 0%m 0 0 %l\\n" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/libstdc++-dev.files" - - find -H "$PKGDEPLOYDIR/include/c++" -type f -printf "file %p 0%m 0 0\\n" |\ + pkg_scan_dir "$PKGDEPLOYDIR/include/c++" |\ sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/libstdc++-dev.files" if [ -f "$PKGDEPLOYDIR/lib/libmpx.a" ]; then diff --git a/util/misc.sh b/util/misc.sh index 9fcf8ae..a68a09f 100644 --- a/util/misc.sh +++ b/util/misc.sh @@ -53,3 +53,9 @@ unfuck_libtool() { sed -i "s#libdir='\$install_libdir'#libdir='$libdir'#g" "$PKGBUILDDIR/libtool" } + +pkg_scan_dir() { + find -H "$1" -type d -printf "dir %p 0%m 0 0\\n" | tail -n +2 + find -H "$1" -type l -printf "slink %p 0%m 0 0 %l\\n" + find -H "$1" -type f -printf "file %p 0%m 0 0\\n" +}