summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-08-04 00:58:08 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-08-04 01:02:18 (EDT)
commite896bac2af929d6c59e6fdad20b41d69d32848fd (patch)
tree2c84f6a70efa4d4dc8245a381a9aedea7498b7b9 /src
parent2231b66a936e3fd2ef91a44191d054836bd16711 (diff)
ob-buildopk: Check for BB tar reverse ordering bug
Diffstat (limited to 'src')
-rw-r--r--src/ob-buildopk.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/ob-buildopk.sh b/src/ob-buildopk.sh
index dc630d1..1e661cc 100644
--- a/src/ob-buildopk.sh
+++ b/src/ob-buildopk.sh
@@ -29,6 +29,7 @@ build_opk()
shift 5
local find_not_link=
local touch_noderef=
+ local sort_r=
ob_info "$(ob_get_msg 'build_opk')" \
"${binary}_${version}_${arch}_${plat}.opk"
@@ -41,6 +42,19 @@ build_opk()
else
find_not_link='! -type l' touch_noderef=''
fi
+
+ # Detect whether BusyBox tar inserts files listed with -T in reverse
+ # order.
+ mkdir -p '.opkbuild'
+ touch '.opkbuild/a' '.opkbuild/b'
+ if [ x"$(printf '.opkbuild/a\n.opkbuild/b\n' | ${TAR} -c -T - | \
+ ${TAR} -t | head -n 1)" = x'b' ]; then
+ sort_r='-r'
+ else
+ sort_r=''
+ fi
+ rm -f '.opkbuild/a' '.opkbuild/b'
+
find "${binary}.control" "${binary}.data" ${find_not_link} | xargs \
${TOUCH} ${touch_noderef} -t "${date}"
@@ -48,9 +62,9 @@ build_opk()
# about to tar.
find "${binary}.control" "${binary}.data" | xargs chown -h 0:0
- (cd -- "${binary}.control" && find '.' | LC_ALL=C sort | \
+ (cd -- "${binary}.control" && find '.' | LC_ALL=C sort ${sort_r} | \
${TAR} -cf '../control.tar' --no-recursion -T -)
- (cd -- "${binary}.data" && find '.' | LC_ALL=C sort | \
+ (cd -- "${binary}.data" && find '.' | LC_ALL=C sort ${sort_r} | \
${TAR} -cf '../data.tar' --no-recursion -T -)
${TOUCH} -t "${date}" 'control.tar' 'data.tar'
${GZIP} 'control.tar' 'data.tar'