소스 검색

Change builder logic

DSR! 2 년 전
부모
커밋
b8636a8b12
2개의 변경된 파일59개의 추가작업 그리고 8개의 파일을 삭제
  1. 0 0
      build/fw-base/.gitkeep
  2. 59 8
      tools/builder.sh

+ 0 - 0
build/fw-base/.gitkeep


+ 59 - 8
tools/builder.sh

@@ -17,7 +17,7 @@ if [[ ! -d "$IMAGEBUILDER_FOLDER" || "$PROFILE" == "" ]] || ! grep -q "$ARCHITEC
     exit 1
 fi
 
-# dependencies installed, uninstalled and the order in which they are installed is for a reason!
+# the order in which the dependencies are installed and those that are removed is deliberate!
 # no rtl-sdr, no kmod-usb-net-*, no kmod-rtl8192cu, no kmod-usb-acm
 PACKAGES_NANO="iw at autossh base-files block-mount ca-certificates chat dnsmasq e2fsprogs ethtool firewall hostapd-utils ip6tables iperf3 iwinfo kmod-crypto-manager kmod-fs-ext4 kmod-fs-nfs kmod-fs-vfat kmod-gpio-button-hotplug kmod-ipt-offload kmod-leds-gpio kmod-ledtrig-default-on kmod-ledtrig-netdev kmod-ledtrig-timer kmod-mt76x2u kmod-nf-nathelper kmod-rt2800-usb kmod-rtl8187 kmod-scsi-generic kmod-usb-ohci kmod-usb-storage-extras kmod-usb-uhci kmod-usb2 libbz2-1.0 libcurl4 libelf1 libffi libgmp10 libiconv-full2 libintl libltdl7 libnet-1.2.x libnl200 libreadline8 libustream-mbedtls20150806 libxml2 logd macchanger mtd nano ncat netcat nginx openssh-client openssh-server openssh-sftp-server openssl-util php7-fpm php7-mod-hash php7-mod-json php7-mod-mbstring php7-mod-session php7-mod-sqlite3 ppp ppp-mod-pppoe procps-ng-pkill procps-ng-ps python-logging python-openssl python-sqlite3 ssmtp tcpdump-mini uci uclibcxx uclient-fetch urandom-seed urngd usb-modeswitch usbreset usbutils wget wireless-tools wpad busybox libatomic1 libstdcpp6 -wpad-basic -dropbear -swconfig -odhcpd-ipv6only -odhcp6c"
 
