Skip to content

Instantly share code, notes, and snippets.

@tisyang
Created February 15, 2023 10:17
Show Gist options
  • Save tisyang/01559dcce1270afc0266171ac9941242 to your computer and use it in GitHub Desktop.
Save tisyang/01559dcce1270afc0266171ac9941242 to your computer and use it in GitHub Desktop.
LEDE 编译打包脚本
#!/usr/bin/env bash
# build
DEVICE_ARCH=$(grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/CONFIG_TARGET_(.*)_.*_DEVICE_.*=y/\1/')
DEVICE_TYPE=$(grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/CONFIG_TARGET_.*_(.*)_DEVICE_.*=y/\1/')
DEVICE_NAME=$(grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/CONFIG_TARGET_.*_.*_DEVICE_(.*)=y/\1/')
FILE_DATE=$(date +"%Y%m%d%H%M")
echo "Deivce:"
echo " ARCH: ${DEVICE_ARCH}"
echo " TYPE: ${DEVICE_TYPE}"
echo " NAME: ${DEVICE_NAME}"
echo "Date: ${FILE_DATE}"
echo "Bulding..."
make defconfig
make download -j8
make V=s -j4
# pack
FW_PATH=bin/targets/${DEVICE_ARCH}/${DEVICE_TYPE}
NEW_DIR=OpenWrt_firmware_${DEVICE_NAME}_${FILE_DATE}
if [ -d ${FW_PATH} ]; then
echo "Copy firmware..."
cp -r ${FW_PATH} bin/${NEW_DIR}
cd bin/${NEW_DIR}
rm -rf packages
cd ..
echo "Pack firmware..."
if [ ! -d firmwares ]; then
echo "Create firmwares directory..."
mkdir firmwares
fi
tar -czvf firmwares/${NEW_DIR}.tar.gz ${NEW_DIR}
echo "Pakcage finished: bin/firmwares/${NEW_DIR}.tar.gz"
echo "Move firmware dir..."
mv ${NEW_DIR} firmwares/
cd ..
else
echo "ERROR: not found build directory"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment