From d9f4251eeba3082e2a8f956a7d96d39d77f43c14 Mon Sep 17 00:00:00 2001
From: SolidHal <solidhal@users.noreply.github.com>
Date: Thu, 6 Sep 2018 18:55:46 -0500
Subject: [PATCH] Fixup install scripts, begin move to make build system

---
 makefile                                    | 57 +++++++++++++++++++++
 scripts/InstallScripts/InstallPackages.sh   |  5 --
 scripts/InstallScripts/InstallToInternal.sh |  6 +--
 3 files changed, 59 insertions(+), 9 deletions(-)
 create mode 100644 makefile

diff --git a/makefile b/makefile
new file mode 100644
index 0000000..8973d67
--- /dev/null
+++ b/makefile
@@ -0,0 +1,57 @@
+
+
+
+.PHONY kernel
+kernel:
+	scripts/buildKernel.sh
+
+.PHONY filesystem
+filesystem:
+	clean_img
+	scripts/buildDebianFs.sh
+
+.PHONY kernel_inject
+kernel_inject: #Targets an already build .img and swaps the old kernel with the newly compiled kernel
+	scripts/buildNewKernelIntoFS.sh
+
+.PHONY image
+image:
+	clean_img
+	scripts/buildKernel.sh
+	scripts/buildDebianFs.sh
+
+.PHONY live_image
+live_image:
+	echo "TODO"
+
+.PHONY kernel_config
+kernel_config:
+	scripts/crossmenuconfig.sh
+
+
+.PHONY clean
+clean:
+	echo "Enter one of:"
+	echo "	clean_kernel - which deletes the untar'd kernel folder from build"
+	echo "	clean_ath - which deletes the untar'd ath9k driver folder from build"
+	echo "	clean_img - which deletes the built PrawnOS images, this is ran when make image is ran"
+	echo "	clean_all - which does all of the above"
+	echo "	in most cases none of these need ot be used manually as most cleanup steaps are handled automatically"
+
+.PHONY clean_kernel
+clean_kernel:
+	rm -rf build/linux-4.*
+
+.PHONY clean_ath
+clean_ath:
+	rm -rf build/open-ath9k-htc-firmware
+
+.PHONY clean_img
+clean_img:
+	rm PrawnOS-*-c201-libre-*GB.img
+
+.PHONY clean_all
+clean_all:
+	clean_kernel
+	clean_ath
+	clean_img
diff --git a/scripts/InstallScripts/InstallPackages.sh b/scripts/InstallScripts/InstallPackages.sh
index 63609c8..49b2710 100755
--- a/scripts/InstallScripts/InstallPackages.sh
+++ b/scripts/InstallScripts/InstallPackages.sh
@@ -2,17 +2,12 @@
 
 DIR=/InstallResources
 
-#Setup locales, crda
-apt install -y locales
-dpkg-reconfigure locales
-apt install -y crda
 locale-gen
 #Install lxqt, wicd
 apt install -y xorg acpi-support lightdm tasksel dpkg librsvg2-common xorg xserver-xorg-input-libinput alsa-utils anacron avahi-daemon eject iw libnss-mdns xdg-utils lxqt wicd-daemon wicd wicd-curses wicd-gtk xserver-xorg-input-synaptics
 #Copy in acpi, pulse audio, trackpad settings, funtion key settings
 cp -rf $DIR/default.pa /etc/pulse/default.pa
 cp -rf $DIR/sound.sh /etc/acpi/sound.sh
-mkdir /etc/acpi/events
 cp -rf $DIR/headphone-acpi-toggle /etc/acpi/events/headphone-acpi-toggle
 mkdir /etc/X11/xorg.conf.d/
 cp -rf $DIR/50-synaptics.conf /etc/X11/xorg.conf.d/
diff --git a/scripts/InstallScripts/InstallToInternal.sh b/scripts/InstallScripts/InstallToInternal.sh
index a0272c8..cffe04a 100755
--- a/scripts/InstallScripts/InstallToInternal.sh
+++ b/scripts/InstallScripts/InstallToInternal.sh
@@ -14,12 +14,10 @@ then
     sfdisk /dev/mmcblk2 < $RESOURCES/mmc.partmap
     echo Writing kernel partition
     dd if=/dev/sda1 of=/dev/mmcblk2p1
-    echo Writing Filesystem, this will take a moment...
-    #Set the post install script to run after reboot
-    ./$RESOURCES/runonce.sh $RESOURCES/InstallPackages.sh
+    echo Writing Filesystem, this will take about 4 minutes...
     dd if=/dev/sda2 of=/dev/mmcblk2p2 bs=50M
     echo Expanding Filesystem
-    e2fsck -p /dev/mmcblk2p2
+    e2fsck -p -f /dev/mmcblk2p2
     resize2fs /dev/mmcblk2p2
     echo Rebooting... Please remove the usb drive once shutdown is complete
     reboot