From e896bac2af929d6c59e6fdad20b41d69d32848fd Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 04 Aug 2019 00:58:08 -0400 Subject: ob-buildopk: Check for BB tar reverse ordering bug --- (limited to 'src') 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' -- cgit v0.9.1