Open phhusson opened 8 years ago
So it's just a "version sort" issue? If so, how about changing it from
cat cpio-* ramdisk2 > ramdisk.tmp
to:
rm -f ramdisk.tmp; for f in
ls -v cpio-*
; do cat $f >> ramdisk.tmp; done; cat ramdisk2 >> ramdisk.tmp;
markdown is preventing showing the backquote, so the command is:
for f in <backquote>ls -v cpio-*<backquote>; do cat $f >> ramdisk.tmp; done;
Without changing strip-cpio or post-procrssing filenames: for f in cpio-{x-y}
... or something with ls - 1v
... or, printf
...sort -V
... with xargs
.
The solution with for
should be most compatible, but I'm on my mobile right now and can't really check into the options.
tested it, if it's done in script, you have to do this http://pastebin.com/PrMdhjdT
ls -v
(although documented in the options) does not actually sort
sort
does not have -V option
EDIT: oh and don't use f as a variable, as that's already being used and will cause a conflict in the repack command
How about using filelist order from original cpio dump?
cd "${ramdisk_extract}"
gunzip -c "${bootimg_extract}"/ramdisk.gz | cpio -im
gunzip -c "${bootimg_extract}"/ramdisk.gz | cpio -it0 2>/dev/null > "${bootimg_extract}"/ramdisk.filelist0
doing manipluation, then
# remove deleted objects from ramdisk.filelist0
while read -r -d $'\0' filename ; do
[[ -e "${filename}" || -L "${filename}" ]] && printf "%s\0" "${filename}" >> "${bootimg_extract}"/ramdisk.filelist0.new
done < "${bootimg_extract}"/ramdisk.filelist0
# add new objects to ramdisk.filelist0 and reset filestamp
find . ! -path . -printf "%P\0" | while IFS= read -r -d $'\0' filename ; do
touch -h -t 197001010100 "${filename}"
grep -qZ "^${filename}$" "${bootimg_extract}"/ramdisk.filelist0 || printf "%s\0" "${filename}" >> "${bootimg_extract}"/ramdisk.filelist0.new
done
# build new ramdisk (override extracted orig ramdisk.gz)
cpio --create --null --format='newc' --owner +0:+0 < "${bootimg_extract}"/ramdisk.filelist0.new | gzip -9 > "${bootimg_extract}"/ramdisk.gz
-lrw-r--r-- 1 0 0 13 Jan 1 1970 charger -> /sbin/healthd +lrwxrwxrwx 1 0 0 13 Jan 1 1970 charger -> /sbin/healthd
-drwxr-xr-x 1 0 0 0 Jan 1 1970 dev +drwxr-xr-x 2 0 0 0 Jan 1 1970 dev
Because strip-cpio writes files to cpio-%d, when doing cat cpio-*, cpio-100 comes before cpio-25, which generates weird cases like the folder entry appearing AFTER the file entry. The result being a cpio considered as corrupted