diy.sh 4.9 KB

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