From 21342dee8edb8043f83886042cfae277a22c7141 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 12 Apr 2020 17:05:02 +0200 Subject: [PATCH] Cleanup: move path filtering into pkg_scan_dir Instead of prefixing the search path with $PKGDEPLOYDIR and then stripping the prefix off again every single time, do that inside the pkg_scan_dir function. Signed-off-by: David Oberhollenzer --- pkg/firmware-rpi/build | 3 +-- pkg/linux-lts/build | 4 +--- pkg/linux_headers/build | 3 +-- pkg/musl/build | 3 +-- pkg/nginx/build | 3 +-- pkg/tzdata/build | 7 ++----- util/emptypkg.sh | 13 ++++++++++--- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/pkg/firmware-rpi/build b/pkg/firmware-rpi/build index 2715a0a..5f20e50 100755 --- a/pkg/firmware-rpi/build +++ b/pkg/firmware-rpi/build @@ -12,8 +12,7 @@ deploy() { cp -r ${SOURCE}/boot/* "$PKGDEPLOYDIR/" cp $SCRIPTDIR/pkg/$PKGNAME/*.{files,desc} "$PKGDEPLOYDIR" - pkg_scan_dir "$PKGDEPLOYDIR/overlays" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/boot-rpi-dtbo.files" + pkg_scan_dir "overlays" >> "$PKGDEPLOYDIR/boot-rpi-dtbo.files" } check_update() { diff --git a/pkg/linux-lts/build b/pkg/linux-lts/build index 9db9f37..7bf8f2a 100755 --- a/pkg/linux-lts/build +++ b/pkg/linux-lts/build @@ -67,9 +67,7 @@ deploy() { echo "dir lib 0755 0 0" > "$PKGDEPLOYDIR/linux-modules.files" - pkg_scan_dir "$PKGDEPLOYDIR/lib" | \ - sed "s#$PKGDEPLOYDIR/##g" \ - >> "$PKGDEPLOYDIR/linux-modules.files" + pkg_scan_dir "lib" >> "$PKGDEPLOYDIR/linux-modules.files" ;; esac done diff --git a/pkg/linux_headers/build b/pkg/linux_headers/build index f48c9f8..9f4bb5f 100755 --- a/pkg/linux_headers/build +++ b/pkg/linux_headers/build @@ -20,6 +20,5 @@ deploy() { echo "dir include 0755 0 0" > "$PKGDEPLOYDIR/linux-dev.files" - pkg_scan_dir "$PKGDEPLOYDIR/include" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/linux-dev.files" + pkg_scan_dir "include" >> "$PKGDEPLOYDIR/linux-dev.files" } diff --git a/pkg/musl/build b/pkg/musl/build index 19de955..8ec8c40 100755 --- a/pkg/musl/build +++ b/pkg/musl/build @@ -60,8 +60,7 @@ deploy() { cp libssp_nonshared.a "$PKGDEPLOYDIR/lib" cp "$SCRIPTDIR/pkg/$PKGNAME/libc-dev.files" "$PKGDEPLOYDIR" - pkg_scan_dir "$PKGDEPLOYDIR/include" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/libc-dev.files" + pkg_scan_dir "include" >> "$PKGDEPLOYDIR/libc-dev.files" if [ "x$TC_HARDENING" = "xyes" ]; then echo "requires libc linux-dev fortify-headers" > \ diff --git a/pkg/nginx/build b/pkg/nginx/build index e0f55d6..0378b82 100755 --- a/pkg/nginx/build +++ b/pkg/nginx/build @@ -80,8 +80,7 @@ deploy() { echo "dir srv 0755 0 0" >> "$PKGDEPLOYDIR/nginx.files" echo "dir srv/www 0755 0 0" >> "$PKGDEPLOYDIR/nginx.files" - pkg_scan_dir "$PKGDEPLOYDIR/srv/www" |\ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/nginx.files" + pkg_scan_dir "srv/www" >> "$PKGDEPLOYDIR/nginx.files" fi cat_file_override "nginx.conf" > "$PKGDEPLOYDIR/etc/nginx/nginx.conf" diff --git a/pkg/tzdata/build b/pkg/tzdata/build index 5884c8e..228862c 100644 --- a/pkg/tzdata/build +++ b/pkg/tzdata/build @@ -21,11 +21,8 @@ deploy() { sed -i 's@/usr@@g' "$PKGDEPLOYDIR/bin/tzselect" - pkg_scan_dir "$PKGDEPLOYDIR/share/zoneinfo" | \ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/tzdata.files" - - pkg_scan_dir "$PKGDEPLOYDIR/share/zoneinfo-leaps" | \ - sed "s#$PKGDEPLOYDIR/##g" >> "$PKGDEPLOYDIR/tzdata.files" + pkg_scan_dir "share/zoneinfo" >> "$PKGDEPLOYDIR/tzdata.files" + pkg_scan_dir "share/zoneinfo-leaps" >> "$PKGDEPLOYDIR/tzdata.files" } check_update() { diff --git a/util/emptypkg.sh b/util/emptypkg.sh index 0ed3f7a..70b9aa4 100644 --- a/util/emptypkg.sh +++ b/util/emptypkg.sh @@ -9,9 +9,16 @@ apply_patches() { } 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" + local sp="$PKGDEPLOYDIR/$1" + + find -H "$sp" -type d -printf "dir \"%p\" 0%m 0 0\\n" | tail -n +2 |\ + sed "s#$PKGDEPLOYDIR/##g" + + find -H "$sp" -type l -printf "slink \"%p\" 0%m 0 0 %l\\n" |\ + sed "s#$PKGDEPLOYDIR/##g" + + find -H "$sp" -type f -printf "file \"%p\" 0%m 0 0\\n" |\ + sed "s#$PKGDEPLOYDIR/##g" } fetch_package() {