Newer
Older
Robert Nelson
committed
fi
if [ -n "${chroot_before_hook}" -a -r "${DIR}/${chroot_before_hook}" ] ; then
report_size
echo "Calling chroot_before_hook script: ${chroot_before_hook}"
. "${DIR}/${chroot_before_hook}"
chroot_before_hook=""
fi
if [ -n "${chroot_script}" -a -r "${DIR}/target/chroot/${chroot_script}" ] ; then
report_size
echo "Calling chroot_script script: ${chroot_script}"
sudo cp -v "${DIR}/.project" "${tempdir}/etc/oib.project"
sudo cp -v "${DIR}/target/chroot/${chroot_script}" "${tempdir}/final.sh"
sudo chroot "${tempdir}" /bin/sh -e final.sh
sudo rm -f "${tempdir}/final.sh" || true
sudo rm -f "${tempdir}/etc/oib.project" || true
if [ -f "${tempdir}/npm-debug.log" ] ; then
echo "Log: ERROR: npm error in script, review log [cat ${tempdir}/npm-debug.log]..."
exit 1
fi
fi
##Building final tar file...
if [ -d "${DIR}/deploy/${export_filename}/" ] ; then
rm -rf "${DIR}/deploy/${export_filename}/" || true
mkdir -p "${DIR}/deploy/${export_filename}/" || true
cp -v "${DIR}/.project" "${DIR}/deploy/${export_filename}/image-builder.project"
if [ -n "${chroot_after_hook}" -a -r "${DIR}/${chroot_after_hook}" ] ; then
report_size
echo "Calling chroot_after_hook script: ${chroot_after_hook}"
. "${DIR}/${chroot_after_hook}"
chroot_after_hook=""
fi
#add /boot/uEnv.txt update script
if [ -d "${tempdir}/etc/kernel/postinst.d/" ] ; then
if [ ! -f "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt" ] ; then
sudo cp -v "${OIB_DIR}/target/other/zz-uenv_txt" "${tempdir}/etc/kernel/postinst.d/"
sudo chmod +x "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt"
fi
if [ -f "${tempdir}/usr/bin/qemu-arm-static" ] ; then
sudo rm -f "${tempdir}/usr/bin/qemu-arm-static" || true
Robert Nelson
committed
echo "${rfs_username}:${rfs_password}" > /tmp/user_password.list
sudo mv /tmp/user_password.list "${DIR}/deploy/${export_filename}/user_password.list"
#Fixes:
if [ -d "${tempdir}/etc/ssh/" -a "x${keep_ssh_keys}" = "x" ] ; then
#Remove pre-generated ssh keys, these will be regenerated on first bootup...
sudo rm -rf "${tempdir}"/etc/ssh/ssh_host_* || true
sudo touch "${tempdir}/etc/ssh/ssh.regenerate" || true
if [ -f "${tempdir}/etc/dogtag" ] ; then
sudo cp "${tempdir}/etc/dogtag" "${DIR}/deploy/${export_filename}/ID.txt"
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
cat > "${DIR}/cleanup_script.sh" <<-__EOF__
#!/bin/sh -e
export LC_ALL=C
export DEBIAN_FRONTEND=noninteractive
#set distro:
. /etc/rcn-ee.conf
cleanup () {
echo "Log: (chroot): cleanup"
mkdir -p /boot/uboot/
if [ -f /etc/apt/apt.conf ] ; then
rm -rf /etc/apt/apt.conf || true
fi
apt-get clean
rm -rf /var/lib/apt/lists/*
if [ -d /var/cache/c9-core-installer/ ] ; then
rm -rf /var/cache/c9-core-installer/ || true
fi
if [ -d /var/cache/ipumm-dra7xx-installer/ ] ; then
rm -rf /var/cache/ipumm-dra7xx-installer/ || true
fi
if [ -d /var/cache/ti-c6000-cgt-v8.0.x-installer/ ] ; then
rm -rf /var/cache/ti-c6000-cgt-v8.0.x-installer/ || true
fi
if [ -d /var/cache/ti-pru-cgt-installer/ ] ; then
rm -rf /var/cache/ti-pru-cgt-installer/ || true
fi
if [ -d /var/cache/vpdma-dra7xx-installer/ ] ; then
rm -rf /var/cache/vpdma-dra7xx-installer/ || true
fi
rm -f /usr/sbin/policy-rc.d
if [ "x\${distro}" = "xUbuntu" ] ; then
rm -f /sbin/initctl || true
dpkg-divert --local --rename --remove /sbin/initctl
fi
#This is tmpfs, clear out any left overs...
if [ -d /run/ ] ; then
rm -rf /run/* || true
fi
}
cleanup
rm -f /cleanup_script.sh || true
__EOF__
###MUST BE LAST...
sudo mv "${DIR}/cleanup_script.sh" "${tempdir}/cleanup_script.sh"
sudo chroot "${tempdir}" /bin/sh -e cleanup_script.sh
echo "Log: Complete: [sudo chroot ${tempdir} /bin/sh -e cleanup_script.sh]"
report_size
chroot_umount
if [ "x${chroot_COPY_SETUP_SDCARD}" = "xenable" ] ; then
echo "Log: copying setup_sdcard.sh related files"
sudo cp "${DIR}/tools/setup_sdcard.sh" "${DIR}/deploy/${export_filename}/"
sudo mkdir -p "${DIR}/deploy/${export_filename}/hwpack/"
sudo cp "${DIR}"/tools/hwpack/*.conf "${DIR}/deploy/${export_filename}/hwpack/"
if [ -n "${chroot_uenv_txt}" -a -r "${OIB_DIR}/target/boot/${chroot_uenv_txt}" ] ; then
sudo cp "${OIB_DIR}/target/boot/${chroot_uenv_txt}" "${DIR}/deploy/${export_filename}/uEnv.txt"
if [ -n "${chroot_flasher_uenv_txt}" -a -r "${OIB_DIR}/target/boot/${chroot_flasher_uenv_txt}" ] ; then
sudo cp "${OIB_DIR}/target/boot/${chroot_flasher_uenv_txt}" "${DIR}/deploy/${export_filename}/eMMC-flasher.txt"
if [ -n "${chroot_post_uenv_txt}" -a -r "${OIB_DIR}/target/boot/${chroot_post_uenv_txt}" ] ; then
sudo cp "${OIB_DIR}/target/boot/${chroot_post_uenv_txt}" "${DIR}/deploy/${export_filename}/post-uEnv.txt"
if [ "x${chroot_directory}" = "xenable" ]; then
echo "Log: moving rootfs to directory: [${deb_arch}-rootfs-${deb_distribution}-${deb_codename}]"
sudo mv -v "${tempdir}" "${DIR}/deploy/${export_filename}/${deb_arch}-rootfs-${deb_distribution}-${deb_codename}"
du -h --max-depth=0 "${DIR}/deploy/${export_filename}/${deb_arch}-rootfs-${deb_distribution}-${deb_codename}"
cd "${tempdir}" || true
echo "Log: packaging rootfs: [${deb_arch}-rootfs-${deb_distribution}-${deb_codename}.tar]"
sudo LANG=C tar --numeric-owner -cf "${DIR}/deploy/${export_filename}/${deb_arch}-rootfs-${deb_distribution}-${deb_codename}.tar" .
cd "${DIR}/" || true
ls -lh "${DIR}/deploy/${export_filename}/${deb_arch}-rootfs-${deb_distribution}-${deb_codename}.tar"
sudo chown -R ${USER}:${USER} "${DIR}/deploy/${export_filename}/"
if [ "x${chroot_tarball}" = "xenable" ] ; then
echo "Creating: ${export_filename}.tar"
cd "${DIR}/deploy/" || true
sudo tar cvf ${export_filename}.tar ./${export_filename}
sudo chown -R ${USER}:${USER} "${export_filename}.tar"
cd "${DIR}/" || true
chroot_completed="true"
#