Commit f5d0d451 authored by Daniel Bissani Furlin's avatar Daniel Bissani Furlin

Extracting initrd when is an ASCII file

parent b9f48326
......@@ -129,6 +129,8 @@ for script in `ls ${SCRIPTSDIR}`; do
if [[ "$script" =~ [0-9]+\-chroot\.* ]]; then
initChroot "${CHROOTDIR}" "${LOG_FILE}"
execChroot "$CHROOTDIR" "${SCRIPT_NAME}"
#echo "PARADO"
#read a
closeChroot "${CHROOTDIR}" "${LOG_FILE}"
fi
fi
......
......@@ -54,8 +54,16 @@ if ! test -f initrd.lz; then
rm --recursive --force ${PREFIX}/initrd/*
fi
pinfo "Using '${initname}'"
initrd_type=$(file "${CHROOTDIR}/boot/${initname}")
pushd ${PREFIX}/initrd
gzip --decompress --stdout "${CHROOTDIR}/boot/${initname}" | cpio --extract; $(genErrHandle "Unable to decompress initrd")
if echo ${initrd_type} | grep --quiet --ignore-case "gzip"; then
gzip --decompress --stdout "${CHROOTDIR}/boot/${initname}" | cpio --extract; $(genErrHandle "Unable to decompress initrd")
elif echo ${initrd_type} | grep --quiet --ignore-case "ascii"; then
block_size=$(binwalk --include="compressed data" "${CHROOTDIR}/boot/${initname}" | cut --delimiter=" " --fields=1 | egrep "[0-9]+")
dd if="${CHROOTDIR}/boot/${initname}" bs="${block_size}" skip=1 | gunzip | cpio --extract --make-directories
else
perror "${BASH_SOURCE[0]}: Invalid initrd format"; /bin/bash
fi
find . | cpio --quiet --create -H newc | lzma -7 > ../initrd.lz; $(genErrHandle "Unable to compress initrd")
popd
rm --recursive --force ${PREFIX}/initrd
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment