copy_output.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #!/usr/bin/env bash
  2. set -e
  3. [ "$GLUON_IMAGEDIR" -a "$GLUON_PACKAGEDIR" -a "$LEDE_TARGET" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" ] || exit 1
  4. default_factory_ext='.bin'
  5. default_factory_suffix='-squashfs-factory'
  6. default_sysupgrade_ext='.bin'
  7. default_sysupgrade_suffix='-squashfs-sysupgrade'
  8. output=
  9. profile=
  10. aliases=
  11. factory_ext=
  12. factory_suffix=
  13. sysupgrade_ext=
  14. sysupgrade_suffix=
  15. mkdir -p "${GLUON_IMAGEDIR}/factory" "${GLUON_IMAGEDIR}/sysupgrade"
  16. if [ "$(expr match "$LEDE_TARGET" '.*-.*')" -gt 0 ]; then
  17. LEDE_BINDIR="${LEDE_TARGET//-/\/}"
  18. else
  19. LEDE_BINDIR="${LEDE_TARGET}/generic"
  20. fi
  21. SITE_CODE="$(scripts/site.sh site_code)"
  22. PACKAGE_PREFIX="gluon-${SITE_CODE}-${GLUON_RELEASE}"
  23. copy() {
  24. [ "${output}" ] || return 0
  25. want_device "${output}" || return 0
  26. if [ "$factory_ext" ]; then
  27. rm -f "${GLUON_IMAGEDIR}/factory/gluon-"*"-${output}${factory_ext}"
  28. cp "lede/bin/targets/${LEDE_BINDIR}/lede-${LEDE_TARGET}${profile}${factory_suffix}${factory_ext}" \
  29. "${GLUON_IMAGEDIR}/factory/gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}${factory_ext}"
  30. for alias in $aliases; do
  31. rm -f "${GLUON_IMAGEDIR}/factory/gluon-"*"-${alias}${factory_ext}"
  32. ln -s "gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}${factory_ext}" \
  33. "${GLUON_IMAGEDIR}/factory/gluon-${SITE_CODE}-${GLUON_RELEASE}-${alias}${factory_ext}"
  34. done
  35. fi
  36. if [ "$sysupgrade_ext" ]; then
  37. rm -f "${GLUON_IMAGEDIR}/sysupgrade/gluon-"*"-${output}-sysupgrade${sysupgrade_ext}"
  38. cp "lede/bin/targets/${LEDE_BINDIR}/lede-${LEDE_TARGET}${profile}${sysupgrade_suffix}${sysupgrade_ext}" \
  39. "${GLUON_IMAGEDIR}/sysupgrade/gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}-sysupgrade${sysupgrade_ext}"
  40. for alias in $aliases; do
  41. rm -f "${GLUON_IMAGEDIR}/sysupgrade/gluon-"*"-${alias}-sysupgrade${sysupgrade_ext}"
  42. ln -s "gluon-${SITE_CODE}-${GLUON_RELEASE}-${output}-sysupgrade${sysupgrade_ext}" \
  43. "${GLUON_IMAGEDIR}/sysupgrade/gluon-${SITE_CODE}-${GLUON_RELEASE}-${alias}-sysupgrade${sysupgrade_ext}"
  44. done
  45. fi
  46. }
  47. . scripts/common.inc.sh
  48. device() {
  49. copy
  50. output="$1"
  51. profile="-$2"
  52. aliases=
  53. factory_ext="$default_factory_ext"
  54. factory_suffix="$default_factory_suffix"
  55. sysupgrade_ext="$default_sysupgrade_ext"
  56. sysupgrade_suffix="$default_sysupgrade_suffix"
  57. }
  58. factory_image() {
  59. copy
  60. output="$1"
  61. aliases=
  62. if [ "$3" ]; then
  63. profile="-$2"
  64. factory_ext="$3"
  65. else
  66. profile=""
  67. factory_ext="$2"
  68. fi
  69. factory_suffix=
  70. sysupgrade_ext=
  71. sysupgrade_suffix=
  72. }
  73. sysupgrade_image() {
  74. copy
  75. output="$1"
  76. aliases=
  77. if [ "$3" ]; then
  78. profile="-$2"
  79. sysupgrade_ext="$3"
  80. else
  81. profile=""
  82. sysupgrade_ext="$2"
  83. fi
  84. factory_ext=
  85. factory_suffix=
  86. sysupgrade_suffix=
  87. }
  88. alias() {
  89. aliases="$aliases $1"
  90. }
  91. factory() {
  92. if [ "$2" ]; then
  93. factory_suffix="$1"
  94. factory_ext="$2"
  95. else
  96. factory_ext="$1"
  97. fi
  98. if [ -z "$profile" ]; then
  99. default_factory_ext="$factory_ext"
  100. default_factory_suffix="$factory_suffix"
  101. fi
  102. }
  103. sysupgrade() {
  104. if [ "$2" ]; then
  105. sysupgrade_suffix="$1"
  106. sysupgrade_ext="$2"
  107. else
  108. sysupgrade_ext="$1"
  109. fi
  110. if [ -z "$output" ]; then
  111. default_sysupgrade_ext="$sysupgrade_ext"
  112. default_sysupgrade_suffix="$sysupgrade_suffix"
  113. fi
  114. }
  115. . targets/"$1"; copy
  116. # Copy opkg repo
  117. if [ -z "$DEVICES" ]; then
  118. rm -f "$GLUON_PACKAGEDIR"/*/"$LEDE_BINDIR"/*
  119. rmdir -p "$GLUON_PACKAGEDIR"/*/"$LEDE_BINDIR" 2>/dev/null || true
  120. mkdir -p "${GLUON_PACKAGEDIR}/${PACKAGE_PREFIX}/${LEDE_BINDIR}"
  121. cp "lede/bin/targets/${LEDE_BINDIR}/packages"/* "${GLUON_PACKAGEDIR}/${PACKAGE_PREFIX}/${LEDE_BINDIR}"
  122. fi