Newer
Older
Robert Nelson
committed
manual_deborphan
Robert Nelson
committed
add_user
mkdir -p /opt/source || true
touch /opt/source/list.txt
pkg="wget"
dpkg_check
if [ "x\${pkg_is_not_installed}" = "x" ] ; then
if [ "${rfs_kernel}" ] ; then
for kernel_url in ${rfs_kernel} ; do dl_kernel ; done
Robert Nelson
committed
else
dpkg_package_missing
if [ -f /lib/systemd/systemd ] ; then
systemd_tweaks
fi
rm -f /chroot_script.sh || true
sudo mv "${DIR}/chroot_script.sh" "${tempdir}/chroot_script.sh"
if [ "x${include_firmware}" = "xenable" ] ; then
if [ ! -d "${tempdir}/lib/firmware/" ] ; then
sudo mkdir -p "${tempdir}/lib/firmware/" || true
fi
if [ -d "${DIR}/git/linux-firmware/brcm/" ] ; then
sudo mkdir -p "${tempdir}/lib/firmware/brcm"
sudo cp -v "${DIR}/git/linux-firmware/LICENCE.broadcom_bcm43xx" "${tempdir}/lib/firmware/"
sudo cp -v "${DIR}"/git/linux-firmware/brcm/* "${tempdir}/lib/firmware/brcm"
fi
if [ -f "${DIR}/git/linux-firmware/carl9170-1.fw" ] ; then
sudo cp -v "${DIR}/git/linux-firmware/carl9170-1.fw" "${tempdir}/lib/firmware/"
fi
if [ -f "${DIR}/git/linux-firmware/htc_9271.fw" ] ; then
sudo cp -v "${DIR}/git/linux-firmware/LICENCE.atheros_firmware" "${tempdir}/lib/firmware/"
sudo cp -v "${DIR}/git/linux-firmware/htc_9271.fw" "${tempdir}/lib/firmware/"
fi
if [ -d "${DIR}/git/linux-firmware/rtlwifi/" ] ; then
sudo mkdir -p "${tempdir}/lib/firmware/rtlwifi"
sudo cp -v "${DIR}/git/linux-firmware/LICENCE.rtlwifi_firmware.txt" "${tempdir}/lib/firmware/"
sudo cp -v "${DIR}"/git/linux-firmware/rtlwifi/* "${tempdir}/lib/firmware/rtlwifi"
fi
if [ -d "${DIR}/git/linux-firmware/ti-connectivity/" ] ; then
sudo mkdir -p "${tempdir}/lib/firmware/ti-connectivity"
sudo cp -v "${DIR}/git/linux-firmware/LICENCE.ti-connectivity" "${tempdir}/lib/firmware/"
sudo cp -v "${DIR}"/git/linux-firmware/ti-connectivity/* "${tempdir}/lib/firmware/ti-connectivity"
fi
if [ -f "${DIR}/git/linux-firmware/mt7601u.bin" ] ; then
sudo cp -v "${DIR}/git/linux-firmware/mt7601u.bin" "${tempdir}/lib/firmware/mt7601u.bin"
fi
if [ -n "${early_chroot_script}" -a -r "${DIR}/target/chroot/${early_chroot_script}" ] ; then
report_size
echo "Calling early_chroot_script script: ${early_chroot_script}"
sudo cp -v "${DIR}/.project" "${tempdir}/etc/oib.project"
sudo /bin/bash -e "${DIR}/target/chroot/${early_chroot_script}" "${tempdir}"
early_chroot_script=""
sudo rm -f "${tempdir}/etc/oib.project" || true
sudo chroot "${tempdir}" /bin/bash -e chroot_script.sh
echo "Log: Complete: [sudo chroot ${tempdir} /bin/bash -e chroot_script.sh]"
#Do /etc/issue & /etc/issue.net after chroot_script:
#
#Unpacking base-files (7.2ubuntu5.1) over (7.2ubuntu5) ...
#Setting up base-files (7.2ubuntu5.1) ...
#
#Configuration file '/etc/issue'
# ==> Modified (by you or by a script) since installation.
# ==> Package distributor has shipped an updated version.
# What would you like to do about it ? Your options are:
# Y or I : install the package maintainer's version
# N or O : keep your currently-installed version
# D : show the differences between the versions
# Z : start a shell to examine the situation
# The default action is to keep your current version.
#*** issue (Y/I/N/O/D/Z) [default=N] ? n
if [ ! "x${rfs_console_banner}" = "x" ] || [ ! "x${rfs_console_user_pass}" = "x" ] ; then
Robert Nelson
committed
wfile="${tempdir}/etc/issue"
Robert Nelson
committed
sudo sh -c "cat '${tempdir}/etc/dogtag' >> ${wfile}"
sudo sh -c "echo '' >> ${wfile}"
fi
Robert Nelson
committed
sudo sh -c "echo '${rfs_console_banner}' >> ${wfile}"
sudo sh -c "echo '' >> ${wfile}"
fi
Robert Nelson
committed
sudo sh -c "echo 'default username:password is [${rfs_username}:${rfs_password}]' >> ${wfile}"
sudo sh -c "echo '' >> ${wfile}"
fi
fi
if [ ! "x${rfs_ssh_banner}" = "x" ] || [ ! "x${rfs_ssh_user_pass}" = "x" ] ; then
Robert Nelson
committed
wfile="${tempdir}/etc/issue.net"
sudo sh -c "echo '' >> ${wfile}"
Robert Nelson
committed
sudo sh -c "cat '${tempdir}/etc/dogtag' >> ${wfile}"
sudo sh -c "echo '' >> ${wfile}"
fi
Robert Nelson
committed
sudo sh -c "echo '${rfs_ssh_banner}' >> ${wfile}"
sudo sh -c "echo '' >> ${wfile}"
fi
Robert Nelson
committed
sudo sh -c "echo 'default username:password is [${rfs_username}:${rfs_password}]' >> ${wfile}"
sudo sh -c "echo '' >> ${wfile}"
fi
fi
#usually a qemu failure...
if [ ! "x${rfs_opt_scripts}" = "x" ] ; then
#we might not have read permissions:
if [ -r "${tempdir}/opt/scripts/" ] ; then
if [ ! -f "${tempdir}/opt/scripts/.git/config" ] ; then
echo "Log: ERROR: git clone of ${rfs_opt_scripts} failed.."
exit 1
fi
else
echo "Log: unable to test /opt/scripts/.git/config no read permissions, assuming git clone success"
Robert Nelson
committed
fi
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/bash -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: ${DIR}/${chroot_after_hook}"
. "${DIR}/${chroot_after_hook}"
chroot_after_hook=""
fi
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/bb-node-red-installer ] ; then
rm -rf /var/cache/bb-node-red-installer|| true
fi
if [ -d /var/cache/c9-core-installer/ ] ; then
rm -rf /var/cache/c9-core-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-c6000-cgt-v8.1.x-installer/ ] ; then
rm -rf /var/cache/ti-c6000-cgt-v8.1.x-installer/ || true
fi
if [ -d /var/cache/ti-pru-cgt-installer/ ] ; then
rm -rf /var/cache/ti-pru-cgt-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
# Clear out the /tmp directory
rm -rf /tmp/* || true
}
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/bash -e cleanup_script.sh
echo "Log: Complete: [sudo chroot ${tempdir} /bin/bash -e cleanup_script.sh]"
#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"
sudo chown root:root "${tempdir}/etc/kernel/postinst.d/zz-uenv_txt"
fi
fi
if [ -f "${tempdir}/usr/bin/qemu-arm-static" ] ; then
sudo rm -f "${tempdir}/usr/bin/qemu-arm-static" || true
fi
if [ -f "${tempdir}/usr/bin/qemu-aarch64-static" ] ; then
sudo rm -f "${tempdir}/usr/bin/qemu-aarch64-static" || true
fi
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
fi
#ID.txt:
if [ -f "${tempdir}/etc/dogtag" ] ; then
sudo cp "${tempdir}/etc/dogtag" "${DIR}/deploy/${export_filename}/ID.txt"
sudo chown root:root "${DIR}/deploy/${export_filename}/ID.txt"
#Add Google IPv4 nameservers
if [ -f "${tempdir}/etc/resolv.conf" ] ; then
wfile="${tempdir}/etc/resolv.conf"
sudo sh -c "echo 'nameserver 8.8.8.8' > ${wfile}"
sudo sh -c "echo 'nameserver 8.8.4.4' >> ${wfile}"
fi
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"
#