download-2305.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/bin/sh
  2. # download-2305.sh — fetch the OpenWrt 23.05.6 x86_64 rootfs and the
  3. # few .ipk packages the testbed needs, and pre-extract them.
  4. #
  5. # Idempotent: skips any artifact that already exists.
  6. #
  7. # Run from balancer-lite-lua/testbed/.
  8. set -e
  9. cd "$(dirname "$0")"
  10. VER=23.05.6
  11. BASE_URL="https://downloads.openwrt.org/releases/$VER"
  12. ROOTFS="$VER-x86-64-rootfs.tar.gz"
  13. mkdir -p ipks
  14. # 1. Official rootfs tarball
  15. if [ ! -f "$ROOTFS" ]; then
  16. echo "Fetching $ROOTFS ..."
  17. curl -fSL -o "$ROOTFS" "$BASE_URL/targets/x86/64/openwrt-$ROOTFS"
  18. fi
  19. # 2. .ipk payloads (from the 23.05.6 x86_64 base feed)
  20. fetch_ipk() {
  21. f="$1"
  22. if [ -f "ipks/$f" ]; then
  23. echo " $f: present"
  24. return 0
  25. fi
  26. for feed in "packages/x86_64/base" "packages/x86_64/packages" "packages/x86_64/routing" "targets/x86/64/packages"; do
  27. if curl -fsSL -o "ipks/$f" "$BASE_URL/$feed/$f"; then
  28. echo " $f: fetched from $feed"
  29. return 0
  30. fi
  31. done
  32. echo " $f: NOT FOUND in any feed" >&2
  33. rm -f "ipks/$f"
  34. return 1
  35. }
  36. fetch_ipk lua_5.1.5-11_x86_64.ipk
  37. fetch_ipk liblua5.1.5_5.1.5-11_x86_64.ipk
  38. fetch_ipk openssl-util_3.0.9-2_x86_64.ipk
  39. fetch_ipk libopenssl3_3.0.9-2_x86_64.ipk
  40. fetch_ipk ca-bundle_20241223-1_all.ipk
  41. # 3. Pre-extract rootfs (busybox tar in the image can't read the
  42. # ar-based .ipk either, so extraction happens on the host)
  43. if [ ! -d rootfs ] || [ -z "$(ls -A rootfs 2>/dev/null)" ]; then
  44. rm -rf rootfs ipk-extract
  45. mkdir -p rootfs ipk-extract
  46. echo "Extracting rootfs + ipk payloads ..."
  47. tar xzf "$ROOTFS" -C rootfs
  48. for ipk in ipks/*.ipk; do
  49. tar -xOf "$ipk" ./data.tar.gz | tar -xz -C ipk-extract
  50. done
  51. fi
  52. echo "Done. Build with: docker build -f Dockerfile-2305 -t openwrt-testbed-2305:latest ."