From c8bbc535958aae8e494c4f541bc6017b5cff5239 Mon Sep 17 00:00:00 2001
From: SolidHal <SolidHal@users.noreply.github.com>
Date: Thu, 21 Jun 2018 15:10:57 -0500
Subject: [PATCH] Made some changes and TODOs based on the debian debootstrap
 page

---
 buildDebianFs.sh | 13 ++++++++++---
 buildKernel.sh   |  7 +++++++
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/buildDebianFs.sh b/buildDebianFs.sh
index 6a9d6cc..46f7db1 100755
--- a/buildDebianFs.sh
+++ b/buildDebianFs.sh
@@ -58,11 +58,17 @@ create_image debian-stretch-c201-libre-2GB.img $outdev 50M 40 $outmnt
 # INCLUDES=apt-utils,libc6,libdebconfclient0,awk,libz2-1.0,libblzma5,libselinux1,tar,libtinfo5,zlib1g,udev,kmod,net-tools,traceroute,iproute2,isc-dhcp-client,wpasupplicant,iw,alsa-utils,cgpt,vim-tiny,less,psmisc,netcat-openbsd,ca-certificates,bzip2,xz-utils,unscd,lightdm,lightdm-gtk-greeter,xfce4,xorg,ifupdown,nano,wicd,wicd-curses
 
 # install Debian on it
-qemu-debootstrap --arch=armhf --foreign stretch --variant minbase --include=systemd,systemd-sysv,dbus $outmnt http://deb.debian.org/debian
+#TODO: Try without the variant and include flags
+#TODO: Try without the --foreign flasg as the manpage for debootstrap
+#TODO: OR: --foreign
+# Do the initial unpack phase of bootstrapping only, for example if the target architecture does not match the host architecture. A copy of debootstrap sufficient for completing the bootstrap process will be installed as /debootstrap/debootstrap in the target filesystem. You can run it with the --second-stage option to complete the bootstrapping process.
+qemu-debootstrap --arch armhf --foreign stretch --variant minbase --include=systemd,systemd-sysv,dbus $outmnt http://deb.debian.org/debian
 chroot $outmnt passwd -d root
 #echo -n debsus > $outmnt/etc/hostname
 #install -D -m 644 80disable-recommends $outmnt/etc/apt/apt.conf.d/80disable-recommends
-cp -f /etc/resolv.conf $outmnt/etc/
+#cp -f /etc/resolv.conf $outmnt/etc/
+cp /etc/hosts $outmnt/etc/ #This is what https://wiki.debian.org/EmDebian/CrossDebootstrap suggests
+cp sources.list $outmount/etc/apt/sources.list
 chroot $outmnt apt update
 chroot $outmnt apt install -y udev kmod net-tools inetutils-ping traceroute iproute2 isc-dhcp-client wpasupplicant iw alsa-utils cgpt vim-tiny less psmisc netcat-openbsd ca-certificates bzip2 xz-utils unscd ifupdown nano apt-utils python python-urwid
 chroot $outmnt apt-get autoremove --purge
@@ -70,7 +76,8 @@ chroot $outmnt apt-get clean
 chroot $outmnt apt-get install -d -y wicd-daemon wicd wicd-curses
 #sed -i s/^[3-6]/\#\&/g $outmnt/etc/inittab
 #sed -i s/'enable-cache            hosts   no'/'enable-cache            hosts   yes'/ -i $outmnt/etc/nscd.conf
-rm -f $outmnt/etc/resolv.conf
+#rm -f $outmnt/etc/resolv.conf
+rm -rf $outmnt/etc/hosts #This is what https://wiki.debian.org/EmDebian/CrossDebootstrap suggests
 
 # put the kernel in the kernel partition, modules in /lib/modules and AR9271
 # firmware in /lib/firmware
diff --git a/buildKernel.sh b/buildKernel.sh
index 141bff8..1e41235 100755
--- a/buildKernel.sh
+++ b/buildKernel.sh
@@ -32,6 +32,13 @@ vbutil_kernel --pack vmlinux.kpart \
               --bootloader bootloader.bin
 cd ..
 
+#TODO: Should be able to just include this in /lib/firmware of the target os, and it should be loaded. 
+# or Should be able to include firmware in kernel through kernel config, external firmware.
+# Then the firmware doesn't have to be included in the target fs /lib/firmware
+
+# Either of these should fix the error about the kernel not being able to load the firmware,
+# as it is looking for the propriatary blob and stumbles upon this one in /lib/firmware right now
+
 # build AR9271 firmware
 [ ! -d open-ath9k-htc-firmware ] && git clone --depth 1 https://github.com/qca/open-ath9k-htc-firmware.git
 cd open-ath9k-htc-firmware