@@ -34,10 +34,39 @@ declare -a FORCE_PACKAGES=("libubus20191227_2019-12-27-041c9d1c-1" "busybox_1.30
 IMAGEBUILDER_FOLDER="$(realpath $IMAGEBUILDER_FOLDER)"
 TOOL_FOLDER="$(realpath $(dirname $0)/../tools)"
 BUILD_FOLDER="$(realpath $(dirname $0)/../build)"
+FW_FOLDER="$(realpath $(dirname $0)/../build/fw-base)"
 
 
 
 # steps
+check_deps () {
+    echo "[*] Checking dependencies"
+    echo "******************************"
+    echo ""
+
+    if [ ! -f "$FW_FOLDER/basefw.bin" ]; then
+        echo "[!] Attention!"
+        echo ""
+        echo "File 'build/fw-base/basefw.bin' was not found."
+        echo "You must download the original firmware version 2.7.0 and place it with the name basefw.bin in this path:"
+        echo "$FW_FOLDER"
+        echo ""
+
+        exit 1
+    fi
+
+    if [ ! -f "$FW_FOLDER/basefw-mk7.bin" ] && [ "$ARCHITECTURE" == "mipsel" ]; then
+        echo "[!] Attention!"
+        echo ""
+        echo "File 'build/fw-base/basefw-mk7.bin' was not found."
+        echo "You must download the original MK7 firmware version 1.1.1 and place it with the name basefw-mk7.bin in this path:"
+        echo "$FW_FOLDER"
+        echo ""
+
+        exit 1
+    fi
+}
+
 prepare_builder () {
     echo "[*] Prepare builder"
     echo "******************************"
@@ -68,22 +97,23 @@ prepare_build () {
 
     # clean
     rm -rf _basefw.* basefw.bin
-    rm -rf "$BUILD_FOLDER"
-    mkdir -p "$BUILD_FOLDER/release"
+    rm -rf "$BUILD_FOLDER/rootfs-base"
+    rm -rf "$BUILD_FOLDER/rootfs"
+    mkdir "$BUILD_FOLDER/release"
 
     # get target firmware
     # this work only with lastest binwalk version!
     if [[ "$FLAVOR" == "tetra" || "$FLAVOR" == "universal" ]]; then
-        echo "[+] Downloading TETRA firmware..."
-        wget -q https://github.com/xchwarze/wifi-pineapple-community/raw/main/firmwares/2.7.0-tetra.bin -O basefw.bin
+        #echo "[+] Downloading TETRA firmware..."
+        #wget -q https://github.com/xchwarze/wifi-pineapple-community/raw/main/firmwares/2.7.0-tetra.bin -O basefw.bin
         
         echo "[+] Unpack firmware for get file system"
         binwalk basefw.bin -e 
         binwalk _basefw.bin.extracted/sysupgrade-pineapple-tetra/root -e --preserve-symlinks
         mv _basefw.bin.extracted/sysupgrade-pineapple-tetra/_root.extracted/squashfs-root/ "$BUILD_FOLDER/rootfs-base"
     else
-        echo "[+] Downloading NANO firmware..."
-        wget -q https://github.com/xchwarze/wifi-pineapple-community/raw/main/firmwares/2.7.0-nano.bin -O basefw.bin
+        #echo "[+] Downloading NANO firmware..."
+        #wget -q https://github.com/xchwarze/wifi-pineapple-community/raw/main/firmwares/2.7.0-nano.bin -O basefw.bin
 
         echo "[+] Unpack firmware for get file system"
         binwalk basefw.bin -e --preserve-symlinks
@@ -100,6 +130,27 @@ prepare_build () {
         exit 1
     fi
 
+    # I'm deleting it because I don't use it anymore
+    rm -rf "$BUILD_FOLDER/rootfs-base"
+
+    if [[ "$ARCHITECTURE" == "mipsel" ]]; then
+        #echo "[+] Downloading old MK7 firmware..."
+        #wget -q https://github.com/xchwarze/wifi-pineapple-community/raw/main/firmwares/1.1.1-mk7.bin -O basefw-mk7.bin
+
+        echo "[+] Unpack mipsel firmware for get file system"
+        binwalk basefw-mk7.bin -e --preserve-symlinks
+        mv _basefw-mk7.bin.extracted/squashfs-root/ "$BUILD_FOLDER/rootfs-mk7-base"
+
+        echo "[+] Copying the original mipsel files"
+        "$TOOL_FOLDER/copier.sh" "$TOOL_FOLDER/../lists/mipsel-support.filelist" "$BUILD_FOLDER/rootfs-mk7-base" "$BUILD_FOLDER/rootfs" "true"
+        if [ $? -ne 0 ]; then
+            echo "[!] An error occurred while copying the original mipsel files. Check the log for errors."
+            exit 1
+        fi
+
+        rm -rf "$BUILD_FOLDER/rootfs-mk7-base"
+    fi
+
     echo "[+] Patch file system"
     "$TOOL_FOLDER/fs-patcher.sh" "$ARCHITECTURE" "$FLAVOR" "$BUILD_FOLDER/rootfs"
     if [ $? -ne 0 ]; then
@@ -107,7 +158,6 @@ prepare_build () {
         exit 1
     fi
 
-    rm -rf "$BUILD_FOLDER/rootfs-base"
     echo ""
 }
 
@@ -161,6 +211,7 @@ echo "Wifi Pineapple Cloner - builder"
 echo "************************************** by DSR!"
 echo ""
 
+check_deps
 prepare_builder
 prepare_build
 build "$PROFILE"