diy.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. #=================================================
  3. shopt -s extglob
  4. #latest="$(curl -sfL https://github.com/openwrt/openwrt/tree/master/include | grep -o 'href=".*>kernel: bump 5.15' | head -1 | cut -d / -f 5 | cut -d '"' -f 1)"
  5. latest="master"
  6. current="$(git rev-parse HEAD)"
  7. [ "$latest" ] && git checkout $latest || git checkout master
  8. #git checkout HEAD^
  9. [ "$(echo $(git log -1 --pretty=short) | grep "kernel: bump 5.15")" ] && git checkout $latest
  10. mv -f target/linux package/kernel package/boot package/firmware/linux-firmware include/{kernel-*,netfilter.mk} .github/
  11. git checkout $current
  12. rm -rf target/linux package/kernel package/boot package/firmware/linux-firmware include/kernel-version.mk include/kernel-5.15 include/kernel-defaults.mk
  13. mv -f .github/linux target/
  14. mv -f .github/kernel package/
  15. mv -f .github/boot package/
  16. mv -f .github/linux-firmware package/firmware/
  17. mv -f .github/{kernel-*,netfilter.mk} include/
  18. sed -i 's/ libelf//' tools/Makefile
  19. kernel_v="$(cat include/kernel-5.15 | grep LINUX_KERNEL_HASH-* | cut -f 2 -d - | cut -f 1 -d ' ')"
  20. echo "KERNEL=${kernel_v}" >> $GITHUB_ENV || true
  21. sed -i "s?targets/%S/packages?packages/%A/kmods/$kernel_v?" include/feeds.mk
  22. echo "$(date +"%s")" >version.date
  23. sed -i '/$(curdir)\/compile:/c\$(curdir)/compile: package/opkg/host/compile' package/Makefile
  24. sed -i "s/DEFAULT_PACKAGES:=/DEFAULT_PACKAGES:=luci-app-advanced luci-app-firewall luci-app-gpsysupgrade luci-app-opkg luci-app-upnp luci-app-autoreboot \
  25. luci-app-wizard luci-app-attendedsysupgrade dnsmasq-full luci-base luci-compat luci-lib-ipkg fdisk \
  26. coremark wget-ssl curl htop nano zram-swap kmod-lib-zstd kmod-tcp-bbr bash \
  27. kmod-usb2 kmod-usb3 automount /" include/target.mk
  28. sed -i "/dnsmasq \\\/d" include/target.mk
  29. sh -c "curl -sfL https://github.com/coolsnowwolf/lede/commit/06fcdca1bb9c6de6ccd0450a042349892b372220.patch | patch -d './' -p1 --forward"
  30. sed -i '/ refresh_config();/d' scripts/feeds
  31. [ ! -f feeds.conf ] && {
  32. sed -i '$a src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master' feeds.conf.default
  33. }
  34. rm -rf package/{base-files,network/config/firewall,network/services/dnsmasq,network/services/ppp,system/opkg,libs/mbedtls}
  35. ./scripts/feeds update -a
  36. ./scripts/feeds install -a -p kiddin9
  37. ./scripts/feeds install -a
  38. cd feeds/kiddin9; git pull; cd -
  39. rm -f package/feeds/packages/libpfring; svn export https://github.com/openwrt/packages/trunk/libs/libpfring package/feeds/kiddin9/libpfring
  40. rm -f package/feeds/packages/xtables-addons; svn export https://github.com/openwrt/packages/trunk/net/xtables-addons package/feeds/kiddin9/xtables-addons
  41. curl -sfL https://raw.githubusercontent.com/coolsnowwolf/packages/master/libs/xr_usb_serial_common/patches/0001-fix-build-with-kernel-5.15.patch -o package/feeds/packages/xr_usb_serial_common/patches/0001-fix-build-with-kernel-5.15.patch
  42. (
  43. svn export --force https://github.com/coolsnowwolf/lede/trunk/tools/upx tools/upx
  44. svn export --force https://github.com/coolsnowwolf/lede/trunk/tools/ucl tools/ucl
  45. svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/hack-5.15 target/linux/generic/hack-5.15
  46. rm -rf target/linux/generic/hack-5.15/{220-gc_sections*,781-dsa-register*,780-drivers-net*}
  47. ) &
  48. sed -i 's?zstd$?zstd ucl upx\n$(curdir)/upx/compile := $(curdir)/ucl/compile?g' tools/Makefile
  49. sed -i 's/\/cgi-bin\/\(luci\|cgi-\)/\/\1/g' `find package/feeds/kiddin9/luci-*/ -name "*.lua" -or -name "*.htm*" -or -name "*.js"` &
  50. sed -i 's/Os/O2/g' include/target.mk
  51. sed -i 's/$(TARGET_DIR)) install/$(TARGET_DIR)) install --force-overwrite --force-maintainer/' package/Makefile
  52. sed -i "/mediaurlbase/d" package/feeds/*/luci-theme*/root/etc/uci-defaults/*
  53. sed -i 's/=bbr/=cubic/' package/kernel/linux/files/sysctl-tcp-bbr.conf
  54. # find target/linux/x86 -name "config*" -exec bash -c 'cat kernel.conf >> "{}"' \;
  55. sed -i '$a CONFIG_ACPI=y\nCONFIG_X86_ACPI_CPUFREQ=y\nCONFIG_NR_CPUS=128\nCONFIG_FAT_DEFAULT_IOCHARSET="utf8"\nCONFIG_CRYPTO_CHACHA20_NEON=y\n \
  56. CONFIG_CRYPTO_CHACHA20POLY1305=y\nCONFIG_BINFMT_MISC=y' `find target/linux -path "target/linux/*/config-*"`
  57. sed -i 's/max_requests 3/max_requests 20/g' package/network/services/uhttpd/files/uhttpd.config
  58. #rm -rf ./feeds/packages/lang/{golang,node}
  59. sed -i "s/tty\(0\|1\)::askfirst/tty\1::respawn/g" target/linux/*/base-files/etc/inittab
  60. date=`date +%m.%d.%Y`
  61. sed -i -e "/\(# \)\?REVISION:=/c\REVISION:=$date" -e '/VERSION_CODE:=/c\VERSION_CODE:=$(REVISION)' include/version.mk
  62. sed -i "s/^.*vermagic$/\techo '1' > \$(LINUX_DIR)\/.vermagic/" include/kernel-defaults.mk
  63. sed -i 's/ +kmod-thermal//' package/kernel/mt76/Makefile
  64. sed -i \
  65. -e "s/+\(luci\|luci-ssl\|uhttpd\)\( \|$\)/\2/" \
  66. -e "s/+nginx\( \|$\)/+nginx-ssl\1/" \
  67. -e 's/+python\( \|$\)/+python3/' \
  68. -e 's?../../lang?$(TOPDIR)/feeds/packages/lang?' \
  69. package/feeds/kiddin9/*/Makefile
  70. (
  71. if [ -f sdk.tar.xz ]; then
  72. sed -i 's,$(STAGING_DIR_HOST)/bin/upx,upx,' package/feeds/kiddin9/*/Makefile
  73. mkdir sdk
  74. tar -xJf sdk.tar.xz -C sdk
  75. cp -rf sdk/*/staging_dir/* ./staging_dir/
  76. rm -rf sdk.tar.xz sdk
  77. rm -rf `find "staging_dir/host/" -maxdepth 2 -name 'libelf*'` || true
  78. sed -i '/\(tools\|toolchain\)\/Makefile/d' Makefile
  79. if [ -f /usr/bin/python ]; then
  80. ln -sf /usr/bin/python staging_dir/host/bin/python
  81. else
  82. ln -sf /usr/bin/python3 staging_dir/host/bin/python
  83. fi
  84. ln -sf /usr/bin/python3 staging_dir/host/bin/python3
  85. fi
  86. ) &